Merge pull request '三轮车购买part1' (#71) from zhangwei into dev
Reviewed-on: #71
This commit is contained in:
commit
3a57437262
@ -162,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'],
|
||||
@ -174,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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user