change api for vehicle
This commit is contained in:
parent
9d13dd82ea
commit
46eb73025a
@ -19,11 +19,11 @@ class VehicleContractController extends BaseAdminController
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//更新本地和物流系统
|
||||
$la_result = VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>2]);
|
||||
$la_result = VehicleContract::where('id', $params['id'])->update(['file' => $params['file'],'status'=>1]);
|
||||
$lst_result = curl_post($this->url.'/api/updateContract',[],[
|
||||
'id' => $params['id'],
|
||||
'id' => $la_result['contract_logistic_id'],
|
||||
'file' => $params['file'],
|
||||
'status' => 2
|
||||
'status' => 1
|
||||
]);
|
||||
if($la_result && $lst_result && $lst_result['code'] == 1){
|
||||
//获取合同数据
|
||||
|
@ -125,21 +125,22 @@ class IndexController extends BaseApiController
|
||||
|
||||
//车辆租赁签约合同状态更改
|
||||
public function notifyVehicleContractUpdate(){
|
||||
$param = $this->request->post();
|
||||
if(empty($param['id'])){
|
||||
return $this->fail('缺少参数');
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$model = VehicleContract::where('id',$param['id'])->find();
|
||||
$param = $this->request->post();
|
||||
$model = VehicleContract::where('contract_logistic_id',$param['contract_logistic_id'])->find();
|
||||
if(!$model || $model->isEmpty()){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$result = $model->save($param);
|
||||
if($result && isset($param['status']) && $param['status'] == 4){
|
||||
$result = $model->where('id',$model['id'])->save($param);
|
||||
if($result && isset($param['status']) && $param['status'] == 3){
|
||||
$cars = json_decode($model['cars_info'],true);
|
||||
foreach($cars as $k=>$v) {
|
||||
$cars[$k]['type'] = 0;
|
||||
$cars[$k]['status'] = 0;
|
||||
$cars[$k]['company_id'] = $model['company_b_id'];
|
||||
$cars[$k]['rent_time'] = $model['create_time'];
|
||||
$cars[$k]['create_time'] = $model['create_time'];
|
||||
}
|
||||
VehicleRent::saveAll($cars);
|
||||
}
|
||||
|
@ -3,10 +3,17 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\logic\vehicle\VehicleLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\contract\VehicleContract;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use app\common\model\vehicle\VehicleVillageApply;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
//镇街公司想物流平台申请租赁车辆
|
||||
public function setContractByTownCompany():Json
|
||||
{
|
||||
//获取参数
|
||||
@ -28,13 +35,162 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
// public function vehicleList() {
|
||||
// //获取参数
|
||||
// $params = $this->request->get(['is_rent','license']);
|
||||
// if(empty($params['is_rent'])){
|
||||
// return $this->fail('缺少必要参数');
|
||||
// }
|
||||
// }
|
||||
//小组服务公司租赁申请
|
||||
public function rentApply() {
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求类型错误');
|
||||
}
|
||||
//获取参数
|
||||
$params = $this->request->post('license');
|
||||
//获取当前公司信息
|
||||
$village_company = Company::field('id,company_name,master_name,master_phone,is_contract,company_type')->where('id',$this->userInfo['company_id'])->find();
|
||||
if($village_company->isEmpty() || $village_company['company_type'] != 18){
|
||||
return $this->fail('非小组服务公司不能申请');
|
||||
}
|
||||
if($village_company['is_contract'] != 1){
|
||||
return $this->fail('当前小组服务公司未签约');
|
||||
}
|
||||
//获取签约信息
|
||||
$contract = Contract::field('party_a')->where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
|
||||
if($contract->isEmpty()){
|
||||
return $this->fail('未找到签约镇街公司');
|
||||
}
|
||||
//判断是否申请过
|
||||
$apply = VehicleVillageApply::where('village_company_id',$this->userInfo['company_id'])->where('status','<>',2)->find();
|
||||
if(!$apply->isEmpty()){
|
||||
return $this->fail('已申请了,请勿重复申请');
|
||||
}
|
||||
//设置数据
|
||||
$result = VehicleVillageApply::create([
|
||||
'town_company_id' => $contract['party_a'],
|
||||
'village_company_id' => $village_company['id'],
|
||||
'village_company_name' => $village_company['company_name'],
|
||||
'village_company_user' => $village_company['master_phone'],
|
||||
'village_company_phone' => $village_company['id'],
|
||||
'car_license' => !empty($params) ? $params : '',
|
||||
'type' => !empty($params) ? 1 : 0,
|
||||
'status' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
if($result && $result->id){
|
||||
return $this->success('申请成功');
|
||||
}else{
|
||||
return $this->fail('申请失败');
|
||||
}
|
||||
}
|
||||
|
||||
//镇街公司驳回小组服务公司的租赁申请
|
||||
public function rejectRentApply() {
|
||||
//获取参数
|
||||
$params = $this->request->post(['apply_id','content']);
|
||||
if(empty($params['apply_id']) || empty($params['content'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$apply = VehicleVillageApply::where('id',$params['apply_id'])->where('status',0)->find();
|
||||
if($apply->isEmpty()){
|
||||
return $this->fail('数据错误');
|
||||
}
|
||||
if($apply['town_company_id'] != $this->userInfo['company_id']){
|
||||
return $this->fail('镇街公司信息错误');
|
||||
}
|
||||
//更新
|
||||
$apply -> status = 2;
|
||||
$apply -> notice = $params['content'];
|
||||
$apply -> update_time = time();
|
||||
$result = $apply->save();
|
||||
if($result){
|
||||
return $this->success('驳回成功');
|
||||
}else{
|
||||
return $this->fail('驳回失败');
|
||||
}
|
||||
}
|
||||
|
||||
//镇街公司收到的小组服务公司租赁申请列表
|
||||
public function rentApplyList() {
|
||||
$data = VehicleVillageApply::where('town_company_id',$this->userInfo['company_id'])->where('status',0)->select();
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
}
|
||||
|
||||
//小组服务公司租赁申请详情
|
||||
public function rentApplyInfo() {
|
||||
//获取参数
|
||||
$id = $this->request->get('id');
|
||||
if(empty($id)){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$this->userInfo['company_id'] = 177;
|
||||
//获取数据
|
||||
$data = VehicleVillageApply::where('id',$id)->find();
|
||||
if($data->isEmpty() || $data['town_company_id'] != $this->userInfo['company_id'] || $data['status'] != 0){
|
||||
return $this->fail('获取数据失败');
|
||||
}
|
||||
//获取镇街公司可租赁车辆列表
|
||||
$cars = VehicleRent::field('id,car_license')->where('company_id',$this->userInfo['company_id'])->where('status',0)->where('type',0)->select();
|
||||
return $this->success('请求成功',[
|
||||
'apply' => $data->toArray(),
|
||||
'cars' => $cars->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
public function vehicleIndex() {
|
||||
//获取参数
|
||||
$params = $this->request->get();
|
||||
$company_id = $this->userInfo['company_id'];
|
||||
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();
|
||||
//获取车辆列表
|
||||
$cars = VehicleRent::where('company_id',$company_id)->page($pageNo,$pageSize)->select()->each(function($item){
|
||||
$item['mileage'] = 0;
|
||||
if($item['status'] == 2){
|
||||
$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();
|
||||
}
|
||||
});
|
||||
//设置数据
|
||||
$data = [
|
||||
'contract' => $contract->toArray(),
|
||||
'carlist' => $cars->toArray(),
|
||||
'total' =>6,
|
||||
'rent_num' => 3,
|
||||
'self_num' =>3,
|
||||
];
|
||||
//返回
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
public function vehicleInfo() {
|
||||
//获取参数
|
||||
$carId = $this->request->get('car_id');
|
||||
if(empty($carId)){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
//获取数据
|
||||
$data = VehicleRent::where('car_id',$carId)->find();
|
||||
$data['mileage'] = 0;
|
||||
if($data['status'] == 2){
|
||||
$data['company'] = Company::where('id',$data['rent_company_id'])->find()->append(['province_name', 'city_name', 'area_name', 'street_name', 'village_name','brigade_name']);
|
||||
}
|
||||
return $this->success('请求成功',$data->toArray());
|
||||
}
|
||||
|
||||
public function contractList() {
|
||||
$company_id = $this->userInfo['company_id'];
|
||||
if(empty($company_id)){
|
||||
return $this->fail('公司信息不存在');
|
||||
}
|
||||
$lists = VehicleContract::where('company_a_id',$company_id)->select();
|
||||
$cars = VehicleRent::where('status',1)->select();
|
||||
return $this->success('请求成功',[
|
||||
'contract' => $lists->toArray(),
|
||||
'car' => $cars->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -7,4 +7,9 @@ use app\common\model\BaseModel;
|
||||
class VehicleRent extends BaseModel
|
||||
{
|
||||
protected $name = 'vehicle_rent';
|
||||
|
||||
public function getRentTimeAttr($value): string
|
||||
{
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
}
|
||||
}
|
11
app/common/model/vehicle/VehicleVillageApply.php
Normal file
11
app/common/model/vehicle/VehicleVillageApply.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\vehicle;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class VehicleVillageApply extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = 'vehicle_village_apply';
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user