Accept Merge Request #41: (feature/dgg -> develop)
Merge Request: feat: 第二轮调整 Created By: @大狗哥 Accepted By: @大狗哥 URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/41
This commit is contained in:
commit
9ff359d813
|
|
@ -525,3 +525,39 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,42 @@ class Order extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\app\admin\model\Area::class,'area_id', 'area_code');
|
return $this->belongsTo(\app\admin\model\Area::class,'area_id', 'area_code');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCustomerAttr(string $val)
|
||||||
|
{
|
||||||
|
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 getAddressAttr(string $val, array $data)
|
||||||
|
{
|
||||||
|
//非已派单状态,隐藏用户地址
|
||||||
|
if ($data['status'] !== \app\admin\model\Order::STATUS_DISPATCHED) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class OrderDispatchService extends BaseService
|
||||||
->with(['orderInfo' => function ($query) {
|
->with(['orderInfo' => function ($query) {
|
||||||
$query->with(['area' => function ($query) {
|
$query->with(['area' => function ($query) {
|
||||||
$query->field('id,area_code,merge_name');
|
$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('status', OrderDispatch::STATUS_TOGET)
|
||||||
->where('worker_id', $workerId)
|
->where('worker_id', $workerId)
|
||||||
|
|
@ -26,13 +26,15 @@ class OrderDispatchService extends BaseService
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 工作台列表
|
||||||
* @param int $workerId 师傅id
|
* @param int $workerId 师傅id
|
||||||
* @param string $type 类型:ongoing=进行中,today=当日,tomorrow=昨日,all=全部订单
|
* @param string $type 类型:pending=待沟通,need_visit=待上门,ongoing=服务中,finished=已完成
|
||||||
|
* @param string $needVisitType 待上门类型:today=今日,tomorrow=明日,all=全部
|
||||||
* @param int $pageSize
|
* @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
|
$result = $model
|
||||||
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
|
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
|
|
@ -48,11 +50,15 @@ class OrderDispatchService extends BaseService
|
||||||
*/
|
*/
|
||||||
public function countWorkbenchOrder(int $workerId)
|
public function countWorkbenchOrder(int $workerId)
|
||||||
{
|
{
|
||||||
|
$needVisit = $this->getWorkbenchOrderModel($workerId, 'need_visit')->count();
|
||||||
return [
|
return [
|
||||||
|
'pending' => $this->getWorkbenchOrderModel($workerId, 'pending')->count(),
|
||||||
|
'need_visit' => $needVisit,
|
||||||
'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(),
|
'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(),
|
||||||
'today' => $this->getWorkbenchOrderModel($workerId, 'today')->count(),
|
'finished' => $this->getWorkbenchOrderModel($workerId, 'finished')->count(),
|
||||||
'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(),
|
'today' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'today')->count(),
|
||||||
'all' => $this->getWorkbenchOrderModel($workerId, 'all')->count(),
|
'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'tomorrow')->count(),
|
||||||
|
'all' => $needVisit,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,41 +66,44 @@ class OrderDispatchService extends BaseService
|
||||||
* 获取工作台订单模型
|
* 获取工作台订单模型
|
||||||
* @param int $workerId
|
* @param int $workerId
|
||||||
* @param string $type
|
* @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()
|
$model = $this->getOrderDispatchModel()
|
||||||
->with(['orderInfo' => function ($query) {
|
->with(['orderInfo' => function ($query) {
|
||||||
$query->with(['area' => function ($query) {
|
$query->with(['area' => function ($query) {
|
||||||
$query->field('id,area_code,merge_name');
|
$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);
|
->where('worker_id', $workerId);
|
||||||
|
|
||||||
$status = [
|
|
||||||
OrderDispatch::STATUS_GOTIT,
|
|
||||||
OrderDispatch::STATUS_PLANIT,
|
|
||||||
OrderDispatch::STATUS_CLOCK,
|
|
||||||
];
|
|
||||||
switch ($type) {
|
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':
|
case 'ongoing':
|
||||||
//所有已接单未完成的订单
|
//服务中
|
||||||
$model->whereIn('status', $status);
|
$model->where('status', OrderDispatch::STATUS_CLOCK);
|
||||||
break;
|
break;
|
||||||
case 'today':
|
case 'finished':
|
||||||
$model->whereIn('status', $status);
|
//已完成
|
||||||
$model->where('plan_time', '>=', date('Y-m-d 00:00:00'));
|
$model->where('status', OrderDispatch::STATUS_FINISH);
|
||||||
$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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,6 +211,8 @@ class OrderDispatchService extends BaseService
|
||||||
'tel',
|
'tel',
|
||||||
'remark',
|
'remark',
|
||||||
'detail',
|
'detail',
|
||||||
|
'images',
|
||||||
|
'status',
|
||||||
];
|
];
|
||||||
$orderDispatchFields = [
|
$orderDispatchFields = [
|
||||||
'id',
|
'id',
|
||||||
|
|
@ -262,6 +273,25 @@ class OrderDispatchService extends BaseService
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
Hook::listen('order_dispatch_change', $orderDispatchChangeParams);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完成上门
|
* 完成上门
|
||||||
* @param int $workerId 师傅id
|
* @param int $workerId 师傅id
|
||||||
|
|
@ -331,7 +361,7 @@ class OrderDispatchService extends BaseService
|
||||||
$orderDispatch->images = $this->removeStrCdnUrl($params['complete_images']);
|
$orderDispatch->images = $this->removeStrCdnUrl($params['complete_images']);
|
||||||
$orderDispatch->finish_time = $time;
|
$orderDispatch->finish_time = $time;
|
||||||
|
|
||||||
if ($params['receive_type'] === 1) {
|
if ($params['receive_type'] == 1) {
|
||||||
$orderDispatch->image = $this->removeStrCdnUrl($params['payment_image']);
|
$orderDispatch->image = $this->removeStrCdnUrl($params['payment_image']);
|
||||||
$orderDispatch->offline_total_type = $params['offline_total_type'];
|
$orderDispatch->offline_total_type = $params['offline_total_type'];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ class OrderDispatch extends WorkerApi
|
||||||
|
|
||||||
$pageSize = $this->request->request('page_size', 20);
|
$pageSize = $this->request->request('page_size', 20);
|
||||||
$type = $this->request->request('workbench_type');
|
$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);
|
$this->success('获取成功', $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +94,22 @@ class OrderDispatch extends WorkerApi
|
||||||
$this->success('操作成功', $res);
|
$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
|
* @return void
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ class OrderDispatch extends Validate
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'type|确认类型' => 'require|in:accept,reject',
|
'type|确认类型' => 'require|in:accept,reject',
|
||||||
'order_dispatch_id|订单派单id' => 'require|number',
|
'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',
|
'plan_time|预约时间' => 'require|date',
|
||||||
'images|上门图片' => 'require|max:3000',
|
'images|上门图片' => 'require|max:3000',
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ class OrderDispatch extends Validate
|
||||||
|
|
||||||
protected $scene = [
|
protected $scene = [
|
||||||
'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'],
|
'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'],
|
||||||
'workbenchOrderList' => ['workbench_type'],
|
'workbenchOrderList' => ['workbench_type', 'need_visit_type'],
|
||||||
'info' => ['order_dispatch_id'],
|
'info' => ['order_dispatch_id'],
|
||||||
'appointmentTime' => ['order_dispatch_id', 'plan_time'],
|
'appointmentTime' => ['order_dispatch_id', 'plan_time'],
|
||||||
'arrivedOnSite' => ['order_dispatch_id', 'images'],
|
'arrivedOnSite' => ['order_dispatch_id', 'images'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user