Offline.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\command;
  3. use app\api\model\order\Order;
  4. use app\api\model\system\Message;
  5. use app\api\service\MassagerActionService;
  6. use app\api\service\TencentCloudService;
  7. use app\api\service\ThirdPayService;
  8. use app\api\service\WalletService;
  9. use redis\RedLock;
  10. use think\console\Command;
  11. use think\console\Input;
  12. use think\console\Output;
  13. use think\Db;
  14. use think\Exception;
  15. // 接单超时
  16. class Offline extends Command
  17. {
  18. // 配置定时器的信息
  19. protected function configure()
  20. {
  21. $this->setName('Offline')
  22. ->setDescription('Offline start');
  23. }
  24. /**
  25. * @param Input $input
  26. * @param Output $output
  27. * @return int|void|null
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. * @throws \think\exception\DbException
  31. * @throws \think\Exception
  32. */
  33. protected function execute(Input $input, Output $output)
  34. {
  35. \think\Log::custom_log("助教上线时间过长未更新自动下线", "-------------- start --------------", "offline");
  36. $massagers = \db("massager")->where("online", 1)->where("updatetime", "<", (time() - 6 * 60 * 60))->select();
  37. $logs = [];
  38. foreach ($massagers as $item) {
  39. $s_res = (new MassagerActionService())->workClockIn($item["id"]);
  40. // 下线通知
  41. TencentCloudService::tencent_cloud_vms_send($item["mobile"],'1478967');
  42. array_push($logs, [$item["id"],$s_res->code()]);
  43. }
  44. \think\Log::custom_log("助教上线时间过长未更新自动下线", $logs, "offline");
  45. \think\Log::custom_log("助教上线时间过长未更新自动下线", "--------------- over --------------", "offline");
  46. }
  47. }