This commit is contained in:
unknown 2023-08-30 18:57:41 +08:00
parent 1c662f8cdb
commit 85117f15cc
4 changed files with 36 additions and 21 deletions

View File

@ -138,19 +138,24 @@ class IndexController extends BaseApiController
if ($contract['signing_timer'] == 0) {
VehicleContract::where('id',$id)->update(['signing_timer'=>1]);
}else if($contract['signing_timer'] == 1) {
//更改合同状态
VehicleContract::where('id',$id)->update(['signing_timer'=>2,'status'=>3]);
VehicleRent::where('car_id',$car[0]['id'])->where('company_id',$contract['company_a_id'])->update([
'rent_company_id' => $contract['company_b_id'],
'rent_time' => time()
]);
$party_b_company = Company::field('user_id,master_name,master_phone')->where('id',$contract['company_b_id'])->find();
//通知物流系统添加车辆使用人
curl_post('http://logistics.lihaink.cn/api/createRentCarUser',[],[
'car_id' => $car[0]['id'],
'user_id' => $party_b_company['user_id'],
'user_name' => $party_b_company['master_name'],
'user_phone' => $party_b_company['master_phone'],
]);
if($contract['type'] == 0){
//更改车辆状态
VehicleRent::where('car_id',$car[0]['id'])->where('company_id',$contract['company_a_id'])->update([
'rent_company_id' => $contract['company_b_id'],
'status' => 1,
'rent_time' => time()
]);
$party_b_company = Company::field('user_id,master_name,master_phone')->where('id',$contract['company_b_id'])->find();
//通知物流系统添加车辆使用人
curl_post('http://logistics.lihaink.cn/api/createRentCarUser',[],[
'car_id' => $car[0]['id'],
'user_id' => $party_b_company['user_id'],
'user_name' => $party_b_company['master_name'],
'user_phone' => $party_b_company['master_phone'],
]);
}
}
return json(['success' => true, 'msg' => '成功']);
}

View File

@ -40,9 +40,15 @@ class VehicleController extends BaseApiController
public function setContractByVillageCompany(){
//获取参数
$params = $this->request->post(['apply_id','car_id']);
if(empty($params['apply_id']) || empty($params['car_id'])){
if(empty($params['apply_id'])){
return $this->fail('缺少必要参数');
}
$apply = VehicleVillageApply::where('id',$params['apply_id'])->find();
if($apply['type'] == 0){
if(empty($params['car_id'])){
return $this->fail('缺少必要参数');
}
}
if(empty($this->userInfo['company_id'])){
return $this->fail('签约公司不存在');
}

View File

@ -39,10 +39,16 @@ class VehicleLogic extends BaseLogic
public static function initiate_contract_town($params):array|bool {
//获取申请信息
$apply = VehicleVillageApply::where('id',$params['apply_id'])->find();
//获取车辆信息
$car = VehicleRent::where('car_id',$params['car_id'])->find();
if($car->isEmpty() || $car['status'] == 1){
return ['code'=>0,'msg'=>'车辆信息错误'];
if($apply['type'] == 0){
//获取车辆信息
$car = VehicleRent::where('car_id',$params['car_id'])->find();
if($car->isEmpty() || $car['status'] == 1){
return ['code'=>0,'msg'=>'车辆信息错误'];
}
//生成合同
$carJson = json_encode(['id'=>$car['id'],'license'=>$car['car_license']]);
}else{
$carJson = json_encode(['license'=>$apply['car_license']]);
}
//获取甲方公司
if($params['company_id'] != $apply['town_company_id']){
@ -51,8 +57,6 @@ class VehicleLogic extends BaseLogic
$party_a = Company::field('id,company_name,organization_code,master_name,master_phone,master_email')->where('id',$params['company_id'])->find();
//获取乙方公司
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$apply['village_company_id'])->find();
//生成合同
$carJson = json_encode(['id'=>$car['id'],'license'=>$car['car_license']]);
$data = [
'contract_no' => time(),
'company_a_name' => $party_a['company_name'],
@ -68,7 +72,7 @@ class VehicleLogic extends BaseLogic
'company_b_email' => $party_b['company_email'],
'num' => 1,
'cars_info' => $carJson,
'type' => 0,
'type' => $apply['type'] == 0 ? 0 : 1,
'status' => 0,
'create_time' => time(),
'update_time' => time(),

View File

@ -54,7 +54,7 @@ class RequestUtils{
$req=Array();
}else if(is_array($req)){
//
}else if(is_a($req,"com\junziqian\sdk\bean\Req2MapInterface")){
}else if(is_a($req,"junziqian\sdk\bean\Req2MapInterface")){
$req=$req->build();
}else{
throw new ResultInfoException("不支持的请求req");