This commit is contained in:
luofei 2023-08-09 15:50:16 +08:00
parent cf88ae3699
commit adbe4ace47
3 changed files with 47 additions and 5 deletions

View File

@ -25,7 +25,7 @@ use think\facade\Db;
class LogisticsController extends BaseApiController
{
public array $notNeedLogin = ['courierLogisticsList','logisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder'];
public array $notNeedLogin = ['courierLogisticsList','courierLogisticsDetail','userLogisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder'];
/*
* 获取配送员物流信息列表
@ -53,14 +53,14 @@ class LogisticsController extends BaseApiController
* @param int $logistics_id 物流id
* @return \think\response\Json
*/
public function logisticsDetail(): \think\response\Json
public function courierLogisticsDetail(): \think\response\Json
{
//获取参数
$logistics_id = $this->request->get('logistics_id');
//验证参数
if(empty($logistics_id)) return $this->fail('参数错误');
//返回数据
return $this->data(LogisticsLogic::detail($logistics_id));
return $this->data(LogisticsLogic::cDetail($logistics_id));
}
/*
@ -154,4 +154,14 @@ class LogisticsController extends BaseApiController
return $result['code'] ==1 ? $this->success('取消成功') : $this->fail($result['msg']);
}
public function userLogisticsDetail(): \think\response\Json
{
//获取参数
$params = $this->request->get(['order_id','order_sn']);
//验证参数
if(empty($params['order_id']) || empty($params['order_sn'])) return $this->fail('参数错误');
//返回数据
return $this->data(LogisticsLogic::uDetail($params));
}
}

View File

@ -70,7 +70,7 @@ class LogisticsLogic extends BaseLogic
* @param $id
* @return array
*/
public static function detail($id):array {
public static function cDetail($id):array {
//获取物流信息
$logistics = Logistics::field('id,order_id,order_sn,shop_name,shop_phone,shop_address,user_name,user_address,status,create_time')
->where('id', $id)->find();
@ -109,6 +109,37 @@ class LogisticsLogic extends BaseLogic
];
}
public static function uDetail($params):array {
//获取物流信息
$logistics = Logistics::field('id,order_id,order_sn,courier_id,shop_name,shop_phone,shop_address,user_name,user_address,status,create_time')
->where('order_id', $params['order_id'])->where('order_sn',$params['order_sn'])->find();
//获取物流记录
$records = LogisticsRecord::field('type,user_name,content,create_time')
->where('lst_id', $logistics['id'])->order('create_time desc')->select()->each(function($red_item){
switch ($red_item['type']) {
case 1:
$red_item['content'] = '用户'.$red_item['user_name'].$red_item['content'];
break;
case 2:
$red_item['content'] = '配送员'.$red_item['user_name'].$red_item['content'];
break;
case 3:
$red_item['content'] = '平台'.$red_item['user_name'].$red_item['content'];
break;
default:
$red_item['content'] = '未知';
}
unset($red_item['type'], $red_item['user_name']);
})->toArray();
$courier = Courier::field('nickname,mobile')->where('id', $logistics['courier_id'])->find();
//返回数据
return[
'logistics' => $logistics,
'courier' => $courier,
'record' => $records,
];
}
/*
* 生成物流信息
* @param $params

View File

@ -11,7 +11,8 @@
use think\facade\Route;
Route::rule('courierLstData','Logistics/courierLogisticsList','get');
Route::rule('lstDetail','Logistics/logisticsDetail','get');
Route::rule('lstDetail','Logistics/courierLogisticsDetail','get');
Route::rule('lstDetailToUser','Logistics/userLogisticsDetail','get');
Route::rule('lstSet','Logistics/logisticsCreate','post');
Route::rule('takeGoods','Logistics/courierTakeGoods','post');