This commit is contained in:
xman 2025-06-02 19:19:52 +08:00
parent 27959bda9a
commit 612306d1d9

View File

@ -0,0 +1,54 @@
<?php
namespace app\common\command;
use app\admin\model\Message;
use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchRecord;
use app\admin\model\TtsLog;
use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class CheckTTSOverTimeCommand extends Command
{
protected function configure()
{
$this->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');
}
}