添加消息
This commit is contained in:
parent
62d4d42cc9
commit
b3ba64a651
|
|
@ -6,6 +6,7 @@ namespace app\admin\controller;
|
|||
|
||||
use app\admin\controller\orders\DispatchLogic;
|
||||
use app\admin\model\Admin;
|
||||
use app\admin\model\Message;
|
||||
use app\admin\model\OrderDispatch;
|
||||
use app\admin\model\Worker;
|
||||
use think\Hook;
|
||||
|
|
@ -13,7 +14,7 @@ use think\Hook;
|
|||
class AutoDispatchLogic
|
||||
{
|
||||
|
||||
public static function autoDispatch($order,$auth=null,$isRetry=false)
|
||||
public static function autoDispatch($order, $auth = null, $isRetry = false)
|
||||
{
|
||||
//
|
||||
// if ($order->dispatch_type != 2) {
|
||||
|
|
@ -24,11 +25,26 @@ class AutoDispatchLogic
|
|||
$worker_id = (new DispatchLogic())->getMaxScoreWorker($order);
|
||||
// dd($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->save();
|
||||
return false;
|
||||
}
|
||||
$admin = Admin::where('id',config('system_id'))->find();
|
||||
$admin = Admin::where('id', config('system_id'))->find();
|
||||
$insert = [
|
||||
'admin_id' => $admin->id,
|
||||
'admin_user' => $admin->nickname,
|
||||
|
|
@ -47,8 +63,8 @@ class AutoDispatchLogic
|
|||
$res = $orderDispatch->allowField(true)->save($insert);
|
||||
$order->status = \app\admin\model\Order::STATUS_DISPATCHED;
|
||||
$order->dispatch_time = date('Y-m-d H:i:s');
|
||||
$order->dispatch_admin_id = $admin->id;
|
||||
$order->dispatch_admin_user = $admin->nickname;
|
||||
$order->dispatch_admin_id = $admin->id;
|
||||
$order->dispatch_admin_user = $admin->nickname;
|
||||
$order->worker_id = $worker_id;
|
||||
$order->dispatch_type = 2;
|
||||
$order->save();
|
||||
|
|
@ -67,7 +83,7 @@ class AutoDispatchLogic
|
|||
//日志
|
||||
$hookParams = [
|
||||
'dispatch' => (new OrderDispatch())->where('id', $orderDispatch->id)->find(),
|
||||
'remark' => '自动派单给工程师:'. $worker->name .'('.$worker->tel.')',
|
||||
'remark' => '自动派单给工程师:' . $worker->name . '(' . $worker->tel . ')',
|
||||
];
|
||||
Hook::listen('order_dispatch_change', $hookParams);
|
||||
|
||||
|
|
|
|||
|
|
@ -290,8 +290,9 @@ class Order extends Backend
|
|||
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
$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['auth'] = $auth;
|
||||
$hookparams['remark'] = '录入订单';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user