diff --git a/application/admin/behavior/OrderDispatchLog.php b/application/admin/behavior/OrderDispatchLog.php index faf84c8..21923bd 100644 --- a/application/admin/behavior/OrderDispatchLog.php +++ b/application/admin/behavior/OrderDispatchLog.php @@ -2,6 +2,7 @@ namespace app\admin\behavior; +use think\Exception; use think\Lang; class OrderDispatchLog @@ -9,22 +10,27 @@ class OrderDispatchLog //记录订单任务日志 public function run(&$response) { + try { - Lang::load(APP_PATH . 'admin/lang/zh-cn/orders/dispatch2.php'); + Lang::load(APP_PATH . 'admin/lang/zh-cn/orders/dispatch2.php'); - $Model = new \app\admin\model\OrderDispatch(); - $statusList = $Model->getStatusList(); - $dispatch = $response['dispatch']; //订单对象 - $remark = $response['remark'] ?? ''; //备注 - $data = [ - 'dispatch_id' => $dispatch->id, - 'order_id' => $dispatch->order_id, - 'worker_id' => $dispatch->worker_id, - 'status' => $dispatch->status, - 'status_text' => $statusList[$dispatch->status], - 'remark' => $remark, - ]; - \app\admin\model\OrderDispatchLog::create($data); - //(new \app\admin\model\OrderDispatchLog())->cre($data); + $Model = new \app\admin\model\OrderDispatch(); + $statusList = $Model->getStatusList(); + $dispatch = $response['dispatch']; //订单对象 + $remark = $response['remark'] ?? ''; //备注 + $data = [ + 'dispatch_id' => $dispatch->id, + 'order_id' => $dispatch->order_id, + 'worker_id' => $dispatch->worker_id, + 'status' => $dispatch->status, + 'status_text' => $statusList[$dispatch->status], + 'remark' => $remark, + 'admin_user' => $dispatch->admin_user??'sys', + ]; + \app\admin\model\OrderDispatchLog::create($data); + //(new \app\admin\model\OrderDispatchLog())->cre($data); + }catch (Exception $exception){ + + } } } diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 9ee861f..29e8b23 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -396,7 +396,7 @@ class Order extends Backend //日志 $hookParams = [ 'dispatch' => (new OrderDispatch())->where('id', $res)->find(), - 'remark' => '自动派单,操作人:' . $this->auth->nickname, + 'remark' => '系统自动派单', ]; Hook::listen('order_dispatch_change', $hookParams); diff --git a/application/admin/controller/orders/Dispatch.php b/application/admin/controller/orders/Dispatch.php index 0e521d7..08cfae0 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -170,10 +170,12 @@ class Dispatch extends Backend $hookparams['remark'] = ''; Hook::listen('order_change', $hookparams); + $dispatch = $this->model->get($this->model->id); + $dispatch->admin_user = $this->auth->nickname; //dispatch log $hookParams2 = [ - 'dispatch' => $this->model->get($this->model->id), - 'remark' => '手动派单,操作人:' . $this->auth->nickname, + 'dispatch' => $dispatch, + 'remark' => '手动派单', ]; Hook::listen('order_dispatch_change', $hookParams2); diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 3c3b0b7..8bdf92a 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -208,6 +208,7 @@ class Dispatch2 extends Backend } $result = $row->allowField(true)->save($params); + $row->admin_user = $this->auth->nickname; if($workerChange){ $hookParams = [ 'dispatch' => $row, diff --git a/application/admin/controller/orders/Dispatchlog.php b/application/admin/controller/orders/Dispatchlog.php index 1468930..ec2a273 100644 --- a/application/admin/controller/orders/Dispatchlog.php +++ b/application/admin/controller/orders/Dispatchlog.php @@ -52,6 +52,15 @@ class Dispatchlog extends Backend $dispatch_id = $this->request->get('dispatch_id'); if (false === $this->request->isAjax()) { + //page2变更日志 + + $logs = $this->model + ->where('dispatch_id',$dispatch_id) + ->order('id','desc') + ->select(); + + $this->view->assign('logs',json_encode($logs)); + return $this->view->fetch(); } //如果发送的来源是 Selectpage,则转发到 Selectpage diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php index 71a4611..fcf783e 100644 --- a/application/admin/controller/orders/Dispatchrecord.php +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -128,9 +128,10 @@ class Dispatchrecord extends Backend if($dispatch->status != $params['rate']){ $dispatch->status = $params['rate']; $dispatch->save(); + $dispatch->admin_user = '管理员:'. $this->auth->nickname; $hookParams = [ 'dispatch' => $dispatch, - 'remark' => '管理员跟进:'.$this->auth->nickname.',备注内容:'.$params['remark'], + 'remark' => '人工跟进订单,备注内容:'.$params['remark'], ]; Hook::listen('order_dispatch_change', $hookParams); diff --git a/application/admin/model/orders/Dispatchlog.php b/application/admin/model/orders/Dispatchlog.php index 08aff17..bad0397 100644 --- a/application/admin/model/orders/Dispatchlog.php +++ b/application/admin/model/orders/Dispatchlog.php @@ -27,14 +27,5 @@ class Dispatchlog extends Model protected $append = [ ]; - - - - - - - - - } diff --git a/application/admin/view/orders/dispatchlog/index.html b/application/admin/view/orders/dispatchlog/index.html index 620a14d..1299795 100644 --- a/application/admin/view/orders/dispatchlog/index.html +++ b/application/admin/view/orders/dispatchlog/index.html @@ -1,3 +1,69 @@ + +
@@ -16,9 +82,46 @@
- -
+ + + +
+ + + diff --git a/application/common/Logic/OrderLogic.php b/application/common/Logic/OrderLogic.php index da0d050..3baf2d6 100644 --- a/application/common/Logic/OrderLogic.php +++ b/application/common/Logic/OrderLogic.php @@ -74,7 +74,11 @@ class OrderLogic Hook::listen('order_change', $params); - + if($roleInfo['role'] == 1){ //后台操作 + $orderDispatch->admin_user = '管理员:'. $roleInfo['auth']->nickname; + }else{ + $orderDispatch->admin_user = '师傅:'. $roleInfo['auth']->name; + } $hookParams = [ 'dispatch' => $orderDispatch, 'remark' => $roleInfo['remark'] ?? $orderDispatch->remark, @@ -129,9 +133,14 @@ class OrderLogic //取消 $dispatch->allowField(true)->save(['status' => OrderDispatch::STATUS_CANCEL, 'follow'=>2,'remark' => $remark]); + if(!empty($auth)){ + $dispatch->admin_user = '管理员:'.$auth->nickname; + }else{ + $dispatch->admin_user = 'sys'; + } $hookParams = [ 'dispatch' => $dispatch, - 'remark' => '后台取消,操作说明:'.$remark?:'无'.',操作人:'.$auth->nickname + 'remark' => '后台取消,操作说明:'.$remark?:'无' ]; Hook::listen('order_dispatch_change', $hookParams); diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 958723a..d8d71a3 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -166,6 +166,7 @@ class OrderDispatchService extends BaseService $orderDispatch->save(); + $orderDispatch->admin_user = '师傅:'. $orderDispatch->worker_name; $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, 'remark' => $type == 'accept' ? '师傅接单' : '师傅拒接', @@ -291,6 +292,7 @@ class OrderDispatchService extends BaseService $orderDispatch->plan_time = $planTime; $orderDispatch->save(); + $orderDispatch->admin_user = '师傅:'. $orderDispatch->worker_name; $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, 'remark' => '师傅已和客户预约,预约时间:' . $planTime, @@ -310,6 +312,7 @@ class OrderDispatchService extends BaseService $orderDispatch->plan_time = $planTime; $orderDispatch->save(); + $orderDispatch->admin_user = '师傅:'. $orderDispatch->worker_name; $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, 'remark' => "师傅修改上门时间,旧的时间:{$orderDispatch->plan_time},新的时间:$planTime" @@ -335,6 +338,7 @@ class OrderDispatchService extends BaseService $orderDispatch->arrive_time = $time; $orderDispatch->save(); + $orderDispatch->admin_user = '师傅:'. $orderDispatch->worker_name; //派单状态变更 $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, @@ -417,6 +421,7 @@ class OrderDispatchService extends BaseService $orderDispatch->save(); + $orderDispatch->admin_user = '师傅:'. $orderDispatch->worker_name; //派单状态变更 $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, diff --git a/public/assets/js/backend/orders/dispatchlog.js b/public/assets/js/backend/orders/dispatchlog.js index 6b0223e..a7a21ef 100644 --- a/public/assets/js/backend/orders/dispatchlog.js +++ b/public/assets/js/backend/orders/dispatchlog.js @@ -100,36 +100,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格1绑定事件 Table.api.bindevent(table1); }, - second: function () { - // 表格2 - var table2 = $("#table2"); - table2.bootstrapTable({ - url: 'orders/dispatchlog/index' + location.search, - toolbar: '#toolbar1', - sortName: 'id', - search: false, - commonSearch:false, - visible: false, - showToggle: false, - showColumns: false, - showExport: false, - columns: [ - [ - {field: 'id', title: __('Id')}, - // {field: 'dispatch_id', title: __('Dispatch_id')}, - //{field: 'order_id', title: __('Order_id')}, - //{field: 'worker_id', title: __('Worker_id')}, - // {field: 'status', title: __('Status')}, - {field: 'status_text', title: __('Status_text'), operate: 'LIKE'}, - {field: 'remark', title: __('Remark'), operate: false, table: table2, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} - ] - ] - }); - // 为表格2绑定事件 - Table.api.bindevent(table2); - } + // second: function () { + // // 表格2 + // var table2 = $("#table2"); + // table2.bootstrapTable({ + // url: 'orders/dispatchlog/index' + location.search, + // toolbar: '#toolbar1', + // sortName: 'id', + // search: false, + // commonSearch:false, + // visible: false, + // showToggle: false, + // showColumns: false, + // showExport: false, + // columns: [ + // [ + // {field: 'id', title: __('Id')}, + // // {field: 'dispatch_id', title: __('Dispatch_id')}, + // //{field: 'order_id', title: __('Order_id')}, + // //{field: 'worker_id', title: __('Worker_id')}, + // // {field: 'status', title: __('Status')}, + // {field: 'status_text', title: __('Status_text'), operate: 'LIKE'}, + // {field: 'remark', title: __('Remark'), operate: false, table: table2, class: 'autocontent', formatter: Table.api.formatter.content}, + // {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + // ] + // ] + // }); + // // 为表格2绑定事件 + // Table.api.bindevent(table2); + // } },