add captain api
This commit is contained in:
parent
2d2f14a132
commit
ede25647df
@ -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','sendMessageToApp'];
|
||||
public array $notNeedLogin = ['courierLogisticsList','captainLogisticsList','courierLogisticsDetail','userLogisticsDetail','logisticsCreate','courierTakeGoods','courierCompleteDelivery','userConfirmReceipt','userCancelOrder','courierData','sendMessageToApp'];
|
||||
|
||||
/*
|
||||
* 获取配送员物流信息列表
|
||||
@ -38,14 +38,16 @@ class LogisticsController extends BaseApiController
|
||||
public function courierLogisticsList(): \think\response\Json
|
||||
{
|
||||
//获取参数
|
||||
$params = $this->request->get(['courier_id','status','page_size','page_num','keywords']);
|
||||
$params = $this->request->get(['user_id','user_type','status','page_size','page_num','keywords']);
|
||||
//验证参数
|
||||
if(empty($params['courier_id'])) return $this->fail('参数错误');
|
||||
if(empty($params['user_id'])) return $this->fail('参数错误');
|
||||
if(!isset($params['user_type'])) return $this->fail('参数错误');
|
||||
if(empty($params['keywords'])) $params['keywords'] = '';
|
||||
//返回数据
|
||||
return $this->data(LogisticsLogic::list($params));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取物流信息详情
|
||||
* @method get
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\LogisticsLogic;
|
||||
use app\api\logic\VehicleLogic;
|
||||
|
||||
/**
|
||||
@ -24,5 +23,40 @@ use app\api\logic\VehicleLogic;
|
||||
*/
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = [''];
|
||||
public array $notNeedLogin = ['tricycle','multipleRent'];
|
||||
|
||||
/*
|
||||
* 获取去未出租的三轮车列表
|
||||
*/
|
||||
public function tricycle() {
|
||||
//获取参数
|
||||
$params = $this->request->get(['page_no','page_size']);
|
||||
//获取数据
|
||||
$data = VehicleLogic::lists($params);
|
||||
//返回数据
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 三轮车批量出租
|
||||
*/
|
||||
public function multipleRent() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['company_id','tricycle_ids','start_time','end_time']);
|
||||
//验证参数
|
||||
if(empty($params['company_id']) || empty($params['tricycle_ids']) || empty($params['start_time']) || empty($params['end_time'])) {
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
if(!checkDateIsValid($params['start_time']) || !checkDateIsValid($params['end_time'])){
|
||||
return $this->fail('时间格式错误');
|
||||
}
|
||||
//写入数据
|
||||
$result = VehicleLogic::oneLevelRent($params);
|
||||
//返回结果
|
||||
if($result['code'] == 1){
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
return $this->fail($result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ use app\common\model\logistics\Order;
|
||||
use app\common\model\logistics\Product;
|
||||
use app\common\model\logistics\LogisticsRecord;
|
||||
use app\common\model\logistics\User;
|
||||
use app\common\model\vehicle\Company;
|
||||
use think\facade\Log;
|
||||
|
||||
|
||||
@ -39,6 +40,11 @@ class LogisticsLogic extends BaseLogic
|
||||
*/
|
||||
public static function list($params):array {
|
||||
//获取物流列表
|
||||
if($params['user_type'] == 0){
|
||||
$user = ['courier_id','=',$params['user_id']];
|
||||
}else{
|
||||
$user = ['captain_id','=',$params['user_id']];
|
||||
}
|
||||
if(!isset($params['status'])){
|
||||
$status = ['status','in','0,1'];
|
||||
}elseif($params['status'] == 2){
|
||||
@ -46,7 +52,7 @@ class LogisticsLogic extends BaseLogic
|
||||
}else{
|
||||
$status = ['status','in',$params['status']];
|
||||
}
|
||||
$logistics = Logistics::where('courier_id', $params['courier_id'])
|
||||
$logistics = Logistics::where([$user])
|
||||
->where([$status])
|
||||
->where('(order_sn LIKE "%'.$params['keywords'].'%" OR shop_phone LIKE "%'.$params['keywords'].'%" OR shop_name LIKE "%'.$params['keywords'].'%" OR receiver_phone LIKE "%'.$params['keywords'].'%" OR receiver_name LIKE "%'.$params['keywords'].'%")')
|
||||
->order('update_time desc')
|
||||
@ -163,18 +169,14 @@ class LogisticsLogic extends BaseLogic
|
||||
if($logistics) return ['code'=>0, 'msg'=>'物流信息已存在'];
|
||||
//查找订单信息
|
||||
$order = Order::alias('s')->where('order_id', $params['order_id'])->where('order_sn', $params['order_sn'])->find();
|
||||
if(empty($order['user_address_code'])) return ['code'=>1, 'msg'=>'用户地址信息错误'];
|
||||
if(empty($order['user_address_code'])) return ['code'=>0, 'msg'=>'用户地址信息错误'];
|
||||
//查找商家信息
|
||||
$shop = Merchant::field('mer_id,mer_name,real_name,mer_phone,mer_address,long,lat')->where('mer_id',$order['mer_id'])->find();
|
||||
//匹配配送员
|
||||
$courier = Courier::alias('u')
|
||||
->leftjoin('la_company c', 'c.id = u.company_id')
|
||||
->leftjoin('la_user a','c.user_id = a.id')
|
||||
->field('a.id,a.nickname,a.mobile,c.company_name,a.register_id')
|
||||
->where("CONCAT_WS(',',u.province,u.city,u.area,u.street,u.village,u.brigade) = '". $order['user_address_code']."'")
|
||||
->where('u.is_contract', 1)
|
||||
->where('u.is_captain',1)
|
||||
->find();
|
||||
//获取队长用户信息
|
||||
$captain = Courier::field('id,company_id,nickname,mobile')->where("CONCAT_WS(',',province,city,area,street,village,brigade) = '". $order['user_address_code']."'")->where('is_contract',1)->where('is_captain',1)->find();
|
||||
if(!$captain) return ['code'=>0, 'msg'=>'无法确定所在小队'];
|
||||
//获取配送员信息
|
||||
$courier = Company::field('company_name,user_id,master_name,master_phone')->where('id',$captain['company_id'])->find();
|
||||
//判断配送员是否存在
|
||||
if(!$courier) return ['code'=>0, 'msg'=>'配送员未匹配'];
|
||||
//获取下单用户信息
|
||||
@ -189,9 +191,12 @@ class LogisticsLogic extends BaseLogic
|
||||
'user_id' => $orderUser['uid'],
|
||||
'user_name' => $orderUser['nickname'],
|
||||
'user_phone' => $orderUser['phone'],
|
||||
'courier_id' => $courier['id'],
|
||||
'courier_name' => $courier['nickname'],
|
||||
'courier_phone' => $courier['mobile'],
|
||||
'captain_id' => $captain['id'],
|
||||
'captain_name' => $captain['nickname'],
|
||||
'captain_phone' => $captain['mobile'],
|
||||
'courier_id' => $courier['user_id'],
|
||||
'courier_name' => $courier['master_name'],
|
||||
'courier_phone' => $courier['master_phone'],
|
||||
'courier_company' => $courier['company_name'],
|
||||
'shop_id' => $shop['mer_id'],
|
||||
'shop_name' => $shop['mer_name'],
|
||||
|
@ -16,8 +16,10 @@ namespace app\api\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\vehicle\Company;
|
||||
use app\common\model\vehicle\Vehicle;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆逻辑
|
||||
* Class VehicleLogic
|
||||
@ -25,5 +27,27 @@ use app\common\model\vehicle\Vehicle;
|
||||
*/
|
||||
class VehicleLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 获取未出租的车辆列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function lists($params):array {
|
||||
$offset = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$length = !empty($params['page_size']) ? $params['page_size'] : 15;
|
||||
return Vehicle::field('id,license,gps_imei')->where('status',0)->where('is_del',0)->order('create_time desc')->page($offset, $length)->select()->toArray();
|
||||
}
|
||||
|
||||
public static function oneLevelRent($params):array {
|
||||
//获取承租公司信息
|
||||
$company = Company::where('id',$params['company_id'])->find();
|
||||
//验证公司信息
|
||||
if(!$company){
|
||||
return ['code'=>0,'msg'=>'未找到承租公司'];
|
||||
}
|
||||
$ids = explode(',',$params['tricycle_ids']);
|
||||
dump($company['company_name'],$ids);
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ Route::rule('userMessage','Logistics/sendMessageToApp','get');
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
Route::rule('getCarInfo','Gps/getCarInfo','get');
|
||||
Route::rule('getCarStatus','Gps/getCarStatus','get');
|
||||
Route::rule('getCarHistory','Gps/getCarHistory','get');
|
||||
Route::rule('getCarHistory','Gps/getCarHistory','get');
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
Route::rule('tricycle','Vehicle/tricycle','get');
|
||||
Route::rule('multipleRent','Vehicle/multipleRent','post');
|
12
app/common/model/vehicle/Company.php
Normal file
12
app/common/model/vehicle/Company.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\vehicle;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class Company extends BaseModel
|
||||
{
|
||||
protected $connection = 'mysql3';
|
||||
protected $name = 'la_company';
|
||||
|
||||
}
|
10
app/common/model/vehicle/VehicleRent.php
Normal file
10
app/common/model/vehicle/VehicleRent.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\vehicle;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class VehicleRent extends BaseModel
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user