allocatr/application/common/command/CheckTTSOverTimeCommand.php
2025-06-04 20:48:44 +08:00

55 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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');
$Model->where('status','=',OrderDispatch::STATUS_CLOCK)
->where('type',2)
->where('estimated_finish_time','<',$now)
->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)){
$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;
}
});
$output->info('OVER');
}
}