From 44dda2197677e56395fee33b19d163289f185b89 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Mon, 26 Oct 2026 23:58:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E8=AE=B0=E5=BD=95=E4=B8=8D=E5=8F=AF=E8=A7=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkbenchRegistrationServiceImpl.java | 15 +- .../WorkbenchRegistrationServiceImplTest.java | 208 ++++++++++++++++++ .../views/admin/WorkbenchRegistrationView.vue | 18 +- JC-Salon-WeChat/pages/planning/index.js | 2 +- docs/项目变更记录.md | 8 + 5 files changed, 236 insertions(+), 15 deletions(-) create mode 100644 JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImplTest.java diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImpl.java index 8b09df09..fd825796 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImpl.java @@ -201,7 +201,11 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe public List listForReviewer(Long reviewerId, boolean platformAdmin) { List applications; if (platformAdmin) { - applications = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime)); + applications = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class) + .eq(WorkbenchRegistrationApplicationDO::getRoleType, WorkbenchRegistrationRole.MANAGER) + .eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN) + .eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0) + .orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime)); } else { UserDO reviewer = requireManager(reviewerId); applications = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER).eq(WorkbenchRegistrationApplicationDO::getShopId, reviewer.getShopId()).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime)); @@ -222,15 +226,6 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe ? Map.of() : contentModerationRecordMapper.selectBatchIds(moderationIds).stream() .collect(Collectors.toMap(ContentModerationRecordDO::getId, Function.identity())); - if (platformAdmin) { - applications = applications.stream() - .filter(application -> { - ContentModerationRecordDO moderation = application.getContentModerationRecordId() == null - ? null : moderationById.get(application.getContentModerationRecordId()); - return moderation != null && "APPROVED".equals(moderation.getStatus()); - }) - .collect(Collectors.toList()); - } return applications.stream() .map(application -> toReviewVO(application, applicants.get(application.getUserId()), application.getContentModerationRecordId() == null diff --git a/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImplTest.java b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImplTest.java new file mode 100644 index 00000000..a2fa1364 --- /dev/null +++ b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/registration/service/impl/WorkbenchRegistrationServiceImplTest.java @@ -0,0 +1,208 @@ +package com.xiaowang.jayucloud.salon.core.modules.registration.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.xiaowang.jayucloud.salon.core.modules.integration.service.WechatMiniAuthService; +import com.xiaowang.jayucloud.salon.core.modules.privacy.entity.ContentModerationRecordDO; +import com.xiaowang.jayucloud.salon.core.modules.privacy.mapper.ContentModerationRecordMapper; +import com.xiaowang.jayucloud.salon.core.modules.privacy.service.ContentModerationService; +import com.xiaowang.jayucloud.salon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO; +import com.xiaowang.jayucloud.salon.core.modules.registration.entity.WorkbenchRegistrationStatus; +import com.xiaowang.jayucloud.salon.core.modules.registration.mapper.WorkbenchRegistrationApplicationMapper; +import com.xiaowang.jayucloud.salon.core.modules.registration.vo.WorkbenchRegistrationReviewSummaryVO; +import com.xiaowang.jayucloud.salon.core.modules.registration.vo.WorkbenchRegistrationReviewVO; +import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper; +import com.xiaowang.jayucloud.salon.core.modules.shop.entity.ShopDO; +import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService; +import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.UserShopBindingMapper; +import com.xiaowang.jayucloud.salon.core.modules.shop.support.UserShopBindingSupport; +import com.xiaowang.jayucloud.salon.core.modules.system.service.SystemParameterConfigService; +import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO; +import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper; +import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.transaction.PlatformTransactionManager; + +import java.util.Collection; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class WorkbenchRegistrationServiceImplTest { + + @Mock private WorkbenchRegistrationApplicationMapper applicationMapper; + @Mock private UserMapper userMapper; + @Mock private ShopMapper shopMapper; + @Mock private UserService userService; + @Mock private UserShopBindingSupport userShopBindingSupport; + @Mock private UserShopBindingMapper userShopBindingMapper; + @Mock private WechatMiniAuthService wechatMiniAuthService; + @Mock private SystemParameterConfigService systemParameterConfigService; + @Mock private ContentModerationService contentModerationService; + @Mock private ContentModerationRecordMapper contentModerationRecordMapper; + @Mock private ShopBusinessExpiryService shopBusinessExpiryService; + @Mock private PlatformTransactionManager transactionManager; + + private WorkbenchRegistrationServiceImpl service; + + @BeforeEach + void setUp() { + service = new WorkbenchRegistrationServiceImpl(applicationMapper, userMapper, shopMapper, userService, + userShopBindingSupport, userShopBindingMapper, wechatMiniAuthService, systemParameterConfigService, + contentModerationService, contentModerationRecordMapper, shopBusinessExpiryService, transactionManager); + } + + @Test + void returnsManagerReviewSummaryFromCurrentShopAndSwitch() { + UserDO manager = manager(7L, 21L); + when(userMapper.selectById(7L)).thenReturn(manager); + when(applicationMapper.selectCount(any(Wrapper.class))).thenReturn(3L); + when(systemParameterConfigService.getEnabledValue("WORKBENCH", "MANAGER_REGISTRATION_REVIEW_NOTICE")) + .thenReturn("true"); + + WorkbenchRegistrationReviewSummaryVO summary = service.getReviewSummary(7L); + + assertEquals(3L, summary.getPendingCount()); + assertEquals(true, summary.isNoticeEnabled()); + } + + @Test + void rejectsSummaryForNonManager() { + UserDO staff = new UserDO(); + staff.setId(8L); + staff.setType(3); + staff.setShopId(21L); + when(userMapper.selectById(8L)).thenReturn(staff); + + assertThrows(IllegalArgumentException.class, () -> service.getReviewSummary(8L)); + } + + @Test + void enrichesReviewListWithApplicantProfile() { + when(userMapper.selectById(7L)).thenReturn(manager(7L, 21L)); + WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO(); + application.setId(31L); + application.setUserId(9L); + application.setApplicationNo("SALON-001"); + application.setStatus(WorkbenchRegistrationStatus.PENDING_MANAGER); + application.setShopId(21L); + when(applicationMapper.selectList(any(Wrapper.class))).thenReturn(List.of(application)); + UserDO applicant = new UserDO(); + applicant.setId(9L); + applicant.setNickname("小周"); + applicant.setPhone("13812345678"); + when(userMapper.selectBatchIds(any(Collection.class))).thenReturn(List.of(applicant)); + + List result = service.listForReviewer(7L, false); + + assertEquals(1, result.size()); + assertEquals("小周", result.get(0).getApplicantNickname()); + assertEquals("138****5678", result.get(0).getApplicantMaskedPhone()); + } + + @Test + void locksApplicationAndRejectsAlreadyProcessedReview() { + WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO(); + application.setId(31L); + application.setShopId(21L); + application.setStatus(WorkbenchRegistrationStatus.APPROVED); + when(applicationMapper.selectByIdForUpdate(31L)).thenReturn(application); + when(userMapper.selectById(7L)).thenReturn(manager(7L, 21L)); + + assertThrows(IllegalArgumentException.class, () -> service.approve(7L, false, 31L)); + verify(applicationMapper).selectByIdForUpdate(31L); + } + + @Test + void managerApplicationCannotBeApprovedBeforeContentModerationPasses() { + WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO(); + application.setId(32L); + application.setUserId(9L); + application.setShopId(21L); + application.setRoleType("MANAGER"); + application.setStatus(WorkbenchRegistrationStatus.PENDING_ADMIN); + application.setContentModerationRecordId(81L); + ContentModerationRecordDO moderation = new ContentModerationRecordDO(); + moderation.setId(81L); + moderation.setStatus("PENDING"); + when(applicationMapper.selectByIdForUpdate(32L)).thenReturn(application); + when(contentModerationRecordMapper.selectById(81L)).thenReturn(moderation); + + assertThrows(IllegalArgumentException.class, () -> service.approve(1L, true, 32L)); + + verify(shopMapper, org.mockito.Mockito.never()).updateById(any()); + verify(userMapper, org.mockito.Mockito.never()).updateById(any()); + } + + @Test + void platformAdminListShowsManagerApplicationsWhileContentReviewIsPending() { + WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO(); + application.setId(33L); + application.setUserId(9L); + application.setRoleType("MANAGER"); + application.setShopId(21L); + application.setStatus(WorkbenchRegistrationStatus.PENDING_ADMIN); + application.setContentModerationRecordId(82L); + ContentModerationRecordDO moderation = new ContentModerationRecordDO(); + moderation.setId(82L); + moderation.setStatus("PENDING"); + when(applicationMapper.selectList(any(Wrapper.class))).thenReturn(List.of(application)); + when(userMapper.selectBatchIds(any(Collection.class))).thenReturn(List.of(new UserDO())); + when(contentModerationRecordMapper.selectBatchIds(any(Collection.class))).thenReturn(List.of(moderation)); + + List result = service.listForReviewer(1L, true); + + assertEquals(1, result.size()); + assertEquals(WorkbenchRegistrationStatus.PENDING_ADMIN, result.get(0).getStatus()); + assertEquals("PENDING", result.get(0).getContentModerationStatus()); + } + + @Test + void autoApprovesManagerOnlyWhenLinkedShopContentPassed() { + WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO(); + application.setId(34L); + application.setUserId(9L); + application.setShopId(21L); + application.setRoleType("MANAGER"); + application.setStatus(WorkbenchRegistrationStatus.PENDING_ADMIN); + application.setContentModerationRecordId(83L); + ContentModerationRecordDO moderation = new ContentModerationRecordDO(); + moderation.setId(83L); + moderation.setContentType("SHOP"); + moderation.setUserId(9L); + moderation.setStatus("APPROVED"); + UserDO applicant = new UserDO(); + applicant.setId(9L); + ShopDO shop = new ShopDO(); + shop.setId(21L); + when(applicationMapper.selectByIdForUpdate(34L)).thenReturn(application); + when(contentModerationRecordMapper.selectById(83L)).thenReturn(moderation); + when(systemParameterConfigService.getEnabledValue("WORKBENCH", "MANAGER_REGISTRATION_AUTO_APPROVE")) + .thenReturn("true"); + when(userMapper.selectById(9L)).thenReturn(applicant); + when(shopMapper.selectById(21L)).thenReturn(shop); + + service.processManagerModeration(34L); + + assertEquals(WorkbenchRegistrationStatus.APPROVED, application.getStatus()); + verify(shopBusinessExpiryService).startDefaultValidity(org.mockito.ArgumentMatchers.eq(21L), any()); + verify(userShopBindingSupport).updateBindingStatus(9L, 21L, 1); + verify(userService).syncManagedPermissions(9L); + } + + private UserDO manager(Long id, Long shopId) { + UserDO manager = new UserDO(); + manager.setId(id); + manager.setType(2); + manager.setShopId(shopId); + return manager; + } +} diff --git a/JC-Salon-Frontend/src/views/admin/WorkbenchRegistrationView.vue b/JC-Salon-Frontend/src/views/admin/WorkbenchRegistrationView.vue index 40eeee0f..c69fe804 100644 --- a/JC-Salon-Frontend/src/views/admin/WorkbenchRegistrationView.vue +++ b/JC-Salon-Frontend/src/views/admin/WorkbenchRegistrationView.vue @@ -4,7 +4,7 @@
账号管理

注册审核

-

核验并处理店长与员工的账号申请。

+

处理店长注册申请;员工加入申请由店长在小程序员工页面审核。

{{ applications.length }}条申请记录
@@ -22,7 +22,7 @@ @@ -60,7 +67,10 @@ const columns = [ { title: '操作', key: 'action', width: 150 } ] -const statusLabel = (status: string) => ({ PENDING_ADMIN: '待管理员审核', PENDING_MANAGER: '待店长审核', APPROVED: '已通过', REJECTED: '已驳回' }[status] || status) +const statusLabel = (status: string, moderationStatus?: string) => { + if (status === 'PENDING_ADMIN' && moderationStatus !== 'APPROVED') return '待资料审核' + return ({ PENDING_ADMIN: '待管理员审核', PENDING_MANAGER: '待店长审核', APPROVED: '已通过', REJECTED: '已驳回' }[status] || status) +} const moderationLabel = (status?: string) => ({ APPROVED: '已通过', PENDING: '待审核', RETRY: '重试中', REJECTED: '未通过', MISSING: '未提交' }[status || ''] || '审核中') const moderationColor = (status?: string) => ({ APPROVED: 'green', PENDING: 'processing', RETRY: 'orange', REJECTED: 'red', MISSING: 'default' }[status || ''] || 'processing') diff --git a/JC-Salon-WeChat/pages/planning/index.js b/JC-Salon-WeChat/pages/planning/index.js index b5d8adc7..4d53ce0a 100644 --- a/JC-Salon-WeChat/pages/planning/index.js +++ b/JC-Salon-WeChat/pages/planning/index.js @@ -155,7 +155,7 @@ Page({ const result = await new Promise(resolve => { wx.showModal({ title: '有美甲师申请待审核', - content: `当前有 ${summary.pendingCount} 条美甲师加入申请,是否立即处理?`, + content: `当前有 ${summary.pendingCount} 条美甲师加入申请,请在小程序员工页面审核。是否立即处理?`, cancelText: '稍后处理', confirmText: '立即审核', success: resolve, diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index 910cc6a5..ad526249 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -354,3 +354,11 @@ - 原因是 `MyBatisPlusConfig` 使用显式 `@MapperScan` 包清单,但漏登记新增的 analytics mapper 包;干净编译不会发现该 Spring Bean 注册错误。 - 将 analytics mapper 包加入扫描范围。Core clean compile 通过;实际启动成功,Nacos、MySQL、RabbitMQ 连接正常,Flyway 校验 5 个迁移并确认数据库已是 V5,无待执行迁移;`/health/check` 返回 200。 - 验证后已关闭本次启动的 Core 进程,保留既有 Gateway 进程。 + +## 2026-10-26 Salon 注册审核记录可见性修复 + +- 修复平台管理员注册审核列表隐藏待内容审核店长申请的问题;审核列表现在显示所有待管理员处理的店长申请及其内容审核状态。 +- 内容审核未通过或尚未完成时禁用“通过”,后端原有审核门禁保持不变;驳回仍可使用。 +- 明确后台注册审核页只处理店长申请,员工加入申请由店长在小程序员工页面审核。登录提醒统计的是当前门店待店长审核员工申请,因此与后台店长申请队列不同。 +- 登录提醒文案明确员工申请需在小程序员工页面审核,并保留“立即审核”直达入口。 +- 原因是管理员列表额外过滤掉了内容审核状态非 APPROVED 的申请,而 DEV 的本地 Mock 对未标记场景默认返回 PENDING,导致申请记录不可见。