diff --git a/application/admin/controller/orders/Abnormal.php b/application/admin/controller/orders/Abnormal.php index 724dc15..0e55b82 100644 --- a/application/admin/controller/orders/Abnormal.php +++ b/application/admin/controller/orders/Abnormal.php @@ -4,11 +4,13 @@ namespace app\admin\controller\orders; use app\admin\model\Order; use app\common\controller\Backend; +use app\common\Logic\OrderLogic; use think\Db; use think\Exception; use think\exception\DbException; use think\exception\PDOException; use think\exception\ValidateException; +use think\Hook; /** * 订单异常记录 @@ -114,7 +116,7 @@ class Abnormal extends Backend $this->model->validateFailException()->validate($validate); } - $order = Order::where('id',$params['order_id'])->find(); + $order = Order::where('id',$params['order_id'])->find()->with('dispatch'); if(empty($order)){ throw new Exception('请选择订单'); } @@ -124,6 +126,30 @@ class Abnormal extends Backend $params['abnormal_title'] = $abnormal_title; $params['admin_id'] = $this->auth->id; $params['admin_user'] = $this->auth->username; + + + + if ($params['abnormal_id'] == 2 || $params['abnormal_id'] == 3){ + + $order->status = Order::STATUS_CANCEL; + $order->abnormal_id = $params['abnormal_id']; + $order->abnormal_title = $abnormal_title; + $order->save(); + if (!empty($order->dispatch->id)) { + $orderLogic = new OrderLogic(); + $orderLogic->cancelOrderDispatch($order->dispatch, $this->auth, '订单被取消', false); + //日志 + $hookparams['order'] = $order; + $hookparams['role'] = 1; + $hookparams['auth'] = $this->auth; + $hookparams['remark'] = $params['remark'] ?? ''; + Hook::listen('order_change', $hookparams); + } + + } + + + $result = $this->model->allowField(true)->save($params); Db::commit(); } catch (ValidateException|PDOException|Exception $e) { diff --git a/application/admin/lang/zh-cn/orders/abnormal.php b/application/admin/lang/zh-cn/orders/abnormal.php index e980510..cdb5a5a 100644 --- a/application/admin/lang/zh-cn/orders/abnormal.php +++ b/application/admin/lang/zh-cn/orders/abnormal.php @@ -10,9 +10,9 @@ return [ 'Set status to 1' => '设为已处理', 'Status -1' => '不予处理', 'Set status to -1' => '设为不予处理', - 'Abnormal_id' => '异常类型', - 'Abnormal_title' => '异常类型', - 'Detail' => '异常详情', + 'Abnormal_id' => '报错类型', + 'Abnormal_title' => '报错类型', + 'Detail' => '报错详情', 'Handle_detail' => '处理详情', 'Handle_admin_user' => '处理人', 'Handle_time' => '处理时间', diff --git a/application/admin/view/orders/abnormal/edit.html b/application/admin/view/orders/abnormal/edit.html index cb836df..29c05bb 100644 --- a/application/admin/view/orders/abnormal/edit.html +++ b/application/admin/view/orders/abnormal/edit.html @@ -30,7 +30,17 @@ - +