添加消息

This commit is contained in:
todaywindy 2025-06-18 16:49:05 +08:00
parent 62d4d42cc9
commit b3ba64a651
2 changed files with 23 additions and 6 deletions

View File

@ -6,6 +6,7 @@ namespace app\admin\controller;
use app\admin\controller\orders\DispatchLogic; use app\admin\controller\orders\DispatchLogic;
use app\admin\model\Admin; use app\admin\model\Admin;
use app\admin\model\Message;
use app\admin\model\OrderDispatch; use app\admin\model\OrderDispatch;
use app\admin\model\Worker; use app\admin\model\Worker;
use think\Hook; use think\Hook;
@ -24,6 +25,21 @@ class AutoDispatchLogic
$worker_id = (new DispatchLogic())->getMaxScoreWorker($order); $worker_id = (new DispatchLogic())->getMaxScoreWorker($order);
// dd($worker_id); // dd($worker_id);
if (!$worker_id) { if (!$worker_id) {
$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 . '的新订单,请立即派单!'
];
}
$build = new Message();
$build->saveAll($insert);
$order->dispatch_type = 1; $order->dispatch_type = 1;
$order->save(); $order->save();
return false; return false;

View File

@ -290,8 +290,9 @@ class Order extends Backend
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
$auth = clone $this->auth; $auth = clone $this->auth;
$order = \app\admin\model\Order::get($this->model->id);
//日志 //日志
$hookparams['order'] = \app\admin\model\Order::get($this->model->id); $hookparams['order'] = $order;
$hookparams['role'] = 1; $hookparams['role'] = 1;
$hookparams['auth'] = $auth; $hookparams['auth'] = $auth;
$hookparams['remark'] = '录入订单'; $hookparams['remark'] = '录入订单';