77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Admin\System;
|
|
|
|
use App\Constants\Admin\UserCode;
|
|
use App\Constants\Common\RoleCode;
|
|
use App\Model\AdminSection;
|
|
use App\Model\AdminUser;
|
|
use App\Service\Admin\BaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class DriverService extends BaseService
|
|
{
|
|
/**
|
|
* 注入部门类
|
|
* @var AdminSection
|
|
*/
|
|
#[Inject]
|
|
protected readonly AdminSection $adminSectionModel;
|
|
|
|
/**
|
|
* @var AdminUser
|
|
*/
|
|
#[Inject]
|
|
protected readonly AdminUser $adminUserModel;
|
|
|
|
|
|
public function handle()
|
|
{
|
|
//todo Write logic
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 司机列表
|
|
* @return array
|
|
*/
|
|
public function driverList(): array
|
|
{
|
|
$limit = $this->request->input('limit', 10);
|
|
$cityId = (int)$this->request->input('query_driver_city_id',0);
|
|
$name = $this->request->input('query_driver_name');
|
|
|
|
// $where[] = [
|
|
// ['is_del', '=', UserCode::IS_NO_DEL],
|
|
// ['status','=',UserCode::ENABLE],
|
|
// ['role_id','=',RoleCode::DRIVER]
|
|
// ];
|
|
|
|
$list = $this
|
|
->adminUserModel
|
|
->where('is_del',UserCode::IS_NO_DEL)
|
|
->where('status',UserCode::ENABLE)
|
|
->where('role_id',RoleCode::DRIVER)
|
|
->when($name, function ($query) use ($name) {
|
|
$query->where('name', 'like', "$name%");
|
|
})
|
|
->when($cityId > 0, function ($query) use ($cityId) {
|
|
$query->whereIn('section_id', $this->adminSectionModel->getIdsByCityId($cityId));
|
|
})
|
|
->when($id = $this->request->input('query_driver_id'), function ($query) use ($id) {
|
|
$query->where('id', $id);
|
|
})
|
|
->paginate($limit,['chinese_name','id','mobile','status'])->toArray();
|
|
|
|
return $this->return->success('success',$list);
|
|
}
|
|
} |