Accept Merge Request #143: (feature/hant -> develop)
Merge Request: 鞭策牛马 Created By: @todayswind Accepted By: @todayswind URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/143?initial=true
This commit is contained in:
commit
c5738d7dc1
66
application/common/command/CheckOrderDispatchCommand.php
Normal file
66
application/common/command/CheckOrderDispatchCommand.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\command;
|
||||
|
||||
use app\admin\controller\AutoDispatchLogic;
|
||||
use app\admin\model\Admin;
|
||||
use app\admin\model\Message;
|
||||
use app\admin\model\Order;
|
||||
use app\admin\model\OrderDispatch;
|
||||
use app\common\Logic\OrderLogic;
|
||||
use Carbon\Carbon;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Hook;
|
||||
use function Symfony\Component\Clock\now;
|
||||
|
||||
class CheckOrderDispatchCommand extends Command
|
||||
{
|
||||
protected $title = '鞭策牛马是否派单,每分钟执行一次';
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch')
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
// 查询所有待派单,且未通知过的订单
|
||||
$orders = Db::name('order')
|
||||
->alias('o')
|
||||
->join('order_dispatch_notify n', 'o.id = n.order_id','left')
|
||||
->where('o.status', Order::STATUS_DISPATCHING)
|
||||
->whereNull('n.id') // 没有记录就表示还没通知
|
||||
->where('o.create_time', '<=', (new Carbon())->subMinutes(20)->format('Y-m-d H:i:s'))
|
||||
->field(['o.id','o.area_id','o.order_no'])
|
||||
->select();
|
||||
$log_insert = [];
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
|
||||
foreach ($orders as $order){
|
||||
$area_id = substr($order['area_id'], 0, 4);
|
||||
$res = Admin::where('area_ids', 'like', '%' . $area_id . '%')
|
||||
->column('id');
|
||||
|
||||
$insert = [];
|
||||
foreach ($res as $re) {
|
||||
$insert [] = [
|
||||
'to_id' => $re,
|
||||
'type' => 1,
|
||||
'title' => '订单未派单超时通知',
|
||||
'content' => '您有一条订单号为 ' . $order['order_no'] . ' 超过20分钟未派单,请及时派单!'
|
||||
];
|
||||
}
|
||||
$build = new Message();
|
||||
$build->saveAll($insert);
|
||||
$log_insert [] = [
|
||||
'order_id' => $order['id'],
|
||||
'notified_at' => $now,
|
||||
'created_at' => $now,
|
||||
];
|
||||
}
|
||||
Db::name('order_dispatch_notify')->insertAll($log_insert);
|
||||
}
|
||||
}
|
||||
1
crontab
1
crontab
|
|
@ -1,4 +1,5 @@
|
|||
* * * * * docker exec php-www php /var/www/html/allocatr/think check:dispatch-toget >> /var/log/mycron.log 2>&1
|
||||
* * * * * docker exec php-www php /var/www/html/allocatr/think check:dispatch >> /var/log/mycron.log 2>&1
|
||||
1 9 * * * docker exec php-www php /var/www/html/allocatr/think check:dispatch-record-notice >> /var/log/mycron.log 2>&1
|
||||
*/5 * * * * docker exec php-www php /var/www/html/allocatr/think check:dispatch-sms-plant >> /var/log/mycron.log 2>&1
|
||||
*/5 * * * * docker exec php-www php /var/www/html/allocatr/think check:dispatch-tts-overtime >> /var/log/mycron.log 2>&1
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
return val;
|
||||
}
|
||||
},
|
||||
{field: 'content', title: __('Content'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'content', title: __('Content'), operate: false, table: table, class: 'autocontent', width:'600', formatter: Table.api.formatter.content},
|
||||
// {field: 'uri', title: __('Uri'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
// {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user