新增车辆列表接口
This commit is contained in:
parent
926daa4e05
commit
9b1597dadc
@ -59,10 +59,18 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
|
||||
public function carList():Json {
|
||||
//获取参数
|
||||
$params = $this->request->get(['is_rent','license','company_name','page_no','page_size']);
|
||||
if(empty($params['is_rent'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
if(!in_array($params['is_rent'],[1,2])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取公司id
|
||||
$company_id = $this->userInfo['company_id'];
|
||||
$params['company_id'] = $this->userInfo['company_id'];
|
||||
//获取车辆
|
||||
$result = VehicleLogic::carList($company_id);
|
||||
$result = VehicleLogic::carList($params);
|
||||
//返回数据
|
||||
if($result['code'] == 1){
|
||||
return $this->success($result['msg'],$result['data']);
|
||||
|
@ -65,17 +65,21 @@ class VehicleLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public static function carList($company_id) {
|
||||
$rent = Db::name('vehicle_rent')->where('party_b',$company_id)->where('status',2)->select();
|
||||
if($rent->count() <= 0){
|
||||
return ['code'=>0,'msg'=>'未查找到车辆'];
|
||||
}
|
||||
foreach ($rent as $v) {
|
||||
$carArr = explode(',',$v['car_ids']);
|
||||
foreach ($carArr as $cid) {
|
||||
//请求物流系统获取车辆详情
|
||||
//todo
|
||||
public static function carList($params):array {
|
||||
//请求物流系统获取车辆详情
|
||||
$result = curl_post('http://www.lst.local/api/companyCarList',[],$params);
|
||||
if($result['code'] == 1){
|
||||
foreach ($result['data'] as $k=>$v){
|
||||
if($v['lessee_two_flag'] == 1){
|
||||
$lessee_two_company = Company::where('id','lessee_two_company_id')->find();
|
||||
$result['data'][$k]['lessee_two_company_address'] = $lessee_two_company['address'];
|
||||
}else{
|
||||
$result['data'][$k]['lessee_two_company_address'] = '';
|
||||
}
|
||||
}
|
||||
return ['code'=>1,'msg'=>'请求成功','data'=>$result['data']];
|
||||
}else{
|
||||
return ['code'=>0,'msg'=>'请求失败'];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user