51 lines
1.6 KiB
PHP
51 lines
1.6 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;
|
||
use think\Db;
|
||
use think\Exception;
|
||
|
||
class CheckTTSTaskCommand extends Command
|
||
{
|
||
protected $title = 'dispatch语音发送任务,每1分钟执行一次';
|
||
|
||
protected function configure()
|
||
{
|
||
$this->setName('check:dispatch-tts-task')
|
||
->setDescription($this->title);
|
||
}
|
||
|
||
protected function execute(Input $input, Output $output){
|
||
$Model = new TtsLog();
|
||
$ttsService = new NoticeLogic();
|
||
$Model->where('status','=',0)
|
||
->chunk(100, function ($list)use($ttsService) {
|
||
foreach ($list as $item) {
|
||
try {
|
||
$ttsService->callIt($item);
|
||
}catch (Exception $exception){
|
||
$item->status = -1;
|
||
$item->content = $exception->getMessage();
|
||
$item->save();
|
||
|
||
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())
|
||
]);
|
||
}
|
||
echo $item->id.PHP_EOL;
|
||
}
|
||
});
|
||
$output->info('OVER');
|
||
}
|
||
} |