Merge pull request 'master' (#16) from master into dev

Reviewed-on: #16
This commit is contained in:
weiz 2023-09-07 10:41:03 +08:00
commit e4cffb8455
2 changed files with 41 additions and 12 deletions

View File

@ -12,15 +12,24 @@ class VehicleContractController extends BaseAdminController
//风控中心上传合同 //风控中心上传合同
public function uploadContract() { public function uploadContract() {
//获取参数 //获取参数
$params = $this->request->post(['id','file']); $params = $this->request->post(['id','file','cars']);
if(empty($params['id']) || empty($params['file'])){ if(empty($params['id']) || empty($params['file'])){
return $this->fail('缺少必要参数'); return $this->fail('缺少必要参数');
} }
//获取合同信息 //获取合同信息
$vehicle_contract = VehicleContract::where('id',$params['id'])->find(); $vehicle_contract = VehicleContract::where('id',$params['id'])->findOrEmpty();
if(empty($vehicle_contract)){ if($vehicle_contract->isEmpty()){
return $this->fail('合同信息错误'); return $this->fail('合同信息错误');
} }
if($vehicle_contract['type']==0 && $vehicle_contract['contract_logistic_id'] != 0){
if(empty($params['cars'])){
return $this->fail('缺少必要参数cars');
}
$cars = json_decode($params['cars'],true);
if(empty($cars)){
return $this->fail('参数cars无效');
}
}
if($vehicle_contract['status'] != 0){ if($vehicle_contract['status'] != 0){
return $this->fail('合同状态错误'); return $this->fail('合同状态错误');
} }
@ -29,13 +38,14 @@ class VehicleContractController extends BaseAdminController
//判断合同类型 //判断合同类型
if(!empty($vehicle_contract['contract_logistic_id'])){ if(!empty($vehicle_contract['contract_logistic_id'])){
//更新物流系统 //更新物流系统
curl_post(env('project.logistic_domain').'/api/updateContract',[],[ curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
'id' => $vehicle_contract['contract_logistic_id'], 'id' => $vehicle_contract['contract_logistic_id'],
'file' => $params['file'], 'file' => $params['file'],
'status' => 1 'status' => 1,
'cars_info' => $params['cars']
]); ]);
} }
VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]); VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'cars_info' => $params['cars'],'status'=>1]);
}catch (\Exception $e){ }catch (\Exception $e){
return $this->fail($e->getMessage()); return $this->fail($e->getMessage());
} }
@ -131,8 +141,8 @@ class VehicleContractController extends BaseAdminController
return $this->fail('缺少必要参数'); return $this->fail('缺少必要参数');
} }
//获取数据 //获取数据
$contract = VehicleContract::where('id',$params['id'])->find(); $contract = VehicleContract::where('id',$params['id'])->findOrEmpty();
if(empty($contract)){ if($contract->isEmpty()){
return $this->fail('数据不存在'); return $this->fail('数据不存在');
} }
if($contract['status'] != 1){ if($contract['status'] != 1){
@ -162,8 +172,8 @@ class VehicleContractController extends BaseAdminController
public function sendSms($id,$title) { public function sendSms($id,$title) {
//获取合同数据 //获取合同数据
$contract = VehicleContract::where('id',$id)->find(); $contract = VehicleContract::where('id',$id)->findOrEmpty();
if ($contract && !$contract->isEmpty() && $contract['file'] != '') { if (!$contract->isEmpty() && $contract['file'] != '') {
//发送短信 //发送短信
$data = [ $data = [
//甲方 //甲方
@ -227,8 +237,18 @@ class VehicleContractController extends BaseAdminController
if(empty($id)){ if(empty($id)){
$this->fail('参数错误'); $this->fail('参数错误');
} }
$data = VehicleContract::where('id',$id)->find(); $data = VehicleContract::where('id',$id)->findOrEmpty();
$data['cars_info'] = json_decode($data['cars_info'],true); if($data->isEmpty()){
return $this->fail('未查找到数据');
}
//判断合同类型
if($data['type'] == 0 && $data['contract_logistic_id'] != 0){
//获取平台车辆
$carList = curl_get(env('project.logistic_domain').'/api/getAvailableVehicles');
$data['car_list'] = $carList&&$carList['code']==1 ? $carList['data'] : [];
}else{
$data['cars_info'] = json_decode($data['cars_info'],true);
}
return $this->success('success',$data->toArray()); return $this->success('success',$data->toArray());
} }
} }

View File

@ -33,6 +33,15 @@ class VehicleController extends BaseApiController
if($params['num'] > $doubleRentCar ){ if($params['num'] > $doubleRentCar ){
return $this->fail('数量超过可再租车辆数'); return $this->fail('数量超过可再租车辆数');
} }
//判断物流车辆
$checkNum = curl_post(env('project.logistic_domain').'/api/checkCarNum',[],['num'=>$params['num']]);
if($checkNum == null){
return $this->fail('检查车辆数量错误');
}
if($checkNum['code'] == 0){
return $this->fail($checkNum['msg']);
}
dump($checkNum);die;
//查找乙方公司信息 //查找乙方公司信息
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$this->userInfo['company_id'])->find(); $party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$this->userInfo['company_id'])->find();
if(empty($party_b)) { if(empty($party_b)) {