150 lines
5.2 KiB
PHP
150 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\logic\vehicle\VehicleLogic;
|
|
use app\common\model\Company;
|
|
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']);
|
|
}
|
|
}
|
|
|
|
public function townCompanyCarList():Json {
|
|
//获取参数
|
|
$params = $this->request->get(['is_rent','license','company_name','page_no','page_size']);
|
|
if(empty($params['is_rent'])){
|
|
return $this->fail('缺少必要参数');
|
|
}
|
|
if(!in_array($params['is_rent'],[1,2])){
|
|
return $this->fail('参数错误');
|
|
}
|
|
//获取公司id
|
|
$params['company_id'] = $this->userInfo['company_id'];
|
|
//获取车辆
|
|
$result = VehicleLogic::townCompanyCarList($params);
|
|
//返回数据
|
|
if($result['code'] == 1){
|
|
return $this->success($result['msg'],$result['data']);
|
|
}else{
|
|
return $this->fail($result['msg']);
|
|
}
|
|
}
|
|
|
|
public function villageCompanyCar():Json {
|
|
//获取公司id
|
|
$company_id = $this->userInfo['company_id'];
|
|
if(empty($company_id)){
|
|
return $this->fail('数据错误');
|
|
}
|
|
$result = VehicleLogic::villageCompanyCar($company_id);
|
|
//返回数据
|
|
if($result['code'] == 1){
|
|
return $this->success($result['msg'],$result['data']);
|
|
}else{
|
|
return $this->fail($result['msg']);
|
|
}
|
|
}
|
|
|
|
public function addCar():Json {
|
|
//获取参数
|
|
$params = $this->request->post(['license']);
|
|
//验证参数
|
|
if(empty($params['license'])){
|
|
return $this->fail('缺啥破必要参数');
|
|
}
|
|
//获取公司id
|
|
$params['company_id'] = $this->userInfo['company_id'];
|
|
$result = VehicleLogic::addCar($params);
|
|
//返回数据
|
|
if($result['code'] == 1){
|
|
return $this->success($result['msg']);
|
|
}else{
|
|
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']);
|
|
}
|
|
}
|
|
|
|
public function checkNum():Json {
|
|
//获取参数
|
|
$num = $this->request->get('num');
|
|
$result = curl_post('http://logistics.lihaink.cn/api/checkNum',[],['num'=>$num]);
|
|
//返回数据
|
|
if($result && $result['code'] == 1){
|
|
return $this->success($result['msg'],$result['data']);
|
|
}else{
|
|
return $this->fail($result['msg']);
|
|
}
|
|
}
|
|
} |