hook
This commit is contained in:
parent
79fe024c06
commit
8316a1dfdc
24
application/admin/behavior/SendOverTimeSms.php
Normal file
24
application/admin/behavior/SendOverTimeSms.php
Normal 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){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
43
application/common/command/CheckOrderDispatchCommand.php
Normal file
43
application/common/command/CheckOrderDispatchCommand.php
Normal 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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -46,5 +46,6 @@ return [
|
|||
|
||||
'order_dispatch_change' => [
|
||||
'app\\admin\\behavior\\OrderDispatchLog',
|
||||
'app\\admin\\behavior\\SendOverTimeSms',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user