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