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/behavior/OrderLog.php b/application/admin/behavior/OrderLog.php index fbb0e40..926e37f 100644 --- a/application/admin/behavior/OrderLog.php +++ b/application/admin/behavior/OrderLog.php @@ -27,7 +27,7 @@ class OrderLog 'role' => $role, 'remark' => $remark, 'admin_id' => $auth->id ?? 0, - 'admin_user' => $role==1 ? $auth->nickname : $auth->name + 'admin_user' => $role==1 ? ($auth->nickname ?? 'sys') : $auth->name ]; (new \app\admin\model\OrderLog())->save($data); } diff --git a/application/admin/behavior/SendOverTimeSms.php b/application/admin/behavior/SendOverTimeSms.php new file mode 100644 index 0000000..3a6a7d3 --- /dev/null +++ b/application/admin/behavior/SendOverTimeSms.php @@ -0,0 +1,24 @@ +status == OrderDispatch::STATUS_OVERTIME){ //发送短信 + + } + }catch (Exception $exception){ + + } + } +} diff --git a/application/admin/controller/orders/Auditorder.php b/application/admin/controller/orders/Auditorder.php index aca5b36..022f970 100644 --- a/application/admin/controller/orders/Auditorder.php +++ b/application/admin/controller/orders/Auditorder.php @@ -31,6 +31,7 @@ class Auditorder extends Backend $this->model = new \app\admin\model\Order(); //$this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("statusList", $this->model->getAuditStatusList()); + $this->view->assign("offlineTotalTypeList", $this->model->getOfflineTotalTypeList()); } diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php index 7e93cc1..5a14389 100644 --- a/application/admin/controller/orders/Configorder.php +++ b/application/admin/controller/orders/Configorder.php @@ -30,6 +30,8 @@ class Configorder extends Backend parent::_initialize(); $this->model = new Order(); $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("offlineTotalTypeList", $this->model->getOfflineTotalTypeList()); + } @@ -56,9 +58,10 @@ class Configorder extends Backend return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $list = $this->model - ->scope('tab',Order::TAB_SETTING) + ->tab(Order::TAB_SETTING) + ->auth($this->auth,'dispatch_admin_id') + ->areaauth($this->auth) ->with(['dispatch']) ->where($where) ->order($sort, $order) @@ -121,18 +124,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); - $data['real_amount'] = bcdiv($data['total'],$params['refund_amount'],2); - $data['performance'] = bcdiv($data['real_amount'],$params['cost'],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/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 94eb748..3ac2732 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; @@ -14,8 +15,6 @@ use think\exception\DbException; use think\exception\PDOException; use think\exception\ValidateException; use think\Hook; -use think\Lang; -use think\Loader; /** * 派单列管理 @@ -31,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() { @@ -41,8 +40,7 @@ class Dispatch2 extends Backend $this->model = new \app\admin\model\OrderDispatch; $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("statusList", $this->model->getStatusList()); - - + $this->view->assign("offlineTotalTypeList", $this->model->getOfflineTotalTypeList()); } @@ -72,6 +70,7 @@ class Dispatch2 extends Backend $list = $this->model ->with(['order']) + ->auth($this->auth) ->where($where) ->order($sort, $order) ->paginate($limit); @@ -82,6 +81,8 @@ class Dispatch2 extends Backend $row->btn_abnormal = (in_array($row->status, $this->model->btnActiveStatusList('btn_abnormal'))) ? true : false; $row->btn_finished = (in_array($row->status, $this->model->btnActiveStatusList('btn_finished'))) ? true : false; $row->is_disabled = (in_array($row->status, $this->model->btnActiveStatusList('disabled_status'))) ? true : false; + + $row->btn_record = (in_array($row->status, $this->model->btnActiveStatusList('btn_record'))) ? true : false; // $row->btn_income = (in_array($row->status, $this->model->btnActiveStatusList('btn_income')) && in_array($row->order->status, $orderModel->incomeBtnStatus())) ? true : false; } $result = array("total" => $list->total(), "rows" => $list->items()); @@ -92,88 +93,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(); - } - /** * 编辑 * @@ -188,12 +107,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 +134,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(); @@ -217,7 +148,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; + + //记录日志 + $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(); @@ -288,13 +240,14 @@ class Dispatch2 extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + $params['status'] = OrderDispatch::STATUS_FINISH; $params['finish_time'] = date('Y-m-d H:i:s'); $result = $row->allowField(true)->save($params); //修改订单状态 $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(); @@ -401,6 +354,9 @@ class Dispatch2 extends Backend $remark = $reason; $count = 0; + + $OrderLogic = new OrderLogic(); + Db::startTrans(); try { foreach ($list as $item) { @@ -410,17 +366,19 @@ 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; - $params['role'] = 1; - $params['auth'] = $this->auth; - $params['remark'] = '派单被取消[ID:' . $item->id . '],订单状态回退'; - if (!empty($remark)) { - $params['remark'] .= ',操作备注:' . $remark; - } - Hook::listen('order_change', $params); + //$order->allowField(true)->save(['status' => Order::STATUS_DISPATCHING]); + + /* Hook::listen('order_change', $params); + + $hookParams = [ + 'dispatch' => $item, + 'remark' => '后台取消,adminId:'.$this->auth->id + ]; + Hook::listen('order_dispatch_change', $hookParams);*/ + + $OrderLogic->cancelOrderDispatch($item,$this->auth,$remark); } Db::commit(); } catch (PDOException | Exception $e) { diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php new file mode 100644 index 0000000..160d998 --- /dev/null +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -0,0 +1,148 @@ +model = new \app\admin\model\OrderDispatchRecord; + $this->view->assign("needNoticeList", $this->model->getNeedNoticeList()); + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add($ids=null) + { + if (false === $this->request->isPost()) { + + $dispatch = OrderDispatch::get($ids); + + if(empty($dispatch)){ + $this->error('没有关联派单'); + } + $list = $this->model->where('dispatch_id',$ids)->order('id','desc')->select(); + + $this->assign('dispatch',$dispatch); + + $this->assign('records',$list); + + 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); + } + + $params['admin_id'] = $this->auth->id; + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $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); + 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); + $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 . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + +} diff --git a/application/admin/lang/en/orders/income.php b/application/admin/lang/en/orders/income.php index c3ceab9..13dfad4 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' => '定金', @@ -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/aftersales/aftersale.php b/application/admin/lang/zh-cn/aftersales/aftersale.php index 140d077..47dc7a0 100644 --- a/application/admin/lang/zh-cn/aftersales/aftersale.php +++ b/application/admin/lang/zh-cn/aftersales/aftersale.php @@ -21,7 +21,7 @@ return [ 'From 1' => '师傅', 'From 2' => '顾客', 'From 3' => '平台', - 'Refund_amount' => '总退款金额', + 'Refund_amount' => '退款金额', 'Company_refund_amount' => '公司退款金额', 'Worker_refund_amount' => '师傅退款金额', 'Refund_type' => '退款方式', @@ -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..bbd74eb 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' => '订单状态', @@ -61,4 +61,8 @@ return [ 'Dispatch_time' => '派单时间', 'Delete_time' => '删除时间', 'Coupons' => '优惠', + 'Offline_amount_type' => '线下尾款类型', + 'Offline_amount_type 0' => '无', + 'Offline_amount_type 1' => '师傅收', + 'Offline_amount_type 2' => '公司收', ]; 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..ce505ed 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,11 +36,18 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Total' => '总收款', - 'Online_amount' => '线上收款', - 'Offline_amount' => '线下收款', + 'Online_amount' => '线上预付', + 'Online_amount_last' => '线上尾款', + + 'Offline_amount_type' => '线下尾款类型', + 'Offline_amount_type 0' => '无', + 'Offline_amount_type 1' => '师傅收', + 'Offline_amount_type 2' => '公司收', + + '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 1ef9259..55166ab 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,14 +35,20 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Coupon_id' => '优惠码id', 'Total' => '总收款', - 'Online_amount' => '线上收款', - 'Offline_amount' => '线下收款', + 'Online_amount' => '线上预付', + 'Online_amount_last' => '线上尾款', + 'Offline_amount' => '线下尾款', + + 'Offline_amount_type' => '线下尾款类型', + 'Offline_amount_type 0' => '无', + 'Offline_amount_type 1' => '师傅收', + 'Offline_amount_type 2' => '公司收', 'Discount_amount' => '优惠抵扣', - 'Refund_amount' => '总退款额', + 'Refund_amount' => '退款金额', 'Real_amount' => '实际收款', 'Cost' => '师傅成本', 'Performance' => '预计利润', diff --git a/application/admin/lang/zh-cn/orders/dispatch.php b/application/admin/lang/zh-cn/orders/dispatch.php index c516811..7e30552 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,14 +61,14 @@ return [ 'Order.detail' => '订单详情', 'Order.remark' => '订单备注', 'Order.images' => '图片', - 'Order.plan_time' => '客户预约时间', + 'Order.plan_time' => '预约时间', '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.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', 'Order.cost' => '师傅成本', 'Order.performance' => '预计利润', diff --git a/application/admin/lang/zh-cn/orders/dispatch2.php b/application/admin/lang/zh-cn/orders/dispatch2.php index 4f886f2..e95ea7d 100644 --- a/application/admin/lang/zh-cn/orders/dispatch2.php +++ b/application/admin/lang/zh-cn/orders/dispatch2.php @@ -27,6 +27,13 @@ return [ 'Set status to -20' => '设为已移交', 'Status -30' => '已取消', 'Set status to -30' => '设为已取消', + 'Total' => '线下尾款', + 'Online' => '线上尾款', + 'Amount' => '预计佣金', + 'Offline_total_type' => '线下尾款类型', + 'Offline_total_type 0' => '无', + 'Offline_total_type 1' => '师傅收', + 'Offline_total_type 2' => '公司收', 'Remark' => '备注', 'Notice_num' => '通知次数', 'Plan_time' => '预约时间', @@ -34,9 +41,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,14 +68,14 @@ return [ 'Order.detail' => '订单详情', 'Order.remark' => '订单备注', 'Order.images' => '图片', - 'Order.plan_time' => '客户预约时间', + 'Order.plan_time' => '预约时间', '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.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', 'Order.cost' => '师傅成本', 'Order.performance' => '预计利润', diff --git a/application/admin/lang/zh-cn/orders/dispatchrecord.php b/application/admin/lang/zh-cn/orders/dispatchrecord.php new file mode 100644 index 0000000..c45746f --- /dev/null +++ b/application/admin/lang/zh-cn/orders/dispatchrecord.php @@ -0,0 +1,19 @@ + '任务ID', + 'Worker_id' => '师傅ID', + 'Remark' => '备注', + 'Need_notice' => '提醒师傅', + 'Need_notice 0' => '不需要', + 'Need_notice 1' => '需要', + 'Status' => '通知状态', + 'Status 0' => '未通知', + 'Set status to 0'=> '设为未通知', + 'Status 1' => '已通知', + 'Set status to 1'=> '设为已通知', + 'Notice_time' => '提醒时间', + 'Create_time' => '创建时间', + 'Update_time' => '更新时间', + 'Admin_id' => '管理员ID' +]; diff --git a/application/admin/lang/zh-cn/orders/income.php b/application/admin/lang/zh-cn/orders/income.php index 051ddc1..1731c83 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' => '定金', @@ -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/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/Order.php b/application/admin/model/Order.php index 7c74feb..6ccc972 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use app\admin\library\Auth; use think\Model; use traits\model\SoftDelete; @@ -29,7 +30,8 @@ class Order extends Model protected $append = [ 'status_text', 'collect_text', - 'dispatch_type_text' + 'dispatch_type_text', + 'offline_amount_type_text' ]; @@ -75,6 +77,12 @@ class Order extends Model } + public function getOfflineTotalTypeList() + { + return ['0' => __('Offline_amount_type 0'), '1'=> __('Offline_amount_type 1'),'2' => __('Offline_amount_type 2')]; + } + + public function getStatusTextAttr($value, $data) { $value = $value ?: ($data['status'] ?? ''); @@ -82,6 +90,16 @@ class Order extends Model return $list[$value] ?? ''; } + public function getOfflineAmountTypeTextAttr($value, $data) + { + $value = $value ?: ($data['offline_amount_type'] ?? ''); + $list = $this->getOfflineTotalTypeList(); + return $list[$value] ?? ''; + } + + + + public function getCollectTextAttr($value, $data) { @@ -158,4 +176,38 @@ class Order extends Model { return $this->hasOne(OrderDispatch::class, 'order_id', 'id', [], 'LEFT')->setEagerlyType(0)->where('fa_order_dispatch.status',OrderDispatch::STATUS_FINISH); } + + + /** + * 管理员权限 + * @param $query + * @param Auth $auth + * @param string $auth_admin_id + * @return mixed + */ + public function scopeAuth($query, Auth $auth, string $admin_id_field='admin_id'){ + + if(!$auth->isSuperAdmin()){ + $query->where('fa_order.'.$admin_id_field,$auth->id); + } + return $query; + } + + /** + * 地域权限 + * @param $query + * @param Auth $auth + * @param string $area_id_field + * @return mixed + */ + public function scopeAreaauth($query,Auth $auth,string $area_id_field='area_id'){ + if(!$auth->isSuperAdmin()){ + $areaIds = array_unique(array_filter(explode(',',trim($auth->area_ids)))); + if(!in_array('*',$areaIds)){ + $query->whereIn('fa_order.'.$area_id_field,$areaIds); + } + } + return $query; + } + } diff --git a/application/admin/model/OrderDispatch.php b/application/admin/model/OrderDispatch.php index 983f7e0..d133f6e 100644 --- a/application/admin/model/OrderDispatch.php +++ b/application/admin/model/OrderDispatch.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use app\admin\library\Auth; use think\Model; @@ -38,7 +39,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 +50,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() @@ -57,6 +60,11 @@ class OrderDispatch extends Model return ['0' => __('Is_notice 0'), '1' => __('Is_notice 1')]; } + public function getOfflineTotalTypeList() + { + return ['0' => __('Offline_total_type 0'), '1'=> __('Offline_total_type 1'),'2' => __('Offline_total_type 2')]; + } + public function getTypeTextAttr($value, $data) { @@ -144,9 +152,34 @@ class OrderDispatch extends Model self::STATUS_CANCEL, self::STATUS_REFUSED, self::STATUS_MOVE - ] + ], + 'btn_record' => [ + self::STATUS_TOGET, + self::STATUS_GOTIT, + self::STATUS_PLANIT, + self::STATUS_OVERTIME, + self::STATUS_CLOCK, + ], ]; return $btns[$btn]??[]; } + + + + /** + * 管理员权限 + * @param $query + * @param Auth $auth + * @param string $auth_admin_id + * @return mixed + */ + public function scopeAuth($query, Auth $auth, string $admin_id_field='admin_id'){ + + if(!$auth->isSuperAdmin()){ + $query->where('fa_order_dispatch.'.$admin_id_field,$auth->id); + } + return $query; + } + } 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 @@ + __('Need_notice 0'), '1' => __('Need_notice 1')]; + } + + public function getStatusList() + { + return ['0' => __('Status 0'), '1' => __('Status 1')]; + } + + + public function getNeedNoticeTextAttr($value, $data) + { + $value = $value ?: ($data['need_notice'] ?? ''); + $list = $this->getNeedNoticeList(); + return $list[$value] ?? ''; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ?: ($data['status'] ?? ''); + $list = $this->getStatusList(); + return $list[$value] ?? ''; + } + + + + +} diff --git a/application/admin/validate/OrderDispatchRecord.php b/application/admin/validate/OrderDispatchRecord.php new file mode 100644 index 0000000..a3173c0 --- /dev/null +++ b/application/admin/validate/OrderDispatchRecord.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} 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/auditorder/edit.html b/application/admin/view/orders/auditorder/edit.html index 5392f79..a1085aa 100644 --- a/application/admin/view/orders/auditorder/edit.html +++ b/application/admin/view/orders/auditorder/edit.html @@ -92,6 +92,14 @@ + +
+ +
+ +
+
+
@@ -99,6 +107,13 @@
+
+ +
+ +
+
+
@@ -106,10 +121,11 @@
+
- +
- + {:build_select('offline_amount_type',$offlineTotalTypeList,$row['dispatch']['offline_total_type'],['class'=>'form-control','data-rule'=>'required'])}
diff --git a/application/admin/view/orders/configorder/edit.html b/application/admin/view/orders/configorder/edit.html index ce8694e..36d8d19 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,24 @@
+
+ +
+ +
+
+
- + +
+
+ +
+ +
+ {:build_select('offline_amount_type',$offlineTotalTypeList,$row['dispatch']['offline_total_type'],['class'=>'form-control','data-rule'=>'required'])}
@@ -52,31 +77,21 @@ +
- +
-
+ +
diff --git a/application/admin/view/orders/dispatch2/add.html b/application/admin/view/orders/dispatch2/add.html index 47b59d9..0198677 100644 --- a/application/admin/view/orders/dispatch2/add.html +++ b/application/admin/view/orders/dispatch2/add.html @@ -13,7 +13,7 @@

订单详情: {$row.detail}

订单备注: {$row.remark}

- +
diff --git a/application/admin/view/orders/dispatch2/edit.html b/application/admin/view/orders/dispatch2/edit.html index 5dc52a5..fb9b9e2 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'} + +
@@ -71,6 +78,15 @@
+
+ +
+ +
+
+ + {if $row['is_receipt']==0 } +
@@ -78,11 +94,35 @@
- {if $row['is_receipt'] } +
+ +
+ +
+
+ + {/if} + + {if $row['is_receipt']==1 } +
- +
- + +
+
+ +
+ +
+ +
+
+ +
+ +
+ {:build_select('offline_total_type',$offlineTotalTypeList,$row['offline_total_type'],['class'=>'form-control','data-rule'=>'required'])}
@@ -93,7 +133,7 @@
- +
@@ -124,7 +164,7 @@
- +
@@ -132,8 +172,7 @@ @@ -142,43 +181,40 @@
- +
- +
+
- +
- -
-
-
- -
- +
+ +
+ + + +
- +
- -
- {foreach name="statusList" item="vo"} - - {/foreach} -
- +
+ +