CancelDispatch.php 911 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\command;
  3. use think\console\Input;
  4. use think\console\Output;
  5. use think\console\Command;
  6. use app\common\model\works\ServiceWork;
  7. class CancelDispatch extends Command
  8. {
  9. protected function configure()
  10. {
  11. $this->setName('cancel_dispatch')
  12. ->setDescription('派单5分钟未领取的工单自动取消');
  13. }
  14. protected function execute(Input $input, Output $output)
  15. {
  16. $this->cancelDispatch();
  17. }
  18. /*
  19. * 超过5分钟未领取工单的,取消分配
  20. */
  21. protected function cancelDispatch()
  22. {
  23. ServiceWork::where('work_status',1)
  24. ->where('dispatch_time','<',strtotime('-5 minutes'))
  25. ->update([
  26. 'master_worker_id' => 0,
  27. 'work_status' => 0,
  28. 'dispatch_time' => 0,
  29. 'first_contact_time' => 0,
  30. 'estimated_finish_time' => 0,
  31. ]);
  32. }
  33. }