From 11d92b3d27cbbce6c0a0e23ebc1a9d70feed1139 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Sat, 25 Jul 2026 14:02:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BA=97=E9=95=BF=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E5=91=98=E5=B7=A5=E8=B4=A6=E5=8F=B7=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/AdminManagerController.java | 31 +++++++++ .../manager/dto/ManagerEmployeeStatusDTO.java | 8 +++ .../admin/AdminManagerControllerTest.java | 43 +++++++++++++ JY-Salon-WeChat/api/employees.js | 8 +++ .../pages/employee-detail/index.js | 53 ++++++++++++++++ .../pages/employee-detail/index.wxml | 22 +++++++ .../pages/employee-detail/index.wxss | 63 +++++++++++++++++++ docs/项目变更记录.md | 9 +++ 8 files changed, 237 insertions(+) create mode 100644 JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/dto/ManagerEmployeeStatusDTO.java diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java index bca9e205..c9fb5497 100644 --- a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java @@ -16,6 +16,7 @@ import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleRuleVO; import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleVO; import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerCreateDTO; import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerUpdateDTO; +import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerEmployeeStatusDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO; @@ -311,6 +312,36 @@ public class AdminManagerController { return Result.success(userService.unbindUserInShopWithOperator(userId, shopId, currentUser.getType())); } + @PutMapping("/employees/{userId}/status") + @RequirePermission("user:edit") + @OperationGuard(action = "manager-employee-status-update", ttlSeconds = 10, message = "员工状态更新处理中,请勿重复点击") + public Result updateEmployeeStatus(HttpServletRequest request, + @PathVariable Long userId, + @RequestBody ManagerEmployeeStatusDTO dto) { + UserDO currentUser = adminScopeHelper.getCurrentUser(request); + if (dto == null || dto.getStatus() == null) { + throw new RuntimeException("员工状态不能为空"); + } + Integer normalizedStatus = Integer.valueOf(1).equals(dto.getStatus()) ? 1 : 0; + if (currentUser != null && userId.equals(currentUser.getId()) && normalizedStatus == 0) { + throw new RuntimeException("不能停用自己的账号"); + } + UserVO targetUser = userService.getUserById(userId); + if (targetUser == null) { + throw new RuntimeException("目标员工不存在"); + } + if (!adminScopeHelper.isPlatformAdmin(currentUser)) { + adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权修改其他店铺员工状态"); + } + adminScopeHelper.ensureAssignableUserType(currentUser, targetUser.getType()); + if (!Integer.valueOf(3).equals(targetUser.getType())) { + throw new RuntimeException("只能修改员工状态"); + } + Long shopId = adminScopeHelper.resolveShopScope(currentUser, null); + adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再修改员工状态"); + return Result.success(userService.updateUserStatusInShop(userId, normalizedStatus, shopId)); + } + @GetMapping("/employees/schedules") @RequirePermission("schedule:view") public Result> schedules(HttpServletRequest request, diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/dto/ManagerEmployeeStatusDTO.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/dto/ManagerEmployeeStatusDTO.java new file mode 100644 index 00000000..243b94e0 --- /dev/null +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/dto/ManagerEmployeeStatusDTO.java @@ -0,0 +1,8 @@ +package com.xiaowang.jayucloud.core.modules.manager.dto; + +import lombok.Data; + +@Data +public class ManagerEmployeeStatusDTO { + private Integer status; +} diff --git a/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerControllerTest.java b/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerControllerTest.java index 008ae9fc..12a4dde7 100644 --- a/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerControllerTest.java +++ b/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerControllerTest.java @@ -14,6 +14,7 @@ import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleRuleVO; import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleVO; import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerCreateDTO; import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerUpdateDTO; +import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerEmployeeStatusDTO; import com.xiaowang.jayucloud.core.modules.planning.service.PlanningService; import com.xiaowang.jayucloud.core.modules.product.service.ProductService; import com.xiaowang.jayucloud.core.modules.product.vo.ProductVO; @@ -435,6 +436,48 @@ class AdminManagerControllerTest { verify(userService, never()).deleteUser(any()); } + @Test + void updateEmployeeStatusShouldUseShopScopedUserStatus() { + MockHttpServletRequest request = new MockHttpServletRequest(); + UserDO manager = new UserDO(); + manager.setId(5L); + manager.setType(2); + manager.setShopId(8L); + UserVO targetUser = new UserVO(); + targetUser.setId(7L); + targetUser.setType(3); + ManagerEmployeeStatusDTO dto = new ManagerEmployeeStatusDTO(); + dto.setStatus(0); + when(adminScopeHelper.getCurrentUser(request)).thenReturn(manager); + when(adminScopeHelper.isPlatformAdmin(manager)).thenReturn(false); + when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L); + when(userService.getUserById(7L)).thenReturn(targetUser); + when(userService.updateUserStatusInShop(7L, 0, 8L)).thenReturn(true); + + Result result = controller.updateEmployeeStatus(request, 7L, dto); + + assertThat(result.getData()).isTrue(); + verify(adminScopeHelper).ensureUserAccessibleInCurrentShop(manager, 7L, "无权修改其他店铺员工状态"); + verify(adminScopeHelper).ensureAssignableUserType(manager, 3); + verify(userService).updateUserStatusInShop(7L, 0, 8L); + } + + @Test + void updateEmployeeStatusShouldRejectDisablingSelf() { + MockHttpServletRequest request = new MockHttpServletRequest(); + UserDO manager = new UserDO(); + manager.setId(5L); + manager.setType(2); + ManagerEmployeeStatusDTO dto = new ManagerEmployeeStatusDTO(); + dto.setStatus(0); + when(adminScopeHelper.getCurrentUser(request)).thenReturn(manager); + + assertThatThrownBy(() -> controller.updateEmployeeStatus(request, 5L, dto)) + .isInstanceOf(RuntimeException.class) + .hasMessage("不能停用自己的账号"); + verify(userService, never()).updateUserStatusInShop(any(), any(), any()); + } + @Test void saveScheduleShouldResolveShopScopeBeforeSaving() { MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/JY-Salon-WeChat/api/employees.js b/JY-Salon-WeChat/api/employees.js index 9ce8cb6a..e9334d40 100644 --- a/JY-Salon-WeChat/api/employees.js +++ b/JY-Salon-WeChat/api/employees.js @@ -51,6 +51,14 @@ module.exports = { }) }, + updateStatus(userId, status) { + return request({ + url: `/manager/employees/${userId}/status`, + method: 'PUT', + data: { status } + }) + }, + schedules(params) { return request({ url: '/manager/employees/schedules', diff --git a/JY-Salon-WeChat/pages/employee-detail/index.js b/JY-Salon-WeChat/pages/employee-detail/index.js index de8c6369..fb724dac 100644 --- a/JY-Salon-WeChat/pages/employee-detail/index.js +++ b/JY-Salon-WeChat/pages/employee-detail/index.js @@ -18,6 +18,10 @@ Page({ id: '', employee: {}, loadError: '', + statusUpdating: false, + statusConfirmVisible: false, + pendingStatusValue: 1, + pendingStatusText: '', deleteConfirmVisible: false, deletingEmployee: false, resetConfirmVisible: false, @@ -94,6 +98,55 @@ Page({ stopTap() { }, + requestToggleStatus() { + if (this.data.statusUpdating) { + return + } + const currentStatusCode = String(this.data.employee.currentStatusCode || '').trim() + const nextStatus = currentStatusCode === 'DISABLED' ? 1 : 0 + const pendingStatusText = nextStatus === 1 ? '恢复正常' : '停用账号' + this.setData({ + statusConfirmVisible: true, + pendingStatusValue: nextStatus, + pendingStatusText + }) + }, + + closeStatusConfirm() { + if (this.data.statusUpdating) { + return + } + this.setData({ + statusConfirmVisible: false, + pendingStatusValue: 1, + pendingStatusText: '' + }) + }, + + async confirmToggleStatus() { + if (this.data.statusUpdating || !this.data.id) { + return + } + this.setData({ statusUpdating: true }) + try { + const success = await employeesApi.updateStatus(this.data.id, this.data.pendingStatusValue) + if (!success) { + throw new Error('员工状态更新失败') + } + this.setData({ + statusConfirmVisible: false, + pendingStatusValue: 1, + pendingStatusText: '' + }) + wx.showToast({ title: '状态已更新', icon: 'success' }) + await this.loadDetail() + } catch (error) { + wx.showToast({ title: error.message || '员工状态更新失败', icon: 'none' }) + } finally { + this.setData({ statusUpdating: false }) + } + }, + requestResetPassword() { if (this.data.resettingPassword) { return diff --git a/JY-Salon-WeChat/pages/employee-detail/index.wxml b/JY-Salon-WeChat/pages/employee-detail/index.wxml index fc7d7998..0071e760 100644 --- a/JY-Salon-WeChat/pages/employee-detail/index.wxml +++ b/JY-Salon-WeChat/pages/employee-detail/index.wxml @@ -71,6 +71,16 @@ + + + 账号状态 + 停用会同步账号管理中的停用状态,并使该员工账号无法登录;休假仍通过请假/排班管理控制。 + + + + 排班设置 @@ -145,4 +155,16 @@ + + + + ! + 确认修改账号状态 + {{pendingStatusValue === 0 ? '停用后该员工账号将无法登录店务系统。' : '恢复后该员工账号将重新可登录。'}} + + + + + + diff --git a/JY-Salon-WeChat/pages/employee-detail/index.wxss b/JY-Salon-WeChat/pages/employee-detail/index.wxss index 45966c1a..66bcfe7a 100644 --- a/JY-Salon-WeChat/pages/employee-detail/index.wxss +++ b/JY-Salon-WeChat/pages/employee-detail/index.wxss @@ -186,6 +186,69 @@ font-weight: 800; } +.status-card { + display: flex; + flex-direction: column; + gap: 24rpx; + margin-top: 24rpx; + padding: 28rpx; +} + +.status-copy { + flex: 1; + min-width: 0; +} + +.status-title, +.status-desc { + display: block; +} + +.status-title { + color: #302c27; + font-size: 28rpx; + font-weight: 800; +} + +.status-desc { + margin-top: 10rpx; + color: #7b6f66; + font-size: 22rpx; + line-height: 1.5; +} + +.status-btn { + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + width: 70%; + max-width: 360rpx; + min-width: 0; + min-height: 78rpx; + margin: 0 auto; + padding: 0; + border-radius: 14rpx; + font-size: 26rpx; + font-weight: 800; +} + +.status-btn::after { + border: 0; +} + +.status-btn.disable { + border: 1rpx solid #e3b7b7; + background: #fff2f2; + color: #b55454; +} + +.status-btn.enable { + border: 1rpx solid #b9d9c2; + background: #eef8f0; + color: #3f7950; +} + .reset-btn::after { border: 0; } diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index 9d19bc0e..81df7ca6 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -586,3 +586,12 @@ - 后端范围:预约规划服务、员工信息服务、订单项查询 mapper 及对应定向测试。 - 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 - 验证结果:`NailArtistInfoServiceImplTest` 与 `PlanningServiceImplTest` 共 29 个测试通过;店务小程序改动 JS 语法检查通过;改动文件 BOM 检查通过;`git diff --check` 无实质错误。 + +## 2026-07-25 店务员工账号状态改为可直接维护 + +- 变更原因:店长需要在员工详情直接维护员工当前状态,并确认“停用”是否与账号管理中的停用一致。 +- 处理方式:新增店务员工状态更新接口 `PUT /admin/manager/employees/{userId}/status`,仅修改账号状态;店长不可将自己停用;员工详情新增“账号状态”操作区,支持停用账号与恢复正常。休假仍由请假/排班例外控制,不通过该入口修改。 +- 状态口径:停用与账号管理中的停用保持一致,统一落在 `t_user.status`;停用后账号不可登录,恢复正常后重新可登录。当前状态展示仍按 `停用 > 休假 > 正常` 计算。 +- 影响范围:`AdminManagerController`、`JY-Salon-WeChat/pages/employee-detail/`、店务员工 API 封装。 +- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 +- 验证结果:`AdminManagerControllerTest` 与 `NailArtistInfoServiceImplTest` 共 35 个测试通过;员工详情页 JS 语法检查通过。