This commit is contained in:
yaooo 2023-10-14 09:38:26 +08:00
commit b24a5c9596
5 changed files with 191 additions and 50 deletions

View File

@ -41,7 +41,7 @@ class VehicleContractController extends BaseAdminController
'status' => 1,
];
//判断合同类型
if($vehicle_contract['type'] == 0){
if($vehicle_contract['type'] == 0 && $vehicle_contract['contract_logistic_id'] != 0){
$data['cars_info'] = $params['cars'];
}
if(!empty($vehicle_contract['contract_logistic_id'])){
@ -158,6 +158,9 @@ class VehicleContractController extends BaseAdminController
if($contract['type'] == 0){
$smsTitle = '《租赁合同》';
$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){
$smsTitle = '《解约合同》';
$notify_url = env('project.website_domain').'/api/index/cancelRent';

View File

@ -204,14 +204,15 @@ class IndexController extends BaseApiController
foreach ($cars as $k => $v) {
$hasCar = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
if($hasCar->isEmpty()){
$data[$k]['contract_id'] = $contract['id'];
$data[$k]['company_id'] = $contract['company_b_id'];
$data[$k]['car_id'] = $v['id'];
$data[$k]['car_license'] = $v['license'];
$data[$k]['type'] = 0;
$data[$k]['status'] = 0;
$data[$k]['company_id'] = $contract['company_b_id'];
$data[$k]['rent_time'] = 0;
$data[$k]['rent_contract_id'] = 0;
$data[$k]['rent_company_id'] = 0;
$data[$k]['contract_id'] = $contract['id'];
$data[$k]['rent_time'] = 0;
$data[$k]['create_time'] = strtotime($contract['create_time']);
}
}
@ -280,8 +281,9 @@ class IndexController extends BaseApiController
$vehicle = json_decode($contract['cars_info'], true);
VehicleRent::where('car_id', $vehicle['id'])->update([
'status' => 2,
'rent_time' => time(),
'rent_contract_id' => $contract['id'],
'rent_company_id' => $contract['company_b_id'],
'rent_time' => time(),
]);
$party_b = Company::where('id', $contract['company_b_id'])->find();
//通知物流系统跟新
@ -291,13 +293,6 @@ class IndexController extends BaseApiController
'use_user_name' => $party_b['master_name'],
'use_user_phone' => $party_b['master_phone']
]);
CompanyProperty::create([
'company_id' => $contract['company_b_id'],
'object_id' => $vehicle['id'],
'type' => 1,
'create_time' => time(),
'update_time' => time(),
]);
return json(['success' => true, 'msg' => '成功']);
} else {
return json(['success' => true, 'msg' => '成功']);
@ -365,6 +360,7 @@ class IndexController extends BaseApiController
'car_license' => $vehicle['license'],
'status' => 2,
'rent_time' => time(),
'rent_contract_id' => $contract['id'],
'rent_company_id' => $contract['company_b_id'],
'create_time' => time(),
'type' => 1
@ -446,9 +442,94 @@ class IndexController extends BaseApiController
$vehicleBuyRecord = VehicleBuyRecord::where('contract_id',$contract['id'])->findOrEmpty();
if(!$vehicleBuyRecord->isEmpty()){
//小组公司与镇街公司解约
if($vehicleBuyRecord['status'] == 1){}
//镇街公司与平台公司解约
if($vehicleBuyRecord['status'] == 1){
//获取租赁车辆信息
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
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' => $vehicleBuyRecord['num'],
'company_id' => $vehicleBuyRecord['company_id'],
'company_name' => $vehicleBuyRecord['company_name'],
'company_code' => $vehicleBuyRecord['company_code'],
'company_user' => $vehicleBuyRecord['company_user'],
'company_phone' => $vehicleBuyRecord['company_phone'],
'company_email' => $vehicleBuyRecord['company_email'],
'cars_info' => $vehicleBuyRecord['cars_info'],
'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']);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
return json(['success' => true, 'msg' => '成功']);
}
//小组公司与镇街公司解约,然后镇街公司与平台公司解约
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){
//删除本地租赁信息
VehicleRent::where('car_id','in',$cars_ids)->delete();
//删除物流系统租赁信息
@ -475,23 +556,20 @@ class IndexController extends BaseApiController
}
//生成本地合同
VehicleContract::create($curl_result['data']);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>3]);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
return json(['success' => true, 'msg' => '成功']);
}
}else{
//更改租赁列表车辆状态
$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]);
VehicleRent::where('car_id', $vehicle['id'])->update([
'status' => 3,
]);
VehicleContract::where('id', $vehicleRentInfo['rent_contract_id'])->delete();
VehicleRent::where('car_id', $vehicle[0]['id'])->delete();
//通知物流系统跟新
curl_post(env('project.logistic_domain').'/api/cancelRent', [], [
'car_id' => $vehicle['id'],
'status' => 1
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [], [
'car_id' => $vehicle[0]['id']
]);
return json(['success' => true, 'msg' => '成功']);
}

View File

