From c6b986f06f7070a4c5f7abd2b5f9ff8c4fe86de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Wed, 7 May 2025 20:13:24 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E9=9A=90=E8=97=8F=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 19 +++++++++++++++++++ application/common/model/Order.php | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/application/common.php b/application/common.php index 088dccd..bdabd39 100755 --- a/application/common.php +++ b/application/common.php @@ -525,3 +525,22 @@ if (!function_exists('dd')) { } } +if (!function_exists('maskExceptFirstChar')) { + /** + * 将字符串的首个字符保留,其余字符全部替换为 * + */ + function maskExceptFirstChar(string $str): string + { + $length = mb_strlen($str, 'UTF-8'); + + if ($length <= 1) { + return $str; + } + + $firstChar = mb_substr($str, 0, 1, 'UTF-8'); + $masked = str_repeat('*', $length - 1); + + return $firstChar . $masked; + } +} + diff --git a/application/common/model/Order.php b/application/common/model/Order.php index 2c60e3b..58c144c 100644 --- a/application/common/model/Order.php +++ b/application/common/model/Order.php @@ -18,4 +18,9 @@ class Order extends Model { return $this->belongsTo(\app\admin\model\Area::class,'area_id', 'area_code'); } + + public function getCustomerAttr(string $val) + { + return maskExceptFirstChar($val); + } } From f39f3a3ce66ed4ac08801d309b7f326699c8de6e Mon Sep 17 00:00:00 2001 From: gcd Date: Wed, 7 May 2025 22:04:33 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=E7=BB=86=E8=8A=82=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 17 ++++++++++++++ application/common/model/Order.php | 23 +++++++++++++++++++ application/services/OrderDispatchService.php | 4 +++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/application/common.php b/application/common.php index bdabd39..993baf7 100755 --- a/application/common.php +++ b/application/common.php @@ -544,3 +544,20 @@ if (!function_exists('maskExceptFirstChar')) { } } +if (!function_exists('maskPhone')) { + function maskPhone($phone) { + $length = strlen($phone); + + if ($length === 11) { + return substr($phone, 0, 3) . '****' . substr($phone, 7); + } + + if ($length >= 3) { + return substr($phone, 0, 3) . str_repeat('*', $length - 3); + } + + return str_repeat('*', $length); + } + +} + diff --git a/application/common/model/Order.php b/application/common/model/Order.php index 58c144c..9d90050 100644 --- a/application/common/model/Order.php +++ b/application/common/model/Order.php @@ -23,4 +23,27 @@ class Order extends Model { return maskExceptFirstChar($val); } + + public function getTelAttr(string $val, array $data) + { + if ($data['status'] !== \app\admin\model\Order::STATUS_DISPATCHED) { + return maskPhone($val); + } + + return $val; + } + + public function getImagesAttr($val) + { + if (empty($val)) { + return []; + } + + $images = explode(',', $val); + foreach ($images as $k => $v) { + $images[$k] = cdnurl($v, true); + } + + return $images; + } } diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 24cd514..6b717f9 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -202,6 +202,8 @@ class OrderDispatchService extends BaseService 'tel', 'remark', 'detail', + 'images', + 'status', ]; $orderDispatchFields = [ 'id', @@ -331,7 +333,7 @@ class OrderDispatchService extends BaseService $orderDispatch->images = $this->removeStrCdnUrl($params['complete_images']); $orderDispatch->finish_time = $time; - if ($params['receive_type'] === 1) { + if ($params['receive_type'] == 1) { $orderDispatch->image = $this->removeStrCdnUrl($params['payment_image']); $orderDispatch->offline_total_type = $params['offline_total_type']; From 087315f2cfc7c42baa80bf1eeedfaa67a485825f Mon Sep 17 00:00:00 2001 From: gcd Date: Wed, 7 May 2025 22:18:45 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=E9=9D=9E=E6=B4=BE=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=8C=E9=9A=90=E8=97=8F=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/Order.php | 10 ++++++++++ application/services/OrderDispatchService.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/application/common/model/Order.php b/application/common/model/Order.php index 9d90050..05e1248 100644 --- a/application/common/model/Order.php +++ b/application/common/model/Order.php @@ -33,6 +33,16 @@ class Order extends Model return $val; } + public function getAddressAttr(string $val, array $data) + { + //非已派单状态,隐藏用户地址 + if ($data['status'] !== \app\admin\model\Order::STATUS_DISPATCHED) { + return ''; + } + + return $val; + } + public function getImagesAttr($val) { if (empty($val)) { diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 6b717f9..6a140bf 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -16,7 +16,7 @@ class OrderDispatchService extends BaseService ->with(['orderInfo' => function ($query) { $query->with(['area' => function ($query) { $query->field('id,area_code,merge_name'); - }])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id'); + }])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id,status'); }]) ->where('status', OrderDispatch::STATUS_TOGET) ->where('worker_id', $workerId) @@ -67,7 +67,7 @@ class OrderDispatchService extends BaseService ->with(['orderInfo' => function ($query) { $query->with(['area' => function ($query) { $query->field('id,area_code,merge_name'); - }])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id,customer,tel'); + }])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id,customer,tel,status'); }]) ->where('worker_id', $workerId); From c4adcf28a5ed9e7d5a14629a3917d89054f7fd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Thu, 8 May 2025 18:06:13 +0800 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 15 +++++++++++++++ application/worker/controller/OrderDispatch.php | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 6a140bf..13f5286 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -264,6 +264,21 @@ class OrderDispatchService extends BaseService return true; } + public function updatePlanTime(int $workerId, int $orderDispatchId, string $planTime) + { + $orderDispatch = $this->getOrderDispatchInfo($workerId, $orderDispatchId); + $orderDispatch->plan_time = $planTime; + $orderDispatch->save(); + + $orderDispatchChangeParams = [ + 'dispatch' => $orderDispatch, + 'remark' => `师傅已修改上门时间,旧的时间:${$orderDispatch->plan_time},新的时间:${$planTime}` + ]; + Hook::listen('order_dispatch_change', $orderDispatchChangeParams); + + return true; + } + /** * 完成上门 * @param int $workerId 师傅id diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index 6f07222..e9218c1 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -93,6 +93,22 @@ class OrderDispatch extends WorkerApi $this->success('操作成功', $res); } + /** + * 修改上门时间 + * @return void + */ + public function updatePlanTime() + { + $params = $this->request->request(); + $validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.appointmentTime'); + if ($validate !== true) { + $this->error($validate); + } + + $res = $this->getOrderDispatchService()->updatePlanTime($this->user['id'], $params['order_dispatch_id'], $params['plan_time']); + $this->success('操作成功', $res); + } + /** * 提交上门信息 * @return void From 05529db202c7ab850c13c53abae95ccef64a9a0f Mon Sep 17 00:00:00 2001 From: gcd Date: Thu, 8 May 2025 20:52:12 +0800 Subject: [PATCH 5/8] =?UTF-8?q?feat:=20=E5=B7=A5=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BF=AE=E6=94=B9=E4=B8=8A=E9=97=A8=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 13f5286..cfcd84e 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -267,12 +267,16 @@ class OrderDispatchService extends BaseService public function updatePlanTime(int $workerId, int $orderDispatchId, string $planTime) { $orderDispatch = $this->getOrderDispatchInfo($workerId, $orderDispatchId); + if ($orderDispatch->status !== OrderDispatch::STATUS_PLANIT) { + $this->apiError('该单不支持修改上门时间'); + } + $orderDispatch->plan_time = $planTime; $orderDispatch->save(); $orderDispatchChangeParams = [ 'dispatch' => $orderDispatch, - 'remark' => `师傅已修改上门时间,旧的时间:${$orderDispatch->plan_time},新的时间:${$planTime}` + 'remark' => "师傅修改上门时间,旧的时间:{$orderDispatch->plan_time},新的时间:$planTime" ]; Hook::listen('order_dispatch_change', $orderDispatchChangeParams); From 4066e74c1e87a9fde60f18f6eb12023b2123b542 Mon Sep 17 00:00:00 2001 From: gcd Date: Thu, 8 May 2025 22:08:33 +0800 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20=E5=B7=A5=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index cfcd84e..736d17e 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -27,7 +27,7 @@ class OrderDispatchService extends BaseService /** * @param int $workerId 师傅id - * @param string $type 类型:ongoing=进行中,today=当日,tomorrow=昨日,all=全部订单 + * @param string $type 类型:pending=待沟通,need_visit=待上门,ongoing=服务中,finished=已完成 * @param int $pageSize */ public function workbenchOrderList(int $workerId, string $type, int $pageSize) @@ -49,10 +49,10 @@ class OrderDispatchService extends BaseService public function countWorkbenchOrder(int $workerId) { return [ - 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), - 'today' => $this->getWorkbenchOrderModel($workerId, 'today')->count(), - 'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(), - 'all' => $this->getWorkbenchOrderModel($workerId, 'all')->count(), + 'pending' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), + 'need_visit' => $this->getWorkbenchOrderModel($workerId, 'today')->count(), + 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(), + 'finished' => $this->getWorkbenchOrderModel($workerId, 'all')->count(), ]; } From d3df3a1d41f1bd8fb6efd0038331c23f2f4cf32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Fri, 9 May 2025 11:47:45 +0800 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BD=9C=E5=8F=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 64 +++++++++++-------- .../worker/controller/OrderDispatch.php | 3 +- application/worker/validate/OrderDispatch.php | 5 +- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 736d17e..89cb5c6 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -26,13 +26,15 @@ class OrderDispatchService extends BaseService } /** + * 工作台列表 * @param int $workerId 师傅id * @param string $type 类型:pending=待沟通,need_visit=待上门,ongoing=服务中,finished=已完成 + * @param string $needVisitType 待上门类型:today=今日,tomorrow=明日,all=全部 * @param int $pageSize */ - public function workbenchOrderList(int $workerId, string $type, int $pageSize) + public function workbenchOrderList(int $workerId, string $type, int $pageSize, string $needVisitType) { - $model = $this->getWorkbenchOrderModel($workerId, $type); + $model = $this->getWorkbenchOrderModel($workerId, $type, $needVisitType); $result = $model ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time']) ->order('id desc') @@ -49,10 +51,13 @@ class OrderDispatchService extends BaseService public function countWorkbenchOrder(int $workerId) { return [ - 'pending' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), - 'need_visit' => $this->getWorkbenchOrderModel($workerId, 'today')->count(), - 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(), - 'finished' => $this->getWorkbenchOrderModel($workerId, 'all')->count(), + 'pending' => $this->getWorkbenchOrderModel($workerId, 'pending')->count(), + 'need_visit' => $this->getWorkbenchOrderModel($workerId, 'need_visit')->count(), + 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), + 'finished' => $this->getWorkbenchOrderModel($workerId, 'finished')->count(), + 'today' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'today')->count(), + 'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'tomorrow')->count(), + 'all' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'all')->count(), ]; } @@ -60,8 +65,9 @@ class OrderDispatchService extends BaseService * 获取工作台订单模型 * @param int $workerId * @param string $type + * @param string $needVisitType */ - private function getWorkbenchOrderModel(int $workerId, string $type) + private function getWorkbenchOrderModel(int $workerId, string $type, string $needVisitType = '') { $model = $this->getOrderDispatchModel() ->with(['orderInfo' => function ($query) { @@ -71,30 +77,32 @@ class OrderDispatchService extends BaseService }]) ->where('worker_id', $workerId); - $status = [ - OrderDispatch::STATUS_GOTIT, - OrderDispatch::STATUS_PLANIT, - OrderDispatch::STATUS_CLOCK, - ]; switch ($type) { + case 'pending': + //待沟通 + $model->where('status', OrderDispatch::STATUS_GOTIT); + break; + case 'need_visit': + //待上门 + $model->where('status', OrderDispatch::STATUS_PLANIT); + switch ($needVisitType) { + case 'today': + $model->where('plan_time', '>=', date('Y-m-d 00:00:00')); + $model->where('plan_time', '<=', date('Y-m-d 23:59:59')); + break; + case 'tomorrow': + $model->where('plan_time', '>=', date('Y-m-d 00:00:00', strtotime('+1 day'))); + $model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day'))); + break; + } + break; case 'ongoing': - //所有已接单未完成的订单 - $model->whereIn('status', $status); + //服务中 + $model->where('status', OrderDispatch::STATUS_CLOCK); break; - case 'today': - $model->whereIn('status', $status); - $model->where('plan_time', '>=', date('Y-m-d 00:00:00')); - $model->where('plan_time', '<=', date('Y-m-d 23:59:59')); - break; - case 'tomorrow': - $model->whereIn('status', $status); - $model->where('plan_time', '>=', date('Y-m-d 00:00:00', strtotime('+1 day'))); - $model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day'))); - break; - case 'all': - $status[] = OrderDispatch::STATUS_REFUSED; - $status[] = OrderDispatch::STATUS_FINISH; - $model->whereIn('status', $status); + case 'finished': + //已完成 + $model->where('status', OrderDispatch::STATUS_FINISH); break; } diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index e9218c1..5e9f151 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -48,7 +48,8 @@ class OrderDispatch extends WorkerApi $pageSize = $this->request->request('page_size', 20); $type = $this->request->request('workbench_type'); - $res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize); + $needVisitType = $this->request->request('need_visit_type'); + $res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize, $needVisitType); $this->success('获取成功', $res); } diff --git a/application/worker/validate/OrderDispatch.php b/application/worker/validate/OrderDispatch.php index 0937eed..95e8039 100644 --- a/application/worker/validate/OrderDispatch.php +++ b/application/worker/validate/OrderDispatch.php @@ -9,7 +9,8 @@ class OrderDispatch extends Validate protected $rule = [ 'type|确认类型' => 'require|in:accept,reject', 'order_dispatch_id|订单派单id' => 'require|number', - 'workbench_type|工作台类型' => 'require|in:ongoing,today,tomorrow,all', + 'workbench_type|工作台类型' => 'require|in:pending,need_visit,ongoing,finished', + 'need_visit_type|待上门类型' => 'require|in:today,tomorrow,all', 'plan_time|预约时间' => 'require|date', 'images|上门图片' => 'require|max:3000', @@ -30,7 +31,7 @@ class OrderDispatch extends Validate protected $scene = [ 'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'], - 'workbenchOrderList' => ['workbench_type'], + 'workbenchOrderList' => ['workbench_type', 'need_visit_type'], 'info' => ['order_dispatch_id'], 'appointmentTime' => ['order_dispatch_id', 'plan_time'], 'arrivedOnSite' => ['order_dispatch_id', 'images'], From 83982cac9f53d24e40e836e9cebb23b8ac308c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Fri, 9 May 2025 15:06:19 +0800 Subject: [PATCH 8/8] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BD=9C=E5=8F=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 89cb5c6..0d977b6 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -50,14 +50,15 @@ class OrderDispatchService extends BaseService */ public function countWorkbenchOrder(int $workerId) { + $needVisit = $this->getWorkbenchOrderModel($workerId, 'need_visit')->count(); return [ 'pending' => $this->getWorkbenchOrderModel($workerId, 'pending')->count(), - 'need_visit' => $this->getWorkbenchOrderModel($workerId, 'need_visit')->count(), + 'need_visit' => $needVisit, 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), 'finished' => $this->getWorkbenchOrderModel($workerId, 'finished')->count(), 'today' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'today')->count(), 'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'tomorrow')->count(), - 'all' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'all')->count(), + 'all' => $needVisit, ]; }