setName('check:dispatch-tts-overtime') ->setDescription($this->title); } protected function execute(Input $input, Output $output){ $Model = new OrderDispatch(); $now = date('Y-m-d H:i:s'); $Model->where('status','=',OrderDispatch::STATUS_CLOCK) ->where('type',2) ->where('estimated_finish_time','<',$now) ->where('tts_notice','<',3) ->chunk(100, function ($list) { $ids = []; $logs = []; try { foreach ($list as $item) { $ids[] = $item->id; //修改状态 $logs[] = [ 'dispatch_id' => $item->id, 'order_id'=>$item->order_id, 'type' => 3, 'outid' => md5(time().rand(1000,9999).rand(1000,9999)), 'create_time' => date('Y-m-d H:i:s'), 'status' => 0, 'update_time' => date('Y-m-d H:i:s') ]; (new TtsLog())->insertAll($logs); } if(!empty($ids)){ $count = OrderDispatch::whereIn('id',$ids)->update(['follow'=>0,'tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]); echo $count.PHP_EOL; } }catch (Exception $exception){ Db::name('debug_log')->insert([ 'title' => $this->title, 'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(), 'create_time' => date('Y-m-d H:i:s', time()) ]); } }); $output->info('OVER'); } }