@ -39,7 +39,7 @@ class RechargeController extends BaseApiController
public function deposit_lists()
{
$params=$this->request->param();
$list=CompanyAccountLog::where('company_id',$this->userId)->page($params['page_no'],15)->select();
$list=CompanyAccountLog::where('company_id',$this->userInfo['company_id'])->page($params['page_no'],15)->select();
$datas=[];
foreach($list as $k=>$v){
$datas[$k]['create_time']=$v['create_time'];

View File

@ -26,25 +26,24 @@ class TaskController extends BaseApiController
[$page, $limit] = $this->getPage();
$time = strtotime(date('Y-m-d'));
$userCompanyInfo = Company::where('id', $this->userInfo['company_id'])->find();
$where = [];
if ($this->userInfo['admin_id'] != 0) {
$where[] = ['company_id', '=', $this->userInfo['company_id']];
}
if ($userCompanyInfo['company_type'] == 18) {
if ($this->userInfo['admin_id'] != 0) {
$where[] = ['company_id', '=', $this->userInfo['company_id']];
$is_captain = User::where('id', $this->userId)->value('is_captain');
if ($is_captain == 1) {
$where[] = ['type', 'in', [31,33]];
} else {
$is_captain = User::where('id', $this->userId)->value('is_captain');
if ($is_captain == 1) {
$where[] = ['type', 'in', [31,33]];
} else {
$where[] = ['type', '=', 33];
$where[] = ['director_uid', '=', $this->userId];
}
$where[] = ['company_id', '=', $this->userInfo['company_id']];
$where[] = ['type', '=', 33];
$where[] = ['director_uid', '=', $this->userId];
}
// $where[] = ['company_id', '=', $this->userInfo['company_id']];
}
if ($userCompanyInfo['company_type'] == 41) {
$where[] = ['director_uid', '=', $this->userId];
$where[] = ['company_id', '=', $this->userInfo['company_id']];
// $where[] = ['company_id', '=', $this->userInfo['company_id']];
}
if (isset($param['date_time']) && $param['date_time'] != '') {
$time = strtotime($param['date_time']);

View File

@ -199,7 +199,7 @@ class VehicleController extends BaseApiController
}
//小组服务公司租赁申请
public function rentApply() {
public function rentApply() {
//验证请求类型
if(!$this->request->isPost()){
return $this->fail('请求类型错误');
@ -243,7 +243,7 @@ class VehicleController extends BaseApiController
return $this->fail('请勿重复申请');
}
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;
}else{
$cars_info = null;
@ -632,6 +632,9 @@ class VehicleController extends BaseApiController
$xzRentCars = array_column($xzRentCars,'car_id');
//5、获取平台未出租的车辆
$result = curl_post(env('project.logistic_domain').'/api/Vehicle/getFreeCars',[],['ids'=>implode(',',array_merge($zjRentCars,$xzRentCars))]);
foreach($result['data'] as $k => $v){
$result['data'][$k]['checked'] = [];
}
//6、返回
return $this->success('success',$result['data']);
}
@ -685,7 +688,6 @@ class VehicleController extends BaseApiController
}
//生成本地合同
VehicleContract::create($curl_result['data']);
return $this->success('合同发起成功,等待审核 from task');
}
//如果没有租赁车俩和上传自有车辆,但有购买镇街公司租赁的车辆 则发起镇街公司与平台公司的解约合同
if($xzRentCars->isEmpty() && !$zjRentCars->isEmpty()){
@ -720,26 +722,27 @@ class VehicleController extends BaseApiController
'company_email' => $xzCompany['master_email'],
'cars_info' => json_encode($cars),
'num' => count($cars),
'status' => 2,
'status' => 3,
'contract_id' => $res->id,
'create_time' => time()
]);
//更改本地车辆状态
VehicleRent::where('car_id','in',$car_ids)->update(['status'=>1]);
return $this->success('合同发起成功,等待审核 from task');
}
//如果有租赁车俩和上传自有车辆,但没有购买镇街公司租赁的车辆 则先向镇街公司发起解约合同
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();
//生成本地解约合同
VehicleContract::create([
$res = VehicleContract::create([
'contract_no' => time(),
'contract_logistic_id' => 0,
'company_a_name' => $zjCompany['company_name'],
'company_a_code' => $zjCompany['organization_code'],
'company_a_user' => $zjCompany['master_name'],
'company_a_phone' => $zjCompany['master_phone'],
'company_a_email' => $zjCompany['master_email'],
'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'],
@ -747,13 +750,71 @@ class VehicleController extends BaseApiController
'company_b_phone' => $xzCompany['master_phone'],
'company_b_email' => $xzCompany['master_email'],
'num' =>1,
'cars_info' => json_encode($cars),
'cars_info' => json_encode([['id'=>$xzRentCars['car_id'],'license'=>$xzRentCars['car_license']]]),
'type' => 2,
'status' => 0,
'create_time' => time(),
'update_time' => time(),
]);
return $this->success('合同发起成功,等待审核 from task');
//生成关联记录
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' => 1,
'contract_id' => $res->id,
'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)]);
return $this->success('合同发起成功,等待审核 from task');
}
}