11
This commit is contained in:
parent
3ba56639a0
commit
81b48813a9
@ -17,28 +17,35 @@ class VehicleContractController extends BaseAdminController
|
||||
//获取参数
|
||||
$params = $this->request->post(['id','file']);
|
||||
if(empty($params['id']) || empty($params['file'])){
|
||||
return $this->fail('参数错误');
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取合同信息
|
||||
$contract = VehicleContract::where('id',$params['id'])->find();
|
||||
if($contract->isEmpty()){
|
||||
$vehicle_contract = VehicleContract::where('id',$params['id'])->find();
|
||||
if(empty($vehicle_contract)){
|
||||
return $this->fail('合同信息错误');
|
||||
}
|
||||
if($vehicle_contract['status'] != 0){
|
||||
return $this->fail('合同状态错误');
|
||||
}
|
||||
//更新本地
|
||||
$la_result = VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]);
|
||||
//判断合同类型
|
||||
if(!empty($la_result['contract_logistic_id'])){
|
||||
//更新物流系统
|
||||
curl_post($this->url.'/api/updateContract',[],[
|
||||
'id' => $la_result['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1
|
||||
]);
|
||||
try {
|
||||
//判断合同类型
|
||||
if(!empty($vehicle_contract['contract_logistic_id'])){
|
||||
//更新物流系统
|
||||
curl_post($this->url.'/api/updateContract',[],[
|
||||
'id' => $vehicle_contract['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1
|
||||
]);
|
||||
}
|
||||
VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]);
|
||||
}catch (\Exception $e){
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $contract['company_a_phone'],
|
||||
'name' => $contract['company_a_name'],
|
||||
'mobile' => $vehicle_contract['company_a_phone'],
|
||||
'name' => $vehicle_contract['company_a_name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
$this->rentNoticeSms($sms);
|
||||
@ -79,7 +86,9 @@ class VehicleContractController extends BaseAdminController
|
||||
$data = VehicleContract::where($where)
|
||||
->page($pageNo, $pageSize)
|
||||
->order('create_time desc')
|
||||
->select();
|
||||
->select()->each(function($item){
|
||||
$item['cars_info'] = json_decode($item['cars_info'],true);
|
||||
});
|
||||
return $this->success('success',['lists'=>$data->toArray(),'page_no'=>$pageNo,'page_size'=>$pageSize,'count'=>$data->count()]);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class IndexController extends BaseApiController
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty','notifyAuthentication','notifyVehicleContractUpdate','notifyVillageCarRent'];
|
||||
|
||||
|
||||
private $domain = 'http://logistics.lihaink.cn';
|
||||
|
||||
/**
|
||||
* @notes 首页数据
|
||||
@ -149,7 +149,7 @@ class IndexController extends BaseApiController
|
||||
]);
|
||||
$party_b_company = Company::field('user_id,master_name,master_phone')->where('id',$contract['company_b_id'])->find();
|
||||
//通知物流系统添加车辆使用人
|
||||
curl_post('http://logistics.lihaink.cn/api/createRentCarUser',[],[
|
||||
curl_post($this->domain.'/api/createRentCarUser',[],[
|
||||
'company_id' => $contract['company_b_id'],
|
||||
'car_id' => $car[0]['id'],
|
||||
'user_id' => $party_b_company['user_id'],
|
||||
@ -159,7 +159,7 @@ class IndexController extends BaseApiController
|
||||
}else{
|
||||
//自有车辆
|
||||
$company_b = Company::where('id',$contract['company_b_id'])->find();
|
||||
$res = curl_post('http://logistics.lihaink.cn/api/addSelfCar',[],[
|
||||
$res = curl_post($this->domain.'/api/addSelfCar',[],[
|
||||
'license' => $car[0]['license'],
|
||||
'company_id' => $contract['company_a_id'],
|
||||
'company_name' => $contract['company_a_name'],
|
||||
@ -184,19 +184,24 @@ class IndexController extends BaseApiController
|
||||
}
|
||||
$param = $this->request->post();
|
||||
$model = VehicleContract::where('contract_logistic_id',$param['contract_logistic_id'])->find();
|
||||
if(!$model || $model->isEmpty()){
|
||||
if(empty($model)){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$cars = json_decode($model['cars_info'],true);
|
||||
$result = $model->where('id',$model['id'])->save($param);
|
||||
if($result && isset($param['status']) && $param['status'] == 3){
|
||||
$cars = json_decode($model['cars_info'],true);
|
||||
$data= [];
|
||||
foreach($cars as $k=>$v) {
|
||||
$cars[$k]['type'] = 0;
|
||||
$cars[$k]['status'] = 0;
|
||||
$cars[$k]['company_id'] = $model['company_b_id'];
|
||||
$cars[$k]['create_time'] = $model['create_time'];
|
||||
$data[$k]['car_id'] = $v['id'];
|
||||
$data[$k]['car_license'] = $v['license'];
|
||||
$data[$k]['type'] = 0;
|
||||
$data[$k]['status'] = 0;
|
||||
$data[$k]['company_id'] = $model['company_b_id'];
|
||||
$data[$k]['create_time'] = strtotime($model['create_time']);
|
||||
}
|
||||
VehicleRent::saveAll($cars);
|
||||
$vehicleRent = new VehicleRent();
|
||||
$vehicleRent -> saveAll($data);
|
||||
|
||||
}
|
||||
//返回
|
||||
return $result ? $this->success('更新成功') : $this->fail('更新失败');
|
||||
|
@ -14,6 +14,8 @@ use think\response\Json;
|
||||
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
public string $url = 'http://logistics.lihaink.cn';
|
||||
// public string $url = 'http://www.lst.local';
|
||||
//镇街公司想物流平台申请租赁车辆
|
||||
public function setContractByTownCompany()
|
||||
{
|
||||
@ -23,16 +25,44 @@ class VehicleController extends BaseApiController
|
||||
if(empty($params['num'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
if(empty($this->userInfo['company_id'])){
|
||||
return $this->fail('签约公司不存在');
|
||||
//查找乙方公司信息
|
||||
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$this->userInfo['company_id'])->find();
|
||||
if(empty($party_b)) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$params['party_b'] = $this->userInfo['company_id'];
|
||||
$result = VehicleLogic::initiate_contract_logistic($params);
|
||||
//返回数据
|
||||
if($result && $result['code'] == 1){
|
||||
return $this->success($result['msg']);
|
||||
}else{
|
||||
return $this->fail($result['msg']);
|
||||
//判断是否是镇街公司
|
||||
if($party_b['company_type'] != 16){
|
||||
return ['code'=>0,'msg'=>'非镇街公司不能签约'];
|
||||
}
|
||||
//发送生成合同给物流信息
|
||||
$curl_result = curl_post($this->url.'/api/signContract',[],[
|
||||
'num' => $params['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(empty($curl_result)){
|
||||
return $this->fail('null return from logistic');
|
||||
}
|
||||
if($curl_result['code'] == 0){
|
||||
return $this->fail($curl_result['msg'].' from logistic');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$create_result = VehicleContract::create($curl_result['data']);
|
||||
if($create_result->id){
|
||||
Db::commit();
|
||||
return $this->success('合同发起成功,等待审核 from task');
|
||||
}else{
|
||||
Db::rollback();
|
||||
return $this->success('合同发起失败,请稍后重试 from task');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage().' from task');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,10 @@ 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($data):array|bool {
|
||||
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',$data['party_b'])->find();
|
||||
$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'=>'非镇街公司不能签约'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user