增加车辆租赁签约相关文件和接口

This commit is contained in:
unknown 2023-08-25 13:58:06 +08:00
parent 11aa471aa7
commit 13255a4271
9 changed files with 172 additions and 52 deletions

View File

@ -191,12 +191,11 @@ class CompanyController extends BaseAdminController
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'],
'master_name' => $company['master_name'],
'master_email' => $company['master_email'],
'id'=>$company['id'],
];
$res = app(JunziqianController::class)->EnterpriseCertification($data);
if ($res->success == true) {
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data]);
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data, 'is_authentication' => 1]);
return $this->success('认证成功', ['email' => $res->data], 1, 1);
} else {
return $this->fail($res->msg);
}

View File

@ -42,7 +42,7 @@ class CeshiController extends BaseApiController
// $all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
$company_id=[];
foreach($all as $k=>$v){
TaskLogic::CronAdd($v);
// TaskLogic::CronAdd($v);
$company_id[]=$v['company_id'];
}
$arr=array_unique($company_id);
@ -74,13 +74,10 @@ class CeshiController extends BaseApiController
}
}
public function ceshi2(){
$res = HttpClient::create()->request('GET', 'https://worker-task.lihaink.cn/v1/notify_authentication?id=183');
$json=json_decode($res->getContent(),true);
halt($json);
$points=$json['data'];
halt($res);
// public function ceshi2(){
// $
// $b=app(RemoteController::class)->shang_date_list('');
}
// }
}

View File

@ -16,10 +16,8 @@ namespace app\api\controller;
use app\api\logic\IndexLogic;
use app\common\model\Company;
use app\common\model\company\CompanyProperty;
use think\facade\Db;
use think\facade\Log;
use think\response\Json;
@ -32,7 +30,7 @@ class IndexController extends BaseApiController
{
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty','notifyAuthentication'];
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate', 'notifyUrl','notifyProperty'];
/**
@ -114,7 +112,39 @@ class IndexController extends BaseApiController
Db::name('user')->where('id', $find['party_b'])->update(['is_contract' => 1]);
}
}
curl_post('http://logistics.lihaink.cn/api/updateRentRecord', [], ['contract_id' => $a['id']]);
try {
//获取租赁信息
$vehicleRent = Db::name('vehicle_rent')->where('contract_id',$a['id'])->find();
//获取公司信息
$company = Db::name('company')->where('id',$vehicleRent['party_b'])->find();
//通知物流系统
if($vehicleRent && $company){
$result = curl_post('http://logistics.lihaink.cn/api/updateRentRecord', [], [
'contract_id' => $a['id'],
'car_id' => $vehicleRent['car_ids'],
'company_id' => $company['id'],
'company_name' => $company['company_name'],
'company_user_id' => $company['user_id'],
'company_user_name' => $company['master_name'],
'company_user_phone' => $company['master_phone'],
'rent_type' => $vehicleRent['rent_type']
]);
if($result['code'] == 1){
$carids = explode(',',$vehicleRent['car_ids']);
$pro_data = [];
foreach($carids as $k => $v){
$pro_data[$k]['company_id']=$company['id'];
$pro_data[$k]['object_id']=$v;
$pro_data[$k]['type']=1;
$pro_data[$k]['create_time']=time();
}
Db::name('company_property')->insertAll($pro_data);
Db::name('vehicle_rent')->where('id',$vehicleRent['id'])->update(['status',2]);
}
}
}catch (\Exception $e){
return false;
}
}
}
@ -154,19 +184,4 @@ class IndexController extends BaseApiController
}
return json(['success' => false, 'msg' => '失败,没有参数']);
}
/**
* 认证回调
*/
public function notifyAuthentication()
{
$parmas = Request()->param();
Log::error('notifyAuthentication', $parmas);
if ($parmas) {
Company::where('id',$parmas['id'])->update(['is_authentication'=>1]);
return json(['success' => true, 'msg' => '成功']);
}
return json(['success' => false, 'msg' => '失败,没有参数']);
}
}

