add message function

This commit is contained in:
luofei 2023-08-14 09:11:38 +08:00
parent dbcf323074
commit 99c2807ba2
3 changed files with 23 additions and 24 deletions

View File

@ -24,7 +24,7 @@ use app\api\logic\LogisticsLogic;
class LogisticsController extends BaseApiController
{
public array $notNeedLogin = ['courierLogisticsList','courierLogisticsDetail','userLogisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder','courierData'];
public array $notNeedLogin = ['courierLogisticsList','courierLogisticsDetail','userLogisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder','courierData','sendMessageToApp'];
/*
* 获取配送员物流信息列表
@ -151,16 +151,15 @@ class LogisticsController extends BaseApiController
return $this->data(LogisticsLogic::uDetail($params));
}
public function courierData():\think\response\Json
{
//获取参数
$params = $this->request->get(['order_sn']);
//验证参数
if(empty($params['order_sn'])) return $this->fail('参数错误');
//获取数据
$result = LogisticsLogic::courierInfo($params);
//返回数据
return $result['code'] ==1 ? $this->success('获取成功',$result['data']) : $this->fail($result['msg']);
/*
* 发送消息给客户端
* @method get
* @param int $logistics_id 物流id
* @return \think\response\Json
*/
public function sendMessageToApp() {
$result = LogisticsLogic::message();
return $result['code'] ==1 ? $this->success('发送成功',$result['data']) : $this->fail($result['msg']);
}
}

View File

@ -366,20 +366,19 @@ class LogisticsLogic extends BaseLogic
}
/*
* 配送员信息
* @param $param
* 发送消息给客户端
* @param $params
* @return array
*/
public static function courierInfo($params) {
public static function message():array {
//获取物流信息
$logistics = Logistics::where('order_sn', $params['order_sn'])->find();
if(!$logistics) return ['code'=>0, 'msg'=>'物流信息不存在'];
//获取配送员信息
$courier = Courier::alias('u')
->field('u.nickname,a.phone')
->leftjoin('la_admin a', 'u.admin_id = a.id')
->where('u.id', $logistics['courier_id'])->find()->toArray();
//返回数据
return ['code'=>1, 'msg'=>'success', 'data'=>$courier];
$logistics = Logistics::where('status', 0)->order('id desc')->find();
if (!$logistics) return ['code'=>0, 'msg'=>'暂无新的物流信息'];
$data = [
'logistics_id' => $logistics['id'],
'user_id' => $logistics['user_id'],
'message' => '您有新的物流信息,请及时查看'
];
return ['code'=>1, 'msg'=>'获取成功', 'data'=>$data];
}
}

View File

@ -20,4 +20,5 @@ Route::rule('doneDelivery','Logistics/courierCompleteDelivery','post');
Route::rule('confirmReceipt','Logistics/userConfirmReceipt','post');
Route::rule('cancelOrder','Logistics/userCancelOrder','post');
Route::rule('courierData','Logistics/courierData','get');
Route::rule('courierData','Logistics/courierData','get');
Route::rule('userMessage','Logistics/sendMessageToApp','get');