update
This commit is contained in:
parent
3b11143b5c
commit
c93a30f7d0
@ -83,7 +83,7 @@ class VehicleContractController extends BaseAdminController
|
||||
}
|
||||
$pageNo = !empty($param['page_no']) ? $param['page_no'] : 1;
|
||||
$pageSize = !empty($param['page_size']) ? $param['page_size'] : 15;
|
||||
$data = VehicleContract::where($where)
|
||||
$data = VehicleContract::where($where)->where('status','in','0,1,2,3')
|
||||
->page($pageNo, $pageSize)
|
||||
->order('create_time desc')
|
||||
->select()->each(function($item){
|
||||
|
@ -36,7 +36,8 @@ class IndexController extends BaseApiController
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty','notifyAuthentication','notifyVehicleContractUpdate','notifyVillageCarRent'];
|
||||
|
||||
private $domain = 'http://logistics.lihaink.cn';
|
||||
// private $domain = 'http://logistics.lihaink.cn';
|
||||
private $domain = 'http://www.lst.local';
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
@ -131,48 +132,45 @@ class IndexController extends BaseApiController
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if(!$contract || $contract->isEmpty()){
|
||||
if(empty($contract)){
|
||||
return json(['success' => false, 'msg' => '参数错误']);
|
||||
}
|
||||
$car = json_decode($contract['cars_info']);
|
||||
if($contract['status'] != 2){
|
||||
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||
}
|
||||
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]);
|
||||
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($this->domain.'/api/createRentCarUser',[],[
|
||||
'company_id' => $contract['company_b_id'],
|
||||
'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'],
|
||||
]);
|
||||
}else{
|
||||
//自有车辆
|
||||
$company_b = Company::where('id',$contract['company_b_id'])->find();
|
||||
$res = curl_post($this->domain.'/api/addSelfCar',[],[
|
||||
'license' => $car[0]['license'],
|
||||
//判断是否是自有车辆
|
||||
if($contract['type'] == 1){
|
||||
//添加车辆到物流系统
|
||||
$vehicle = json_decode($contract['cars_info'],true);
|
||||
$curl_res = curl_post($this->domain.'/api/addSelfCar',[],[
|
||||
'license'=>$vehicle['license'],
|
||||
'company_id' => $contract['company_a_id'],
|
||||
'company_name' => $contract['company_a_name'],
|
||||
'company_user' => $contract['company_a_user'],
|
||||
'company_phone' => $contract['company_a_phone'],
|
||||
'user_id' => $company_b['user_id'],
|
||||
'user_name' => $contract['company_b_user'],
|
||||
'user_phone' => $contract['company_b_phone']
|
||||
]);
|
||||
if($res && $res['code'] == 1){
|
||||
$cars_info = json_encode(['id'=>$curl_res['data']['car_id'],'license'=>$vehicle['license']]);
|
||||
VehicleContract::where('id',$id)->update(['cars_info'=>$cars_info,'update_time'=>time()]);
|
||||
VehicleRent::create([
|
||||
'car_id' => $curl_res['data']['car_id'],
|
||||
'company_id' => $contract['company_a_id'],
|
||||
'car_license' => $vehicle['license'],
|
||||
'status' => 2,
|
||||
'rent_time' => time(),
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'create_time' => time(),
|
||||
'type' => 1
|
||||
]);
|
||||
}else if($contract['type'] == 0){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
@ -3,19 +3,16 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\logic\vehicle\VehicleLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use app\common\model\vehicle\VehicleVillageApply;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
public string $url = 'http://logistics.lihaink.cn';
|
||||
// public string $url = 'http://www.lst.local';
|
||||
// public string $url = 'http://logistics.lihaink.cn';
|
||||
public string $url = 'http://www.lst.local';
|
||||
//镇街公司想物流平台申请租赁车辆
|
||||
public function setContractByTownCompany()
|
||||
{
|
||||
@ -69,26 +66,45 @@ class VehicleController extends BaseApiController
|
||||
//镇街公司生成小组服务公司租赁合同
|
||||
public function setContractByVillageCompany(){
|
||||
//获取参数
|
||||
$params = $this->request->post(['apply_id','car_id']);
|
||||
if(empty($params['apply_id'])){
|
||||
$params = $this->request->post(['id','car_id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$apply = VehicleVillageApply::where('id',$params['apply_id'])->find();
|
||||
if($apply['type'] == 0){
|
||||
//获取数据
|
||||
$vehicleContract = VehicleContract::where('id',$params['id'])->find();
|
||||
if(empty($vehicleContract)){
|
||||
return $this->fail('未找到数据');
|
||||
}
|
||||
if($this->userInfo['company_id'] != $vehicleContract['company_a_id']){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($vehicleContract['status'] != -1) {
|
||||
return $this->fail('数据状态错误');
|
||||
}
|
||||
if($vehicleContract['type'] == 0){
|
||||
if(empty($params['car_id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
return $this->fail('缺少参数car_id');
|
||||
}
|
||||
}
|
||||
if(empty($this->userInfo['company_id'])){
|
||||
return $this->fail('签约公司不存在');
|
||||
}
|
||||
$params['party_a'] = $this->userInfo['company_id'];
|
||||
$result = VehicleLogic::initiate_contract_town($params);
|
||||
//返回数据
|
||||
if($result && $result['code'] == 1){
|
||||
return $this->success($result['msg']);
|
||||
if($vehicleContract['type'] == 0){
|
||||
$car = VehicleRent::field('car_id as id,car_license as license')->where('car_id',$params['car_id'])->find();
|
||||
if(empty($car)){
|
||||
return $this->fail('车辆数据有误');
|
||||
}
|
||||
$json = json_encode($car->toArray());
|
||||
//更改车辆状态
|
||||
VehicleRent::where('car_id',$params['car_id'])->update(['status'=>1]);
|
||||
//更改状态
|
||||
$result = VehicleContract::where('id',$params['id'])->update(['status'=>0,'cars_info'=>$json,'update_time'=>time()]);
|
||||
}else{
|
||||
return $this->fail($result['msg']);
|
||||
//更改状态
|
||||
$result = VehicleContract::where('id',$params['id'])->update(['status'=>0,'update_time'=>time()]);
|
||||
}
|
||||
//返回数据
|
||||
if($result){
|
||||
return $this->success('合同生成成功,等待风控部审核');
|
||||
}else{
|
||||
return $this->fail('合同生成失败,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +117,7 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
//获取数据
|
||||
$contract = VehicleContract::where('id',$params['id'])->find();
|
||||
if(!$contract || $contract->isEmpty()){
|
||||
if(empty($contract)){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if($contract['status'] != 1){
|
||||
@ -131,69 +147,96 @@ class VehicleController extends BaseApiController
|
||||
|
||||
//小组服务公司租赁申请
|
||||
public function rentApply() {
|
||||
//验证请求类型
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
}
|
||||
//获取参数
|
||||
$params = $this->request->post('license');
|
||||
$license = $this->request->post('license');
|
||||
//获取当前公司信息
|
||||
$village_company = Company::field('id,company_name,master_name,master_phone,is_contract,company_type')->where('id',$this->userInfo['company_id'])->find();
|
||||
if($village_company->isEmpty() || $village_company['company_type'] != 18){
|
||||
$party_b = Company::field('id,company_name,master_name,master_phone,master_email,is_contract,organization_code,company_type')->where('id',$this->userInfo['company_id'])->find();
|
||||
if(empty($party_b)){
|
||||
return $this->fail('账号异常');
|
||||
}
|
||||
if($party_b['company_type'] != 18){
|
||||
return $this->fail('非小组服务公司不能申请');
|
||||
}
|
||||
if($village_company['is_contract'] != 1){
|
||||
if($party_b['is_contract'] != 1){
|
||||
return $this->fail('当前小组服务公司未签约');
|
||||
}
|
||||
//获取签约信息
|
||||
$contract = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
|
||||
if($contract->isEmpty()){
|
||||
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
|
||||
$party_a = Company::field('id,company_name,master_name,master_phone,master_email,is_contract,organization_code,company_type')->where('id',$contract['party_a'])->find();
|
||||
if(empty($contract) || empty($party_a)){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
if($party_a['company_type'] != 16){
|
||||
return $this->fail('不能与非镇街公司签约');
|
||||
}
|
||||
if($party_a['is_contract'] != 1){
|
||||
return $this->fail('当前镇街公司未签约');
|
||||
}
|
||||
//判断是否申请过
|
||||
$apply = VehicleVillageApply::where('village_company_id',$this->userInfo['company_id'])->where('status','<>',2)->find();
|
||||
if($apply){
|
||||
return $this->fail('已申请了,请勿重复申请');
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$this->userInfo['company_id'])->where('status','<>',4)->find();
|
||||
if(!empty($vehicleContract)){
|
||||
return $this->fail('请勿重复申请');
|
||||
}
|
||||
//设置数据
|
||||
$result = VehicleVillageApply::create([
|
||||
'town_company_id' => $contract['party_a'],
|
||||
'village_company_id' => $village_company['id'],
|
||||
'village_company_name' => $village_company['company_name'],
|
||||
'village_company_user' => $village_company['master_name'],
|
||||
'village_company_phone' => $village_company['master_phone'],
|
||||
'car_license' => !empty($params) ? $params : '',
|
||||
'type' => !empty($params) ? 1 : 0,
|
||||
'status' => 0,
|
||||
$data = [
|
||||
'contract_logistic_id' => 0,
|
||||
'contract_no' => time(),
|
||||
'company_a_id' => $party_a['id'],
|
||||
'company_a_name' => $party_a['company_name'],
|
||||
'company_a_code' => $party_a['organization_code'],
|
||||
'company_a_user' => $party_a['master_name'],
|
||||
'company_a_phone' => $party_a['master_phone'],
|
||||
'company_a_email' => $party_a['master_email'],
|
||||
'company_b_id' => $party_b['id'],
|
||||
'company_b_name' => $party_b['company_name'],
|
||||
'company_b_code' => $party_b['organization_code'],
|
||||
'company_b_user' => $party_b['master_name'],
|
||||
'company_b_phone' => $party_b['master_phone'],
|
||||
'company_b_email' => $party_b['master_email'],
|
||||
'cars_info' => isset($license) ? json_encode(['license'=>$license]) : null,
|
||||
'num' => 1,
|
||||
'type' => isset($license) ? 1 : 0,
|
||||
'status' => -1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
if($result && $result->id){
|
||||
return $this->success('申请成功');
|
||||
'update_time' => time()
|
||||
];
|
||||
//写入数据
|
||||
$result = VehicleContract::create($data);
|
||||
if($result){
|
||||
return $this->success('申请成功,待镇街公司审核');
|
||||
}else{
|
||||
return $this->fail('申请失败');
|
||||
return $this->fail('申请失败,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
//镇街公司驳回小组服务公司的租赁申请
|
||||
public function rejectRentApply() {
|
||||
//验证请求类型
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
}
|
||||
//获取参数
|
||||
$params = $this->request->post(['apply_id','content']);
|
||||
if(empty($params['apply_id']) || empty($params['content'])){
|
||||
$params = $this->request->post(['id','content']);
|
||||
if(empty($params['id']) || empty($params['content'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$apply = VehicleVillageApply::where('id',$params['apply_id'])->where('status',0)->find();
|
||||
if($apply->isEmpty()){
|
||||
return $this->fail('数据错误');
|
||||
$vehicleContract = VehicleContract::where('id',$params['id'])->find();
|
||||
if(empty($vehicleContract)){
|
||||
return $this->fail('未查找到数据');
|
||||
}
|
||||
if($apply['town_company_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('镇街公司信息错误');
|
||||
if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('数据不匹配');
|
||||
}
|
||||
//更新
|
||||
$apply -> status = 2;
|
||||
$apply -> notice = $params['content'];
|
||||
$apply -> update_time = time();
|
||||
$result = $apply->save();
|
||||
$result = VehicleContract::where('id',$params['id'])->update([
|
||||
'status' => 4,
|
||||
'reject_message' => $params['content']
|
||||
]);
|
||||
if($result){
|
||||
return $this->success('驳回成功');
|
||||
}else{
|
||||
@ -203,7 +246,13 @@ class VehicleController extends BaseApiController
|
||||
|
||||
//镇街公司收到的小组服务公司租赁申请列表
|
||||
public function rentApplyList() {
|
||||
$data = VehicleVillageApply::where('town_company_id',$this->userInfo['company_id'])->where('status',0)->select();
|
||||
//获取参数
|
||||
$params = $this->request->get(['status']);
|
||||
$search = [];
|
||||
if(isset($params['status'])){
|
||||
$search[] = ['status','=',$params['status']];
|
||||
}
|
||||
$data = VehicleContract::where('company_a_id',$this->userInfo['company_id'])->where($search)->select();
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
}
|
||||
|
||||
@ -215,38 +264,49 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$data = VehicleVillageApply::where('id',$id)->find();
|
||||
if($data->isEmpty() || $data['town_company_id'] != $this->userInfo['company_id'] || $data['status'] != 0){
|
||||
$vehicleContract = VehicleContract::where('id',$id)->find();
|
||||
if(empty($vehicleContract)){
|
||||
return $this->fail('获取数据失败');
|
||||
}
|
||||
//获取镇街公司可租赁车辆列表
|
||||
$cars = VehicleRent::field('car_id,car_license')->where('company_id',$this->userInfo['company_id'])->where('status',0)->where('type',0)->select();
|
||||
return $this->success('请求成功',[
|
||||
'apply' => $data->toArray(),
|
||||
'cars' => $cars->toArray()
|
||||
]);
|
||||
if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('数据不匹配');
|
||||
}
|
||||
if(!empty($vehicleContract['cars_info'])){
|
||||
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
||||
}
|
||||
//判断申请状态
|
||||
if($vehicleContract['status'] == -1){
|
||||
$vehicleRentCars = VehicleRent::where('company_id',$vehicleContract['company_a_id'])->where('status',0)->select()->toArray();
|
||||
}else{
|
||||
$vehicleRentCars = [];
|
||||
}
|
||||
$data = [
|
||||
'vehicleContract' => $vehicleContract->toArray(),
|
||||
'$vehicleRentCars' => $vehicleRentCars
|
||||
];
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
//镇街公司车辆管理首页
|
||||
public function vehicleIndex() {
|
||||
//获取参数
|
||||
$params = $this->request->get();
|
||||
$company_id = $this->userInfo['company_id'];
|
||||
if(empty($company_id)){
|
||||
return $this->fail('公司信息不存在');
|
||||
public function townCompanyVehicleIndex() {
|
||||
//获取公司信息
|
||||
$company = Company::where('id',$this->userInfo['company_id'])->find();
|
||||
if(empty($company)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($company['company_type'] !=16 ){
|
||||
return $this->fail('非镇街公司不能访问');
|
||||
}
|
||||
//获取小组服务公司申请信息
|
||||
$apply = VehicleVillageApply::where('town_company_id',$company_id)->where('status',0)->select();
|
||||
$vehicleContract = VehicleContract::where('company_a_id',$company['id'])->where('status',-1)->limit(2)->order('create_time desc')->select()->toArray();
|
||||
//获取车辆列表
|
||||
$carList = VehicleRent::where('company_id',$company_id)->select()->each(function($item){
|
||||
$item['mileage'] = 0;
|
||||
if($item['status'] == 1){
|
||||
$company = Company::where('id',$item['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
$item['rent_company'] = $company->toArray();
|
||||
$vehicleRentCars = VehicleRent::where('company_id',$company['id'])->select()->each(function($item){
|
||||
if($item['status'] == 2){
|
||||
$item['rent_user'] = Company::field('company_name,master_name as user_name,master_phone as user_phone,province,city,area,street,village,brigade')->where('id',$item['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
}
|
||||
});
|
||||
})->toArray();
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$villageCompany = Contract::where('party_a',$company_id)->where('signing_timer',2)->select();
|
||||
$villageCompany = Contract::where('party_a',$company['id'])->where('signing_timer',2)->select();
|
||||
//系统车辆数量
|
||||
$rentCar = VehicleRent::field('id')->where('type',0)->select();
|
||||
//可租赁车辆
|
||||
@ -255,8 +315,8 @@ class VehicleController extends BaseApiController
|
||||
$selfCar = VehicleRent::field('id')->where('type',1)->select();
|
||||
//设置数据
|
||||
$data = [
|
||||
'apply' => $apply->toArray(),
|
||||
'car_list' => $carList->toArray(),
|
||||
'apply' => $vehicleContract,
|
||||
'car_list' => $vehicleRentCars,
|
||||
'monitor_num' => $villageCompany->count(),
|
||||
'rent_num' => $rentCar->count(),
|
||||
'can_rent_num' => $canRentCar->count(),
|
||||
@ -266,36 +326,41 @@ class VehicleController extends BaseApiController
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
public function villageIndex() {
|
||||
// $company_id = $this->userInfo['company_id'];
|
||||
// if(empty($company_id)){
|
||||
// return $this->fail('公司信息不存在');
|
||||
// }
|
||||
// $company = Company::where('id',$company_id)->find();
|
||||
// if($company['company_type'] != 18){
|
||||
// return $this->fail('非小组服务公司');
|
||||
// }
|
||||
// $apply = VehicleVillageApply::where('village_company_id',$company_id)->find();
|
||||
// $data = [
|
||||
// 'status' => 0,
|
||||
// ];
|
||||
// if($apply){
|
||||
// $data['apply'] = $apply->toArray();
|
||||
// }else{
|
||||
// $data['apply'] = [];
|
||||
// }
|
||||
// $car = VehicleRent::where('rent_company_id',$company_id)->find();
|
||||
// if($car){
|
||||
// //当前坐标位置
|
||||
// $position = curl_post('http://logistics.lihaink.cn/api/getCarLocal',[],['car_id'=>$car['car_id']]);
|
||||
// if($position && $position['code'] == 1){
|
||||
// $car['position'] = $position['data'];
|
||||
// }
|
||||
// $car['company'] = Company::where('id',$car['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
// }else{
|
||||
// $data['car'] = [];
|
||||
// }
|
||||
// return $this->success('success',$data);
|
||||
public function villageCompanyIndex() {
|
||||
//获取公司信息
|
||||
$company = Company::field('id,company_type,province,city,area,street,village,brigade')->where('id',$this->userInfo['company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
if(empty($company)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($company['company_type'] != 18 ){
|
||||
return $this->fail('非小组公司不能访问');
|
||||
}
|
||||
//获取申请信息
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$company['id'])->order('id desc')->find();
|
||||
if(empty($vehicleContract)){
|
||||
return $this->fail('数据有误');
|
||||
}
|
||||
if(!empty($vehicleContract['cars_info'])){
|
||||
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
||||
if(!empty($vehicleContract['cars_info'])){
|
||||
$arr = $vehicleContract['cars_info'];
|
||||
$arr['mileage'] = 0;
|
||||
$position = curl_get($this->url.'/api/getCarLocal?car_id='.$arr['id']);
|
||||
if($position && $position['code'] == 1){
|
||||
$arr['lon'] = $position['data']['lon'];
|
||||
$arr['lat'] = $position['data']['lat'];
|
||||
}
|
||||
$vehicleContract['cars_info'] = $arr;
|
||||
}
|
||||
}
|
||||
$vehicleContract['province'] = $company['province_name'];
|
||||
$vehicleContract['city'] = $company['city_name'];
|
||||
$vehicleContract['area'] = $company['area_name'];
|
||||
$vehicleContract['street'] = $company['street_name'];
|
||||
$vehicleContract['village'] = $company['village_name'];
|
||||
$vehicleContract['brigade'] = $company['brigade_name'];
|
||||
//返回数据
|
||||
return $this->success('请求成功',$vehicleContract->toArray());
|
||||
}
|
||||
|
||||
//车辆详情
|
||||
@ -307,9 +372,12 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
//获取数据
|
||||
$data = VehicleRent::where('car_id',$carId)->find();
|
||||
if(empty($data)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
$data['mileage'] = 0;
|
||||
if($data['status'] == 1){
|
||||
$data['company'] = Company::where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
$data['company'] = Company::field('company_name,master_name as user_name,master_phone as user_phone,province,city,area,street,village,brigade')->where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
}
|
||||
//当前坐标位置
|
||||
$position = curl_post('http://logistics.lihaink.cn/api/getCarLocal',[],['car_id'=>$carId]);
|
||||
@ -322,38 +390,15 @@ class VehicleController extends BaseApiController
|
||||
public function vehicleTrack() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['car_id','start_time','end_time']);
|
||||
|
||||
if(empty($params['car_id']) || empty($params['start_time']) || empty($params['end_time'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
|
||||
//获取轨迹
|
||||
$url = 'http://logistics.lihaink.cn/api/getCarHistory?car_id='.$params['car_id'].'&start_time='.$params['start_time'].'&end_time='.$params['end_time'];
|
||||
|
||||
$result = curl_get($url);
|
||||
|
||||
return $this->success('success',$result['data']);
|
||||
}
|
||||
|
||||
//镇街公司合同列表
|
||||
public function contractList() {
|
||||
$data = VehicleContract::where('company_a_id',$this->userInfo['company_id'])->where('status',0)->select();
|
||||
return $this->success('success',$data->toArray());
|
||||
}
|
||||
|
||||
//镇街公司合同详情
|
||||
public function contractInfo() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if(empty($id)){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$data = VehicleContract::where('id',$id)->find();
|
||||
$data['cars_info'] = json_decode($data['cars_info'],true);
|
||||
return $this->success('success',$data->toArray());
|
||||
}
|
||||
|
||||
|
||||
public function sendSms($id) {
|
||||
//获取合同数据
|
||||
@ -399,7 +444,7 @@ class VehicleController extends BaseApiController
|
||||
'name' => $v['fullName'],
|
||||
'type' => '《租赁合同》',
|
||||
'code' => 'api/Hetong/url?id='.$id.'&type='.$v['type'],
|
||||
'scene' => 'WQTZ'
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
$scene = NoticeEnum::getSceneByTag($sms['scene']);
|
||||
if (empty($scene)) {
|
||||
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\vehicle;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use app\common\model\vehicle\VehicleVillageApply;
|
||||
|
||||
|
||||
class VehicleLogic extends BaseLogic
|
||||
{
|
||||
public static string $url = 'http://logistics.lihaink.cn';
|
||||
// public static string $url = 'http://www.lst.local';
|
||||
public static function initiate_contract_logistic($params):array|bool {
|
||||
//查找乙方公司信息
|
||||
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$params['party_b'])->find();
|
||||
|
||||
//镇街公司
|
||||
if(!$party_b || $party_b->isEmpty() || $party_b['company_type'] != 16){
|
||||
return ['code'=>0,'msg'=>'非镇街公司不能签约'];
|
||||
}
|
||||
//生成合同
|
||||
$result = curl_post(self::$url.'/api/signContract',[],[
|
||||
'num' => $data['num'],
|
||||
'company_id' => $party_b['id'],
|
||||
'company_name' => $party_b['company_name'],
|
||||
'company_code' => $party_b['organization_code'],
|
||||
'company_user' => $party_b['master_name'],
|
||||
'company_phone' => $party_b['master_phone'],
|
||||
'company_email' => $party_b['master_email'],
|
||||
]);
|
||||
if($result && $result['code'] == 1){
|
||||
VehicleContract::create($result['data']);
|
||||
}
|
||||
return $result ?? false;
|
||||
}
|
||||
|
||||
public static function initiate_contract_town($params):array|bool {
|
||||
//获取申请信息
|
||||
$apply = VehicleVillageApply::where('id',$params['apply_id'])->find();
|
||||
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['party_a'] != $apply['town_company_id']){
|
||||
return ['code'=>0,'msg'=>'镇街公司信息错误'];
|
||||
}
|
||||
$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();
|
||||
$data = [
|
||||
'contract_no' => time(),
|
||||
'company_a_name' => $party_a['company_name'],
|
||||
'company_a_code' => $party_a['company_organization_code'],
|
||||
'company_a_user' => $party_a['company_user'],
|
||||
'company_a_phone' => $party_a['company_phone'],
|
||||
'company_a_email' => $party_a['company_email'],
|
||||
'company_b_id' => $party_b['company_id'],
|
||||
'company_b_name' => $party_b['company_name'],
|
||||
'company_b_code' => $party_b['company_code'],
|
||||
'company_b_user' => $party_b['company_user'],
|
||||
'company_b_phone' => $party_b['company_phone'],
|
||||
'company_b_email' => $party_b['company_email'],
|
||||
'num' => 1,
|
||||
'cars_info' => $carJson,
|
||||
'type' => $apply['type'] == 0 ? 0 : 1,
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
$result = VehicleContract::create($data);
|
||||
//返回
|
||||
if($result->id){
|
||||
return ['code'=>1,'msg'=>'合同发起成功,等待审核'];
|
||||
}else{
|
||||
return ['code'=>0,'msg'=>'合同发起失败,请稍后重试'];
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@ class VehicleRent extends BaseModel
|
||||
|
||||
public function getRentTimeAttr($value): string
|
||||
{
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
return !empty($value) ? date('Y-m-d H:i:s',$value) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user