View File

@ -86,8 +86,7 @@ class JunziqianController extends BaseApiController
if (isset($data['master_email'])) {
$request->emailOrMobile = $data['master_email']; //邮箱
}
$request->notifyUrl = 'https://worker-task.lihaink.cn/v1/notify_authentication?id=' . $data['id'];
// $request->emailOrMobile = ; //邮箱
// $request->emailOrMobile = ; //邮箱
//发起创建企业请求
$response = $requestUtils->doPost("/v2/user/organizationCreate", $request);
return $response;
@ -157,6 +156,7 @@ class JunziqianController extends BaseApiController
$request->notifyUrl = 'https://worker-task.lihaink.cn/notify_url?id=' . $id;
$request->needQifengSign = 1;
//发起PING请求
// halt($request);
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $response;
// return $this->success('', (array)$response);

View File

@ -179,13 +179,12 @@ class RemoteController extends BaseApiController
]);
$json=json_decode($res->getContent(),true);
$points=$json['data'];
if(empty($points)){
return false;
}
$target =[
"lat"=> $latitude1,
"lon"=> $longitude1
];
$closestPoint = $this->getClosestPoint($points, $target);
return $this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat']);
@ -199,6 +198,7 @@ class RemoteController extends BaseApiController
$minDistance = PHP_INT_MAX;
$closestPoint = null;
foreach ($points as $point) {
// halt($point,$target);
$distance = sqrt(pow(($point['lat'] - $target['lat']), 2) + pow(($point['lon'] - $target['lon']), 2));
if ($distance < $minDistance) {
$minDistance = $distance;

View File

@ -8,7 +8,6 @@ use app\common\model\company\CompanyProperty;
use app\common\model\informationg\UserInformationg;
use app\common\model\task\Task;
use app\common\model\user\User;
use think\facade\Log;
class TaskController extends BaseApiController
{
@ -101,7 +100,6 @@ class TaskController extends BaseApiController
public function add_tricycle_coordinate()
{
$parmas = $this->request->param();
Log::error(json_encode($parmas));
$task = Task::where('id', $parmas['id'])->find()->toArray();
$object_id=CompanyProperty::where('company_id',$this->userInfo['company_id'])->value('object_id');
if(!$object_id){
@ -112,28 +110,16 @@ class TaskController extends BaseApiController
$end_time=date('Y-m-d H:i:s',$time);
$datas=[
'car_id'=>$object_id,
'start_time'=>'2023-08-25 00:00:00',
'end_time'=>'2023-08-25 23:59:59'
'start_time'=>$start_time,
'end_time'=>$end_time
];
$data['status'] = 2;
if (isset($parmas['terminus'])) {
if( $parmas['terminus']['lnglat'][0]==null || $parmas['terminus']['lnglat'][0]<=0){
return $this->fail('定位不存在');
}
$res = App(RemoteController::class)->coordinate($datas, $parmas['terminus']['lnglat'][0], $parmas['terminus']['lnglat'][1]);
if($res===false){
return $this->fail('定位不存在|或GPS无轨迹');
}
$task['extend']['update']['terminus'] = $parmas['terminus'];
}
if (isset($parmas['transfer'])) {
if( $parmas['transfer']['lnglat'][0]==null || $parmas['transfer']['lnglat'][0]<=0){
return $this->fail('定位不存在');
}
$res = App(RemoteController::class)->coordinate($datas, $parmas['transfer']['lnglat'][0], $parmas['transfer']['lnglat'][1]);
if($res===false){
return $this->fail('定位不存在|或GPS无轨迹');
}
$task['extend']['update']['transfer'] = $parmas['transfer'];
}
if (isset($task['extend']['update']['terminus']) && isset($task['extend']['update']['transfer'])) {

View File

@ -0,0 +1,60 @@
<?php
namespace app\api\controller;
use app\common\logic\vehicle\VehicleLogic;
use think\response\Json;
class VehicleController extends BaseApiController
{
public function setContractByTownCompany():Json
{
//获取参数
$params = $this->request->post(['party_a','num','car_ids']);
//验证参数
if(empty($params['party_a']) || empty($params['num']) || empty($params['car_ids'])){
return $this->fail('缺少必要参数');
}
if(empty($this->userInfo['company_id'])){
return $this->fail('签约公司不存在');
}
$params['party_b'] = $this->userInfo['company_id'];
if($params['party_b'] == $params['party_a']){
return $this->fail('甲方和乙方不能是同一个公司');
}
$params['rent_type'] = 1;//镇街公司批量租赁
$result = VehicleLogic::initiate_contract($params);
//返回数据
if($result['code'] == 1){
return $this->success($result['msg'],$result['data']);
}else{
return $this->fail($result['msg']);
}
}
public function setContractByVillageCompany():Json
{
//获取参数
$params = $this->request->post(['party_b','car_ids']);
//验证参数
if(empty($params['party_b']) || empty($params['car_ids'])){
return $this->fail('缺少必要参数');
}
if(empty($this->userInfo['company_id'])){
return $this->fail('签约公司不存在');
}
$params['party_a'] = $this->userInfo['company_id'];
if($params['party_b'] == $params['party_a']){
return $this->fail('甲方和乙方不能是同一个公司');
}
$params['rent_type'] = 2;//小组服务公司单辆租赁
$params['num'] = 1;
$result = VehicleLogic::initiate_contract($params);
//返回数据
if($result['code'] == 1){
return $this->success($result['msg'],$result['data']);
}else{
return $this->fail($result['msg']);
}
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace app\common\logic\vehicle;
use app\common\logic\BaseLogic;
use app\common\model\Company;
use app\common\model\contract\Contract;
use Exception;
use think\facade\Db;
class VehicleLogic extends BaseLogic
{
public static function initiate_contract($data):array {
$party_b = Company::field('company_type')->where('id',$data['party_b'])->find();
if($data['rent_type'] == 1){
//镇街公司
if($party_b['company_type'] != 16){
return ['code'=>0,'msg'=>'非镇街公司不能签约'];
}
}elseif($data['rent_type'] == 2){
//小组服务公司
if($party_b['company_type'] != 18){
return ['code'=>0,'msg'=>'非小组服务公司不能签约'];
}
}else{
return ['code'=>0,'msg'=>'参数错误'];
}
Db::startTrans();
try {
$contract = Contract::create([
'contract_type' => 29,
'contract_no' => time(),
'create_time' => time(),
'update_time' => time(),
'check_status' => 1,
'party_a' => $data['party_a'],
'party_b' => $data['party_b'],
'area_manager' => 0,
'type' => 1,
]);
$vehicleRent = Db::name('vehicle_rent')->insert([
'car_ids' => $data['car_ids'],
'contract_id' => $contract->id,
'party_a' => $data['party_a'],
'party_b' => $data['party_b'],
'num' => $data['num'],
'rent_type' => $data['rent_type'],
'status' => 1,
'create_time' => time(),
'update_time' => time(),
]);
if($contract->id && $vehicleRent) {
Db::commit();
return ['code'=>1,'msg'=>'发起成功,等待平台风控部上传合同','data'=>['id'=>$contract->id]];
}else{
Db::rollback();
return ['code'=>0,'msg'=>'发起失败,请稍后重试'];
}
}catch (Exception $e) {
Db::rollback();
return ['code'=>0,'msg'=>$e->getMessage()];
}
}
}

View File

@ -36,5 +36,4 @@ Route::rule('crontab', function () {
Route::post('/notify_url', IndexController::class . '@notifyUrl');
Route::post('/v1/notify_property',IndexController::class . '@notifyProperty');
Route::any('/v1/notify_authentication',IndexController::class . '@notifyAuthentication');
Route::get('/api/junziqian/download_file',JunziqianController::class . '@download_file');