diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 778397c..705fbec 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -12,6 +12,7 @@ use app\common\controller\Backend; use app\common\Logic\OrderLogic; use fast\Tree; use think\Db; +use think\Exception; use think\exception\DbException; use think\exception\PDOException; use think\exception\ValidateException; @@ -387,6 +388,8 @@ class Order extends Backend $orderDispatch = new OrderDispatch(); $orderDispatch->allowField(true)->save($insert); $order->status = \app\admin\model\Order::STATUS_DISPATCHED; + $order->dispatch_time = date('Y-m-d H:i:s'); + $order->dispatch_admin_id = $this->auth->id; $order->save(); //日志 diff --git a/application/admin/controller/orders/Dispatch.php b/application/admin/controller/orders/Dispatch.php index 6e94dac..2e1cc12 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -153,6 +153,8 @@ class Dispatch extends Backend $result = $this->model->allowField(true)->save($insert); $order->status = Order::STATUS_DISPATCHED; + $order->dispatch_time = date('Y-m-d H:i:s'); + $order->dispatch_admin_id = $this->auth->id; $order->save(); //order log diff --git a/application/admin/controller/statistics/Dispatcher.php b/application/admin/controller/statistics/Dispatcher.php new file mode 100644 index 0000000..02da9ff --- /dev/null +++ b/application/admin/controller/statistics/Dispatcher.php @@ -0,0 +1,99 @@ +model = new \app\admin\model\Order(); + } + + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + * + * @return string|Json + * @throws \think\Exception + * @throws DbException + */ + public function index() + { + + + $this->chart(); + + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if (false === $this->request->isAjax()) { + return $this->view->fetch(); + } + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); + $list = $this->model + ->where($where) + ->order($sort, $order) + ->paginate($limit); + $result = ['total' => $list->total(), 'rows' => $list->items()]; + return json($result); + } + + //图表统计 + public function chart(){ + + $filter = $this->request->param('filter/a',[]); + + $orderValid = implode(',',$this->model->tabStatus(Order::TAB_VALID)); + + //"COUNT(CASE WHEN status IN (".$orderValid.") THEN 1 END) AS ing_num", + $fields = [ + 'dispatch_admin_id', + "COUNT(CASE WHEN status = 60 THEN 1 END) AS finish_num", //完成数 + "COUNT(CASE WHEN status IN (".$orderValid.") THEN 1 END) AS count_num", //总订单数 (排除取消 和草稿) + "SUM(CASE WHEN status = 60 THEN total END) AS total", //成效额 + "SUM(CASE WHEN status = 60 THEN total END) AS performance", //业绩 + "SUM(CASE WHEN status = 60 THEN (refund_amount + worker_refund_amount) END) AS refund_total", //退款总数 + "COUNT(CASE WHEN refund_amount > 0 OR worker_refund_amount > 0 THEN 1 END) AS refund_count", //退款订单数量 + "AVG(CASE WHEN status > 10 THEN UNIX_TIMESTAMP(dispatch_time) - UNIX_TIMESTAMP(create_time) END) AS avg_time_diff", //派单时效 + // "SUM(CASE WHEN status = 60 THEN (field1 + field2) END) AS performance", + ]; + + $data = $this->model + ->field($fields) + ->group('dispatch_admin_id') + ->select(); + dump($data);exit; + } + + +} diff --git a/application/admin/lang/zh-cn/statistics/dispatcher.php b/application/admin/lang/zh-cn/statistics/dispatcher.php new file mode 100644 index 0000000..3b32427 --- /dev/null +++ b/application/admin/lang/zh-cn/statistics/dispatcher.php @@ -0,0 +1,70 @@ + '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' => '线下尾款', + 'Online_amount_last' => '线上尾款', + 'Offline_amount_type' => '线下尾款类型', + 'Offline_amount_type 1' => '师傅收', + 'Offline_amount_type 2' => '公司收', + 'Discount_amount' => '优惠抵扣', + 'Refund_amount' => '公司款额', + 'Worker_refund_amount' => '师傅退款', + 'Real_amount' => '实际收款', + 'Cost' => '师傅成本', + 'Material_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全款', + 'Revisit_id' => '回访ID', + 'Dispatch_admin_id' => '派单员', + 'Dispatch_admin_user' => '派单员', + 'Dispatch_time' => '派单时间', + 'Aftersale_id' => '售后ID', + 'Amount_images' => '收款凭据' +]; diff --git a/application/admin/validate/Dispatcherorder.php b/application/admin/validate/Dispatcherorder.php new file mode 100644 index 0000000..5147b99 --- /dev/null +++ b/application/admin/validate/Dispatcherorder.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/Staorder.php b/application/admin/validate/Staorder.php new file mode 100644 index 0000000..75c7104 --- /dev/null +++ b/application/admin/validate/Staorder.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/statistics/dispatcher/add.html b/application/admin/view/statistics/dispatcher/add.html new file mode 100644 index 0000000..b49bd11 --- /dev/null +++ b/application/admin/view/statistics/dispatcher/add.html @@ -0,0 +1,313 @@ +
diff --git a/application/admin/view/statistics/dispatcher/edit.html b/application/admin/view/statistics/dispatcher/edit.html new file mode 100644 index 0000000..6b3b94c --- /dev/null +++ b/application/admin/view/statistics/dispatcher/edit.html @@ -0,0 +1,313 @@ + diff --git a/application/admin/view/statistics/dispatcher/index.html b/application/admin/view/statistics/dispatcher/index.html new file mode 100644 index 0000000..25676e8 --- /dev/null +++ b/application/admin/view/statistics/dispatcher/index.html @@ -0,0 +1,46 @@ +