diff --git a/addons/alioss/config.php b/addons/alioss/config.php index 0d958c2..ac6982f 100644 --- a/addons/alioss/config.php +++ b/addons/alioss/config.php @@ -2,232 +2,232 @@ return [ [ - 'name' => 'accessKeyId', - 'title' => 'AccessKey ID', - 'type' => 'string', + 'name' => 'accessKeyId', + 'title' => 'AccessKey ID', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'LTAI5t87F5mAkaXVKfLcmnrB', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'accessKeySecret', - 'title' => 'AccessKey Secret', - 'type' => 'string', + 'name' => 'accessKeySecret', + 'title' => 'AccessKey Secret', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'fk7KgdqRdJUS6Jc99TlB6mNLKorrsD', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'bucket', - 'title' => 'Bucket名称', - 'type' => 'string', + 'name' => 'bucket', + 'title' => 'Bucket名称', + 'type' => 'string', 'content' => [], - 'value' => 'yourbucket', - 'rule' => 'required;bucket', - 'msg' => '', - 'tip' => '阿里云OSS的空间名', - 'ok' => '', - 'extend' => 'data-rule-bucket="[/^[0-9a-z_\-]{3,63}$/, \'请输入正确的Bucket名称\']"', + 'value' => 'allocatr', + 'rule' => 'required;bucket', + 'msg' => '', + 'tip' => '阿里云OSS的空间名', + 'ok' => '', + 'extend' => 'data-rule-bucket="[/^[0-9a-z_\\-]{3,63}$/, \'请输入正确的Bucket名称\']"', ], [ - 'name' => 'endpoint', - 'title' => 'Endpoint', - 'type' => 'string', + 'name' => 'endpoint', + 'title' => 'Endpoint', + 'type' => 'string', 'content' => [], - 'value' => 'oss-cn-shenzhen.aliyuncs.com', - 'rule' => 'required;endpoint', - 'msg' => '', - 'tip' => '请填写从阿里云存储获取的Endpoint', - 'ok' => '', - 'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\/\/).*$/, \'不能以http(s)://开头\']"', + 'value' => 'allocatr.oss-cn-hangzhou.aliyuncs.com', + 'rule' => 'required;endpoint', + 'msg' => '', + 'tip' => '请填写从阿里云存储获取的Endpoint', + 'ok' => '', + 'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\\/\\/).*$/, \'不能以http(s)://开头\']"', ], [ - 'name' => 'cdnurl', - 'title' => 'CDN地址', - 'type' => 'string', + 'name' => 'cdnurl', + 'title' => 'CDN地址', + 'type' => 'string', 'content' => [], - 'value' => 'https://yourbucket.oss-cn-shenzhen.aliyuncs.com', - 'rule' => 'required;cdnurl', - 'msg' => '', - 'tip' => '请填写CDN地址,必须以http(s)://开头', - 'ok' => '', - 'extend' => 'data-rule-cdnurl="[/^http(s)?:\/\/.*$/, \'必需以http(s)://开头\']"', + 'value' => 'https://allocatr.oss-cn-hangzhou.aliyuncs.com', + 'rule' => 'required;cdnurl', + 'msg' => '', + 'tip' => '请填写CDN地址,必须以http(s)://开头', + 'ok' => '', + 'extend' => 'data-rule-cdnurl="[/^http(s)?:\\/\\/.*$/, \'必需以http(s)://开头\']"', ], [ - 'name' => 'uploadmode', - 'title' => '上传模式', - 'type' => 'select', + 'name' => 'uploadmode', + 'title' => '上传模式', + 'type' => 'select', 'content' => [ 'client' => '客户端直传(速度快,无备份)', 'server' => '服务器中转(占用服务器带宽,可备份)', ], - 'value' => 'server', - 'rule' => '', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'client', + 'rule' => '', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'serverbackup', - 'title' => '服务器中转模式备份', - 'type' => 'radio', + 'name' => 'serverbackup', + 'title' => '服务器中转模式备份', + 'type' => 'radio', 'content' => [ 1 => '备份(附件管理将产生2条记录)', 0 => '不备份', ], - 'value' => '1', - 'rule' => '', - 'msg' => '', - 'tip' => '服务器中转模式下是否备份文件', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => '', + 'msg' => '', + 'tip' => '服务器中转模式下是否备份文件', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'savekey', - 'title' => '保存文件名', - 'type' => 'string', + 'name' => 'savekey', + 'title' => '保存文件名', + 'type' => 'string', 'content' => [], - 'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'expire', - 'title' => '上传有效时长', - 'type' => 'string', + 'name' => 'expire', + 'title' => '上传有效时长', + 'type' => 'string', 'content' => [], - 'value' => '600', - 'rule' => 'required', - 'msg' => '', - 'tip' => '用户停留页面上传有效时长,单位秒', - 'ok' => '', - 'extend' => '', + 'value' => '600', + 'rule' => 'required', + 'msg' => '', + 'tip' => '用户停留页面上传有效时长,单位秒', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'maxsize', - 'title' => '最大可上传', - 'type' => 'string', + 'name' => 'maxsize', + 'title' => '最大可上传', + 'type' => 'string', 'content' => [], - 'value' => '10M', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '10M', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'mimetype', - 'title' => '可上传后缀格式', - 'type' => 'string', + 'name' => 'mimetype', + 'title' => '可上传后缀格式', + 'type' => 'string', 'content' => [], - 'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'multiple', - 'title' => '多文件上传', - 'type' => 'bool', + 'name' => 'multiple', + 'title' => '多文件上传', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '0', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'thumbstyle', - 'title' => '缩略图样式', - 'type' => 'string', + 'name' => 'thumbstyle', + 'title' => '缩略图样式', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => '', - 'msg' => '', - 'tip' => '用于后台列表缩略图样式,可使用:?x-oss-process=image/resize,m_lfit,w_120,h_90', - 'ok' => '', - 'extend' => '', + 'value' => '', + 'rule' => '', + 'msg' => '', + 'tip' => '用于后台列表缩略图样式,可使用:?x-oss-process=image/resize,m_lfit,w_120,h_90', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'chunking', - 'title' => '分片上传', - 'type' => 'radio', + 'name' => 'chunking', + 'title' => '分片上传', + 'type' => 'radio', 'content' => [ 1 => '开启', 0 => '关闭', ], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '0', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'chunksize', - 'title' => '分片大小', - 'type' => 'number', + 'name' => 'chunksize', + 'title' => '分片大小', + 'type' => 'number', 'content' => [], - 'value' => '4194304', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '4194304', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'syncdelete', - 'title' => '附件删除时是否同步删除云存储文件', - 'type' => 'bool', + 'name' => 'syncdelete', + 'title' => '附件删除时是否同步删除云存储文件', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'apiupload', - 'title' => 'API接口使用云存储', - 'type' => 'bool', + 'name' => 'apiupload', + 'title' => 'API接口使用云存储', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'noneedlogin', - 'title' => '免登录上传', - 'type' => 'checkbox', + 'name' => 'noneedlogin', + 'title' => '免登录上传', + 'type' => 'checkbox', 'content' => [ - 'api' => 'API', + 'api' => 'API', 'index' => '前台', 'admin' => '后台', ], - 'value' => '', - 'rule' => '', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '', + 'rule' => '', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], ]; diff --git a/application/admin/behavior/OrderLog.php b/application/admin/behavior/OrderLog.php index aae000c..fbb0e40 100644 --- a/application/admin/behavior/OrderLog.php +++ b/application/admin/behavior/OrderLog.php @@ -2,11 +2,16 @@ namespace app\admin\behavior; +use think\Lang; + class OrderLog { //记录订单日志 public function run(&$response) { + + Lang::load(APP_PATH . 'admin/lang/zh-cn/order.php'); + $Model = new \app\admin\model\Order(); $statusList = $Model->getStatusList(); $order = $response['order']; //订单对象 diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 85f8fb4..16f46ca 100755 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -8,6 +8,8 @@ use app\common\controller\Backend; use fast\Random; use fast\Tree; use think\Db; +use think\exception\PDOException; +use think\exception\ValidateException; use think\Validate; /** @@ -294,4 +296,66 @@ class Admin extends Backend $this->dataLimitField = 'id'; return parent::selectpage(); } + + public function areaget(){ + $user_id = request()->get('user_id'); + $data = model('area')->getTree(); + + if ($user_id){ + $user = model('admin')->get($user_id); + $in_areas = explode(',',$user->area_ids ?? ''); + foreach ($data as &$datum){ + if (in_array($datum['id'],$in_areas)){ + $datum['state'] = [ + 'selected' => true + ]; + } + } + + } + + return $data; + } + public function area($ids = null){ + if (false === $this->request->isPost()) { + +// dd($areas); + $this->view->assign('user_id',$ids); +// dd($areas); + 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; + // 获取当前ID对应的订单信息 + $user = $this->model->get($ids); + if (!$user) { + $this->error('订单不存在'); + } + 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); + } + $result = $user->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(); + } } diff --git a/application/admin/controller/orders/Abnormal.php b/application/admin/controller/orders/Abnormal.php index 4ec3662..724dc15 100644 --- a/application/admin/controller/orders/Abnormal.php +++ b/application/admin/controller/orders/Abnormal.php @@ -89,7 +89,7 @@ class Abnormal extends Backend { if (false === $this->request->isPost()) { - $order_id = $this->request->get('order_id'); + $order_id = $this->request->get('ids'); $this->assign('order_id',$order_id); diff --git a/application/admin/controller/orders/Auditorder.php b/application/admin/controller/orders/Auditorder.php index c09a7e3..aca5b36 100644 --- a/application/admin/controller/orders/Auditorder.php +++ b/application/admin/controller/orders/Auditorder.php @@ -62,7 +62,7 @@ class Auditorder extends Backend $list = $this->model ->scope('tab',Order::TAB_AUDIT) ->alias('order') - ->with(['auditadmin:id,username,nickname']) + ->with(['auditadmin']) ->where($where) ->order($sort, $order) ->paginate($limit); @@ -109,6 +109,9 @@ class Auditorder extends Backend return $this->view->fetch(); } $params = $this->request->post('row/a'); + + $audit_status = $params['audit_status']; + if (empty($params)) { $this->error(__('Parameter %s can not be empty', '')); } @@ -122,14 +125,22 @@ class Auditorder extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + + if($audit_status){ + $params['status'] = Order::STATUS_FINISHED; + }else{ + $params['status'] = Order::STATUS_CHECKING; + } + $params['audit_admin_id'] = $this->auth->id; - $params['status'] = Order::STATUS_FINISHED; + $result = $row->allowField(true)->save($params); - $params['order'] = $row; - $params['role'] = 1; - $params['auth'] = $this->auth; - Hook::listen('order_change',$params); + $hookParams['order'] = $row; + $hookParams['role'] = 1; + $hookParams['auth'] = $this->auth; + $hookParams['remark'] = $params['audit_remark']; + Hook::listen('order_change',$hookParams); Db::commit(); } catch (ValidateException|PDOException|Exception $e) { diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php new file mode 100644 index 0000000..819592b --- /dev/null +++ b/application/admin/controller/orders/Configorder.php @@ -0,0 +1,156 @@ +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 + ->tab(Order::TAB_SETTING) + ->auth($this->auth) + ->areaauth($this->auth) + ->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'] = 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; + $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/Dispatch.php b/application/admin/controller/orders/Dispatch.php index b5450e2..5881da5 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -52,9 +52,6 @@ class Dispatch extends Backend */ public function index() { - - $orderModel = new Order(); - //当前是否为关联查询 $this->relationSearch = true; //设置过滤方法 @@ -76,7 +73,7 @@ class Dispatch extends Backend $row->btn_edit = (in_array($row->status, $this->model->btnActiveStatusList('btn_edit'))) ? true : false; $row->btn_cancel = (in_array($row->status, $this->model->btnActiveStatusList('btn_cancel'))) ? true : false; $row->btn_abnormal = (in_array($row->status, $this->model->btnActiveStatusList('btn_abnormal'))) ? true : false; - $row->btn_income = (in_array($row->status, $this->model->btnActiveStatusList('btn_income')) && in_array($row->order->status, $orderModel->incomeBtnStatus())) ? 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()); diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php new file mode 100644 index 0000000..3a61efe --- /dev/null +++ b/application/admin/controller/orders/Dispatch2.php @@ -0,0 +1,452 @@ +model = new \app\admin\model\OrderDispatch; + $this->view->assign("typeList", $this->model->getTypeList()); + $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 + ->with(['order']) + ->auth($this->auth) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as &$row) { + $row->btn_edit = (in_array($row->status, $this->model->btnActiveStatusList('btn_edit'))) ? true : false; + $row->btn_cancel = (in_array($row->status, $this->model->btnActiveStatusList('btn_cancel'))) ? true : false; + $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_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()); + + return json($result); + } + return $this->view->fetch(); + } + + + /** + * 添加 + * + * @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(); + } + + /** + * 编辑 + * + * @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')); + } + + $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(); + } + + $params = $this->request->post('row/a'); + + if(isset($params['action']) && $params['action'] == 'finish'){ + + return $this->finish($ids); + } + + 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(); + 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); + } + if($row->worker_id != $params['worker_id']){ //更换了师傅 + + + } + $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(); + } + + + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function finish($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')); + } + + $order = Order::where('id',$row->id)->find(); + + if(empty($order)){ + $this->error(__('未找到关联订单')); + } + + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + $this->view->assign('order', $order); + $this->view->assign('action','finish'); + return $this->view->fetch('edit'); + } + + + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + + $params = $this->preExcludeFields($params); + + if(!in_array($row->status, $this->model->btnActiveStatusList('btn_finished'))){ + $this->error('任务状态变更,请刷新后操作'); + } + + if($order->status != Order::STATUS_DISPATCHED){ + $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); + } + $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]); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + + /** + * 取消派单 + * + * @param $ids + * @return void + * @throws DbException + * @throws DataNotFoundException + * @throws ModelNotFoundException + */ +// public function del($ids = null) +// { +// if (false === $this->request->isPost()) { +// $this->error(__("Invalid parameters")); +// } +// $ids = $ids ?: $this->request->post("ids"); +// if (empty($ids)) { +// $this->error(__('Parameter %s can not be empty', 'ids')); +// } +// $pk = $this->model->getPk(); +// $adminIds = $this->getDataLimitAdminIds(); +// if (is_array($adminIds)) { +// $this->model->where($this->dataLimitField, 'in', $adminIds); +// } +// $list = $this->model->where($pk, 'in', $ids)->whereIn('status', $this->model->deleteStatusList())->select(); +// +// $remark = $this->request->param('remark', ''); +// +// $count = 0; +// Db::startTrans(); +// try { +// foreach ($list as $item) { +// //$count += $item->delete(); +// $order = Order::where('id', $item->order_id)->where('status', Order::STATUS_DISPATCHED)->find(); +// if (!$order) { +// $this->error('订单状态已变更,请刷新后操作'); +// } +// //取消 +// $item->save(['status' => OrderDispatch::STATUS_CANCEL, 'remark' => $remark]); +// //回退订单状态 +// $order->allowField(true)->save(['status' => Order::STATUS_DISPATCHING]); +// +// $params['order'] = $order->ref; +// $params['role'] = 1; +// $params['auth'] = $this->auth; +// $params['remark'] = '派单被取消[ID:' . $item->id . '],订单状态回退'; +// if (!empty($remark)) { +// $params['remark'] .= ',操作备注:' . $remark; +// } +// Hook::listen('order_change', $params); +// } +// Db::commit(); +// } catch (PDOException | Exception $e) { +// Db::rollback(); +// throw $e; +// $this->error($e->getMessage()); +// } +// +// $this->error(__('取消成功')); +// } + + + /** + * 取消派单 + * + * @param $ids + * @return void + * @throws DbException + * @throws DataNotFoundException + * @throws ModelNotFoundException + */ + public function del($ids=null) + { + if (false === $this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $ids = $this->request->post("ids/a"); + $reason = $this->request->post("reason"); + + if (empty($ids)) { + $this->error(__('Parameter %s can not be empty', 'ids')); + } + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + $list = $this->model->where($pk, 'in', $ids)->whereIn('status', $this->model->deleteStatusList())->select(); + + if(count($list) != count($ids)){ + $this->error(__("任务状态不可操作,请刷新页面后再操作")); + } + + $remark = $reason; + $count = 0; + Db::startTrans(); + try { + foreach ($list as $item) { + //$count += $item->delete(); + $order = Order::where('id', $item->order_id)->where('status', Order::STATUS_DISPATCHED)->find(); + if (!$order) { + $this->error('订单状态已变更,请刷新后操作'); + } + //取消 + $item->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); + } + Db::commit(); + } catch (PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + /* if ($count) { + $this->success(); + }*/ + $this->success(__('取消成功')); + } + +} diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 6908ad6..37d1349 100755 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -4,6 +4,9 @@ namespace app\admin\controller\user; use app\common\controller\Backend; use app\common\library\Auth; +use think\Db; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 会员管理 diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index 5a14ade..160b03b 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -49,9 +49,7 @@ class Worker extends Backend unset($v['sort']); unset($v['status']); } - $this->tree = $res; - $this->view->assign("tree", $res); } 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..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 854bd17..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' => '订单状态', @@ -14,8 +14,8 @@ return [ 'Set status to 20' => '设为已派单', 'Status 30' => '进行中', 'Set status to 30' => '设为进行中', - 'Status 40' => '待验收', - 'Set status to 40' => '设为待验收', + 'Status 40' => '待配置', + 'Set status to 40' => '设为待配置', 'Status 41' => '审核驳回', 'Set status to 41' => '设为审核驳回', 'Status 50' => '待财务审核', 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 63aef60..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' => '订单状态', @@ -13,12 +13,12 @@ return [ 'Set status to 20' => '设为已派单', 'Status 30' => '进行中', 'Set status to 30' => '设为进行中', - 'Status 40' => '待验收', - 'Set status to 40' => '设为待验收', + 'Status 40' => '待配置', + 'Set status to 40' => '设为待配置', 'Status 41' => '审核驳回', 'Set status to 41' => '设为审核驳回', - 'Status 50' => '待审核', - 'Set status to 50' => '设为待审核', + 'Status 50' => '待结算', + 'Set status to 50' => '设为待结算', 'Status 60' => '已完成', 'Set status to 60' => '设为已完成', 'Status -10' => '取消', @@ -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 new file mode 100644 index 0000000..80e83dc --- /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/lang/zh-cn/orders/dispatch.php b/application/admin/lang/zh-cn/orders/dispatch.php index 9fc67a1..17e3b46 100644 --- a/application/admin/lang/zh-cn/orders/dispatch.php +++ b/application/admin/lang/zh-cn/orders/dispatch.php @@ -36,14 +36,14 @@ return [ 'Create_time' => '派单时间', 'Update_time' => '编辑时间', 'Order.id' => 'ID', - 'Order.order_no' => '订单号', + 'Order.order_no' => '订单编号', 'Order.customer' => '客户姓名', 'Order.tel' => '客户电话', 'Order.status' => '订单状态', 'Order.status 10' => '未派单', 'Order.status 20' => '已派单', 'Order.status 30' => '进行中', - 'Order.status 40' => '待验收', + 'Order.status 40' => '待配置', 'Order.status 41' => '审核驳回', 'Order.status 50' => '待财务审核', 'Order.status 60' => '已完成', @@ -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.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 new file mode 100644 index 0000000..5d96287 --- /dev/null +++ b/application/admin/lang/zh-cn/orders/dispatch2.php @@ -0,0 +1,82 @@ + 'ID', + 'Order_id' => '订单ID', + 'Type' => '派单方式', + 'Type 1' => '手动', + 'Worker_id' => '师傅ID', + 'Worker_name' => '师傅姓名', + 'Worker_tel' => '师傅电话', + 'Status' => '进度', + 'Status 0' => '待接单', + 'Set status to 0' => '设为待接单', + 'Status 10' => '已接单', + 'Set status to 10' => '设为已接单', + 'Status 25' => '任务超时', + 'Set status to 25' => '设为已开始', + 'Status 20' => '已预约', + 'Set status to 20' => '设为已预约', + 'Status 30' => '已打卡', + 'Set status to 30' => '设为已打卡', + 'Status 60' => '已完成', + 'Set status to 60' => '设为已完成', + 'Status -10' => '已拒接', + 'Set status to -10' => '设为已拒接', + 'Status -20' => '已移交', + 'Set status to -20' => '设为已移交', + 'Status -30' => '已取消', + 'Set status to -30' => '设为已取消', + 'Remark' => '备注', + 'Notice_num' => '通知次数', + 'Plan_time' => '预约时间', + 'Finish_time' => '完成时间', + 'Admin_id' => '派单人ID', + 'Admin_user' => '派单人', + 'Create_time' => '派单时间', + 'Update_time' => '更新时间', + 'Order.id' => 'ID', + 'Order.order_no' => '订单编号', + 'Order.customer' => '客户姓名', + 'Order.tel' => '客户电话', + 'Order.status' => '订单状态', + 'Order.status 10' => '未派单', + 'Order.status 20' => '已派单', + 'Order.status 30' => '进行中', + 'Order.status 40' => '待配置', + 'Order.status 41' => '审核驳回', + 'Order.status 50' => '待财务审核', + 'Order.status 60' => '已完成', + 'Order.status -10' => '取消', + 'Order.area_id' => '地域', + 'Order.address' => '详细地址', + 'Order.lng' => '经度', + 'Order.lat' => '纬度', + 'Order.work_tel_id' => '工作机', + 'Order.source_shop' => '来源店铺', + 'Order.source' => '订单来源', + 'Order.source_uid' => '来源UID', + 'Order.item_id' => '服务ID', + 'Order.item_title' => '服务名称', + 'Order.detail' => '订单详情', + 'Order.remark' => '订单备注', + 'Order.images' => '图片', + 'Order.plan_time' => '预约时间', + 'Order.admin_id' => '录单员ID', + 'Order.coupon_id' => '优惠码id', + 'Order.total' => '总收款', + 'Order.online_amount' => '线上收款', + 'Order.offline_amount' => '线下收款', + 'Order.discount_amount' => '优惠抵扣', + 'Order.refund_amount' => '退款金额', + 'Order.real_amount' => '实际收款', + 'Order.cost' => '师傅成本', + 'Order.performance' => '预计利润', + 'Order.cancel_reason_id' => '取消原因', + 'Order.cancel_detail' => '取消详情', + 'Order.audit_remark' => '审核备注', + 'Order.audit_admin_id' => '审核员', + 'Order.create_time' => '录单时间', + 'Order.update_time' => '更新时间', + 'Order.delete_time' => '删除时间' +]; diff --git a/application/admin/lang/zh-cn/orders/income.php b/application/admin/lang/zh-cn/orders/income.php index 83c21e4..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' => '定金', @@ -12,7 +12,7 @@ return [ 'Item_type 4' => '其它', 'Status' => '审核状态', - 'Status 0' => '待审核', + 'Status 0' => '待结算', 'Status 1' => '通过', 'Status -1' => '未通过', 'Audit_remark' => '审核备注', 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 0888265..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' => '订单状态', @@ -12,8 +12,8 @@ return [ 'Set status to 20' => '设为已派单', 'Status 30' => '进行中', 'Set status to 30' => '设为进行中', - 'Status 40' => '待验收', - 'Set status to 40' => '设为待验收', + 'Status 40' => '待配置', + 'Set status to 40' => '设为待配置', 'Status 41' => '审核驳回', 'Set status to 41' => '设为审核驳回', 'Status 50' => '待财务审核', @@ -35,7 +35,7 @@ return [ 'Detail' => '订单详情', 'Remark' => '订单备注', 'Images' => '图片', - 'Plan_time' => '客户预约时间', + 'Plan_time' => '预约时间', 'Admin_id' => '录单员ID', 'Total' => '总收款', 'Cost' => '师傅成本', diff --git a/application/admin/model/Area.php b/application/admin/model/Area.php index 89743f0..34c075f 100644 --- a/application/admin/model/Area.php +++ b/application/admin/model/Area.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use fast\Tree; use think\Model; @@ -16,6 +17,41 @@ class Area extends Model return $this->where('area_code','=',$code) ->value('merge_name'); } + + public function getTree(){ + + $res = $this->field(['city_code','code','name','level','province_code']) + ->where('level','<',3) + ->select(); + + +// dd($ruleList); + + foreach ($res as &$v) { + $v = $v->toArray(); + $v['state'] = ['selected' => false]; + if ($v['level'] == 2){ + $v['pid'] = $v['province_code'] ?: 0; + $v['parent'] = $v['province_code'] ?: '#'; + }else{ + $v['pid'] = $v['city_code'] ?: 0; + $v['parent'] = $v['city_code'] ?: '#'; + } + $v['id'] = $v['code']; + $v['text'] = $v['name']; + unset($v['province_code']); + unset($v['city_code']); + unset($v['level']); + unset($v['code']); + } +// dd($res); + Tree::instance()->init($res)->icon = + [' ', ' ', ' ']; + + $res = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0)); +// dd($res); + return $res; + } } diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index 2dba643..49e7437 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; @@ -37,6 +38,8 @@ class Order extends Model const TAB_PENDING = 'pending'; //跟进中 + const TAB_SETTING = 'setting'; //跟进中 + const TAB_AUDIT = 'audit'; //审核 const TAB_REVIEW = 'review'; //回访 @@ -121,10 +124,13 @@ class Order extends Model self::TAB_AUDIT => [ self::STATUS_AUDITING, self::STATUS_FINISHED - ], //待审核 + ], //待结算 self::TAB_REVIEW => [ self::STATUS_FINISHED ], + self::TAB_SETTING => [ + self::STATUS_CHECKING + ], ]; return $tabStatus[$tab] ?? []; } @@ -148,4 +154,43 @@ class Order extends Model public function auditadmin(){ return $this->belongsTo(Admin::class,'audit_admin_id',); } + + public function dispatch() + { + 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 5c80de9..b4b073f 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; @@ -34,10 +35,11 @@ class OrderDispatch extends Model const STATUS_TOGET = 0; //待接 const STATUS_GOTIT = 10; //已接 const STATUS_PLANIT = 20; //已预约 + const STATUS_OVERTIME = 25; //超时(过了预约时间) const STATUS_CLOCK = 30; //已打卡 const STATUS_FINISH = 60; //完成 const STATUS_REFUSED = -10; //拒绝 - const STATUS_MOVE = -20; //中转 + const STATUS_MOVE = -20; //中转(状态废弃) const STATUS_CANCEL = -30; //取消 @@ -48,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() @@ -86,6 +90,7 @@ class OrderDispatch extends Model self::STATUS_TOGET, self::STATUS_GOTIT, self::STATUS_PLANIT, + self::STATUS_OVERTIME, self::STATUS_CLOCK, ]; } @@ -112,29 +117,57 @@ class OrderDispatch extends Model self::STATUS_TOGET, self::STATUS_GOTIT, self::STATUS_PLANIT, + self::STATUS_OVERTIME, self::STATUS_CLOCK, ], 'btn_cancel' => [ //取消按钮 self::STATUS_TOGET, self::STATUS_GOTIT, self::STATUS_PLANIT, + self::STATUS_OVERTIME, self::STATUS_CLOCK, ], 'btn_abnormal' => [ //添加异常按钮 self::STATUS_TOGET, self::STATUS_GOTIT, self::STATUS_PLANIT, + self::STATUS_OVERTIME, self::STATUS_CLOCK, ], - 'btn_income' => [ + 'btn_finished' => [ self::STATUS_TOGET, self::STATUS_GOTIT, self::STATUS_PLANIT, + self::STATUS_OVERTIME, self::STATUS_CLOCK, - self::STATUS_FINISH + //self::STATUS_FINISH ], + 'disabled_status' => [ + self::STATUS_FINISH, + self::STATUS_CANCEL, + self::STATUS_REFUSED, + self::STATUS_MOVE + ] ]; 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/tags.php b/application/admin/tags.php index 7f7020c..4e901f3 100755 --- a/application/admin/tags.php +++ b/application/admin/tags.php @@ -15,9 +15,4 @@ return [ 'app_end' => [ '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/aftersales/aftersale/add.html b/application/admin/view/aftersales/aftersale/add.html index ccb7a53..46dec49 100644 --- a/application/admin/view/aftersales/aftersale/add.html +++ b/application/admin/view/aftersales/aftersale/add.html @@ -3,21 +3,10 @@