新增车辆详情接口

This commit is contained in:
unknown 2023-08-26 16:15:14 +08:00
parent dc3c91719e
commit 35f172a673
2 changed files with 30 additions and 5 deletions

View File

@ -3,6 +3,7 @@
namespace app\api\controller;
use app\common\logic\vehicle\VehicleLogic;
use app\common\model\Company;
use think\response\Json;
class VehicleController extends BaseApiController
@ -58,7 +59,7 @@ class VehicleController extends BaseApiController
}
}
public function carList():Json {
public function townCompanyCarList():Json {
//获取参数
$params = $this->request->get(['is_rent','license','company_name','page_no','page_size']);
if(empty($params['is_rent'])){
@ -70,7 +71,7 @@ class VehicleController extends BaseApiController
//获取公司id
$params['company_id'] = $this->userInfo['company_id'];
//获取车辆
$result = VehicleLogic::carList($params);
$result = VehicleLogic::townCompanyCarList($params);
//返回数据
if($result['code'] == 1){
return $this->success($result['msg'],$result['data']);
@ -96,4 +97,27 @@ class VehicleController extends BaseApiController
return $this->fail($result['msg']);
}
}
public function getCarInfo():Json {
//获取参数
$params = $this->request->get(['car_id','car_type']);
if(empty($params['car_id']) || empty($params['car_type'])){
return $this->fail('缺少必要参数');
}
if(!in_array($params['car_type'],[1,2])){
return $this->fail('车辆类型错误');
}
//获取车辆详情
$result = curl_post('http://logistics.lihaink.cn/api/carInfo',[],$params);
//返回数据
if($result && $result['code'] == 1){
if($result['data']['type'] == 1 && $result['data']['lessee_two_flag'] == 1){
$lessee_two_company = Company::where('id','lessee_two_company_id')->find();
$result['data']['lessee_two_company_address'] = $lessee_two_company['address'];
}
return $this->success($result['msg'],$result['data']);
}else{
return $this->fail($result['msg']);
}
}
}

View File

@ -11,6 +11,7 @@ use think\facade\Db;
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 {
$party_b = Company::field('company_type')->where('id',$data['party_b'])->find();
if($data['rent_type'] == 1){
@ -71,10 +72,10 @@ class VehicleLogic extends BaseLogic
}
}
public static function carList($params):array {
public static function townCompanyCarList($params):array {
//请求物流系统获取车辆详情
$result = curl_post(self::$url.'/api/companyCarList',[],$params);
if($result['code'] == 1){
if($result && $result['code'] == 1){
foreach ($result['data'] as $k=>$v){
if($v['lessee_two_flag'] == 1){
$lessee_two_company = Company::where('id','lessee_two_company_id')->find();
@ -95,7 +96,7 @@ class VehicleLogic extends BaseLogic
return ['code'=>0,'msg'=>'非小组服务公司不能添加车辆'];
}
$result = curl_post(self::$url.'/api/addVehicle',[],$params);
if($result['code'] == 1){
if($result && $result['code'] == 1){
return ['code'=>1,'msg'=>$result['msg']];
}else{
return ['code'=>0,'msg'=>$result['msg']];