Merge pull request 'update' (#88) from zhangwei into master
Reviewed-on: http://git.excellentkk.cn/mkm/TaskSystem/pulls/88
This commit is contained in:
commit
5c56fa4a51
@ -11,10 +11,8 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\company\CompanyProperty;
|
||||
@ -32,9 +30,7 @@ use think\response\Json;
|
||||
*/
|
||||
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','systemCarRent','cancelContract'];
|
||||
|
||||
private $domain = 'https://logistics.lihaink.cn';
|
||||
// private $domain = 'http://www.lst.local';
|
||||
@ -124,6 +120,85 @@ class IndexController extends BaseApiController
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
||||
//系统车辆租赁回来
|
||||
public function systemCarRent() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if(empty($id)){
|
||||
return json(['success' => false, 'msg' => '缺少参数']);
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if(empty($contract)){
|
||||
return json(['success' => false, 'msg' => '参数错误']);
|
||||
}
|
||||
if($contract['type'] != 0){
|
||||
return json(['success' => false, 'msg' => '合同类型错误']);
|
||||
}
|
||||
if($contract['status'] != 2){
|
||||
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||
}
|
||||
//判断签约方
|
||||
if ($contract['signing_timer'] == 0) {
|
||||
//更新合同的签约次数
|
||||
$res = VehicleContract::where('id',$id)->update(['signing_timer'=>1]);
|
||||
if(!$res){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else if($contract['signing_timer'] == 1) {
|
||||
//更改合同状态
|
||||
VehicleContract::where('id',$id)->update(['signing_timer'=>2,'status'=>3]);
|
||||
//添加车辆到租赁列表
|
||||
$vehicle = json_decode($contract['cars_info'],true);
|
||||
VehicleRent::where('car_id',$vehicle['id'])->update([
|
||||
'status' => 2,
|
||||
'rent_time' => time(),
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
]);
|
||||
$car_id = $vehicle['id'];
|
||||
$party_b = Company::where('id',$contract['company_b_id'])->find();
|
||||
//通知物流系统跟新
|
||||
curl_post($this->domain.'/api/updateVehicleRent',[],[
|
||||
'car_id' => $car_id,
|
||||
'use_user_id' => $party_b['user_id'],
|
||||
'use_user_name' => $party_b['master_name'],
|
||||
'use_user_phone' => $party_b['master_phone']
|
||||
]);
|
||||
CompanyProperty::create([
|
||||
'company_id' => $contract['company_b_id'],
|
||||
'object_id' => $car_id,
|
||||
'type' => 1
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//解除合同回调
|
||||
public function cancelContract() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if(empty($id)){
|
||||
return json(['success' => false, 'msg' => '缺少参数']);
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if(empty($contract)){
|
||||
return json(['success' => false, 'msg' => '参数错误']);
|
||||
}
|
||||
if($contract['type'] != 2){
|
||||
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||
}
|
||||
if($contract['status'] != 2){
|
||||
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function notifyVillageCarRent(){
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
@ -139,7 +214,11 @@ class IndexController extends BaseApiController
|
||||
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||
}
|
||||
if ($contract['signing_timer'] == 0) {
|
||||
VehicleContract::where('id',$id)->update(['signing_timer'=>1]);
|
||||
$res = VehicleContract::where('id',$id)->update(['signing_timer'=>1]);
|
||||
if(!$res){
|
||||
return json(['success' => false, 'msg' => '更新失败']);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else if($contract['signing_timer'] == 1) {
|
||||
//更改合同状态
|
||||
VehicleContract::where('id',$id)->update(['signing_timer'=>2,'status'=>3]);
|
||||
@ -190,8 +269,10 @@ class IndexController extends BaseApiController
|
||||
'object_id' => $car_id,
|
||||
'type' => 1
|
||||
]);
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}else{
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
||||
//车辆租赁签约合同状态更改
|
||||
@ -245,9 +326,10 @@ class IndexController extends BaseApiController
|
||||
$data[$k]['type']=1;
|
||||
}
|
||||
}
|
||||
if (count($data)>0){
|
||||
$res = CompanyProperty::insertAll($data);
|
||||
if (count($data)<=0){
|
||||
return json(['success' => false, 'msg' => '失败']);
|
||||
}
|
||||
$res = CompanyProperty::insertAll($data);
|
||||
if ($res) {
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
} else {
|
||||
|
@ -144,14 +144,27 @@ class VehicleController extends BaseApiController
|
||||
],
|
||||
'url' => $contract['file']
|
||||
];
|
||||
$signRes = app(JunziqianController::class)->Signing($signData, $params['id'],'https://worker-task.lihaink.cn/api/index/notifyVillageCarRent');
|
||||
$notify_url = '';
|
||||
if($contract['type'] == 0){
|
||||
$notify_url = 'https://worker-task.lihaink.cn/api/index/systemCarRent';
|
||||
}elseif($contract['type'] == 1){
|
||||
$notify_url = 'https://worker-task.lihaink.cn/api/index/selfCarRent';
|
||||
}elseif($contract['type'] == 2){
|
||||
$notify_url = 'https://worker-task.lihaink.cn/api/index/cancelRent';
|
||||
}
|
||||
$signRes = app(JunziqianController::class)->Signing($signData, $params['id'],$notify_url);
|
||||
if ($signRes->success) {
|
||||
$contract->save([
|
||||
'id' => $contract['id'],
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2
|
||||
]);
|
||||
$this->sendSms($params['id']);
|
||||
if($contract['type'] == 2){
|
||||
$smsTitle = '《解约合同》';
|
||||
}else{
|
||||
$smsTitle = '《租赁合同》';
|
||||
}
|
||||
$this->sendSms($params['id'],$smsTitle);
|
||||
return $this->success('合同发送成功');
|
||||
} else {
|
||||
return $this->fail($signRes->msg);
|
||||
@ -164,7 +177,17 @@ class VehicleController extends BaseApiController
|
||||
if(empty($id)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$this->sendSms($id);
|
||||
//获取数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if(empty($contract)){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($contract['type'] == 2){
|
||||
$smsTitle = '《解约合同》';
|
||||
}else{
|
||||
$smsTitle = '《租赁合同》';
|
||||
}
|
||||
$this->sendSms($id,$smsTitle);
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
|
||||
@ -416,10 +439,77 @@ class VehicleController extends BaseApiController
|
||||
//获取轨迹
|
||||
$url = $this->url.'/api/getCarHistory?car_id='.$params['car_id'].'&start_time='.$params['start_time'].'&end_time='.$params['end_time'];
|
||||
$result = curl_get($url);
|
||||
$data = [];
|
||||
foreach($result['data'] as $k => $v){
|
||||
$data[$k]['latitude'] = $v['lat'];
|
||||
$data[$k]['longitude'] = $v['lon'];
|
||||
}
|
||||
return $this->success('success',$result['data']);
|
||||
}
|
||||
|
||||
public function sendSms($id) {
|
||||
public function cancelContract() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['car_id']);
|
||||
if(empty($params['car_id'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$this->userInfo['company_id'] = 188;
|
||||
//获取车辆信息
|
||||
$carInfo = VehicleRent::where('car_id',$params['car_id'])->where('type',1)->find();
|
||||
if(empty($carInfo)){
|
||||
return $this->fail('车辆信息错误');
|
||||
}
|
||||
if($carInfo['rent_company_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('当前公司与车辆信息不匹配');
|
||||
}
|
||||
//获取甲方公司信息
|
||||
$party_a = Company::where('id',$carInfo['company_id'])->find();
|
||||
if(empty($party_a)){
|
||||
return $this->fail('甲方公司信息错误');
|
||||
}
|
||||
//获取乙方公司信息
|
||||
$party_b = Company::where('id',$this->userInfo['company_id'])->find();
|
||||
if(empty($party_b)){
|
||||
return $this->fail('乙方公司信息错误');
|
||||
}
|
||||
//判断是否申请过
|
||||
$vehicleContract = VehicleContract::where('company_b_id',$this->userInfo['company_id'])->where('type',3)->where('status','<>',4)->find();
|
||||
if(!empty($vehicleContract)){
|
||||
return $this->fail('请勿重复申请');
|
||||
}
|
||||
//设置数据
|
||||
$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' => json_encode(['id'=>$carInfo['car_id'],'license'=>$carInfo['car_license']]),
|
||||
'num' => 1,
|
||||
'type' => 2,
|
||||
'status' => -1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time()
|
||||
];
|
||||
//写入数据
|
||||
$result = VehicleContract::create($data);
|
||||
if($result){
|
||||
return $this->success('申请成功,待镇街公司审核');
|
||||
}else{
|
||||
return $this->fail('申请失败,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
public function sendSms($id,$title) {
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if ($contract && !$contract->isEmpty() && $contract['file'] != '') {
|
||||
@ -461,7 +551,7 @@ class VehicleController extends BaseApiController
|
||||
$sms = [
|
||||
'mobile' => $v['master_phone'],
|
||||
'name' => $v['fullName'],
|
||||
'type' => '《租赁合同》',
|
||||
'type' => $title,
|
||||
'code' => 'api/Hetong/info?id='.$id.'&type='.$v['type'],
|
||||
'scene' => 'WQ'
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user