This commit is contained in:
xman 2025-03-31 15:15:41 +08:00
parent 79fe024c06
commit 8316a1dfdc
3 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace app\admin\behavior;
use app\admin\model\OrderDispatch;
use think\Exception;
use think\Lang;
class SendOverTimeSms
{
//发短信通知
public function run(&$response)
{
//todo...
try {
$dispatch = $response['dispatch'];
if($dispatch->status == OrderDispatch::STATUS_OVERTIME){ //发送短信
}
}catch (Exception $exception){
}
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace app\common\command;
use app\admin\model\OrderDispatch;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Hook;
class CheckOrderDispatchCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-overtime')
->setDescription('检测dispatch表超时任务');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s');
$Model->where('status',OrderDispatch::STATUS_PLANIT)
->where('plan_time','<=',$now)
->chunk(100, function ($list) {
foreach ($list as $item) {
//1修改为超时
$item->status = OrderDispatch::STATUS_OVERTIME;
$item->save();
$params = ['dispatch'=>$item,'remark'=>'系统自动处理,任务超时'];
Hook::listen('order_dispatch_change',$params);
}
});
}
}

View File

@ -46,5 +46,6 @@ return [
'order_dispatch_change' => [
'app\\admin\\behavior\\OrderDispatchLog',
'app\\admin\\behavior\\SendOverTimeSms',
],
];