diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 01c0b7a..367d1bc 100755 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -2,6 +2,7 @@ namespace app\admin\controller; +use app\admin\model\OrderDispatch; use app\common\controller\Backend; use app\common\exception\UploadException; use app\common\library\Upload; @@ -324,4 +325,46 @@ class Ajax extends Backend $response = Response::create($data, '', 200, $header); return $response; } + + public function get_config(){ + + + $order = new \app\admin\model\Order(); + $user = \model('admin')->find($this->auth->id); + + $group = \model('auth_group_access')->where('uid',$this->auth->id)->find()->group_id ?? 0; + + if ($group == 2 || $group == 6) { + // 生成 SQL 语句 + $ids = $user->area_ids??''; + if ($ids == ''){ + $to_dispatch = 0; + }else{ + $ids = explode(',',$ids); + $area_codes = $this->filterAreaCodes($ids); + + $order->where(function ($q) use ($area_codes) { + foreach ($area_codes as $area_code) { + $q->whereOr('area_id', 'like', $area_code . '%'); + } + }); + $to_dispatch = $order->where('status',\app\admin\model\Order::STATUS_DISPATCHING)->count(); + } + }else{ + $to_dispatch = $order->where('status',\app\admin\model\Order::STATUS_DISPATCHING)->count(); + } + //待跟进 + $to_follow = OrderDispatch::where('follow',0)->auth($this->auth)->count(); + +// return [ +// 'order/index' => $to_dispatch, +// 'orders/dispatch2' => $to_follow +// ]; + $rs = [ + 'order/index' => [$to_dispatch, 'red', 'badge'], //待派单 + 'orders/dispatch2' => [$to_follow, 'yellow', 'badge'], //待跟进 + ]; + + return json_encode($rs); + } } diff --git a/application/admin/controller/orders/Auditorder.php b/application/admin/controller/orders/Auditorder.php index ceddbab..5bb3bda 100644 --- a/application/admin/controller/orders/Auditorder.php +++ b/application/admin/controller/orders/Auditorder.php @@ -131,10 +131,12 @@ class Auditorder extends Backend $row->validateFailException()->validate($validate); } + $txt = '审核通过'; if($audit_status){ $params['status'] = Order::STATUS_FINISHED; }else{ $params['status'] = Order::STATUS_CHECKONCE; + $txt = '审核未通过'; } $params['audit_admin_id'] = $this->auth->id; @@ -145,7 +147,7 @@ class Auditorder extends Backend $hookParams['order'] = $row; $hookParams['role'] = 1; $hookParams['auth'] = $this->auth; - $hookParams['remark'] = $params['audit_remark']; + $hookParams['remark'] = $txt.'审核备注:'.$params['audit_remark']; Hook::listen('order_change',$hookParams); if($params['status'] == Order::STATUS_CHECKONCE){ @@ -154,7 +156,7 @@ class Auditorder extends Backend 'to_id' => $row->dispatch_admin_id, 'type' => 1, 'title' => '订单结算审核未通过', - 'content' => '【订单结算未通过】订单编号:'.$row->order_no.',审核说明:'.$params['audit_remark'].',审核人:'.$this->auth->nickname + 'content' => '【订单结算未通过】订单编号:'.$row->order_no.',审核备注:'.$params['audit_remark'].',审核人:'.$this->auth->nickname ]); } diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php index 2f96d10..f145a3d 100644 --- a/application/admin/controller/orders/Configorder.php +++ b/application/admin/controller/orders/Configorder.php @@ -153,7 +153,7 @@ class Configorder extends Backend $params['order'] = $row; $params['role'] = 1; $params['auth'] = $this->auth; - $params['remark'] = ''; + $params['remark'] = '完成订单配置'; Hook::listen('order_change', $params); diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index ad68d05..8c7ed1d 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -87,16 +87,18 @@ class Dispatch2 extends Backend if(!in_array($row->status, $this->model->btnActiveStatusList('btn_record')) ){ //正常情况,执行不到这里来,不用担心循环执行问题 - $row->follow = 2; - OrderDispatch::where('id',$row->id)->update(['follow'=>2]); + if($row->follow != 2){ + $row->follow = 2; + OrderDispatch::where('id',$row->id)->update(['follow'=>2]); + } } - if($row->btn_record){ - - if($row->btn_record != 2){ - $row->btn_record = true; - }else{ + if($row->btn_record ){ + if($row->follow == 2){ $row->btn_record = false; } + } + + /*if($row->follow == 0 ){ $row->btn_record = true; @@ -125,7 +127,7 @@ class Dispatch2 extends Backend // } // } // } - } + // $row->btn_income = (in_array($row->status, $this->model->btnActiveStatusList('btn_income')) && in_array($row->order->status, $orderModel->incomeBtnStatus())) ? true : false; if($row->status == -10){ //拒绝 diff --git a/application/admin/controller/orders/Dispatchlog.php b/application/admin/controller/orders/Dispatchlog.php index ea0788d..7deb1e1 100644 --- a/application/admin/controller/orders/Dispatchlog.php +++ b/application/admin/controller/orders/Dispatchlog.php @@ -72,6 +72,7 @@ class Dispatchlog extends Backend } } $this->view->assign('logs',json_encode($orderLogs)); + $this->view->assign('cdnurl',config('upload.cdnurl')); return $this->view->fetch(); } //如果发送的来源是 Selectpage,则转发到 Selectpage diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php index e9ec383..defc19f 100644 --- a/application/admin/controller/orders/Dispatchrecord.php +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -156,7 +156,7 @@ class Dispatchrecord extends Backend $dispatch->record_count ++; //$params['admin_id'] = $this->auth->id; $result = $this->model->allowField(true)->save($params); - $dispatch->save(); + $dispatch->allowField(true)->save(); Db::commit(); } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); diff --git a/application/admin/controller/statistics/Worker.php b/application/admin/controller/statistics/Worker.php index e240d2e..c7b839c 100644 --- a/application/admin/controller/statistics/Worker.php +++ b/application/admin/controller/statistics/Worker.php @@ -185,7 +185,7 @@ class Worker extends Backend $viewSubsql->where('create_time','>=',$filter['start_time']); } if(!empty($filter['end_time'])){ - $viewSubsql->where('create_time','<=',$filter['start_time']); + $viewSubsql->where('create_time','<=',$filter['end_time']); } return $viewSubsql->group('worker_id')->buildSql(); } @@ -215,7 +215,7 @@ class Worker extends Backend $builder->where('create_time','>=',$filter['start_time']); } if(!empty($filter['end_time'])){ - $builder->where('create_time','<=',$filter['start_time']); + $builder->where('create_time','<=',$filter['end_time']); } $builder->group('worker_id'); @@ -258,7 +258,7 @@ class Worker extends Backend $builder->where('create_time','>=',$filter['start_time']); } if(!empty($filter['end_time'])){ - $builder->where('create_time','<=',$filter['start_time']); + $builder->where('create_time','<=',$filter['end_time']); } //->where('dispatch_admin_id','>',0); diff --git a/application/admin/view/orders/dispatchlog/index.html b/application/admin/view/orders/dispatchlog/index.html index de686b7..21f5b81 100644 --- a/application/admin/view/orders/dispatchlog/index.html +++ b/application/admin/view/orders/dispatchlog/index.html @@ -113,6 +113,8 @@