2023-08-19 13:30:28 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | author: likeadminTeam
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
use app\api\logic\VehicleLogic;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 车辆管理
|
|
|
|
|
* Class VehicleController
|
|
|
|
|
* @package app\api\controller
|
|
|
|
|
*/
|
|
|
|
|
class VehicleController extends BaseApiController
|
|
|
|
|
{
|
2023-08-21 16:16:22 +08:00
|
|
|
|
public array $notNeedLogin = ['tricycle','multipleRent','singleRent'];
|
2023-08-21 12:00:22 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 获取去未出租的三轮车列表
|
|
|
|
|
*/
|
|
|
|
|
public function tricycle() {
|
|
|
|
|
//获取参数
|
|
|
|
|
$params = $this->request->get(['page_no','page_size']);
|
|
|
|
|
//获取数据
|
|
|
|
|
$data = VehicleLogic::lists($params);
|
|
|
|
|
//返回数据
|
|
|
|
|
return $this->success('请求成功',$data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 三轮车批量出租
|
|
|
|
|
*/
|
|
|
|
|
public function multipleRent() {
|
|
|
|
|
//获取参数
|
2023-08-21 16:16:22 +08:00
|
|
|
|
$params = $this->request->post(['company_id','car_ids','start_time','end_time']);
|
2023-08-21 12:00:22 +08:00
|
|
|
|
//验证参数
|
2023-08-21 16:16:22 +08:00
|
|
|
|
if(empty($params['company_id']) || empty($params['car_ids']) || empty($params['start_time']) || empty($params['end_time'])) {
|
2023-08-21 12:00:22 +08:00
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
|
}
|
|
|
|
|
if(!checkDateIsValid($params['start_time']) || !checkDateIsValid($params['end_time'])){
|
|
|
|
|
return $this->fail('时间格式错误');
|
|
|
|
|
}
|
|
|
|
|
//写入数据
|
|
|
|
|
$result = VehicleLogic::oneLevelRent($params);
|
|
|
|
|
//返回结果
|
|
|
|
|
if($result['code'] == 1){
|
2023-08-21 16:16:22 +08:00
|
|
|
|
return $this->success($result['msg']);
|
|
|
|
|
}else{
|
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 三轮车单辆出租
|
|
|
|
|
*/
|
|
|
|
|
public function singleRent() {
|
|
|
|
|
//获取参数
|
|
|
|
|
$params = $this->request->post(['lessor_company_id','tenant_company_id','car_id','start_time','end_time']);
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($params['lessor_company_id']) || empty($params['tenant_company_id']) || empty($params['car_id']) || empty($params['start_time']) || empty($params['end_time'])){
|
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
|
}
|
|
|
|
|
if(!checkDateIsValid($params['start_time']) || !checkDateIsValid($params['end_time'])){
|
|
|
|
|
return $this->fail('时间格式错误');
|
|
|
|
|
}
|
|
|
|
|
//写入数据
|
|
|
|
|
$result = VehicleLogic::twoLevelRent($params);
|
|
|
|
|
//返回结果
|
|
|
|
|
if($result['code'] == 1){
|
|
|
|
|
return $this->success($result['msg']);
|
2023-08-21 12:00:22 +08:00
|
|
|
|
}else{
|
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-19 13:30:28 +08:00
|
|
|
|
}
|