update
This commit is contained in:
parent
f4e3aba605
commit
6400e6e005
94
app/adminapi/controller/platform/PlatformController.php
Normal file
94
app/adminapi/controller/platform/PlatformController.php
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\adminapi\controller\platform;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\controller\BaseAdminController;
|
||||||
|
use app\adminapi\lists\platform\PlatformLists;
|
||||||
|
use app\adminapi\logic\platform\PlatformLogic;
|
||||||
|
use app\adminapi\validate\platform\PlatformValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform控制器
|
||||||
|
* Class PlatformController
|
||||||
|
* @package app\adminapi\controller
|
||||||
|
*/
|
||||||
|
class PlatformController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new PlatformLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new PlatformValidate())->post()->goCheck('add');
|
||||||
|
$result = PlatformLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(PlatformLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new PlatformValidate())->post()->goCheck('edit');
|
||||||
|
$result = PlatformLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(PlatformLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new PlatformValidate())->post()->goCheck('delete');
|
||||||
|
PlatformLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new PlatformValidate())->goCheck('detail');
|
||||||
|
$result = PlatformLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
64
app/adminapi/lists/platform/PlatformLists.php
Normal file
64
app/adminapi/lists/platform/PlatformLists.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\adminapi\lists\platform;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\platform\Platform;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform列表
|
||||||
|
* Class PlatformLists
|
||||||
|
* @package app\adminapi\lists
|
||||||
|
*/
|
||||||
|
class PlatformLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'%like%' => ['company_name', 'company_user', 'company_phone', 'company_address'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return Platform::where($this->searchWhere)->where('is_del',1)
|
||||||
|
->field(['id', 'company_name', 'company_user', 'company_phone', 'company_address', 'is_del'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return Platform::where($this->searchWhere)->where('is_del',1)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,23 +1,11 @@
|
|||||||
<?php
|
<?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\adminapi\lists\vehicle;
|
namespace app\adminapi\lists\vehicle;
|
||||||
|
|
||||||
|
|
||||||
use app\adminapi\lists\BaseAdminDataLists;
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
use app\common\model\logistics\Logistics;
|
use app\common\model\logistics\Logistics;
|
||||||
use app\common\model\logistics\Product;
|
use app\common\model\logistics\Product;
|
||||||
|
use app\common\model\platform\Platform;
|
||||||
use app\common\model\vehicle\Vehicle;
|
use app\common\model\vehicle\Vehicle;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\vehicle\VehicleRent;
|
use app\common\model\vehicle\VehicleRent;
|
||||||
@ -40,7 +28,7 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'%like%' => ['gps_imei'],
|
'%like%' => ['gps_imei'],
|
||||||
'=' => ['license','status'],
|
'=' => ['license','status','type','is_check'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,26 +44,16 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return Vehicle::where($this->searchWhere)->where('is_del',0)
|
return Vehicle::where($this->searchWhere)->where('is_del',1)
|
||||||
->field(['id', 'license', 'gps_imei', 'gps_carid', 'status'])
|
->field(['id','company_id','license', 'gps_imei', 'status','type','is_check'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
->each(function($item){
|
->each(function($item){
|
||||||
$item['status_name'] = $item->status_name;
|
$item['status_name'] = $item->status_name;
|
||||||
$item['rent'] = VehicleRent::where('car_id',$item['id'])->find();
|
$item['type_name'] = $item->type_name;
|
||||||
$product_count = 0;
|
$item['is_check_name'] = $item->is_check_name;
|
||||||
if($item['rent'] && $item['rent']['lessee_two_flag'] == 1){
|
$item['company_name'] = Platform::where('id',$item['company_id'])->column('company_name')[0];
|
||||||
//获取物流信息
|
|
||||||
$logistics = Logistics::field('order_id')->where('courier_id',$item['rent']['lessee_two_user_id'])->where('status',1)->select()->toArray();
|
|
||||||
foreach($logistics as $v){
|
|
||||||
//获取订单信息
|
|
||||||
Product::field('product_num')->where('order_id', $v['order_id'])->select()->each(function($pro_item) use(&$product_count){
|
|
||||||
$product_count += $pro_item['product_num'];
|
|
||||||
})->toArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$item['goods_total'] = $product_count;
|
|
||||||
return $item;
|
return $item;
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
@ -90,7 +68,7 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return Vehicle::where($this->searchWhere)->count();
|
return Vehicle::where($this->searchWhere)->where('is_del',1)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
102
app/adminapi/logic/platform/PlatformLogic.php
Normal file
102
app/adminapi/logic/platform/PlatformLogic.php
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\adminapi\logic\platform;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\platform\Platform;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform逻辑
|
||||||
|
* Class PlatformLogic
|
||||||
|
* @package app\adminapi\logic
|
||||||
|
*/
|
||||||
|
class PlatformLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Platform::create([
|
||||||
|
'company_name' => $params['company_name'],
|
||||||
|
'company_user' => $params['company_user'],
|
||||||
|
'company_phone' => $params['company_phone'],
|
||||||
|
'company_address' => $params['company_address'],
|
||||||
|
'is_del' => 1,
|
||||||
|
'create_time' => time()
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Platform::where('id', $params['id'])->update([
|
||||||
|
'company_name' => $params['company_name'],
|
||||||
|
'company_user' => $params['company_user'],
|
||||||
|
'company_phone' => $params['company_phone'],
|
||||||
|
'company_address' => $params['company_address'],
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
$model = Platform::find($params);
|
||||||
|
$model->is_del = 2;
|
||||||
|
return $model->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return Platform::where('is_del',1)->findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,7 @@
|
|||||||
<?php
|
<?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\adminapi\logic\vehicle;
|
namespace app\adminapi\logic\vehicle;
|
||||||
|
|
||||||
|
use app\common\logic\GpsLogic;
|
||||||
use app\api\logic\GpsLogic;
|
|
||||||
use app\common\model\vehicle\Vehicle;
|
use app\common\model\vehicle\Vehicle;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -39,20 +25,15 @@ class VehicleLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//获取gps_car_id
|
|
||||||
$car = (new GpsLogic()) -> info($params['gps_imei']);
|
|
||||||
if($car['code'] == 0){
|
|
||||||
self::setError('添加失败');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Vehicle::create([
|
Vehicle::create([
|
||||||
|
'company_id' => $params['company_id'],
|
||||||
'license' => $params['license'],
|
'license' => $params['license'],
|
||||||
'gps_imei' => $params['gps_imei'],
|
'gps_imei' => $params['gps_imei'],
|
||||||
'gps_carid' => $car['data']['carId'],
|
'type' => 1,
|
||||||
'status' => $params['status'],
|
'status' => 1,
|
||||||
'is_del' => 0
|
'is_del' => 1,
|
||||||
|
'is_check' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -74,22 +55,13 @@ class VehicleLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//获取数据
|
|
||||||
$data = Vehicle::where('id',$params['id'])->find();
|
|
||||||
if($data['gps_imei'] != $params['gps_imei']){
|
|
||||||
//获取gps_car_id
|
|
||||||
$car = (new GpsLogic()) -> info($params['gps_imei']);
|
|
||||||
if($car['code'] == 0){
|
|
||||||
self::setError('添加失败');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$data['gps_carid'] = $car['data']['carId'];
|
|
||||||
}
|
|
||||||
Vehicle::where('id', $params['id'])->update([
|
Vehicle::where('id', $params['id'])->update([
|
||||||
|
'company_id' => $params['company_id'],
|
||||||
'license' => $params['license'],
|
'license' => $params['license'],
|
||||||
'gps_imei' => $params['gps_imei'],
|
'gps_imei' => $params['gps_imei'],
|
||||||
'gps_carid' => $data['gps_carid'],
|
'type' => $params['type'],
|
||||||
'status' => $params['status']
|
'status' => $params['status'],
|
||||||
|
'is_check' => $params['is_check']
|
||||||
]);
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -112,10 +84,10 @@ class VehicleLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = Vehicle::where('id', $params['id'])->find();
|
$data = Vehicle::where('id', $params['id'])->find();
|
||||||
if($data['is_del'] !== 0){
|
if($data['is_del'] !== 1){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Vehicle::where('id', $params['id'])->update(['is_del' => 1]);
|
Vehicle::where('id', $params['id'])->update(['is_del' => 2]);
|
||||||
return true;
|
return true;
|
||||||
}catch (\Exception $e){
|
}catch (\Exception $e){
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
@ -133,8 +105,7 @@ class VehicleLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$data = Vehicle::findOrEmpty($params['id']);
|
$data = Vehicle::where('is_del',1)->findOrEmpty($params['id']);
|
||||||
$data['status_name'] = $data->status_name;
|
|
||||||
return $data->toArray();
|
return $data->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
90
app/adminapi/validate/platform/PlatformValidate.php
Normal file
90
app/adminapi/validate/platform/PlatformValidate.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace app\adminapi\validate\platform;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform验证器
|
||||||
|
* Class PlatformValidate
|
||||||
|
* @package app\adminapi\validate
|
||||||
|
*/
|
||||||
|
class PlatformValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'company_name' => 'require',
|
||||||
|
'company_user' => 'require',
|
||||||
|
'company_phone' => 'require|mobile',
|
||||||
|
'company_address' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'company_name' => '平台公司名称',
|
||||||
|
'company_user' => '平台公司负责人',
|
||||||
|
'company_phone' => '平台公司联系电话',
|
||||||
|
'company_address' => '平台公司地址',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return PlatformValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['company_name','company_user','company_phone','company_address']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return PlatformValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','company_name','company_user','company_phone','company_address','is_del']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return PlatformValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return PlatformValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/28 13:37
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,9 +31,12 @@ class VehicleValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
'id' => 'require',
|
||||||
|
'company_id' => 'require|integer',
|
||||||
'license' => 'require|unique:vehicle',
|
'license' => 'require|unique:vehicle',
|
||||||
'gps_imei' => 'require|unique:vehicle',
|
'gps_imei' => 'require|number|unique:vehicle',
|
||||||
'status' => 'require',
|
'type' => 'require|in:1,2',
|
||||||
|
'status' => 'require|in:1,2',
|
||||||
|
'is_check' => 'require|in:1,2',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -43,9 +46,12 @@ class VehicleValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $field = [
|
protected $field = [
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
|
'company_id' => '所属公司',
|
||||||
'license' => '车辆牌照',
|
'license' => '车辆牌照',
|
||||||
'gps_imei' => 'gps定位器设备标志',
|
'gps_imei' => 'gps定位器设备标志',
|
||||||
'status' => '车辆状态:0:未出租 1:一级出租 2:二级出租',
|
'type' => '车辆类型:1:平台自营 2:社会车辆',
|
||||||
|
'status' => '车辆状态:1:未出租 2:已出租',
|
||||||
|
'is_check' => '是否审核:1:未审核 2:已审核',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +63,7 @@ class VehicleValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['license','gps_imei','status']);
|
return $this->only(['company_id','license','gps_imei']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +75,7 @@ class VehicleValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','license','gps_imei','status'])->remove('license', 'unique')->remove('gps_imei', 'unique');
|
return $this->only(['id','company_id','license','gps_imei','status','type','is_check'])->remove('license', 'unique')->remove('gps_imei', 'unique');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
20
app/common/model/platform/Platform.php
Normal file
20
app/common/model/platform/Platform.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\common\model\platform;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform模型
|
||||||
|
* Class Platform
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class Platform extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'platform';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -15,7 +15,19 @@ class Vehicle extends BaseModel
|
|||||||
|
|
||||||
public function getStatusNameAttr($value,$data): string
|
public function getStatusNameAttr($value,$data): string
|
||||||
{
|
{
|
||||||
$status = [0=>'未出租',1=>'一级出租',2=>'二级出租'];
|
$status = [1=>'未出租',2=>'已出租'];
|
||||||
return $status[$data['status']];
|
return $status[$data['status']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTypeNameAttr($value,$data): string
|
||||||
|
{
|
||||||
|
$type = [1=>'平台车辆',2=>'社会车辆'];
|
||||||
|
return $type[$data['type']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsCheckNameAttr($value,$data): string
|
||||||
|
{
|
||||||
|
$is_check = [1=>'未审核',2=>'已审核'];
|
||||||
|
return $is_check[$data['is_check']];
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user