From d3d63f4872c608fbb5c2bb0c8ee5b83aef5fec49 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sat, 29 Mar 2025 20:54:18 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BE=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Dispatch2.php | 19 +++- application/admin/lang/en/orders/income.php | 2 +- .../admin/lang/zh-cn/aftersales/aftersale.php | 2 +- application/admin/lang/zh-cn/order.php | 2 +- .../admin/lang/zh-cn/orders/abnormal.php | 2 +- .../admin/lang/zh-cn/orders/auditorder.php | 4 +- .../admin/lang/zh-cn/orders/configorder.php | 4 +- .../admin/lang/zh-cn/orders/dispatch.php | 4 +- .../admin/lang/zh-cn/orders/dispatch2.php | 6 +- .../admin/lang/zh-cn/orders/income.php | 2 +- .../admin/lang/zh-cn/orders/movelog.php | 2 +- .../admin/lang/zh-cn/orders/revisitorder.php | 4 +- application/admin/model/OrderDispatch.php | 6 +- .../admin/view/aftersales/aftersale/edit.html | 2 +- .../admin/view/orders/dispatch2/edit.html | 105 ++++++++++-------- application/index/lang/zh-cn.php | 2 +- public/assets/js/backend/orders/abnormal.js | 24 ++-- public/assets/js/backend/orders/dispatch2.js | 22 +++- 18 files changed, 127 insertions(+), 87 deletions(-) diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 94eb748..03eda33 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -14,8 +14,6 @@ use think\exception\DbException; use think\exception\PDOException; use think\exception\ValidateException; use think\Hook; -use think\Lang; -use think\Loader; /** * 派单列管理 @@ -188,12 +186,20 @@ class Dispatch2 extends Backend if (!$row) { $this->error(__('No Results were found')); } + + $order = Order::where('id',$row->id)->with(['area'])->find(); + + if(empty($order)){ + $this->error(__('未找到关联订单')); + } + $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { $this->view->assign('row', $row); + $this->view->assign('order', $order); return $this->view->fetch(); } @@ -207,6 +213,10 @@ class Dispatch2 extends Backend if (empty($params)) { $this->error(__('Parameter %s can not be empty', '')); } + + if(!in_array($row->status ,$this->model->btnActiveStatusList('btn_edit'))){ + $this->error(__('任务状态已变更,请刷新后再操作')); + } $params = $this->preExcludeFields($params); $result = false; Db::startTrans(); @@ -216,8 +226,13 @@ class Dispatch2 extends Backend $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); + } + if($row->worker_id != $params['worker_id']){ //更换了师傅 + + } $result = $row->allowField(true)->save($params); + Db::commit(); } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); diff --git a/application/admin/lang/en/orders/income.php b/application/admin/lang/en/orders/income.php index c3ceab9..2b58ba9 100644 --- a/application/admin/lang/en/orders/income.php +++ b/application/admin/lang/en/orders/income.php @@ -3,7 +3,7 @@ return [ 'Id' => 'ID', 'Order_id' => '订单ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Tel' => '客户手机', 'Item_type' => '收款事项', 'Item_type 1' => '定金', diff --git a/application/admin/lang/zh-cn/aftersales/aftersale.php b/application/admin/lang/zh-cn/aftersales/aftersale.php index 140d077..5ca10f3 100644 --- a/application/admin/lang/zh-cn/aftersales/aftersale.php +++ b/application/admin/lang/zh-cn/aftersales/aftersale.php @@ -45,7 +45,7 @@ return [ 'Handle_admin_user' => '处理人', 'Star' => '评分', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', diff --git a/application/admin/lang/zh-cn/order.php b/application/admin/lang/zh-cn/order.php index e670f8d..4232711 100644 --- a/application/admin/lang/zh-cn/order.php +++ b/application/admin/lang/zh-cn/order.php @@ -2,7 +2,7 @@ return [ 'Id' => 'ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Customer' => '客户姓名', 'Tel' => '客户电话', 'Status' => '订单状态', diff --git a/application/admin/lang/zh-cn/orders/abnormal.php b/application/admin/lang/zh-cn/orders/abnormal.php index 460cdcf..e980510 100644 --- a/application/admin/lang/zh-cn/orders/abnormal.php +++ b/application/admin/lang/zh-cn/orders/abnormal.php @@ -21,7 +21,7 @@ return [ 'Create_time' => '创建时间', 'Update_time' => '编辑时间', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', diff --git a/application/admin/lang/zh-cn/orders/auditorder.php b/application/admin/lang/zh-cn/orders/auditorder.php index 16f856f..8cb14e3 100644 --- a/application/admin/lang/zh-cn/orders/auditorder.php +++ b/application/admin/lang/zh-cn/orders/auditorder.php @@ -3,7 +3,7 @@ return [ 'Id' => 'ID', 'User_id' => '用户ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Customer' => '客户姓名', 'Tel' => '客户电话', 'Status' => '订单状态', @@ -36,7 +36,7 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Total' => '总收款', 'Online_amount' => '线上收款', diff --git a/application/admin/lang/zh-cn/orders/configorder.php b/application/admin/lang/zh-cn/orders/configorder.php index 1ef9259..ce888c7 100644 --- a/application/admin/lang/zh-cn/orders/configorder.php +++ b/application/admin/lang/zh-cn/orders/configorder.php @@ -2,7 +2,7 @@ return [ 'Id' => 'ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Customer' => '客户姓名', 'Tel' => '客户电话', 'Status' => '订单状态', @@ -35,7 +35,7 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Coupon_id' => '优惠码id', 'Total' => '总收款', diff --git a/application/admin/lang/zh-cn/orders/dispatch.php b/application/admin/lang/zh-cn/orders/dispatch.php index c516811..279701f 100644 --- a/application/admin/lang/zh-cn/orders/dispatch.php +++ b/application/admin/lang/zh-cn/orders/dispatch.php @@ -36,7 +36,7 @@ return [ 'Create_time' => '派单时间', 'Update_time' => '编辑时间', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', @@ -61,7 +61,7 @@ return [ 'Order.detail' => '订单详情', 'Order.remark' => '订单备注', 'Order.images' => '图片', - 'Order.plan_time' => '客户预约时间', + 'Order.plan_time' => '预约时间', 'Order.admin_id' => '录单员ID', 'Order.coupon_id' => '优惠码id', 'Order.total' => '总收款', diff --git a/application/admin/lang/zh-cn/orders/dispatch2.php b/application/admin/lang/zh-cn/orders/dispatch2.php index 4f886f2..23b36fb 100644 --- a/application/admin/lang/zh-cn/orders/dispatch2.php +++ b/application/admin/lang/zh-cn/orders/dispatch2.php @@ -34,9 +34,9 @@ return [ 'Admin_id' => '派单人ID', 'Admin_user' => '派单人', 'Create_time' => '派单时间', - 'Update_time' => '编辑时间', + 'Update_time' => '更新时间', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', @@ -61,7 +61,7 @@ return [ 'Order.detail' => '订单详情', 'Order.remark' => '订单备注', 'Order.images' => '图片', - 'Order.plan_time' => '客户预约时间', + 'Order.plan_time' => '预约时间', 'Order.admin_id' => '录单员ID', 'Order.coupon_id' => '优惠码id', 'Order.total' => '总收款', diff --git a/application/admin/lang/zh-cn/orders/income.php b/application/admin/lang/zh-cn/orders/income.php index 051ddc1..ffaca18 100644 --- a/application/admin/lang/zh-cn/orders/income.php +++ b/application/admin/lang/zh-cn/orders/income.php @@ -3,7 +3,7 @@ return [ 'Id' => 'ID', 'Order_id' => '订单ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Tel' => '客户手机', 'Item_type' => '收款事项', 'Item_type 1' => '定金', diff --git a/application/admin/lang/zh-cn/orders/movelog.php b/application/admin/lang/zh-cn/orders/movelog.php index 57c5f60..6b30dd2 100644 --- a/application/admin/lang/zh-cn/orders/movelog.php +++ b/application/admin/lang/zh-cn/orders/movelog.php @@ -12,7 +12,7 @@ return [ 'Remark' => '备注', 'Create_time' => '创建时间', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', diff --git a/application/admin/lang/zh-cn/orders/revisitorder.php b/application/admin/lang/zh-cn/orders/revisitorder.php index 428b6cf..a238d49 100644 --- a/application/admin/lang/zh-cn/orders/revisitorder.php +++ b/application/admin/lang/zh-cn/orders/revisitorder.php @@ -2,7 +2,7 @@ return [ 'Id' => 'ID', - 'Order_no' => '订单号', + 'Order_no' => '订单编号', 'Customer' => '客户姓名', 'Tel' => '客户电话', 'Status' => '订单状态', @@ -35,7 +35,7 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Total' => '总收款', 'Cost' => '师傅成本', diff --git a/application/admin/model/OrderDispatch.php b/application/admin/model/OrderDispatch.php index 983f7e0..005252f 100644 --- a/application/admin/model/OrderDispatch.php +++ b/application/admin/model/OrderDispatch.php @@ -38,7 +38,7 @@ class OrderDispatch extends Model const STATUS_CLOCK = 30; //已打卡 const STATUS_FINISH = 60; //完成 const STATUS_REFUSED = -10; //拒绝 - const STATUS_MOVE = -20; //中转 + const STATUS_MOVE = -20; //中转(状态废弃) const STATUS_CANCEL = -30; //取消 @@ -49,7 +49,9 @@ class OrderDispatch extends Model public function getStatusList() { - return ['0' => __('Status 0'), '10' => __('Status 10'), '20' => __('Status 20'),'25' => __('Status 25'), '30' => __('Status 30'), '60' => __('Status 60'), '-10' => __('Status -10'), '-20' => __('Status -20'), '-30' => __('Status -30')]; + return ['0' => __('Status 0'), '10' => __('Status 10'), '20' => __('Status 20'),'25' => __('Status 25'), '30' => __('Status 30'), '60' => __('Status 60'), '-10' => __('Status -10'), + // '-20' => __('Status -20'), + '-30' => __('Status -30')]; } public function getIsNoticeList() diff --git a/application/admin/view/aftersales/aftersale/edit.html b/application/admin/view/aftersales/aftersale/edit.html index f56e3a4..b0afe98 100644 --- a/application/admin/view/aftersales/aftersale/edit.html +++ b/application/admin/view/aftersales/aftersale/edit.html @@ -3,7 +3,7 @@
- +
diff --git a/application/admin/view/orders/dispatch2/edit.html b/application/admin/view/orders/dispatch2/edit.html index 5dc52a5..8e5ca56 100644 --- a/application/admin/view/orders/dispatch2/edit.html +++ b/application/admin/view/orders/dispatch2/edit.html @@ -8,23 +8,13 @@ - {notempty name ='action'} - - -
- +
-
- -
- -
-
@@ -33,20 +23,37 @@
- - - - - - +
+ +
+ +
+
- - - - - - +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + {notempty name ='action'} + +
@@ -78,7 +85,18 @@
- {if $row['is_receipt'] } + {if $row['is_receipt']==0 } + +
+ +
+ +
+
+ + {/if} + + {if $row['is_receipt']==1 }
@@ -124,7 +142,7 @@
- +
@@ -142,43 +160,40 @@
- +
- +
+
- +
- -
-
-
- -
- +
+ +
+ + + +
- +
- -
- {foreach name="statusList" item="vo"} - - {/foreach} -
- +
+ +
-
+ {notempty name='row.audit_admin_id'} diff --git a/application/admin/view/orders/dispatch2/edit.html b/application/admin/view/orders/dispatch2/edit.html index 8e5ca56..f402e54 100644 --- a/application/admin/view/orders/dispatch2/edit.html +++ b/application/admin/view/orders/dispatch2/edit.html @@ -150,8 +150,7 @@ diff --git a/application/config.php b/application/config.php index 4582b2d..ff66689 100755 --- a/application/config.php +++ b/application/config.php @@ -173,7 +173,7 @@ return [ // 日志保存目录 'path' => LOG_PATH, // 日志记录级别 - 'level' => [], + 'level' => ['log','error'], ], // +---------------------------------------------------------------------- // | Trace设置 开启 app_trace 后 有效 diff --git a/public/assets/js/backend/orders/configorder.js b/public/assets/js/backend/orders/configorder.js index df3b4c8..4b740b7 100644 --- a/public/assets/js/backend/orders/configorder.js +++ b/public/assets/js/backend/orders/configorder.js @@ -49,6 +49,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'online_amount', title: __('Online_amount'), operate:'BETWEEN'}, {field: 'offline_amount', title: __('Offline_amount'), operate:'BETWEEN'}, + {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'}, + {field: 'real_amount', title: __('Real_amount'), operate:'BETWEEN'}, + {field: 'cost', title: __('Cost'), operate:'BETWEEN'}, + {field: 'performance', title: __('Performance'), operate:'BETWEEN'}, + // {field: 'dispatch_type', title: __('Dispatch_type')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, From 86a1df86de44ad36328d3e45c542f2289bee6ad1 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 31 Mar 2025 10:48:39 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/orders/Configorder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php index 819592b..fb193dd 100644 --- a/application/admin/controller/orders/Configorder.php +++ b/application/admin/controller/orders/Configorder.php @@ -58,7 +58,7 @@ class Configorder extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->tab(Order::TAB_SETTING) - ->auth($this->auth) + ->auth($this->auth,'dispatch_admin_id') ->areaauth($this->auth) ->with(['dispatch']) ->where($where) From a36fd9805f50ef346518f9b8fe7bfc364b0e8872 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 31 Mar 2025 10:53:47 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E5=9B=9E=E8=AE=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/js/backend/orders/revisitorder.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/public/assets/js/backend/orders/revisitorder.js b/public/assets/js/backend/orders/revisitorder.js index d38fbdc..f3decb2 100644 --- a/public/assets/js/backend/orders/revisitorder.js +++ b/public/assets/js/backend/orders/revisitorder.js @@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin index_url: 'orders/revisitorder/index' + location.search, add_url: 'orders/revisitorder/add', edit_url: 'orders/revisitorder/edit', - del_url: 'orders/revisitorder/del', + // del_url: 'orders/revisitorder/del', multi_url: 'orders/revisitorder/multi', import_url: 'orders/revisitorder/import', table: 'order', @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin fixedRightNumber: 1, columns: [ [ - {checkbox: true}, + // {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, {field: 'customer', title: __('Customer'), operate: 'LIKE'}, @@ -57,7 +57,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'delete_time', title: __('Delete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, + align:'left', + buttons:[ + { + name: 'edit', + text:"回访", + title:"回访", + icon: 'fa fa-pencil', + //title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-editone', + visible:function(row){ + if(row.revisit_id <= 0){ + return true; + } + return false; + } + }, + ] + } ] ] }); From 7a4bafcc12eb66a64fb6e85160c96e212651762f Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 31 Mar 2025 11:15:08 +0800 Subject: [PATCH 05/21] =?UTF-8?q?dispatch=20=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Dispatch2.php | 14 +++++++- application/admin/model/OrderDispatchLog.php | 36 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 application/admin/model/OrderDispatchLog.php diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 3a61efe..62d8628 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -4,6 +4,7 @@ namespace app\admin\controller\orders; use app\admin\model\Order; use app\admin\model\OrderDispatch; +use app\admin\model\OrderDispatchLog; use app\common\controller\Backend; use app\common\Logic\OrderLogic; use think\Db; @@ -229,8 +230,19 @@ class Dispatch2 extends Backend $row->validateFailException()->validate($validate); } if($row->worker_id != $params['worker_id']){ //更换了师傅 + $worker = model('worker')->where('id',$params['worker_id'])->find(); + $params ['worker_name'] = $worker->name; + $params ['worker_tel'] = $worker->tel; - + //记录日志 + OrderDispatchLog::create([ + 'dispatch_id' => $row->id, + 'order_id' => $row->order_id, + 'worker_id' => $params['worker_id'], + 'status' => $row->status, + 'status_text' => $this->model->getStatusList()[$row->status], + 'remark' => '师傅由 ('.$row->worker_id.')'.$row->worker_name.' 更换为('.$params['worker_id'].')'.$worker->name + ]); } $result = $row->allowField(true)->save($params); diff --git a/application/admin/model/OrderDispatchLog.php b/application/admin/model/OrderDispatchLog.php new file mode 100644 index 0000000..b01cd48 --- /dev/null +++ b/application/admin/model/OrderDispatchLog.php @@ -0,0 +1,36 @@ + Date: Mon, 31 Mar 2025 11:28:33 +0800 Subject: [PATCH 06/21] =?UTF-8?q?dispatch=20=E5=A2=9E=E5=8A=A0=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/behavior/OrderDispatchLog.php | 31 +++++++++++++++++++ .../admin/controller/orders/Dispatch2.php | 21 ++++++++----- application/tags.php | 4 +++ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 application/admin/behavior/OrderDispatchLog.php diff --git a/application/admin/behavior/OrderDispatchLog.php b/application/admin/behavior/OrderDispatchLog.php new file mode 100644 index 0000000..87e815b --- /dev/null +++ b/application/admin/behavior/OrderDispatchLog.php @@ -0,0 +1,31 @@ +getStatusList(); + $dispatch = $response['dispatch']; //订单对象 + $remark = $response['remark'] ?? ''; //备注 + + $data = [ + 'dispatch_id' => $dispatch->id, + 'order_id' => $dispatch->order_id, + 'worker_id' => $dispatch->worker_id, + 'order_status' => $dispatch->status, + 'order_status_text' => $statusList[$dispatch->status], + 'remark' => $remark, + ]; + \app\admin\model\OrderDispatchLog::create($data); + //(new \app\admin\model\OrderDispatchLog())->cre($data); + } +} diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 62d8628..107f4db 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -229,23 +229,28 @@ class Dispatch2 extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + + $workerChange = false; + $remark = ''; if($row->worker_id != $params['worker_id']){ //更换了师傅 $worker = model('worker')->where('id',$params['worker_id'])->find(); $params ['worker_name'] = $worker->name; $params ['worker_tel'] = $worker->tel; //记录日志 - OrderDispatchLog::create([ - 'dispatch_id' => $row->id, - 'order_id' => $row->order_id, - 'worker_id' => $params['worker_id'], - 'status' => $row->status, - 'status_text' => $this->model->getStatusList()[$row->status], - 'remark' => '师傅由 ('.$row->worker_id.')'.$row->worker_name.' 更换为('.$params['worker_id'].')'.$worker->name - ]); + $remark = '师傅由 ('.$row->worker_id.')'.$row->worker_name.' 更换为('.$params['worker_id'].')'.$worker->name; + $workerChange = true; + } $result = $row->allowField(true)->save($params); + if($workerChange){ + $hookParams = [ + 'dispatch' => $row, + 'remark' => $remark, + ]; + Hook::listen('order_dispatch_change', $hookParams); + } Db::commit(); } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); diff --git a/application/tags.php b/application/tags.php index f51a20b..f1d6c53 100755 --- a/application/tags.php +++ b/application/tags.php @@ -43,4 +43,8 @@ return [ 'app\\admin\\behavior\\OrderLog', 'app\\admin\\behavior\\OrderChangeAfter', ], + + 'order_dispatch_change' => [ + 'app\\admin\\behavior\\OrderDispatchLog', + ], ]; From 65aea577864c3ef72bb3d491d3447e0ea6a694a4 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 31 Mar 2025 11:33:44 +0800 Subject: [PATCH 07/21] =?UTF-8?q?dispatch=20=E5=A2=9E=E5=8A=A0=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Dispatch2.php | 94 ++----------------- application/common/Logic/OrderLogic.php | 7 ++ 2 files changed, 16 insertions(+), 85 deletions(-) diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 107f4db..1ff69b6 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -30,7 +30,7 @@ class Dispatch2 extends Backend */ protected $model = null; - protected $searchFields = 'order.order_no,order.tel,order.customer,worker_name,worker_tel'; + protected $searchFields = 'order.id,order.order_no,order.tel,order.customer,worker_name,worker_tel'; public function _initialize() { @@ -92,88 +92,6 @@ class Dispatch2 extends Backend } - /** - * 添加 - * - * @return string - * @throws \think\Exception - */ - public function add() - { - if (false === $this->request->isPost()) { - $id = $this->request->param('order_id'); - $order = model('order')->where('id', $id)->find(); - if (!$order) { - $this->error(__('No results were found')); - } - - $items = Db::name('item') - ->where('status',1) - ->field(['id','title','key_word','pid']) - ->order('pid','asc') - ->order('sort','desc') - ->select(); - - $tree = $this->buildTree($items); - $formattedTree = $this->formatTree($tree); - - $area_name = model('area')->getNameByCode($order->area_id); - $order->area_name = str_replace(',','/',$area_name); - $this->view->assign('items', $formattedTree); - $this->view->assign('row', $order); - - return $this->view->fetch(); - } - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - $params = $this->preExcludeFields($params); - - if ($this->dataLimit && $this->dataLimitFieldAutoFill) { - $params[$this->dataLimitField] = $this->auth->id; - } - $result = false; - Db::startTrans(); - try { - //是否采用模型验证 - if ($this->modelValidate) { - $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; - $this->model->validateFailException()->validate($validate); - } - $order = model('order')->where('id',$params['order_id'])->find(); - if (!$order){ - $this->error(__('No results were found')); - } - $insert = [ - 'admin_id' => $this->auth->id, - 'admin_user' => $this->auth->nickname, - 'order_id' => $params['order_id'], - 'type' => 1, - 'worker_id' => $params['worker_id'], - 'plan_time' => $order['plan_time'], - 'is_receipt' => $order['receive_type'] == 1 - ]; - - $worker = model('worker')->where('id',$params['worker_id'])->find(); - $insert ['worker_name'] = $worker->name; - $insert ['worker_tel'] = $worker->tel; - - $result = $this->model->allowField(true)->save($insert); - $order->status = Order::STATUS_DISPATCHED; - $order->save(); - Db::commit(); - } catch (ValidateException | PDOException | Exception $e) { - Db::rollback(); - $this->error($e->getMessage()); - } - if ($result === false) { - $this->error(__('No rows were inserted')); - } - $this->success(); - } - /** * 编辑 * @@ -327,7 +245,7 @@ class Dispatch2 extends Backend //修改订单状态 $OrderLogic = new OrderLogic(); - $OrderLogic -> dispachFinishAfter($row,['role'=>1,'auth'=>$this->auth]); + $OrderLogic -> dispachFinishAfter($row,['role'=>1,'auth'=>$this->auth,'remark'=>'后台操作,adminId:'.$this->auth->id]); Db::commit(); } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); @@ -443,7 +361,7 @@ class Dispatch2 extends Backend $this->error('订单状态已变更,请刷新后操作'); } //取消 - $item->save(['status' => OrderDispatch::STATUS_CANCEL, 'remark' => $remark]); + $item->allowField(true)->save(['status' => OrderDispatch::STATUS_CANCEL, 'remark' => $remark]); //回退订单状态 $order->allowField(true)->save(['status' => Order::STATUS_DISPATCHING]); $params['order'] = $order; @@ -454,6 +372,12 @@ class Dispatch2 extends Backend $params['remark'] .= ',操作备注:' . $remark; } Hook::listen('order_change', $params); + + $hookParams = [ + 'dispatch' => $item, + 'remark' => '后台取消,adminId:'.$this->auth->id + ]; + Hook::listen('order_dispatch_change', $hookParams); } Db::commit(); } catch (PDOException | Exception $e) { diff --git a/application/common/Logic/OrderLogic.php b/application/common/Logic/OrderLogic.php index 92a1b77..63c45ff 100644 --- a/application/common/Logic/OrderLogic.php +++ b/application/common/Logic/OrderLogic.php @@ -57,6 +57,13 @@ class OrderLogic $params['remark'] = $roleInfo['remark'] ?? $orderDispatch->remark; Hook::listen('order_change', $params); + + + $hookParams = [ + 'dispatch' => $orderDispatch, + 'remark' => $roleInfo['remark'] ?? $orderDispatch->remark, + ]; + Hook::listen('order_dispatch_change', $hookParams); } } \ No newline at end of file From 066c6fb584214894e69270646933bc64e540e198 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Mon, 31 Mar 2025 14:15:54 +0800 Subject: [PATCH 08/21] text --- .../admin/controller/orders/Configorder.php | 6 ++-- application/admin/lang/en/orders/income.php | 2 +- .../admin/lang/zh-cn/orders/auditorder.php | 5 +-- .../admin/lang/zh-cn/orders/configorder.php | 5 +-- .../admin/lang/zh-cn/orders/dispatch.php | 4 +-- .../admin/lang/zh-cn/orders/dispatch2.php | 4 +-- .../admin/lang/zh-cn/orders/income.php | 2 +- .../admin/view/orders/configorder/edit.html | 32 +++++++++++-------- .../admin/view/orders/dispatch/add.html | 2 +- .../admin/view/orders/dispatch2/add.html | 2 +- .../admin/view/orders/dispatch2/edit.html | 8 ++--- public/assets/js/backend/orders/auditorder.js | 1 + .../assets/js/backend/orders/configorder.js | 15 +++++---- 13 files changed, 50 insertions(+), 38 deletions(-) diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php index fb193dd..54b54d3 100644 --- a/application/admin/controller/orders/Configorder.php +++ b/application/admin/controller/orders/Configorder.php @@ -122,18 +122,20 @@ class Configorder extends Backend $data = [ 'status' => Order::STATUS_AUDITING, + 'online_amount_last' => $params['online_amount_last'], 'offline_amount' => $params['offline_amount'], 'refund_amount' => $params['refund_amount'], 'cost' => $params['cost'], ]; - $data['total'] = bcadd($row->online_amount,$params['offline_amount'],2); + $last_amount = bcadd($params['online_amount_last'],$params['offline_amount'],2); + + $data['total'] = bcadd($row->online_amount,$last_amount,2); $data['real_amount'] = bcsub($data['total'],$params['refund_amount'],2); $data['performance'] = bcsub($data['real_amount'],$params['cost'],2); $result = $row->allowField(true)->save($data); //日志 - $params['order'] = $row; $params['role'] = 1; $params['auth'] = $this->auth; diff --git a/application/admin/lang/en/orders/income.php b/application/admin/lang/en/orders/income.php index 2b58ba9..13dfad4 100644 --- a/application/admin/lang/en/orders/income.php +++ b/application/admin/lang/en/orders/income.php @@ -13,7 +13,7 @@ return [ 'Amount' => '收款金额', 'Income_type' => '收款方式', 'Income_type 1' => '平台收款', - 'Income_type 2' => '线下收款', + 'Income_type 2' => '线下尾款', 'Admin_id' => '创建人ID', 'Admin_user' => '创建人', 'Payment_time' => '收款时间', diff --git a/application/admin/lang/zh-cn/orders/auditorder.php b/application/admin/lang/zh-cn/orders/auditorder.php index 8cb14e3..c23df85 100644 --- a/application/admin/lang/zh-cn/orders/auditorder.php +++ b/application/admin/lang/zh-cn/orders/auditorder.php @@ -39,8 +39,9 @@ return [ 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Total' => '总收款', - 'Online_amount' => '线上收款', - 'Offline_amount' => '线下收款', + 'Online_amount' => '线上预付', + 'Online_amount_last' => '线上尾款', + 'Offline_amount' => '线下尾款', 'Discount_amount' => '优惠抵扣', 'Real_amount' => '实际收款', 'Refund_amount' => '退款金额', diff --git a/application/admin/lang/zh-cn/orders/configorder.php b/application/admin/lang/zh-cn/orders/configorder.php index 80e83dc..c565930 100644 --- a/application/admin/lang/zh-cn/orders/configorder.php +++ b/application/admin/lang/zh-cn/orders/configorder.php @@ -39,8 +39,9 @@ return [ 'Admin_id' => '录单员ID', 'Coupon_id' => '优惠码id', 'Total' => '总收款', - 'Online_amount' => '线上收款', - 'Offline_amount' => '线下收款', + 'Online_amount' => '线上预付', + 'Online_amount_last' => '线上尾款', + 'Offline_amount' => '线下尾款', 'Discount_amount' => '优惠抵扣', 'Refund_amount' => '退款金额', 'Real_amount' => '实际收款', diff --git a/application/admin/lang/zh-cn/orders/dispatch.php b/application/admin/lang/zh-cn/orders/dispatch.php index 17e3b46..7e30552 100644 --- a/application/admin/lang/zh-cn/orders/dispatch.php +++ b/application/admin/lang/zh-cn/orders/dispatch.php @@ -65,8 +65,8 @@ return [ 'Order.admin_id' => '录单员ID', 'Order.coupon_id' => '优惠码id', 'Order.total' => '总收款', - 'Order.online_amount' => '线上收款', - 'Order.offline_amount' => '线下收款', + 'Order.online_amount' => '线上预付', + 'Order.offline_amount' => '线下尾款', 'Order.discount_amount' => '优惠抵扣', 'Order.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', diff --git a/application/admin/lang/zh-cn/orders/dispatch2.php b/application/admin/lang/zh-cn/orders/dispatch2.php index 5d96287..dd75a8c 100644 --- a/application/admin/lang/zh-cn/orders/dispatch2.php +++ b/application/admin/lang/zh-cn/orders/dispatch2.php @@ -65,8 +65,8 @@ return [ 'Order.admin_id' => '录单员ID', 'Order.coupon_id' => '优惠码id', 'Order.total' => '总收款', - 'Order.online_amount' => '线上收款', - 'Order.offline_amount' => '线下收款', + 'Order.online_amount' => '线上预付', + 'Order.offline_amount' => '线下尾款', 'Order.discount_amount' => '优惠抵扣', 'Order.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', diff --git a/application/admin/lang/zh-cn/orders/income.php b/application/admin/lang/zh-cn/orders/income.php index ffaca18..1731c83 100644 --- a/application/admin/lang/zh-cn/orders/income.php +++ b/application/admin/lang/zh-cn/orders/income.php @@ -19,7 +19,7 @@ return [ 'Amount' => '收款金额', 'Income_type' => '收款方式', 'Income_type 1' => '平台收款', - 'Income_type 2' => '线下收款', + 'Income_type 2' => '线下尾款', 'Admin_id' => '创建人ID', 'Admin_user' => '创建人', 'Payment_time' => '收款时间', diff --git a/application/admin/view/orders/configorder/edit.html b/application/admin/view/orders/configorder/edit.html index f364e58..a063836 100644 --- a/application/admin/view/orders/configorder/edit.html +++ b/application/admin/view/orders/configorder/edit.html @@ -1,5 +1,16 @@
+ + {notempty name='row.audit_remark'} +
+ +
+
{$row.audit_remark|htmlentities}
+
+
+ {/notempty} + +
@@ -38,10 +49,17 @@
+
+ +
+ +
+
+
- +
@@ -66,18 +84,6 @@
--> - {notempty name='row.audit_admin_id'} - -
- -
- -
-
- - {/notempty} - -