aa
This commit is contained in:
parent
c12c54428f
commit
e6c1bf9c65
@ -12,38 +12,40 @@ class VehicleContractController extends BaseAdminController
|
||||
// private string $url = 'http://www.lst.local';
|
||||
private string $url = 'http://logistics.lihaink.cn';
|
||||
|
||||
//风控中心上传合同
|
||||
public function uploadContract() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['id','file']);
|
||||
if(empty($params['id']) || empty($params['file'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//更新本地和物流系统
|
||||
$la_result = VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]);
|
||||
$lst_result = curl_post($this->url.'/api/updateContract',[],[
|
||||
'id' => $la_result['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 1
|
||||
]);
|
||||
if($la_result && $lst_result && $lst_result['code'] == 1){
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::field('')->where('id',$params['id'])->find();
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $contract['company_a_phone'],
|
||||
'name' => $contract['company_a_name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
$this->rentNoticeSms($sms);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
if($la_result==0 || !$lst_result){
|
||||
return $this->success('没有更新', [], 1, 1);
|
||||
}
|
||||
return $this->fail('上传失败');
|
||||
//获取合同信息
|
||||
$contract = VehicleContract::where('id',$params['id'])->find();
|
||||
if($contract->isEmpty()){
|
||||
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
|
||||
]);
|
||||
}
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $contract['company_a_phone'],
|
||||
'name' => $contract['company_a_name'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
$this->rentNoticeSms($sms);
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
}
|
||||
|
||||
//发送通知短信
|
||||
public function rentNoticeSms($params) {
|
||||
try {
|
||||
$scene = NoticeEnum::getSceneByTag($params['scene']);
|
||||
|
@ -34,7 +34,7 @@ class IndexController extends BaseApiController
|
||||
{
|
||||
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty','notifyAuthentication','notifyVehicleContractUpdate'];
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty','notifyAuthentication','notifyVehicleContractUpdate','notifyVillageCarRent'];
|
||||
|
||||
|
||||
|
||||
@ -123,6 +123,38 @@ class IndexController extends BaseApiController
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
||||
public function notifyVillageCarRent(){
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if(empty($id)){
|
||||
return json(['success' => false, 'msg' => '缺少参数']);
|
||||
}
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if(!$contract || $contract->isEmpty()){
|
||||
return json(['success' => false, 'msg' => '参数错误']);
|
||||
}
|
||||
$car = json_decode($contract['cars_info']);
|
||||
if ($contract['signing_timer'] == 0) {
|
||||
VehicleContract::where('id',$id)->update(['signing_timer'=>1]);
|
||||
}else if($contract['signing_timer'] == 1) {
|
||||
VehicleContract::where('id',$id)->update(['signing_timer'=>2,'status'=>3]);
|
||||
VehicleRent::where('car_id',$car[0]['id'])->where('company_id',$contract['company_a_id'])->update([
|
||||
'rent_company_id' => $contract['company_b_id'],
|
||||
'rent_time' => time()
|
||||
]);
|
||||
$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',[],[
|
||||
'car_id' => $car[0]['id'],
|
||||
'user_id' => $party_b_company['user_id'],
|
||||
'user_name' => $party_b_company['master_name'],
|
||||
'user_phone' => $party_b_company['master_phone'],
|
||||
]);
|
||||
}
|
||||
return json(['success' => true, 'msg' => '成功']);
|
||||
}
|
||||
|
||||
//车辆租赁签约合同状态更改
|
||||
public function notifyVehicleContractUpdate(){
|
||||
if(!$this->request->isPost()){
|
||||
|
@ -126,7 +126,7 @@ class JunziqianController extends BaseApiController
|
||||
return $this->success('', (array)$response);
|
||||
}
|
||||
//签约
|
||||
public function Signing($data, $id)
|
||||
public function Signing($data, $id, $notify = 'https://worker-task.lihaink.cn/notify_url')
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
$request = new ApplySignReq();
|
||||
@ -135,7 +135,7 @@ class JunziqianController extends BaseApiController
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 1; //合同上传方式 url
|
||||
$request->url = $data['url'];
|
||||
$request->notifyUrl = 'https://worker-task.lihaink.cn/notify_url?id=' . $id;
|
||||
$request->notifyUrl = $notify.'?id='.$id;
|
||||
$request->needQifengSign = 1;
|
||||
//发起PING请求
|
||||
// halt($request);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\logic\vehicle\VehicleLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
@ -26,7 +27,7 @@ class VehicleController extends BaseApiController
|
||||
return $this->fail('签约公司不存在');
|
||||
}
|
||||
$params['party_b'] = $this->userInfo['company_id'];
|
||||
$result = VehicleLogic::initiate_contract($params);
|
||||
$result = VehicleLogic::initiate_contract_logistic($params);
|
||||
//返回数据
|
||||
if($result && $result['code'] == 1){
|
||||
return $this->success($result['msg']);
|
||||
@ -35,6 +36,64 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
//镇街公司生成小组服务公司租赁合同
|
||||
public function setContractByVillageCompany(){
|
||||
//获取参数
|
||||
$params = $this->request->post(['apply_id','car_id']);
|
||||
if(empty($params['apply_id']) || empty($params['car_id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
if(empty($this->userInfo['company_id'])){
|
||||
return $this->fail('签约公司不存在');
|
||||
}
|
||||
$params['party_a'] = $this->userInfo['company_id'];
|
||||
$result = VehicleLogic::initiate_contract_town($params);
|
||||
//返回数据
|
||||
if($result && $result['code'] == 1){
|
||||
return $this->success($result['msg']);
|
||||
}else{
|
||||
return $this->fail($result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
//镇街公司发起合同
|
||||
public function initiatingRentCarContract() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['id']);
|
||||
if(empty($params['id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$contract = VehicleContract::where('id',$params['id'])->find();
|
||||
if(!$contract || $contract->isEmpty()){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if($contract['status'] != 1){
|
||||
return $this->fail('合同状态错误');
|
||||
}
|
||||
$signData = [
|
||||
'name' => $contract['company_a_name'] . '的合同',
|
||||
'signatories' => [
|
||||
['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]
|
||||
],
|
||||
'url' => $contract['file']
|
||||
];
|
||||
$signRes = app(JunziqianController::class)->Signing($signData, $params['id'],'https://worker-task.lihaink.cn/api/notifyVillageCarRent');
|
||||
if ($signRes->success) {
|
||||
$contract->save([
|
||||
'id' => $contract['id'],
|
||||
'contract_no' => $signRes->data,
|
||||
'status' => 2
|
||||
]);
|
||||
$this->sendSms($params['id']);
|
||||
return $this->success('合同发送成功');
|
||||
} else {
|
||||
return $this->fail($signRes->msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//小组服务公司租赁申请
|
||||
public function rentApply() {
|
||||
if(!$this->request->isPost()){
|
||||
@ -134,6 +193,7 @@ class VehicleController extends BaseApiController
|
||||
]);
|
||||
}
|
||||
|
||||
//镇街公司车辆管理首页
|
||||
public function vehicleIndex() {
|
||||
//获取参数
|
||||
$params = $this->request->get();
|
||||
@ -141,30 +201,35 @@ class VehicleController extends BaseApiController
|
||||
if(empty($company_id)){
|
||||
return $this->fail('公司信息不存在');
|
||||
}
|
||||
$pageNo = $params['page_no'] ?? 1;
|
||||
$pageSize = $params['page_size'] ?? 15;
|
||||
//获取签约信息
|
||||
$contract = VehicleContract::where('company_a_id',$company_id)->limit(2)->select();
|
||||
//获取小组服务公司申请信息
|
||||
$apply = VehicleVillageApply::where('town_company_id',$company_id)->where('status',0)->select();
|
||||
//获取车辆列表
|
||||
$cars = VehicleRent::where('company_id',$company_id)->page($pageNo,$pageSize)->select()->each(function($item){
|
||||
$carList = VehicleRent::where('company_id',$company_id)->select()->each(function($item){
|
||||
$item['mileage'] = 0;
|
||||
if($item['status'] == 2){
|
||||
if($item['status'] == 1){
|
||||
$company = Company::where('id',$item['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
$item['rent_company'] = $company->toArray();
|
||||
}
|
||||
});
|
||||
//获取该公司已签约的小组服务公司数量
|
||||
$villageCompany = Contract::where('party_a',$company_id)->where('signing_timer',2)->select();
|
||||
//系统车辆数量
|
||||
$rentCar = VehicleRent::field('id')->where('type',0)->select();
|
||||
//自有车辆数量
|
||||
$selfCar = VehicleRent::field('id')->where('type',1)->select();
|
||||
//设置数据
|
||||
$data = [
|
||||
'contract' => $contract->toArray(),
|
||||
'carlist' => $cars->toArray(),
|
||||
'total' =>6,
|
||||
'rent_num' => 3,
|
||||
'self_num' =>3,
|
||||
'apply' => $apply->toArray(),
|
||||
'car_list' => $carList->toArray(),
|
||||
'monitor_num' => $villageCompany->count(),
|
||||
'rent_num' => $rentCar->count(),
|
||||
'self_num' => $selfCar->count(),
|
||||
];
|
||||
//返回
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
//车辆详情
|
||||
public function vehicleInfo() {
|
||||
//获取参数
|
||||
$carId = $this->request->get('car_id');
|
||||
@ -174,23 +239,78 @@ class VehicleController extends BaseApiController
|
||||
//获取数据
|
||||
$data = VehicleRent::where('car_id',$carId)->find();
|
||||
$data['mileage'] = 0;
|
||||
if($data['status'] == 2){
|
||||
if($data['status'] == 1){
|
||||
$data['company'] = Company::where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
}
|
||||
//当前坐标位置
|
||||
$position = curl_post('http://logistics.lihaink.cn/api/getCarLocal',[],['car_id'=>$carId]);
|
||||
if($position && $position['code'] == 1){
|
||||
$data['position'] = $position['data'];
|
||||
}
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
}
|
||||
|
||||
public function contractList() {
|
||||
$company_id = $this->userInfo['company_id'];
|
||||
if(empty($company_id)){
|
||||
return $this->fail('公司信息不存在');
|
||||
|
||||
public function sendSms($id) {
|
||||
//获取合同数据
|
||||
$contract = VehicleContract::where('id',$id)->find();
|
||||
if ($contract && !$contract->isEmpty() && $contract['file'] != '') {
|
||||
//发送短信
|
||||
$data = [
|
||||
//甲方
|
||||
[
|
||||
"applyNo" => $contract['contract_no'],
|
||||
"fullName" => $contract['company_a_name'],
|
||||
"identityCard" => $contract['company_a_code'],
|
||||
"identityType" => 12,
|
||||
"master_phone" => $contract['company_a_phone'],
|
||||
"type"=>"party_a"
|
||||
],
|
||||
//乙方
|
||||
[
|
||||
"applyNo" => $contract['contract_no'],
|
||||
"fullName" => $contract['company_b_name'],
|
||||
"identityCard" => $contract['company_b_code'],
|
||||
"identityType" => 12,
|
||||
"master_phone" => $contract['company_b_phone'],
|
||||
"type"=>"party_b"
|
||||
|
||||
],
|
||||
];
|
||||
|
||||
$url = [];
|
||||
foreach ($data as $v) {
|
||||
$res = app(JunziqianController::class)->SigningLink($v);
|
||||
if (!$res->success) {
|
||||
return false;
|
||||
}
|
||||
if ($v['type'] == 'party_a') {
|
||||
$url['party_a'] =$res->data;
|
||||
} else {
|
||||
$url['party_b'] =$res->data;
|
||||
}
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $v['master_phone'],
|
||||
'name' => $v['fullName'],
|
||||
'type' => '《租赁合同》',
|
||||
'code' => 'api/Hetong/url?id='.$id.'&type='.$v['type'],
|
||||
'scene' => 'WQTZ'
|
||||
];
|
||||
$scene = NoticeEnum::getSceneByTag($sms['scene']);
|
||||
if (empty($scene)) {
|
||||
throw new \Exception('场景值异常');
|
||||
}
|
||||
event('Notice', [
|
||||
'scene_id' => $scene,
|
||||
'params' => $sms
|
||||
]);
|
||||
}
|
||||
VehicleContract::where('id', $id)->update(['url' => json_encode($url)]);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
$lists = VehicleContract::where('company_a_id',$company_id)->select();
|
||||
$cars = VehicleRent::where('status',1)->select();
|
||||
return $this->success('请求成功',[
|
||||
'contract' => $lists->toArray(),
|
||||
'car' => $cars->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -5,13 +5,15 @@ namespace app\common\logic\vehicle;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use app\common\model\vehicle\VehicleVillageApply;
|
||||
|
||||
|
||||
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($data):array|bool {
|
||||
public static function initiate_contract_logistic($data):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();
|
||||
//镇街公司
|
||||
@ -33,4 +35,50 @@ class VehicleLogic extends BaseLogic
|
||||
}
|
||||
return $result ?? false;
|
||||
}
|
||||
|
||||
public static function initiate_contract_town($params):array|bool {
|
||||
//获取申请信息
|
||||
$apply = VehicleVillageApply::where('id',$params['apply_id'])->find();
|
||||
//获取车辆信息
|
||||
$car = VehicleRent::where('car_id',$params['car_id'])->find();
|
||||
if($car->isEmpty() || $car['status'] == 1){
|
||||
return ['code'=>0,'msg'=>'车辆信息错误'];
|
||||
}
|
||||
//获取甲方公司
|
||||
if($params['company_id'] != $apply['town_company_id']){
|
||||
return ['code'=>0,'msg'=>'镇街公司信息错误'];
|
||||
}
|
||||
$party_a = Company::field('id,company_name,organization_code,master_name,master_phone,master_email')->where('id',$params['company_id'])->find();
|
||||
//获取乙方公司
|
||||
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$apply['village_company_id'])->find();
|
||||
//生成合同
|
||||
$carJson = json_encode(['id'=>$car['id'],'license'=>$car['car_license']]);
|
||||
$data = [
|
||||
'contract_no' => time(),
|
||||
'company_a_name' => $party_a['company_name'],
|
||||
'company_a_code' => $party_a['company_organization_code'],
|
||||
'company_a_user' => $party_a['company_user'],
|
||||
'company_a_phone' => $party_a['company_phone'],
|
||||
'company_a_email' => $party_a['company_email'],
|
||||
'company_b_id' => $party_b['company_id'],
|
||||
'company_b_name' => $party_b['company_name'],
|
||||
'company_b_code' => $party_b['company_code'],
|
||||
'company_b_user' => $party_b['company_user'],
|
||||
'company_b_phone' => $party_b['company_phone'],
|
||||
'company_b_email' => $party_b['company_email'],
|
||||
'num' => 1,
|
||||
'cars_info' => $carJson,
|
||||
'type' => 0,
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
$result = VehicleContract::create($data);
|
||||
//返回
|
||||
if($result->id){
|
||||
return ['code'=>1,'msg'=>'合同发起成功,等待审核'];
|
||||
}else{
|
||||
return ['code'=>0,'msg'=>'合同发起失败,请稍后重试'];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user