54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?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 CheckTTSPlantCommand extends Command
|
||
{
|
||
protected function configure()
|
||
{
|
||
$this->setName('check:dispatch-tts-plant')
|
||
->setDescription('dispatch已预约任务语音提醒,每小时执行一次');
|
||
}
|
||
|
||
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_PLANIT)
|
||
->where('plan_time','between',[$now,$afterTwoHours])
|
||
->where('tts_notice','<',2)
|
||
->chunk(100, function ($list) {
|
||
$ids = [];
|
||
$logs = [];
|
||
foreach ($list as $item) {
|
||
$ids[] = $item->id;
|
||
//修改状态
|
||
$logs[] = [
|
||
'dispatch_id' => $item->id,
|
||
'order_id'=>$item->order_id,
|
||
'type' => 2,
|
||
'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'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);
|
||
}
|
||
});
|
||
$output->info('OVER');
|
||
}
|
||
} |