From 13255a4271ece9cc1cb6ca3de05158dbe6a60e68 Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Fri, 25 Aug 2023 13:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=A6=E8=BE=86=E7=A7=9F?= =?UTF-8?q?=E8=B5=81=E7=AD=BE=E7=BA=A6=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/controller/CompanyController.php | 5 +- app/api/controller/CeshiController.php | 13 ++-- app/api/controller/IndexController.php | 53 +++++++++------ app/api/controller/JunziqianController.php | 4 +- app/api/controller/RemoteController.php | 6 +- app/api/controller/TaskController.php | 18 +----- app/api/controller/VehicleController.php | 60 +++++++++++++++++ app/common/logic/vehicle/VehicleLogic.php | 64 +++++++++++++++++++ route/app.php | 1 - 9 files changed, 172 insertions(+), 52 deletions(-) create mode 100644 app/api/controller/VehicleController.php create mode 100644 app/common/logic/vehicle/VehicleLogic.php diff --git a/app/adminapi/controller/CompanyController.php b/app/adminapi/controller/CompanyController.php index a6266254c..65d3dac54 100644 --- a/app/adminapi/controller/CompanyController.php +++ b/app/adminapi/controller/CompanyController.php @@ -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); } diff --git a/app/api/controller/CeshiController.php b/app/api/controller/CeshiController.php index e1c6af663..2e901cc4c 100644 --- a/app/api/controller/CeshiController.php +++ b/app/api/controller/CeshiController.php @@ -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(''); - } + // } } \ No newline at end of file diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 1151379c9..f075068b8 100755 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -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' => '失败,没有参数']); - } } diff --git a/app/api/controller/JunziqianController.php b/app/api/controller/JunziqianController.php index b5686c83d..bcea160ed 100644 --- a/app/api/controller/JunziqianController.php +++ b/app/api/controller/JunziqianController.php @@ -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); diff --git a/app/api/controller/RemoteController.php b/app/api/controller/RemoteController.php index a4720f379..91d17cff1 100644 --- a/app/api/controller/RemoteController.php +++ b/app/api/controller/RemoteController.php @@ -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; diff --git a/app/api/controller/TaskController.php b/app/api/controller/TaskController.php index ae8261c72..bff7608a9 100644 --- a/app/api/controller/TaskController.php +++ b/app/api/controller/TaskController.php @@ -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'])) { diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php new file mode 100644 index 000000000..b712c766d --- /dev/null +++ b/app/api/controller/VehicleController.php @@ -0,0 +1,60 @@ +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']); + } + } +} \ No newline at end of file diff --git a/app/common/logic/vehicle/VehicleLogic.php b/app/common/logic/vehicle/VehicleLogic.php new file mode 100644 index 000000000..c9fd5289d --- /dev/null +++ b/app/common/logic/vehicle/VehicleLogic.php @@ -0,0 +1,64 @@ +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()]; + } + } +} \ No newline at end of file diff --git a/route/app.php b/route/app.php index 995d38958..36cf7d634 100755 --- a/route/app.php +++ b/route/app.php @@ -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'); \ No newline at end of file