feat : driver
This commit is contained in:
@@ -26,6 +26,11 @@ class DriverRequest extends FormRequest
|
|||||||
'query_driver_city_id' => 'sometimes|integer|exists:system_city,id',
|
'query_driver_city_id' => 'sometimes|integer|exists:system_city,id',
|
||||||
'query_driver_id' =>'sometimes|integer|exists:admin_user,id',
|
'query_driver_id' =>'sometimes|integer|exists:admin_user,id',
|
||||||
'limit' => 'required|integer',
|
'limit' => 'required|integer',
|
||||||
|
'city_id' => 'required|integer|exists:system_city,id',
|
||||||
|
'driver_ids' => 'required|string',
|
||||||
|
'driver_num' => 'required',
|
||||||
|
'site_ids' => 'required|string',
|
||||||
|
'driver_id' =>'required|integer|exists:admin_user,id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +45,11 @@ class DriverRequest extends FormRequest
|
|||||||
'query_driver_name',
|
'query_driver_name',
|
||||||
'query_driver_city_id',
|
'query_driver_city_id',
|
||||||
'query_driver_id'
|
'query_driver_id'
|
||||||
]
|
],
|
||||||
|
'driver_sequence_list' => ['city_id'],
|
||||||
|
'setting_driver_sequence'=> ['driver_ids'],
|
||||||
|
'setting_driver_num' => ['driver_id','driver_num'],
|
||||||
|
'site_sequence_list_by_driver' => ['driver_id'],
|
||||||
|
'setting_site_sequence' => ['driver_id','site_ids'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ abstract class BaseService
|
|||||||
*/
|
*/
|
||||||
protected int $roleId = 0;
|
protected int $roleId = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected int $cityId = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主构造函数(获取请求对象)
|
* 主构造函数(获取请求对象)
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +50,6 @@ abstract class BaseService
|
|||||||
{
|
{
|
||||||
$this->adminId = Context::get("admin_id",0);
|
$this->adminId = Context::get("admin_id",0);
|
||||||
$this->roleId = Context::get("role_id",0);
|
$this->roleId = Context::get("role_id",0);
|
||||||
$this->cityId = Context::get("city_id",0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ class DriverService extends BaseService
|
|||||||
*/
|
*/
|
||||||
public function driverSequenceList(): array
|
public function driverSequenceList(): array
|
||||||
{
|
{
|
||||||
|
$this->cityId = (int)$this->request->input('city_id',0);
|
||||||
if (empty($this->cityId)) return $this->return->success('success',['list' => []]);
|
if (empty($this->cityId)) return $this->return->success('success',['list' => []]);
|
||||||
|
|
||||||
$list = $this
|
$list = $this
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Admin\User;
|
namespace App\Service\Admin\User;
|
||||||
|
|
||||||
use App\Constants\Admin\UserCode;
|
use App\Constants\Admin\UserCode;
|
||||||
|
use App\Constants\Common\RoleCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Extend\StringUtil;
|
use App\Extend\StringUtil;
|
||||||
use App\Lib\Crypto\CryptoFactory;
|
use App\Lib\Crypto\CryptoFactory;
|
||||||
use App\Model\AdminRole;
|
use App\Model\AdminRole;
|
||||||
use App\Model\AdminUser;
|
use App\Model\AdminUser;
|
||||||
|
use App\Model\DriverSequence;
|
||||||
use App\Service\Admin\BaseService;
|
use App\Service\Admin\BaseService;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -101,6 +103,17 @@ class EmployeeService extends BaseService
|
|||||||
|
|
||||||
if (!$model->save()) throw new ErrException('账号添加失败');
|
if (!$model->save()) throw new ErrException('账号添加失败');
|
||||||
|
|
||||||
|
//写入关联表
|
||||||
|
$res = match ($model->role_id) {
|
||||||
|
RoleCode::DRIVER =>
|
||||||
|
(new DriverSequence)->insert([
|
||||||
|
'driver_id' => $model->id,
|
||||||
|
]),
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!$res) throw new ErrException('关联表添加失败');
|
||||||
|
|
||||||
return $this->return->success();
|
return $this->return->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +126,7 @@ class EmployeeService extends BaseService
|
|||||||
$id = (int)$this->request->input('id');
|
$id = (int)$this->request->input('id');
|
||||||
$name = $this->request->input('chinese_name');
|
$name = $this->request->input('chinese_name');
|
||||||
$account = $this->request->input('account');
|
$account = $this->request->input('account');
|
||||||
|
$roleId = $this->request->input('role_id', 0);
|
||||||
|
|
||||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||||
if (empty($info)) throw new ErrException('数据不存在');
|
if (empty($info)) throw new ErrException('数据不存在');
|
||||||
@@ -123,12 +137,29 @@ class EmployeeService extends BaseService
|
|||||||
if (!empty($oldName) && $oldName->id != $info->id) throw new ErrException('员工已存在');
|
if (!empty($oldName) && $oldName->id != $info->id) throw new ErrException('员工已存在');
|
||||||
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new ErrException('账号已存在');
|
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new ErrException('账号已存在');
|
||||||
|
|
||||||
|
if ($info->role_id != $roleId) {
|
||||||
|
//写入关联表
|
||||||
|
$del = match ($info->role_id) {
|
||||||
|
RoleCode::DRIVER => (new DriverSequence)->where('driver_id', $info->id)->delete(),
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
|
||||||
|
$add = match ($roleId) {
|
||||||
|
RoleCode::DRIVER => (new DriverSequence)->insert([
|
||||||
|
'driver_id' => $info->id,
|
||||||
|
]),
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!$del || !$add) throw new ErrException('关联表修改失败');
|
||||||
|
}
|
||||||
|
|
||||||
$info->username = $account;
|
$info->username = $account;
|
||||||
$info->mobile = $account;
|
$info->mobile = $account;
|
||||||
$info->chinese_name = $name;
|
$info->chinese_name = $name;
|
||||||
$info->status = $this->request->input('status', 1);
|
$info->status = $this->request->input('status', 1);
|
||||||
$info->avatar = $this->request->input('avatar',0);
|
$info->avatar = $this->request->input('avatar',0);
|
||||||
$info->role_id = $this->request->input('role_id', 0);
|
$info->role_id = $roleId;
|
||||||
$info->city_id = $this->request->input('city_id', 0);
|
$info->city_id = $this->request->input('city_id', 0);
|
||||||
$info->section_id = $this->request->input('section_id', 0);
|
$info->section_id = $this->request->input('section_id', 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user