支持店长维护员工账号状态
This commit is contained in:
+31
@@ -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<Boolean> 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<List<ArtistScheduleVO>> schedules(HttpServletRequest request,
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.xiaowang.jayucloud.core.modules.manager.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ManagerEmployeeStatusDTO {
|
||||
private Integer status;
|
||||
}
|
||||
+43
@@ -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<Boolean> 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();
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -71,6 +71,16 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card status-card">
|
||||
<view class="status-copy">
|
||||
<text class="status-title">账号状态</text>
|
||||
<text class="status-desc">停用会同步账号管理中的停用状态,并使该员工账号无法登录;休假仍通过请假/排班管理控制。</text>
|
||||
</view>
|
||||
<button class="status-btn {{employee.currentStatusCode === 'DISABLED' ? 'enable' : 'disable'}}" loading="{{statusUpdating}}" disabled="{{statusUpdating}}" bindtap="requestToggleStatus">
|
||||
{{employee.currentStatusCode === 'DISABLED' ? '恢复正常' : '停用账号'}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="section">
|
||||
<view class="menu-grid">
|
||||
<view class="card menu-card" data-url="/pages/schedule-setting/index" bindtap="go">排班设置</view>
|
||||
@@ -145,4 +155,16 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{statusConfirmVisible}}" class="delete-confirm-mask" bindtap="closeStatusConfirm">
|
||||
<view class="delete-confirm-panel" catchtap="stopTap">
|
||||
<view class="delete-confirm-icon">!</view>
|
||||
<text class="delete-confirm-title">确认修改账号状态</text>
|
||||
<text class="delete-confirm-desc">{{pendingStatusValue === 0 ? '停用后该员工账号将无法登录店务系统。' : '恢复后该员工账号将重新可登录。'}}</text>
|
||||
<view class="delete-confirm-actions">
|
||||
<button class="delete-confirm-cancel" disabled="{{statusUpdating}}" bindtap="closeStatusConfirm">取消</button>
|
||||
<button class="delete-confirm-submit" loading="{{statusUpdating}}" disabled="{{statusUpdating}}" bindtap="confirmToggleStatus">{{pendingStatusText}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 语法检查通过。
|
||||
|
||||
Reference in New Issue
Block a user