setName('check:dispatch-toget') ->setDescription('【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,5分钟执行一次'); } protected function execute(Input $input, Output $output){ //$this->_toget(); $this->_toarrive(); $output->info('OVER'); } //未接单检测 private function _toget(){ try { $Model = new OrderDispatch(); $now = date('Y-m-d H:i:s', time() - 5 * 60); //创建三十分名以上未接的任务 $OrderLogic = new OrderLogic(); $Model->where('status', OrderDispatch::STATUS_TOGET) ->where('type', 2) ->where('create_time', '<=', $now) ->chunk(100, function ($list) use ($OrderLogic) { foreach ($list as $item) { try { //取消旧单 $OrderLogic->noWorkerCanGetIt($item); //自动重派新单 $order = Order::get($item->order_id); AutoDispatchLogic::autoDispatch($order,$order->admin_id); echo 'succ:' . $item->id . PHP_EOL; } catch (Exception $exception) { echo $exception->getMessage() . PHP_EOL; } } }); }catch (Exception $exception){ echo $exception->getMessage(). PHP_EOL; } } //预约时间过了未上门检测 private function _toarrive(){ try { $Model = new OrderDispatch(); $now = date('Y-m-d H:i:s', time() - 5 * 60); //创建三十分名以上未接的任务 $count = $Model->whereIn('status', [OrderDispatch::STATUS_PLANIT,OrderDispatch::STATUS_OVERTIME]) ->where('type', 2) ->where('follow', 1) ->where('plan_time', '<=', $now) ->update(['follow'=>0]); echo 'arrive_count:'. $count. PHP_EOL; }catch (Exception $exception){ echo $exception->getMessage(). PHP_EOL; } } }