新增自有车辆添加接口

This commit is contained in:
unknown 2023-08-26 14:04:16 +08:00
parent 44fd957def
commit 8080091c63
2 changed files with 32 additions and 0 deletions

View File

@ -78,4 +78,22 @@ class VehicleController extends BaseApiController
return $this->fail($result['msg']);
}
}
public function addCar():Json {
//获取参数
$params = $this->request->post(['license']);
//验证参数
if(empty($params['license'])){
return $this->fail('缺啥破必要参数');
}
//获取公司id
$params['company_id'] = $this->userInfo['company_id'];
$result = VehicleLogic::addCar($params);
//返回数据
if($result['code'] == 1){
return $this->success($result['msg']);
}else{
return $this->fail($result['msg']);
}
}
}

View File

@ -82,4 +82,18 @@ class VehicleLogic extends BaseLogic
return ['code'=>0,'msg'=>'请求失败'];
}
}
public static function addCar($params):array {
$company = Company::field('company_type')->where('id',$params['company_id'])->find();
if($company['company_type'] != 18){
return ['code'=>0,'msg'=>'非小组服务公司不能添加车辆'];
}
//http://logistics.lihaink.cn
$result = curl_post('http://www.lst.local/api/addVehicle',[],$params);
if($result['code'] == 1){
return ['code'=>1,'msg'=>$result['msg']];
}else{
return ['code'=>0,'msg'=>$result['msg']];
}
}
}