2023-08-07 16:12:28 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | author: likeadminTeam
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
2023-08-09 11:18:21 +08:00
|
|
|
|
use app\api\logic\LogisticsLogic;
|
2023-08-07 16:12:28 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-19 13:30:28 +08:00
|
|
|
|
* 物流管理
|
|
|
|
|
* Class LogisticsController
|
2023-08-07 16:12:28 +08:00
|
|
|
|
* @package app\api\controller
|
|
|
|
|
*/
|
|
|
|
|
class LogisticsController extends BaseApiController
|
|
|
|
|
{
|
|
|
|
|
|
2023-08-14 09:11:38 +08:00
|
|
|
|
public array $notNeedLogin = ['courierLogisticsList','courierLogisticsDetail','userLogisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder','courierData','sendMessageToApp'];
|
2023-08-07 16:12:28 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 获取配送员物流信息列表
|
|
|
|
|
* @method get
|
|
|
|
|
* @param int $courier_id 配送员id
|
|
|
|
|
* @param int $status 物流状态
|
|
|
|
|
* @param int $page_size 每页数量
|
|
|
|
|
* @param int $page_num 页码
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
|
|
|
|
public function courierLogisticsList(): \think\response\Json
|
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-09 11:18:21 +08:00
|
|
|
|
$params = $this->request->get(['courier_id','status','page_size','page_num','keywords']);
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($params['courier_id'])) return $this->fail('参数错误');
|
|
|
|
|
if(empty($params['keywords'])) $params['keywords'] = '';
|
|
|
|
|
//返回数据
|
|
|
|
|
return $this->data(LogisticsLogic::list($params));
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 获取物流信息详情
|
|
|
|
|
* @method get
|
|
|
|
|
* @param int $logistics_id 物流id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
2023-08-09 15:50:16 +08:00
|
|
|
|
public function courierLogisticsDetail(): \think\response\Json
|
2023-08-07 16:12:28 +08:00
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-09 11:18:21 +08:00
|
|
|
|
$logistics_id = $this->request->get('logistics_id');
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($logistics_id)) return $this->fail('参数错误');
|
2023-08-07 16:12:28 +08:00
|
|
|
|
//返回数据
|
2023-08-09 15:50:16 +08:00
|
|
|
|
return $this->data(LogisticsLogic::cDetail($logistics_id));
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 生成物流信息
|
|
|
|
|
* @method post
|
|
|
|
|
* @param int $order_id 订单id
|
|
|
|
|
* @param string $order_sn 订单编号
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
|
|
|
|
public function logisticsCreate(): \think\response\Json
|
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-09 11:18:21 +08:00
|
|
|
|
$params = $this->request->post(['order_id','order_sn']);
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($params['order_id']) || empty($params['order_sn'])) return $this->fail('参数错误');
|
|
|
|
|
//生成数据
|
|
|
|
|
$result = LogisticsLogic::create($params);
|
|
|
|
|
//返回数据
|
2023-08-10 15:21:11 +08:00
|
|
|
|
return $result['code'] ==1 ? $this->success('生成成功',$result['data']) : $this->fail($result['msg']);
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 配送员提取商品
|
|
|
|
|
* @method post
|
|
|
|
|
* @param int $logistics_id 物流id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
|
|
|
|
public function courierTakeGoods(): \think\response\Json
|
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-10 10:53:03 +08:00
|
|
|
|
$params = $this->request->post(['logistics_id','order_id','order_sn']);
|
2023-08-09 14:41:05 +08:00
|
|
|
|
//验证参数
|
2023-08-10 10:53:03 +08:00
|
|
|
|
if(empty($params['logistics_id']) || empty($params['order_id']) || empty($params['order_sn'])) return $this->fail('参数错误');
|
2023-08-09 14:41:05 +08:00
|
|
|
|
//提取商品
|
|
|
|
|
$result = LogisticsLogic::takeGoods($params);
|
|
|
|
|
//返回数据
|
|
|
|
|
return $result['code'] ==1 ? $this->success('提取成功') : $this->fail($result['msg']);
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 配送员完成配送
|
|
|
|
|
* @method post
|
|
|
|
|
* @param int $logistics_id 物流id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
|
|
|
|
public function courierCompleteDelivery(): \think\response\Json
|
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-10 10:53:03 +08:00
|
|
|
|
$params = $this->request->post(['logistics_id','take_code']);
|
2023-08-09 14:41:05 +08:00
|
|
|
|
//验证参数
|
2023-08-10 10:53:03 +08:00
|
|
|
|
if(empty($params['logistics_id']) || empty($params['take_code'])) return $this->fail('参数错误');
|
2023-08-09 14:41:05 +08:00
|
|
|
|
//完成配送
|
|
|
|
|
$result = LogisticsLogic::doneDelivery($params);
|
|
|
|
|
//返回数据
|
|
|
|
|
return $result['code'] ==1 ? $this->success('配送完成') : $this->fail($result['msg']);
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2023-08-10 10:53:03 +08:00
|
|
|
|
* 用户取消订单
|
2023-08-07 16:12:28 +08:00
|
|
|
|
* @method post
|
|
|
|
|
* @param int $logistics_id 物流id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
2023-08-10 10:53:03 +08:00
|
|
|
|
public function userCancelOrder(): \think\response\Json
|
2023-08-07 16:12:28 +08:00
|
|
|
|
{
|
|
|
|
|
//获取参数
|
2023-08-09 15:26:33 +08:00
|
|
|
|
$params = $this->request->post(['order_id','order_sn']);
|
2023-08-09 15:00:12 +08:00
|
|
|
|
//验证参数
|
2023-08-09 15:26:33 +08:00
|
|
|
|
if(empty($params['order_id']) || empty($params['order_sn'])) return $this->fail('参数错误');
|
2023-08-09 15:00:12 +08:00
|
|
|
|
//完成配送
|
2023-08-10 10:53:03 +08:00
|
|
|
|
$result = LogisticsLogic::cancel($params);
|
2023-08-09 15:00:12 +08:00
|
|
|
|
//返回数据
|
2023-08-10 10:53:03 +08:00
|
|
|
|
return $result['code'] ==1 ? $this->success('取消成功') : $this->fail($result['msg']);
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2023-08-10 10:53:03 +08:00
|
|
|
|
* 商超端物流详情
|
2023-08-07 16:12:28 +08:00
|
|
|
|
* @method post
|
|
|
|
|
* @param int $logistics_id 物流id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
*/
|
2023-08-09 15:50:16 +08:00
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-07 16:12:28 +08:00
|
|
|
|
}
|