Merge branch 'dev' of https://gitea.lihaink.cn/mkm/TaskSystem into dev
This commit is contained in:
commit
9cafd54067
@ -30,6 +30,9 @@ class VehicleContractController extends BaseAdminController
|
||||
return $this->fail('参数cars无效');
|
||||
}
|
||||
}
|
||||
if($vehicle_contract['type'] == 3){
|
||||
$params['cars'] = $vehicle_contract['cars_info'];
|
||||
}
|
||||
if($vehicle_contract['status'] != 0){
|
||||
return $this->fail('合同状态错误');
|
||||
}
|
||||
@ -159,7 +162,18 @@ class VehicleContractController extends BaseAdminController
|
||||
],
|
||||
'url' => $contract['file']
|
||||
];
|
||||
$signRes = app(JunziqianController::class)->VehicleRentSigning($signData, $params['id'],env('project.website_domain').'/api/index/townCarRent');
|
||||
$notify_url = '';
|
||||
if($contract['type'] == 0){
|
||||
$smsTitle = '《租赁合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/townCarRent';
|
||||
}elseif($contract['type'] == 2){
|
||||
$smsTitle = '《解约合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/cancelRent';
|
||||
}elseif($contract['type'] == 3){
|
||||
$smsTitle = '《购买合同》';
|
||||
$notify_url = env('project.website_domain').'/api/index/buyCar';
|
||||
}
|
||||
$signRes = app(JunziqianController::class)->VehicleRentSigning($signData, $params['id'],$notify_url);
|
||||
if ($signRes->success) {
|
||||
$contract->save([
|
||||
'id' => $contract['id'],
|
||||
@ -171,7 +185,7 @@ class VehicleContractController extends BaseAdminController
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2,
|
||||
]);
|
||||
$this->sendSms($params['id'],'《租赁合同》');
|
||||
$this->sendSms($params['id'],$smsTitle);
|
||||
return $this->success('合同发送成功');
|
||||
} else {
|
||||
return $this->fail($signRes->msg);
|
||||
|
@ -37,7 +37,7 @@ use think\response\Json;
|
||||
*/
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl', 'notifyProperty', 'notifyAuthentication', 'notifyVehicleContractUpdate','townCarRent','systemCarRent', 'selfCarRent', 'cancelRent'];
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl', 'notifyProperty', 'notifyAuthentication', 'notifyVehicleContractUpdate','townCarRent','systemCarRent', 'selfCarRent', 'cancelRent', 'buyCar'];
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
@ -450,6 +450,86 @@ class IndexController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
//购买合同回调
|
||||
public function buyCar() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if (empty($id)) {
|
||||
return json(['success' => false, 'msg' => '失败4.1']);
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id', $id)->find();
|
||||
if (empty($contract)) {
|
||||
return json(['success' => false, 'msg' => '失败4.2']);
|
||||
}
|
||||
if ($contract['type'] != 3) {
|
||||
return json(['success' => false, 'msg' => '失败4.3']);
|
||||
}
|
||||
if ($contract['status'] != 2) {
|
||||
return json(['success' => false, 'msg' => '失败4.4']);
|
||||
}
|
||||
if ($contract['signing_timer'] == 0) {
|
||||
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
|
||||
if (!$res) {
|
||||
return json(['success' => false, 'msg' => '失败4.5']);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else if ($contract['signing_timer'] == 1) {
|
||||
//获取签约后的合同
|
||||
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
|
||||
$signContractFile = $signContractFile ?? '';
|
||||
//获取签约后的证据
|
||||
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
|
||||
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
|
||||
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
|
||||
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
|
||||
$contractEvidence = json_encode([
|
||||
'party_a' => $signContractEvidenceToPartyA,
|
||||
'party_b' => $signContractEvidenceToPartyB
|
||||
]);
|
||||
//更新本地合同状态
|
||||
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>2,'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
|
||||
//判断是否有监管车辆
|
||||
$jgCars = VehicleRent::where('rent_company_id',$contract['company_b_id'])->where('status',2)->where('type',2)->findOrEmpty();
|
||||
if($jgCars->isEmpty()){
|
||||
//获取小组服务公司的镇街公司
|
||||
//获取镇街公司信息
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$contract['company_b_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
//将车辆加入到本地租赁列表
|
||||
$cars = json_decode($contract['cars_info'], true);
|
||||
//写入数据
|
||||
$data = [
|
||||
'car_id' => $cars[0]['id'],
|
||||
'car_license' => $cars[0]['license'],
|
||||
'type' => 2,
|
||||
'status' => 2,
|
||||
'company_id' => $zjCompany['party_a'],
|
||||
'rent_time' => time(),
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'contract_id' => $contract['id'],
|
||||
'create_time' => time()
|
||||
];
|
||||
$vehicleRent = new VehicleRent();
|
||||
$vehicleRent->saveAll($data);
|
||||
}
|
||||
//更新远程
|
||||
$updateSverRes = curl_post(env('project.logistic_domain').'/api/contractUpdate',[],[
|
||||
'id' => $contract['contract_logistic_id'],
|
||||
'signing_timer' => 2,
|
||||
'status' => 3,
|
||||
'contract_url'=>$signContractFile,
|
||||
'contract_evidence'=>$contractEvidence
|
||||
]);
|
||||
if(!$updateLocalRes || $updateSverRes['code']==0){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '更新成功']);
|
||||
}
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
}
|
||||
|
||||
//车辆租赁签约合同状态更改
|
||||
public function notifyVehicleContractUpdate()
|
||||
{
|
||||
|
@ -642,4 +642,79 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
//获取空闲车辆列表
|
||||
public function getFreeCars(): \think\response\Json
|
||||
{
|
||||
//1、获取当前登录用户信息并判断其公司是否是小组服务公司
|
||||
$xzCompany = Company::field('id,company_type')->where('id',$this->userInfo['company_id'])->findOrEmpty();
|
||||
if($xzCompany->isEmpty() || $xzCompany['company_type'] != 18){
|
||||
return $this->fail('当前用户非小组服务公司');
|
||||
}
|
||||
//2、获取小组服务公司签约的镇街公司
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
//3、获取镇街公司向平台租赁的且未二次租赁给小组公司的车辆
|
||||
$zjRentCars = VehicleRent::field('car_id')->where('company_id',$zjCompany['party_a'])->where('status',0)->select()->toArray();
|
||||
$zjRentCars = array_column($zjRentCars,'car_id');
|
||||
//4、获取小组公司自己租赁的车辆
|
||||
$xzRentCars = VehicleRent::field('car_id')->where('company_id',$zjCompany['party_a'])->where('rent_company_id',$xzCompany['id'])->where('status',2)->select()->toArray();
|
||||
$xzRentCars = array_column($xzRentCars,'car_id');
|
||||
//5、获取平台未出租的车辆
|
||||
$result = curl_post(env('project.logistic_domain').'/api/Vehicle/getFreeCars',[],['ids'=>implode(',',array_merge($zjRentCars,$xzRentCars))]);
|
||||
//6、返回
|
||||
return $this->success('success',$result['data']);
|
||||
}
|
||||
|
||||
//申请购车
|
||||
public function buyCars() {
|
||||
//验证请求类型
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
}
|
||||
//1、获取购买车辆的id参数
|
||||
$cars = $this->request->post('cars');
|
||||
$cars = json_decode($cars,true);
|
||||
if(empty($cars)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取小组服务公司信息
|
||||
$xzCompany = Company::field('id,company_name,master_name,master_phone,master_email,organization_code,company_type')->where('id',$this->userInfo['company_id'])->findOrEmpty();
|
||||
if($xzCompany->isEmpty() || $xzCompany['company_type'] != 18){
|
||||
return $this->fail('当前用户非小组服务公司');
|
||||
}
|
||||
//获取镇街公司信息
|
||||
$zjCompany = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
|
||||
//判断购买车辆中是否包含镇街公司租赁的车辆
|
||||
$car_ids = array_column($cars,'id');
|
||||
$zjRentCars = VehicleRent::field('car_id,car_license')->where('company_id',$zjCompany['party_a'])->where('car_id','in',$car_ids)->select();
|
||||
//判断小组服务公司是否租车或者有自有车辆
|
||||
$xzRentCars = VehicleRent::where('rent_company_id',$xzCompany['id'])->where('status','in','1,2')->findOrEmpty();
|
||||
//如果没有租赁车俩和上传自有车辆,也没有购买镇街公司租赁的车辆 则直接发起购买合同
|
||||
if($xzRentCars->isEmpty() && $zjRentCars->isEmpty()){
|
||||
//发送生成合同给物流系统
|
||||
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[],[
|
||||
'num' => count($cars),
|
||||
'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),
|
||||
'type' => 3
|
||||
]);
|
||||
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']);
|
||||
return $this->success('合同发起成功,等待审核 from task'
|
||||
);
|
||||
}
|
||||
//2、判断当前小组服务公司是否租赁车辆,如果已经租赁车辆,则发起与镇街公司解除租赁关系的合同申请 =》如果解除合同签约成功将当前车辆状态重置为未出租,然后进行第三步
|
||||
//3、如果当前小组服务公司没有租赁车辆,则判断购买的车辆中是否有镇街公司租赁的车辆,如果有,则发起镇街公司与平台公司的解除合同 =》 当解除合同签约成功,
|
||||
//4、如果当前小组服务公司没有租赁车辆且购买的车辆中不包含镇街公司租赁的车辆,则直接发起与平台公司的购车合同
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user