a
This commit is contained in:
parent
636fb51c03
commit
fc96a26498
@ -10,6 +10,8 @@ use app\common\model\platform\Platform;
|
|||||||
|
|
||||||
class ContractController extends BaseAdminController
|
class ContractController extends BaseAdminController
|
||||||
{
|
{
|
||||||
|
private $domain = 'https://worker-task.lihaink.cn';
|
||||||
|
// private $domain = 'http://www.task.local';
|
||||||
public function initiatingContract() {
|
public function initiatingContract() {
|
||||||
//获取参数
|
//获取参数
|
||||||
$params = $this->request->post(['id']);
|
$params = $this->request->post(['id']);
|
||||||
@ -18,18 +20,16 @@ class ContractController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
//获取数据
|
//获取数据
|
||||||
$contract = Contract::where('id',$params['id'])->find();
|
$contract = Contract::where('id',$params['id'])->find();
|
||||||
if(!$contract || $contract->isEmpty()){
|
if(empty($contract)){
|
||||||
return $this->fail('数据不存在');
|
return $this->fail('数据不存在');
|
||||||
}
|
}
|
||||||
if($contract['status'] != 1){
|
if($contract['status'] != 1){
|
||||||
return $this->fail('合同状态错误');
|
return $this->fail('合同状态错误');
|
||||||
}
|
}
|
||||||
//获取平台公司
|
|
||||||
$platform = Platform::find(1);
|
|
||||||
$signData = [
|
$signData = [
|
||||||
'name' => $platform['company_name'] . '的合同',
|
'name' => $contract['company_a_name'] . '的合同',
|
||||||
'signatories' => [
|
'signatories' => [
|
||||||
['fullName' => $platform['company_name'], 'identityType' => 12, 'identityCard' => $platform['company_organization_code'], 'email' => $platform['company_email'], 'noNeedVerify' => 1, 'signLevel' => 1],
|
['fullName' => $contract['company_a_name'], 'identityType' => 12, 'identityCard' => $contract['company_a_code'], 'email' => $contract['company_a_email'], 'noNeedVerify' => 1, 'signLevel' => 1],
|
||||||
['fullName' => $contract['company_b_name'], 'identityType' => 12, 'identityCard' => $contract['company_b_code'], 'email' => $contract['company_b_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
|
['fullName' => $contract['company_b_name'], 'identityType' => 12, 'identityCard' => $contract['company_b_code'], 'email' => $contract['company_b_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
|
||||||
],
|
],
|
||||||
'url' => $contract['file']
|
'url' => $contract['file']
|
||||||
@ -43,7 +43,7 @@ class ContractController extends BaseAdminController
|
|||||||
]);
|
]);
|
||||||
$this->sendSms($params['id']);
|
$this->sendSms($params['id']);
|
||||||
$newData = Contract::where('id', $params['id'])->find();
|
$newData = Contract::where('id', $params['id'])->find();
|
||||||
curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[
|
curl_post($this->domain.'/api/index/notifyVehicleContractUpdate',[],[
|
||||||
'contract_logistic_id' => $contract['id'],
|
'contract_logistic_id' => $contract['id'],
|
||||||
'contract_no' => $signRes->data,
|
'contract_no' => $signRes->data,
|
||||||
'url' => $newData['url'],
|
'url' => $newData['url'],
|
||||||
@ -58,7 +58,7 @@ class ContractController extends BaseAdminController
|
|||||||
public function sendSms($id) {
|
public function sendSms($id) {
|
||||||
//获取合同数据
|
//获取合同数据
|
||||||
$contract = Contract::where('id',$id)->find();
|
$contract = Contract::where('id',$id)->find();
|
||||||
if ($contract && !$contract->isEmpty() && $contract['file'] != '') {
|
if (!empty($contract) && $contract['file'] != '') {
|
||||||
//发送短信
|
//发送短信
|
||||||
$data = [
|
$data = [
|
||||||
//甲方
|
//甲方
|
||||||
@ -134,16 +134,22 @@ class ContractController extends BaseAdminController
|
|||||||
$data = Contract::where($where)
|
$data = Contract::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()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detail() {
|
public function detail() {
|
||||||
|
//获取参数
|
||||||
$id = $this->request->get('id');
|
$id = $this->request->get('id');
|
||||||
if(empty($id)){
|
if(empty($id)) {
|
||||||
$this->fail('参数错误');
|
return $this->fail('参数错误');
|
||||||
}
|
}
|
||||||
$data = Contract::where('id',$id)->find();
|
$data = Contract::where('id',$id)->find();
|
||||||
|
if(empty($data)){
|
||||||
|
return $this->fail('没找到数据');
|
||||||
|
}
|
||||||
$data['cars_info'] = json_decode($data['cars_info'],true);
|
$data['cars_info'] = json_decode($data['cars_info'],true);
|
||||||
return $this->success('success',$data->toArray());
|
return $this->success('success',$data->toArray());
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace app\api\controller;
|
|||||||
use app\common\model\contract\Contract;
|
use app\common\model\contract\Contract;
|
||||||
use app\common\model\platform\Platform;
|
use app\common\model\platform\Platform;
|
||||||
use app\common\model\vehicle\Vehicle;
|
use app\common\model\vehicle\Vehicle;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
class ContractController extends BaseApiController
|
class ContractController extends BaseApiController
|
||||||
{
|
{
|
||||||
@ -23,9 +24,8 @@ class ContractController extends BaseApiController
|
|||||||
}
|
}
|
||||||
//获取车辆数据
|
//获取车辆数据
|
||||||
$cars = Vehicle::field('id,license')->where([
|
$cars = Vehicle::field('id,license')->where([
|
||||||
['type','=',1],
|
['type','=',0],
|
||||||
['status','=',1],
|
['status','=',0],
|
||||||
['is_del','=',1],
|
|
||||||
])->limit($params['num'])->select();
|
])->limit($params['num'])->select();
|
||||||
if($cars->isEmpty() || $cars->count() < $params['num']){
|
if($cars->isEmpty() || $cars->count() < $params['num']){
|
||||||
return $this->fail('车辆数量不足');
|
return $this->fail('车辆数量不足');
|
||||||
@ -50,17 +50,23 @@ class ContractController extends BaseApiController
|
|||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'update_time' => time(),
|
'update_time' => time(),
|
||||||
];
|
];
|
||||||
//写入数据
|
Db::startTrans();
|
||||||
$result = Contract::create($data);
|
try {
|
||||||
//更改车辆状态
|
$res1 = Contract::create($data);
|
||||||
$carStatus = Vehicle::where('id','in',array_column($cars->toArray(),'id'))->update(['status'=>2,'update_time'=>time()]);
|
$res2 = Vehicle::where('id','in',array_column($cars->toArray(),'id'))->update(['status'=>1,'update_time'=>time()]);
|
||||||
//返回
|
if($res1->id && $res2){
|
||||||
if($result->id && $carStatus) {
|
$data['contract_logistic_id'] = $res1->id;
|
||||||
$data['contract_logistic_id'] = $result->id;
|
$data['type'] = 0;
|
||||||
$data['type'] = 0;
|
Db::commit();
|
||||||
return $this->success('合同发起成功,等待审核',$data);
|
return $this->success('合同发起成功,等待审核',$data);
|
||||||
}else{
|
}else{
|
||||||
return $this->fail('请求失败');
|
Db::rollback();
|
||||||
|
return $this->fail('合同发起失败,请稍后重试');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,19 +10,15 @@ class HetongController extends BaseApiController
|
|||||||
|
|
||||||
public function url()
|
public function url()
|
||||||
{
|
{
|
||||||
$id = Request()->get('id');
|
$params = $this->request->get(['id','type']);
|
||||||
$type = Request()->get('type');
|
if(empty($params['id']) || empty($params['type'])){
|
||||||
$msg='合同不存在';
|
return $this->fail('缺少必要参数');
|
||||||
if(empty($type) || empty($id)){
|
|
||||||
$msg='参数错误';
|
|
||||||
}
|
}
|
||||||
if ($id && $type) {
|
$find = Contract::where('id', $params['id'])->find();
|
||||||
$find = Contract::where('id', $id)->find();
|
if (!empty($find) && $find['url']) {
|
||||||
if ($find && $find['url']) {
|
$url = json_decode($find['url'], true);
|
||||||
$url = json_decode($find['url'], true);
|
if(isset($url[$params['type']])){
|
||||||
if(isset($url[$type])){
|
return redirect($url[$params['type']]);
|
||||||
return redirect($url[$type]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
|
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
|
||||||
|
@ -33,6 +33,9 @@ class IndexController extends BaseApiController
|
|||||||
|
|
||||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate','notifyUrl'];
|
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate','notifyUrl'];
|
||||||
|
|
||||||
|
private $domain = 'https://worker-task.lihaink.cn';
|
||||||
|
// private $domain = 'http://www.task.local';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 首页数据
|
* @notes 首页数据
|
||||||
@ -101,22 +104,28 @@ class IndexController extends BaseApiController
|
|||||||
}
|
}
|
||||||
//获取合同数据
|
//获取合同数据
|
||||||
$contract = Contract::where('id',$params['id'])->find();
|
$contract = Contract::where('id',$params['id'])->find();
|
||||||
if(!$contract || $contract->isEmpty()){
|
if(empty($contract)){
|
||||||
return json(['success' => false, 'msg' => '参数错误']);
|
return json(['success' => false, 'msg' => '参数错误']);
|
||||||
}
|
}
|
||||||
$carIds = implode(',',array_column(json_decode($contract['cars_info']),'id'));
|
if($contract['status'] != 2){
|
||||||
|
return json(['success' => false, 'msg' => '合同状态错误']);
|
||||||
|
}
|
||||||
|
$vehicle = json_decode($contract['cars_info'],true);
|
||||||
if ($contract['signing_timer'] == 0) {
|
if ($contract['signing_timer'] == 0) {
|
||||||
Contract::where('id',$params['id'])->update(['signing_timer'=>1]);
|
//更新本地合同状态
|
||||||
curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[
|
Contract::where('id',$contract['id'])->update(['signing_timer'=>1]);
|
||||||
|
//更新远程
|
||||||
|
curl_post($this->domain.'/api/index/notifyVehicleContractUpdate',[],[
|
||||||
'contract_logistic_id' => $contract['id'],
|
'contract_logistic_id' => $contract['id'],
|
||||||
'signing_timer' => 1,
|
'signing_timer' => 1,
|
||||||
]);
|
]);
|
||||||
}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]);
|
//更新远程
|
||||||
$cars = json_decode($contract['cars_info'],true);
|
Vehicle::where('id','in',array_column($vehicle,'id'))->update(['status'=>3]);
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach($cars as $v){
|
foreach($vehicle as $v){
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'car_id' => $v['id'],
|
'car_id' => $v['id'],
|
||||||
'company_id' => $contract['company_b_id'],
|
'company_id' => $contract['company_b_id'],
|
||||||
@ -125,15 +134,16 @@ class IndexController extends BaseApiController
|
|||||||
'company_phone' => $contract['company_b_phone'],
|
'company_phone' => $contract['company_b_phone'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
VehicleRent::saveAll($data);
|
$vehicleRent = new VehicleRent();
|
||||||
curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[
|
$vehicleRent -> saveAll($data);
|
||||||
|
curl_post($this->domain.'/api/index/notifyVehicleContractUpdate',[],[
|
||||||
'contract_logistic_id' => $contract['id'],
|
'contract_logistic_id' => $contract['id'],
|
||||||
'signing_timer' => 2,
|
'signing_timer' => 2,
|
||||||
'status' => 3
|
'status' => 3
|
||||||
]);
|
]);
|
||||||
curl_post('https://worker-task.lihaink.cn/v1/notify_property',[],[
|
curl_post($this->domain.'/api/v1/notify_property',[],[
|
||||||
'company_id' => $contract['company_b_id'],
|
'company_id' => $contract['company_b_id'],
|
||||||
'object_id' => $carIds
|
'object_id' => implode(',',array_column($vehicle,'id'))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return json(['success' => true, 'msg' => '成功']);
|
return json(['success' => true, 'msg' => '成功']);
|
||||||
|
@ -26,6 +26,9 @@ class JunziqianController extends BaseApiController
|
|||||||
private $encryMethod;
|
private $encryMethod;
|
||||||
/**默认ts单位:1毫秒,2秒*/
|
/**默认ts单位:1毫秒,2秒*/
|
||||||
private $tsType;
|
private $tsType;
|
||||||
|
|
||||||
|
private $domain = 'http://logistics.lihaink.cn';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填充签名数据
|
* 填充签名数据
|
||||||
* @param $req array
|
* @param $req array
|
||||||
@ -135,7 +138,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/api/index/notifyUrl?id='.$id;
|
$request->notifyUrl = $this->domain.'/api/index/notifyUrl?id='.$id;
|
||||||
$request->needQifengSign = 1;
|
$request->needQifengSign = 1;
|
||||||
//发起PING请求
|
//发起PING请求
|
||||||
// halt($request);
|
// halt($request);
|
||||||
|
@ -32,4 +32,6 @@ Route::rule('createRentCarUser','Contract/createRentCarUser','post');
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
Route::rule('signContract','Contract/signContract','post');
|
Route::rule('signContract','Contract/signContract','post');
|
||||||
Route::rule('updateContract','Contract/updateContract','post');
|
Route::rule('updateContract','Contract/updateContract','post');
|
||||||
|
|
||||||
|
Route::rule('hetong/url','Hetong/url','get');
|
Loading…
x
Reference in New Issue
Block a user