车辆购买done
This commit is contained in:
parent
78fa71edef
commit
6bd04e5c2a
@ -158,6 +158,9 @@ class VehicleContractController extends BaseAdminController
|
|||||||
if($contract['type'] == 0){
|
if($contract['type'] == 0){
|
||||||
$smsTitle = '《租赁合同》';
|
$smsTitle = '《租赁合同》';
|
||||||
$notify_url = env('project.website_domain').'/api/index/townCarRent';
|
$notify_url = env('project.website_domain').'/api/index/townCarRent';
|
||||||
|
}elseif($contract['type'] == 1){
|
||||||
|
$smsTitle = '《自有车辆上传合同》';
|
||||||
|
$notify_url = env('project.website_domain').'/api/index/selfCarRent';
|
||||||
}elseif($contract['type'] == 2){
|
}elseif($contract['type'] == 2){
|
||||||
$smsTitle = '《解约合同》';
|
$smsTitle = '《解约合同》';
|
||||||
$notify_url = env('project.website_domain').'/api/index/cancelRent';
|
$notify_url = env('project.website_domain').'/api/index/cancelRent';
|
||||||
|
@ -360,6 +360,7 @@ class IndexController extends BaseApiController
|
|||||||
'car_license' => $vehicle['license'],
|
'car_license' => $vehicle['license'],
|
||||||
'status' => 2,
|
'status' => 2,
|
||||||
'rent_time' => time(),
|
'rent_time' => time(),
|
||||||
|
'rent_contract_id' => $contract['id'],
|
||||||
'rent_company_id' => $contract['company_b_id'],
|
'rent_company_id' => $contract['company_b_id'],
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'type' => 1
|
'type' => 1
|
||||||
@ -482,7 +483,51 @@ class IndexController extends BaseApiController
|
|||||||
return json(['success' => true, 'msg' => '成功']);
|
return json(['success' => true, 'msg' => '成功']);
|
||||||
}
|
}
|
||||||
//小组公司与镇街公司解约,然后镇街公司与平台公司解约
|
//小组公司与镇街公司解约,然后镇街公司与平台公司解约
|
||||||
if($vehicleBuyRecord['status'] == 2){}
|
if($vehicleBuyRecord['status'] == 2){
|
||||||
|
//获取租赁车辆信息
|
||||||
|
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
|
||||||
|
//获取镇街公司信息
|
||||||
|
$zjCompany = Company::where('id',$rentCarsInfo['company_id'])->findOrEmpty();
|
||||||
|
//判断购买车辆中是否包含镇街公司租赁的车辆
|
||||||
|
$car_ids = array_column(json_decode($vehicleBuyRecord['cars_info'],true),'id');
|
||||||
|
$zjRentCars = VehicleRent::field('car_id as id,car_license as license')->where('company_id',$zjCompany['id'])->where('car_id','in',$car_ids)->where('status',0)->where('type',0)->select();
|
||||||
|
if($rentCarsInfo['type'] == 0){
|
||||||
|
//修改租赁车俩状态
|
||||||
|
VehicleRent::where('id',$rentCarsInfo['id'])->update(['status'=>0,'rent_company_id'=>0,'rent_contract_id'=>0,'rent_time'=>0]);
|
||||||
|
}
|
||||||
|
if($rentCarsInfo['type'] == 1){
|
||||||
|
//修改租赁车俩状态
|
||||||
|
VehicleRent::where('id',$rentCarsInfo['id'])->delete();
|
||||||
|
}
|
||||||
|
//删除原合同
|
||||||
|
VehicleContract::where('id',$rentCarsInfo['rent_contract_id'])->delete();
|
||||||
|
//修改物流系统车辆租赁信息
|
||||||
|
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
|
||||||
|
'car_id' => $cars_ids[0]
|
||||||
|
]);
|
||||||
|
//发送镇公司与平台公司的解约合同
|
||||||
|
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||||
|
'num' => count($zjRentCars),
|
||||||
|
'company_id' => $zjCompany['id'],
|
||||||
|
'company_name' => $zjCompany['company_name'],
|
||||||
|
'company_code' => $zjCompany['organization_code'],
|
||||||
|
'company_user' => $zjCompany['master_name'],
|
||||||
|
'company_phone' => $zjCompany['master_phone'],
|
||||||
|
'company_email' => $zjCompany['master_email'],
|
||||||
|
'cars_info' => json_encode($zjRentCars),
|
||||||
|
'type' => 2
|
||||||
|
]);
|
||||||
|
if(empty($curl_result)){
|
||||||
|
return $this->fail('null return from logistic');
|
||||||
|
}
|
||||||
|
if($curl_result['code'] == 0){
|
||||||
|
return $this->fail($curl_result['msg'].' from logistic');
|
||||||
|
}
|
||||||
|
//生成本地合同
|
||||||
|
VehicleContract::create($curl_result['data']);
|
||||||
|
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>3]);
|
||||||
|
return json(['success' => true, 'msg' => '成功']);
|
||||||
|
}
|
||||||
//镇街公司与平台公司解约
|
//镇街公司与平台公司解约
|
||||||
if($vehicleBuyRecord['status'] == 3){
|
if($vehicleBuyRecord['status'] == 3){
|
||||||
//删除本地租赁信息
|
//删除本地租赁信息
|
||||||
@ -518,16 +563,13 @@ class IndexController extends BaseApiController
|
|||||||
//更改租赁列表车辆状态
|
//更改租赁列表车辆状态
|
||||||
$vehicle = json_decode($contract['cars_info'], true);
|
$vehicle = json_decode($contract['cars_info'], true);
|
||||||
//获取租赁车辆信息
|
//获取租赁车辆信息
|
||||||
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle['id'])->find();
|
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle[0]['id'])->find();
|
||||||
//更新原始合同类型
|
//更新原始合同类型
|
||||||
VehicleContract::where('id', $vehicleRentInfo['contract_id'])->update(['status' => 6]);
|
VehicleContract::where('id', $vehicleRentInfo['rent_contract_id'])->delete();
|
||||||
VehicleRent::where('car_id', $vehicle['id'])->update([
|
VehicleRent::where('car_id', $vehicle[0]['id'])->delete();
|
||||||
'status' => 3,
|
|
||||||
]);
|
|
||||||
//通知物流系统跟新
|
//通知物流系统跟新
|
||||||
curl_post(env('project.logistic_domain').'/api/cancelRent', [], [
|
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
|
||||||
'car_id' => $vehicle['id'],
|
'car_id' => $vehicle[0]['id']
|
||||||
'status' => 1
|
|
||||||
]);
|
]);
|
||||||
return json(['success' => true, 'msg' => '成功']);
|
return json(['success' => true, 'msg' => '成功']);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ class VehicleController extends BaseApiController
|
|||||||
return $this->fail('请勿重复申请');
|
return $this->fail('请勿重复申请');
|
||||||
}
|
}
|
||||||
if($params['type'] == 1){
|
if($params['type'] == 1){
|
||||||
$cars_info = json_encode(['license'=>$params['license'],'pic'=>$params['pic']]);
|
$cars_info = json_encode([['license'=>$params['license'],'pic'=>$params['pic']]]);
|
||||||
$car_type = 1;
|
$car_type = 1;
|
||||||
}else{
|
}else{
|
||||||
$cars_info = null;
|
$cars_info = null;
|
||||||
@ -768,6 +768,48 @@ class VehicleController extends BaseApiController
|
|||||||
'create_time' => time()
|
'create_time' => time()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
//如果有租赁车俩和上传自有车辆,也有购买镇街公司租赁的车辆 则先向镇街公司发起解约合同,再由镇街公司向平台公司发起解约合同
|
||||||
|
if(!$xzRentCars->isEmpty() && !$zjRentCars->isEmpty()){
|
||||||
|
//获取镇街公司信息
|
||||||
|
$zjCompanyInfo = Company::field('id,company_name,master_name,master_phone,master_email,organization_code')->where('id',$zjCompany['party_a'])->findOrEmpty();
|
||||||
|
//生成本地解约合同
|
||||||
|
$res = VehicleContract::create([
|
||||||
|
'contract_no' => time(),
|
||||||
|
'contract_logistic_id' => 0,
|
||||||
|
'company_a_id' => $zjCompanyInfo['id'],
|
||||||
|
'company_a_name' => $zjCompanyInfo['company_name'],
|
||||||
|
'company_a_code' => $zjCompanyInfo['organization_code'],
|
||||||
|
'company_a_user' => $zjCompanyInfo['master_name'],
|
||||||
|
'company_a_phone' => $zjCompanyInfo['master_phone'],
|
||||||
|
'company_a_email' => $zjCompanyInfo['master_email'],
|
||||||
|
'company_b_id' => $xzCompany['id'],
|
||||||
|
'company_b_name' => $xzCompany['company_name'],
|
||||||
|
'company_b_code' => $xzCompany['organization_code'],
|
||||||
|
'company_b_user' => $xzCompany['master_name'],
|
||||||
|
'company_b_phone' => $xzCompany['master_phone'],
|
||||||
|
'company_b_email' => $xzCompany['master_email'],
|
||||||
|
'num' =>1,
|
||||||
|
'cars_info' => json_encode([['id'=>$xzRentCars['car_id'],'license'=>$xzRentCars['car_license']]]),
|
||||||
|
'type' => 2,
|
||||||
|
'status' => 0,
|
||||||
|
'create_time' => time(),
|
||||||
|
'update_time' => time(),
|
||||||
|
]);
|
||||||
|
//生成关联记录
|
||||||
|
VehicleBuyRecord::create([
|
||||||
|
'company_id' => $xzCompany['id'],
|
||||||
|
'company_name' => $xzCompany['company_name'],
|
||||||
|
'company_code' => $xzCompany['organization_code'],
|
||||||
|
'company_user' => $xzCompany['master_name'],
|
||||||
|
'company_phone' => $xzCompany['master_phone'],
|
||||||
|
'company_email' => $xzCompany['master_email'],
|
||||||
|
'cars_info' => json_encode($cars),
|
||||||
|
'num' => count($cars),
|
||||||
|
'status' => 2,
|
||||||
|
'contract_id' => $res->id,
|
||||||
|
'create_time' => time()
|
||||||
|
]);
|
||||||
|
}
|
||||||
//更新物流系统
|
//更新物流系统
|
||||||
curl_post(env('project.logistic_domain').'/api/Vehicle/updateVehicleStatusToBuy',[],['car_ids'=>implode(',',$car_ids)]);
|
curl_post(env('project.logistic_domain').'/api/Vehicle/updateVehicleStatusToBuy',[],['car_ids'=>implode(',',$car_ids)]);
|
||||||
return $this->success('合同发起成功,等待审核 from task');
|
return $this->success('合同发起成功,等待审核 from task');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user