diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php new file mode 100644 index 0000000..7e93cc1 --- /dev/null +++ b/application/admin/controller/orders/Configorder.php @@ -0,0 +1,155 @@ +model = new Order(); + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->scope('tab',Order::TAB_SETTING) + ->with(['dispatch']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) + { + + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + + + + /** + * 编辑 + * + * @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); + + if($row->status != Order::STATUS_CHECKING){ + $this->error('订单不允许操作'); + } + $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); + } + + $data = [ + 'status' => Order::STATUS_AUDITING, + '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); + $result = $row->allowField(true)->save($data); + + //日志 + + $params['order'] = $row; + $params['role'] = 1; + $params['auth'] = $this->auth; + $params['remark'] = ''; + + Hook::listen('order_change', $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/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index c36bbd6..324610e 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -288,7 +288,10 @@ class Dispatch2 extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + $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]); Db::commit(); diff --git a/application/admin/lang/zh-cn/orders/configorder.php b/application/admin/lang/zh-cn/orders/configorder.php new file mode 100644 index 0000000..670808e --- /dev/null +++ b/application/admin/lang/zh-cn/orders/configorder.php @@ -0,0 +1,87 @@ + 'ID', + 'Order_no' => '订单号', + 'Customer' => '客户姓名', + 'Tel' => '客户电话', + 'Status' => '订单状态', + 'Status 0' => '草稿', + 'Set status to 0' => '设为草稿', + 'Status 10' => '未派单', + 'Set status to 10' => '设为未派单', + 'Status 20' => '已派单', + 'Set status to 20' => '设为已派单', + 'Status 30' => '进行中', + 'Set status to 30' => '设为进行中', + 'Status 40' => '待验收', + 'Set status to 40' => '设为待验收', + 'Status 50' => '待财务审核', + 'Set status to 50' => '设为待财务审核', + 'Status 60' => '已完成', + 'Set status to 60' => '设为已完成', + 'Status -10' => '取消', + 'Set status to -10' => '设为取消', + 'Area_id' => '地域', + 'Address' => '详细地址', + 'Lng' => '经度', + 'Lat' => '纬度', + 'Work_tel_id' => '工作机', + 'Source_shop' => '来源店铺', + 'Source' => '订单来源', + 'Source_uid' => '来源UID', + 'Item_id' => '服务ID', + 'Item_title' => '服务名称', + 'Detail' => '订单详情', + 'Remark' => '订单备注', + 'Images' => '图片', + 'Plan_time' => '客户预约时间', + 'Admin_id' => '录单员ID', + 'Coupon_id' => '优惠码id', + 'Total' => '总收款', + 'Online_amount' => '线上收款', + 'Offline_amount' => '线下收款', + 'Discount_amount' => '优惠抵扣', + 'Refund_amount' => '总退款额', + 'Real_amount' => '实际收款', + 'Cost' => '师傅成本', + 'Performance' => '预计利润', + 'Cancel_reason_id' => '取消原因', + 'Cancel_detail' => '取消详情', + 'Audit_remark' => '审核备注', + 'Audit_admin_id' => '审核员', + 'Create_time' => '录单时间', + 'Update_time' => '更新时间', + 'Delete_time' => '删除时间', + 'Dispatch_type' => '1 手动派单 2自动排单', + 'Receive_type' => '1 定金 2全款', + 'Dispatch.id' => 'ID', + 'Dispatch.order_id' => '订单ID', + 'Dispatch.type' => '派单方式', + 'Dispatch.type 1' => '手动', + 'Dispatch.worker_id' => '师傅ID', + 'Dispatch.worker_name' => '师傅姓名', + 'Dispatch.worker_tel' => '师傅电话', + 'Dispatch.status' => '进度', + 'Dispatch.status 0' => '待接单', + 'Dispatch.status 10' => '已接单', + 'Dispatch.status 20' => '已预约', + 'Dispatch.status 25' => '已开始未打卡', + 'Dispatch.status 30' => '已打卡', + 'Dispatch.status 60' => '已完成', + 'Dispatch.status -10' => '已拒接', + 'Dispatch.status -20' => '已移交', + 'Dispatch.status -30' => '已取消', + 'Dispatch.is_receipt' => '是否收款:0否,1是', + 'Dispatch.total' => '师傅收款金额', + 'Dispatch.remark' => '备注', + 'Dispatch.notice_num' => '通知次数', + 'Dispatch.images' => '完成图片', + 'Dispatch.image' => '收款凭证', + 'Dispatch.plan_time' => '预约时间', + 'Dispatch.finish_time' => '完成时间', + 'Dispatch.admin_id' => '派单人ID', + 'Dispatch.admin_user' => '派单人', + 'Dispatch.create_time' => '派单时间', + 'Dispatch.update_time' => '编辑时间' +]; diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index 2dba643..9438193 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -37,6 +37,8 @@ class Order extends Model const TAB_PENDING = 'pending'; //跟进中 + const TAB_SETTING = 'setting'; //跟进中 + const TAB_AUDIT = 'audit'; //审核 const TAB_REVIEW = 'review'; //回访 @@ -125,6 +127,9 @@ class Order extends Model self::TAB_REVIEW => [ self::STATUS_FINISHED ], + self::TAB_SETTING => [ + self::STATUS_CHECKING + ], ]; return $tabStatus[$tab] ?? []; } @@ -148,4 +153,9 @@ class Order extends Model public function auditadmin(){ return $this->belongsTo(Admin::class,'audit_admin_id',); } + + public function dispatch() + { + return $this->hasOne(OrderDispatch::class, 'id', 'order_id', [], 'LEFT')->setEagerlyType(0)->where('fa_order_dispatch.status',OrderDispatch::STATUS_FINISH); + } } diff --git a/application/admin/model/order/Dispatch.php b/application/admin/model/order/Dispatch.php new file mode 100644 index 0000000..f1001b7 --- /dev/null +++ b/application/admin/model/order/Dispatch.php @@ -0,0 +1,12 @@ + [ 'app\\admin\\behavior\\AdminLog', ], - - 'order_change' => [ - 'app\\admin\\behavior\\OrderLog', - 'app\\admin\\behavior\\OrderChangeAfter', - ], ]; diff --git a/application/admin/validate/Configorder.php b/application/admin/validate/Configorder.php new file mode 100644 index 0000000..45391dd --- /dev/null +++ b/application/admin/validate/Configorder.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/orders/configorder/add.html b/application/admin/view/orders/configorder/add.html new file mode 100644 index 0000000..2cf869e --- /dev/null +++ b/application/admin/view/orders/configorder/add.html @@ -0,0 +1,239 @@ +
diff --git a/application/admin/view/orders/configorder/edit.html b/application/admin/view/orders/configorder/edit.html new file mode 100644 index 0000000..daa72a0 --- /dev/null +++ b/application/admin/view/orders/configorder/edit.html @@ -0,0 +1,75 @@ + diff --git a/application/admin/view/orders/configorder/index.html b/application/admin/view/orders/configorder/index.html new file mode 100644 index 0000000..b967c83 --- /dev/null +++ b/application/admin/view/orders/configorder/index.html @@ -0,0 +1,45 @@ +