feat:chef

This commit is contained in:
LAPTOP-7SGDREK0\shiweijun
2025-01-08 17:52:29 +08:00
parent ce9d16eeda
commit 804d65b725
6 changed files with 67 additions and 68 deletions

View File

@@ -136,7 +136,7 @@ class EmployeeService extends BaseService
$id = (int)$this->request->input('id');
$name = $this->request->input('chinese_name');
$account = $this->request->input('account');
$roleId = $this->request->input('role_id', 0);
$roleId = (int)$this->request->input('role_id', 0);
$info = $this->adminUserModel->getAdminInfoById($id);
if (empty($info)) throw new ErrException('数据不存在');
@@ -151,6 +151,7 @@ class EmployeeService extends BaseService
//写入关联表
$del = match ($info->role_id) {
RoleCode::DRIVER => (new DriverSequence)->where('driver_id', $info->id)->delete(),
RoleCode::CHEF => (new Chef)->where('user_id', $info->id)->delete(),
default => true,
};
@@ -158,6 +159,7 @@ class EmployeeService extends BaseService
RoleCode::DRIVER => (new DriverSequence)->insert([
'driver_id' => $info->id,
]),
RoleCode::CHEF => $this->addChef($info->id),
default => true,
};
@@ -171,7 +173,7 @@ class EmployeeService extends BaseService
$info->avatar = $this->request->input('avatar',0);
$info->role_id = $roleId;
$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);
if (!$info->save()) throw new ErrException('账号修改失败');
@@ -194,7 +196,13 @@ class EmployeeService extends BaseService
$info->is_del = UserCode::IS_DEL;
if (!$info->save()) throw new ErrException('账号删除失败');
$del = match ($info->role_id) {
RoleCode::DRIVER => (new DriverSequence)->where('driver_id', $info->id)->update(['is_del' => UserCode::IS_DEL]),
RoleCode::CHEF => (new Chef)->where('user_id', $info->id)->update(['is_del' => UserCode::IS_DEL]),
default => true,
};
if (!$info->save() || !$del) throw new ErrException('账号删除失败');
return $this->return->success();
}