aa
This commit is contained in:
parent
a6fa3befb9
commit
4f350ae096
@ -18,6 +18,7 @@ namespace app\api\controller;
|
|||||||
use app\api\logic\IndexLogic;
|
use app\api\logic\IndexLogic;
|
||||||
use app\common\model\contract\Contract;
|
use app\common\model\contract\Contract;
|
||||||
use app\common\model\vehicle\Vehicle;
|
use app\common\model\vehicle\Vehicle;
|
||||||
|
use app\common\model\vehicle\VehicleRent;
|
||||||
use think\response\Json;
|
use think\response\Json;
|
||||||
|
|
||||||
|
|
||||||
@ -113,6 +114,18 @@ class IndexController extends BaseApiController
|
|||||||
}else if($contract['signing_timer'] == 1) {
|
}else if($contract['signing_timer'] == 1) {
|
||||||
Contract::where('id',$params['id'])->update(['signing_timer'=>2,'status'=>3]);
|
Contract::where('id',$params['id'])->update(['signing_timer'=>2,'status'=>3]);
|
||||||
Vehicle::where('id','in',$carIds)->update(['status'=>3]);
|
Vehicle::where('id','in',$carIds)->update(['status'=>3]);
|
||||||
|
$cars = json_decode($contract['cars_info'],true);
|
||||||
|
$data = [];
|
||||||
|
foreach($cars as $v){
|
||||||
|
$data[] = [
|
||||||
|
'car_id' => $v['id'],
|
||||||
|
'company_id' => $contract['company_b_id'],
|
||||||
|
'company_name' => $contract['company_b_name'],
|
||||||
|
'company_user' => $contract['company_b_user'],
|
||||||
|
'company_phone' => $contract['company_b_phone'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
VehicleRent::saveAll($data);
|
||||||
curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[
|
curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[
|
||||||
'contract_logistic_id' => $contract['id'],
|
'contract_logistic_id' => $contract['id'],
|
||||||
'signing_timer' => 2,
|
'signing_timer' => 2,
|
||||||
|
@ -135,7 +135,7 @@ class JunziqianController extends BaseApiController
|
|||||||
$request->serverCa = 1; //是否需要服务端云证书
|
$request->serverCa = 1; //是否需要服务端云证书
|
||||||
$request->fileType = 1; //合同上传方式 url
|
$request->fileType = 1; //合同上传方式 url
|
||||||
$request->url = $data['url'];
|
$request->url = $data['url'];
|
||||||
$request->notifyUrl = 'http://logistics.lihaink.cn/notify_url?id=' . $id;
|
$request->notifyUrl = 'http://logistics.lihaink.cn/api/index/notifyUrl?id='.$id;
|
||||||
$request->needQifengSign = 1;
|
$request->needQifengSign = 1;
|
||||||
//发起PING请求
|
//发起PING请求
|
||||||
// halt($request);
|
// halt($request);
|
||||||
|
@ -3,7 +3,9 @@ namespace app\api\controller;
|
|||||||
|
|
||||||
use app\api\logic\VehicleLogic;
|
use app\api\logic\VehicleLogic;
|
||||||
use app\common\model\vehicle\Vehicle;
|
use app\common\model\vehicle\Vehicle;
|
||||||
|
use app\common\model\vehicle\VehicleRent;
|
||||||
use app\common\model\vehicle\VehicleUser;
|
use app\common\model\vehicle\VehicleUser;
|
||||||
|
use think\facade\Db;
|
||||||
use think\response\Json;
|
use think\response\Json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,16 +55,58 @@ class VehicleController extends BaseApiController
|
|||||||
|
|
||||||
public function createRentCarUser() {
|
public function createRentCarUser() {
|
||||||
//获取参数
|
//获取参数
|
||||||
$params = $this->request->post(['car_id','user_id','user_name','user_phone']);
|
$params = $this->request->post(['company_id','car_id','user_id','user_name','user_phone']);
|
||||||
if(empty($params['car_id']) || empty($params['user_id']) || empty($params['user_name']) || empty($params['user_phone'])){
|
if(empty($params['company_id']) || empty($params['car_id']) || empty($params['user_id']) || empty($params['user_name']) || empty($params['user_phone'])){
|
||||||
return $this->fail('缺少必要参数');
|
return $this->fail('缺少必要参数');
|
||||||
}
|
}
|
||||||
$result = VehicleUser::create([
|
$vehicleRent = VehicleRent::where('car_id',$params['car_id'])->where('company_id',$params['company_id'])->find();
|
||||||
'car_id' => $params['car_id'],
|
$vehicleRent -> user_id = $params['user_id'];
|
||||||
'user_id' => $params['user_id'],
|
$vehicleRent -> user_name = $params['user_name'];
|
||||||
'user_name' => $params['user_name'],
|
$vehicleRent -> user_phone = $params['user_phone'];
|
||||||
'user_phone' => $params['user_phone'],
|
$result = $vehicleRent -> save();
|
||||||
]);
|
return $result ? $this->success('sucess') : $this->fail('error');
|
||||||
return $result->id ? $this->success('sucess') : $this->fail('error');
|
}
|
||||||
|
|
||||||
|
//添加自有车辆
|
||||||
|
public function addSelfCar() {
|
||||||
|
//获取参数
|
||||||
|
$params = $this->request->post(['license','company_id','company_name','company_user','company_phone','user_id','user_name','user_phone']);
|
||||||
|
if(empty($params['license']) || empty($params['user_id']) || empty($params['user_name']) || empty($params['user_phone'])){
|
||||||
|
return $this->fail('error');
|
||||||
|
}
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
//写入数据
|
||||||
|
$vehicle = Vehicle::create([
|
||||||
|
'license' => $params['license'],
|
||||||
|
'gps_imei' => '',
|
||||||
|
'type' => 1,
|
||||||
|
'status' => 3,
|
||||||
|
'is_del' => 1,
|
||||||
|
'create_time' => time(),
|
||||||
|
'update_time' => time(),
|
||||||
|
]);
|
||||||
|
$vehicleRent = VehicleRent::create([
|
||||||
|
'car_id'=> $vehicle->id,
|
||||||
|
'company_id' => $params['company_id'],
|
||||||
|
'company_name' => $params['company_name'],
|
||||||
|
'company_user' => $params['company_user'],
|
||||||
|
'company_phone' => $params['company_phone'],
|
||||||
|
'use_user_id' => $params['user_id'],
|
||||||
|
'use_user_name' => $params['user_name'],
|
||||||
|
'use_user_phone' => $params['user_phone'],
|
||||||
|
]);
|
||||||
|
if($vehicle->id && $vehicleRent->id){
|
||||||
|
Db::commit();
|
||||||
|
return $this->success('success',['car_id'=>$vehicle->id]);
|
||||||
|
}else{
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail('error');
|
||||||
|
}
|
||||||
|
}catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user