From 612306d1d9804d30d221a62fc15a6773979bedc4 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 2 Jun 2025 19:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/CheckTTSOverTimeCommand.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 application/common/command/CheckTTSOverTimeCommand.php diff --git a/application/common/command/CheckTTSOverTimeCommand.php b/application/common/command/CheckTTSOverTimeCommand.php new file mode 100644 index 0000000..f63584e --- /dev/null +++ b/application/common/command/CheckTTSOverTimeCommand.php @@ -0,0 +1,54 @@ +setName('check:dispatch-tts-overtime') + ->setDescription('dispatch超时未完成任务语音通知,每10分钟执行一次'); + } + + protected function execute(Input $input, Output $output){ + $Model = new OrderDispatch(); + $now = date('Y-m-d H:i:s'); //两小时通知 + $afterTwoHours = date('Y-m-d H:i:s', strtotime('+1 hours')); + + $Model->where('status','=',OrderDispatch::STATUS_CLOCK) + ->where('estimated_finish_time','between',[$now,$afterTwoHours]) + ->where('tts_notice','<',3) + ->chunk(100, function ($list) { + $ids = []; + $logs = []; + 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)){ + OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]); + } + }); + $output->info('OVER'); + } +} \ No newline at end of file