Salon美甲师注册申请关联微信账号
自动发布开发环境 Nacos 配置 / publish (push) Successful in 26s

This commit is contained in:
2026-10-30 03:46:24 +08:00
parent 5a787a93f3
commit 7b40ee1650
27 changed files with 733 additions and 91 deletions
@@ -331,6 +331,9 @@ public class WechatMiniAuthServiceImpl implements WechatMiniAuthService {
UserDO phoneUser = findActiveUserByPhone(phone);
if (phoneUser != null) {
if (requiresWechatIdentityForStaff(phoneUser)) {
return WechatMiniLoginResultVO.needManualLogin("美甲师档案不能通过手机号关联,请使用关联微信身份或联系店长完成关联。");
}
if (userShopBindingSupport.listActiveShopIdsByUserId(phoneUser.getId()).isEmpty()) {
return WechatMiniLoginResultVO.registrationRequired(userService.phoneLoginByVerifiedPhone(phone));
}
@@ -339,6 +342,11 @@ public class WechatMiniAuthServiceImpl implements WechatMiniAuthService {
return WechatMiniLoginResultVO.registrationRequired(userService.phoneLoginByVerifiedPhone(phone));
}
private boolean requiresWechatIdentityForStaff(UserDO user) {
return user != null && Integer.valueOf(3).equals(user.getType())
&& !StringUtils.hasText(user.getAccount());
}
@Override
@Transactional(rollbackFor = Exception.class)
/**
@@ -361,6 +369,10 @@ public class WechatMiniAuthServiceImpl implements WechatMiniAuthService {
TicketPayload ticketPayload = readTicketPayload(requestDTO.getTicket());
LoginResponseVO loginResponse;
if (ticketPayload.getUserId() != null) {
UserDO ticketUser = userMapper.selectById(ticketPayload.getUserId());
if (requiresWechatIdentityForStaff(ticketUser)) {
throw new BusinessException("美甲师档案尚未关联微信身份,请联系店长完成关联");
}
loginResponse = userService.loginByUserId(ticketPayload.getUserId(), shopId);
} else if (StringUtils.hasText(ticketPayload.getPhone())) {
loginResponse = userService.loginByVerifiedPhone(ticketPayload.getPhone(), shopId);
@@ -216,12 +216,25 @@ public class AdminManagerController {
dto.setShopId(managedShopId);
dto.setShopIds(List.of(managedShopId));
}
if (dto.getAccount() == null && dto.getPassword() == null) {
return Result.success(userService.createUnlinkedEmployee(dto, dto.getShopId()));
}
return Result.success(userService.createUser(dto));
}
@PostMapping("/employees/users/unlinked")
@RequirePermission("user:create")
@OperationGuard(action = "manager-user-create-unlinked", ttlSeconds = 10, message = "美甲师档案创建处理中,请勿重复提交")
public Result<Long> createUnlinkedEmployee(HttpServletRequest request,
@RequestBody UserDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
dto.setType(3);
adminScopeHelper.ensureAssignableUserType(currentUser, dto.getType());
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
Long managedShopId = adminScopeHelper.getManagedShopId(currentUser);
dto.setShopId(managedShopId);
dto.setShopIds(List.of(managedShopId));
}
return Result.success(userService.createUnlinkedEmployee(dto, dto.getShopId()));
}
@GetMapping("/employees/schedules")
@RequirePermission("schedule:view")
public Result<List<ArtistScheduleVO>> schedules(HttpServletRequest request,
@@ -42,6 +42,11 @@ public class AdminWorkbenchRegistrationController {
return Result.success(registrationService.getReviewSummary(requireUserId(request)));
}
@GetMapping("/unassociated")
public Result<List<WorkbenchRegistrationReviewVO>> unassociatedApplications(HttpServletRequest request) {
return Result.success(registrationService.listUnassociatedApplications(requireUserId(request)));
}
@PostMapping("/{id}/approve")
public Result<Boolean> approve(HttpServletRequest request, @PathVariable Long id,
@RequestBody(required = false) WorkbenchRegistrationApproveDTO requestDTO) {
@@ -0,0 +1,56 @@
package com.xiaowang.jayucloud.salon.core.modules.registration.controller;
import com.xiaowang.jayucloud.salon.core.common.Result;
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageDirectUploadService;
import com.xiaowang.jayucloud.salon.core.modules.file.vo.ObjectStorageFileVO;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.WechatMiniAuthService;
import com.xiaowang.jayucloud.salon.core.modules.registration.vo.WorkbenchRegistrationAvatarVO;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.Locale;
@RestController
@RequestMapping("/user/workbench/register")
public class WorkbenchRegistrationAvatarController {
private static final long MAX_AVATAR_SIZE = 5L * 1024 * 1024;
private final WechatMiniAuthService wechatMiniAuthService;
private final ObjectStorageDirectUploadService objectStorageDirectUploadService;
public WorkbenchRegistrationAvatarController(WechatMiniAuthService wechatMiniAuthService,
ObjectStorageDirectUploadService objectStorageDirectUploadService) {
this.wechatMiniAuthService = wechatMiniAuthService;
this.objectStorageDirectUploadService = objectStorageDirectUploadService;
}
@PostMapping("/avatar")
public Result<WorkbenchRegistrationAvatarVO> uploadAvatar(
@RequestParam("registrationTicket") String registrationTicket,
@RequestParam("file") MultipartFile file) {
if (!StringUtils.hasText(registrationTicket)) return Result.error("注册票据不能为空");
if (file == null || file.isEmpty() || file.getSize() > MAX_AVATAR_SIZE) {
return Result.error("头像不能为空且不能超过5MB");
}
String contentType = file.getContentType() == null ? "" : file.getContentType().toLowerCase(Locale.ROOT);
String filename = file.getOriginalFilename() == null ? "" : file.getOriginalFilename().toLowerCase(Locale.ROOT);
boolean supportedImage = ("image/jpeg".equals(contentType) && (filename.endsWith(".jpg") || filename.endsWith(".jpeg")))
|| ("image/png".equals(contentType) && filename.endsWith(".png"))
|| ("image/webp".equals(contentType) && filename.endsWith(".webp"));
if (!supportedImage) return Result.error("头像仅支持 JPG、PNG 或 WebP 图片");
try {
wechatMiniAuthService.validateRegistrationTicket(registrationTicket);
ObjectStorageFileVO fileVO = objectStorageDirectUploadService.upload(file);
wechatMiniAuthService.rememberRegistrationAvatarUpload(registrationTicket, fileVO.getId());
return Result.success(new WorkbenchRegistrationAvatarVO(fileVO.getId()));
} catch (Exception error) {
return Result.error(error.getMessage() == null ? "头像上传失败" : error.getMessage());
}
}
}
@@ -287,10 +287,13 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
require(moderation != null && "APPROVED".equals(moderation.getStatus()), "门店资料内容审核通过后才能审核注册申请");
}
if (WorkbenchRegistrationRole.STAFF.equals(application.getRoleType())) {
require(request != null && request.getTargetArtistUserId() != null, "请选择要关联的美甲师");
UserDO target = userMapper.selectById(request.getTargetArtistUserId());
require(target != null && Integer.valueOf(3).equals(target.getType()) && Objects.equals(target.getShopId(), application.getShopId()), "目标美甲师不属于当前门店");
Long targetArtistUserId = request != null && request.getTargetArtistUserId() != null
? request.getTargetArtistUserId() : application.getTargetArtistUserId();
require(targetArtistUserId != null, "请选择要关联的美甲师");
require(targetArtistUserId > 0, "目标美甲师不合法");
UserDO target = loadActiveArtistForUpdate(targetArtistUserId, application.getShopId());
require(!hasActiveWechatBinding(target.getId()), "目标美甲师已关联微信账号");
require(!hasPendingAssociation(target.getId(), applicationId), "该美甲师已被其他申请预关联");
application.setTargetArtistUserId(target.getId());
return approveApplication(application, reviewerId, request);
}
@@ -313,21 +316,16 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
}
if (WorkbenchRegistrationRole.STAFF.equals(application.getRoleType())) {
Long targetId = application.getTargetArtistUserId();
UserDO target = userMapper.selectById(targetId);
require(target != null && Integer.valueOf(3).equals(target.getType()), "目标美甲师不存在");
if (Boolean.TRUE.equals(request == null ? false : request.getUseApplicantNickname()) && StringUtils.hasText(application.getApplicantNickname())) {
UserDO target = loadActiveArtistForUpdate(targetId, application.getShopId());
if (request != null && Boolean.TRUE.equals(request.getUseApplicantNickname()) && StringUtils.hasText(application.getApplicantNickname())) {
requireApplicantProfileApproved(application);
target.setNickname(application.getApplicantNickname());
}
if (Boolean.TRUE.equals(request == null ? false : request.getUseApplicantAvatar()) && application.getApplicantAvatarFileId() != null) {
if (request != null && Boolean.TRUE.equals(request.getUseApplicantAvatar()) && application.getApplicantAvatarFileId() != null) {
requireApplicantProfileApproved(application);
ObjectStorageFileVO file = contentModerationFile(application.getApplicantAvatarFileId());
target.setAvatar(file.getFileUrl());
}
if (Boolean.TRUE.equals(request == null ? false : request.getUseApplicantNickname())
|| Boolean.TRUE.equals(request == null ? false : request.getUseApplicantAvatar())) {
target.setProfileModerationStatus("APPROVED");
}
target.setStatus(1);
userMapper.updateById(target);
wechatMiniAuthService.transferRegistrationBinding(application.getUserId(), target.getId());
@@ -366,7 +364,11 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
public List<WorkbenchRegistrationArtistVO> listUnboundArtists(Long reviewerId, Long applicationId) {
WorkbenchRegistrationApplicationDO application = loadReviewable(reviewerId, false, applicationId);
List<UserDO> users = userMapper.selectList(Wrappers.lambdaQuery(UserDO.class).eq(UserDO::getType, 3).eq(UserDO::getShopId, application.getShopId()).eq(UserDO::getStatus, 1).eq(UserDO::getIsDelete, 0).orderByAsc(UserDO::getNickname));
return users.stream().filter(user -> !hasActiveWechatBinding(user.getId())).map(user -> new WorkbenchRegistrationArtistVO(user.getId(), user.getNickname(), user.getAvatar())).collect(Collectors.toList());
return users.stream()
.filter(user -> !hasActiveWechatBinding(user.getId()))
.filter(user -> !hasPendingAssociation(user.getId(), applicationId))
.map(user -> new WorkbenchRegistrationArtistVO(user.getId(), user.getNickname(), user.getAvatar()))
.collect(Collectors.toList());
}
@Override
@@ -379,15 +381,34 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
public boolean preAssociate(Long reviewerId, Long applicationId, Long targetArtistUserId) {
WorkbenchRegistrationApplicationDO application = loadReviewable(reviewerId, false, applicationId);
require(targetArtistUserId != null, "请选择美甲师");
UserDO target = userMapper.selectById(targetArtistUserId);
require(target != null && Integer.valueOf(3).equals(target.getType()) && Objects.equals(target.getShopId(), application.getShopId()), "目标美甲师不属于当前门店");
UserDO target = loadActiveArtistForUpdate(targetArtistUserId, application.getShopId());
require(!hasActiveWechatBinding(target.getId()), "目标美甲师已关联微信账号");
WorkbenchRegistrationApplicationDO occupied = applicationMapper.selectOne(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getTargetArtistUserId, targetArtistUserId).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0));
require(occupied == null || Objects.equals(occupied.getId(), applicationId), "该美甲师已被其他申请预关联");
require(!hasPendingAssociation(targetArtistUserId, applicationId), "该美甲师已被其他申请预关联");
application.setTargetArtistUserId(targetArtistUserId);
return applicationMapper.updateById(application) > 0;
}
private UserDO loadActiveArtistForUpdate(Long userId, Long shopId) {
UserDO artist = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class)
.eq(UserDO::getId, userId)
.eq(UserDO::getType, 3)
.eq(UserDO::getShopId, shopId)
.eq(UserDO::getStatus, 1)
.eq(UserDO::getIsDelete, 0)
.last("FOR UPDATE"));
require(artist != null, "目标美甲师不属于当前门店或已停用");
return artist;
}
private boolean hasPendingAssociation(Long artistUserId, Long currentApplicationId) {
WorkbenchRegistrationApplicationDO occupied = applicationMapper.selectOne(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class)
.eq(WorkbenchRegistrationApplicationDO::getTargetArtistUserId, artistUserId)
.eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER)
.eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0)
.last("LIMIT 1 FOR UPDATE"));
return occupied != null && !Objects.equals(occupied.getId(), currentApplicationId);
}
private boolean hasActiveWechatBinding(Long userId) {
return wechatMiniBindingMapper.selectCount(Wrappers.lambdaQuery(WechatMiniBindingDO.class).eq(WechatMiniBindingDO::getUserId, userId).eq(WechatMiniBindingDO::getStatus, 1)) > 0;
}
@@ -473,7 +494,11 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
WorkbenchRegistrationReviewVO review = new WorkbenchRegistrationReviewVO();
BeanUtils.copyProperties(application, review);
if (applicant != null) {
boolean approved = "APPROVED".equals(moderation == null ? null : moderation.getStatus());
boolean approved = moderation != null
&& "STAFF_REGISTRATION".equals(moderation.getContentType())
&& Objects.equals(application.getId(), moderation.getBusinessId())
&& Objects.equals(application.getUserId(), moderation.getUserId())
&& "APPROVED".equals(moderation.getStatus());
review.setApplicantNickname(approved ? (StringUtils.hasText(application.getApplicantNickname()) ? application.getApplicantNickname() : applicant.getNickname()) : null);
review.setApplicantAvatar(approved && application.getApplicantAvatarFileId() != null
? objectStorageFileService.createTemporaryModerationUrl(application.getApplicantAvatarFileId(), 30) : null);
@@ -390,7 +390,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
userDO.setContactPhone(StringUtils.hasText(userDTO.getContactPhone()) ? userDTO.getContactPhone().trim() : phone);
userDO.setWechatId(UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId()));
userDO.setType(3);
userDO.setStatus(0);
userDO.setStatus(1);
userDO.setIsDelete(0);
userDO.setProfileModerationStatus("PENDING");
userDO.setAvatar(StringUtils.hasText(userDTO.getAvatar()) ? normalizeStoredAvatar(userDTO.getAvatar()) : DEFAULT_AVATAR_URL);
@@ -1260,6 +1260,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
if (userDO == null) {
return buildRegistrationRequiredResponse(normalizedPhone, null, "PHONE_NOT_REGISTERED");
}
assertWechatLinkedForStaffLogin(userDO);
if (userShopBindingSupport.listActiveShopIdsByUserId(userDO.getId()).isEmpty()) {
return buildRegistrationRequiredResponse(normalizedPhone, userDO, "NO_SHOP_BINDING");
}
@@ -1331,6 +1332,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
* @param userDO parameter `userDO` supplied by the caller
* @return result consumed by the caller or returned to the frontend
*/
assertWechatLinkedForStaffLogin(userDO);
assertUserAvailable(userDO);
clearLoginFailureCount(userDO.getAccount());
}
@@ -2551,6 +2553,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
*/
throw new RuntimeException("未绑定手机号,请联系店员");
}
assertWechatLinkedForStaffLogin(userDO);
if (userDO.getStatus() != null && !Integer.valueOf(1).equals(userDO.getStatus())) {
/**
* Run business method `RuntimeException`.
@@ -2679,6 +2682,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
* @param userDO parameter `userDO` supplied by the caller
* @return private void result consumed by the caller or returned to the frontend
*/
static void assertWechatLinkedForStaffLogin(UserDO userDO) {
if (userDO != null && Integer.valueOf(3).equals(userDO.getType())
&& !StringUtils.hasText(userDO.getAccount())) {
throw new RuntimeException("美甲师档案不能通过手机号登录,请使用关联微信身份或联系店长完成关联");
}
}
private void handleLoginPasswordFailure(UserDO userDO) {
if (userDO == null || !StringUtils.hasText(userDO.getAccount())) {
/**
@@ -0,0 +1,70 @@
-- 为美甲师申请保存审核资料与目标员工,并保证一个待审核申请最多预关联一个员工。
DROP PROCEDURE IF EXISTS salon_v9_add_column_if_missing;
DROP PROCEDURE IF EXISTS salon_v9_add_unique_index_if_missing;
DELIMITER $$
CREATE PROCEDURE salon_v9_add_column_if_missing(
IN p_table_name VARCHAR(64),
IN p_column_name VARCHAR(64),
IN p_definition TEXT
)
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND COLUMN_NAME = p_column_name
) THEN
SET @salon_v9_sql = CONCAT('ALTER TABLE `', p_table_name, '` ADD COLUMN `', p_column_name, '` ', p_definition);
PREPARE salon_v9_stmt FROM @salon_v9_sql;
EXECUTE salon_v9_stmt;
DEALLOCATE PREPARE salon_v9_stmt;
END IF;
END$$
CREATE PROCEDURE salon_v9_add_unique_index_if_missing(
IN p_table_name VARCHAR(64),
IN p_index_name VARCHAR(64),
IN p_columns TEXT
)
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND INDEX_NAME = p_index_name
) THEN
SET @salon_v9_sql = CONCAT('ALTER TABLE `', p_table_name, '` ADD UNIQUE INDEX `', p_index_name, '` ', p_columns);
PREPARE salon_v9_stmt FROM @salon_v9_sql;
EXECUTE salon_v9_stmt;
DEALLOCATE PREPARE salon_v9_stmt;
END IF;
END$$
DELIMITER ;
CALL salon_v9_add_column_if_missing(
't_workbench_registration_application', 'target_artist_user_id',
'bigint NULL COMMENT ''店长预关联或审核确认的目标美甲师用户ID'''
);
CALL salon_v9_add_column_if_missing(
't_workbench_registration_application', 'applicant_nickname',
'varchar(100) NULL COMMENT ''美甲师申请昵称,审核通过前不展示'''
);
CALL salon_v9_add_column_if_missing(
't_workbench_registration_application', 'applicant_avatar_file_id',
'bigint NULL COMMENT ''美甲师申请头像文件ID,审核通过前不展示'''
);
CALL salon_v9_add_column_if_missing(
't_workbench_registration_application', 'pending_target_artist_user_id',
'bigint GENERATED ALWAYS AS (CASE WHEN role_type = ''STAFF'' AND status = ''PENDING_MANAGER'' AND COALESCE(is_delete, 0) = 0 THEN target_artist_user_id ELSE NULL END) STORED COMMENT ''待审核申请预关联员工唯一值'''
);
CALL salon_v9_add_unique_index_if_missing(
't_workbench_registration_application', 'uk_registration_pending_target_artist',
'(`pending_target_artist_user_id`)'
);
DROP PROCEDURE IF EXISTS salon_v9_add_column_if_missing;
DROP PROCEDURE IF EXISTS salon_v9_add_unique_index_if_missing;
@@ -2,6 +2,8 @@ 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.integration.mapper.WechatMiniBindingMapper;
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageFileService;
import com.xiaowang.jayucloud.salon.core.modules.privacy.moderation.LocalMockContentModerationProvider;
import com.xiaowang.jayucloud.salon.core.modules.privacy.moderation.ModerationOutcome;
import com.xiaowang.jayucloud.salon.core.modules.privacy.entity.ContentModerationRecordDO;
@@ -9,6 +11,7 @@ import com.xiaowang.jayucloud.salon.core.modules.privacy.mapper.ContentModeratio
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.dto.WorkbenchRegistrationApproveDTO;
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;
@@ -52,6 +55,8 @@ class WorkbenchRegistrationServiceImplTest {
@Mock private ContentModerationRecordMapper contentModerationRecordMapper;
@Mock private ShopBusinessExpiryService shopBusinessExpiryService;
@Mock private PlatformTransactionManager transactionManager;
@Mock private WechatMiniBindingMapper wechatMiniBindingMapper;
@Mock private ObjectStorageFileService objectStorageFileService;
private WorkbenchRegistrationServiceImpl service;
@@ -59,7 +64,8 @@ class WorkbenchRegistrationServiceImplTest {
void setUp() {
service = new WorkbenchRegistrationServiceImpl(applicationMapper, userMapper, shopMapper, userService,
userShopBindingSupport, userShopBindingMapper, wechatMiniAuthService, systemParameterConfigService,
contentModerationService, contentModerationRecordMapper, shopBusinessExpiryService, transactionManager);
contentModerationService, contentModerationRecordMapper, shopBusinessExpiryService, transactionManager,
wechatMiniBindingMapper, objectStorageFileService);
}
@Test
@@ -88,7 +94,7 @@ class WorkbenchRegistrationServiceImplTest {
}
@Test
void enrichesReviewListWithApplicantProfile() {
void hidesApplicantProfileUntilItsContentModerationPasses() {
when(userMapper.selectById(7L)).thenReturn(manager(7L, 21L));
WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO();
application.setId(31L);
@@ -106,7 +112,7 @@ class WorkbenchRegistrationServiceImplTest {
List<WorkbenchRegistrationReviewVO> result = service.listForReviewer(7L, false);
assertEquals(1, result.size());
assertEquals("小周", result.get(0).getApplicantNickname());
assertEquals(null, result.get(0).getApplicantNickname());
assertEquals("138****5678", result.get(0).getApplicantMaskedPhone());
}
@@ -123,6 +129,43 @@ class WorkbenchRegistrationServiceImplTest {
verify(applicationMapper).selectByIdForUpdate(31L);
}
@Test
void approvesStaffApplicationByTransferringWechatIdentityToSelectedEmployee() {
WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO();
application.setId(41L);
application.setUserId(99L);
application.setShopId(21L);
application.setRoleType("STAFF");
application.setStatus(WorkbenchRegistrationStatus.PENDING_MANAGER);
when(applicationMapper.selectByIdForUpdate(41L)).thenReturn(application);
when(userMapper.selectById(7L)).thenReturn(manager(7L, 21L));
UserDO applicant = new UserDO();
applicant.setId(99L);
when(userMapper.selectById(99L)).thenReturn(applicant);
UserDO target = new UserDO();
target.setId(51L);
target.setType(3);
target.setShopId(21L);
target.setStatus(1);
target.setIsDelete(0);
target.setNickname("门店员工");
when(userMapper.selectOne(any(Wrapper.class))).thenReturn(target);
when(wechatMiniBindingMapper.selectCount(any(Wrapper.class))).thenReturn(0L);
when(applicationMapper.selectOne(any(Wrapper.class))).thenReturn(null);
WorkbenchRegistrationApproveDTO request = new WorkbenchRegistrationApproveDTO();
request.setTargetArtistUserId(51L);
assertEquals(true, service.approve(7L, false, 41L, request));
assertEquals(WorkbenchRegistrationStatus.APPROVED, application.getStatus());
assertEquals(51L, application.getTargetArtistUserId());
assertEquals(0, applicant.getStatus());
assertEquals(1, target.getStatus());
verify(wechatMiniAuthService).transferRegistrationBinding(99L, 51L);
verify(userShopBindingSupport).updateBindingStatus(51L, 21L, 1);
verify(userService).syncManagedPermissions(51L);
}
@Test
void managerApplicationCannotBeApprovedBeforeContentModerationPasses() {
WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO();
+12
View File
@@ -26,6 +26,18 @@ module.exports = {
})
},
uploadRegistrationAvatar(registrationTicket, filePath) {
const { uploadFile } = require('../utils/upload')
return uploadFile({
url: '/user/workbench/register/avatar',
baseUrl: API_DOMAIN,
filePath,
name: 'file',
formData: { registrationTicket },
errorMessage: '头像上传失败'
})
},
getAvailableRegistrationShops() {
return request({
url: '/user/workbench/shops/available',
+20 -3
View File
@@ -24,7 +24,7 @@ module.exports = {
createUser(data) {
return request({
url: '/manager/employees/users',
url: '/manager/employees/users/unlinked',
method: 'POST',
data
})
@@ -80,10 +80,27 @@ module.exports = {
})
},
approveApplication(id) {
unassociatedApplications() {
return request({ url: '/user/workbench/registration/unassociated' })
},
unboundArtists(id) {
return request({ url: `/user/workbench/registration/${id}/unbound-artists` })
},
preAssociateApplication(id, targetArtistUserId) {
return request({
url: `/user/workbench/registration/${id}/pre-associate`,
method: 'POST',
data: { targetArtistUserId }
})
},
approveApplication(id, data) {
return request({
url: `/user/workbench/registration/${id}/approve`,
method: 'POST'
method: 'POST',
data
})
},
+14 -2
View File
@@ -28,7 +28,13 @@ async function run() {
await authApi.logout()
await employeesApi.reviewSummary()
await employeesApi.reviewApplications()
await employeesApi.approveApplication(12)
await employeesApi.unboundArtists(12)
await employeesApi.preAssociateApplication(14, 22)
await employeesApi.approveApplication(12, {
targetArtistUserId: 22,
useApplicantNickname: true,
useApplicantAvatar: false
})
await employeesApi.rejectApplication(12, '资料不完整')
assert.deepStrictEqual(requests.map(item => [item.method || 'GET', item.url, item.data]), [
@@ -39,7 +45,13 @@ async function run() {
['POST', 'http://127.0.0.1:80/api/user/logout', undefined],
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/summary', undefined],
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/list', undefined],
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/12/approve', undefined],
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/12/unbound-artists', undefined],
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/14/pre-associate', { targetArtistUserId: 22 }],
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/12/approve', {
targetArtistUserId: 22,
useApplicantNickname: true,
useApplicantAvatar: false
}],
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/12/reject', { reason: '资料不完整' }]
])
assert(requests.every(item => !item.url.includes('/api/admin/')))
+74 -13
View File
@@ -1,7 +1,6 @@
const employeesApi = require('../../api/employees')
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
const EMPLOYEE_COLORS = ['#7BA7C7', '#8FB89A', '#A894C7', '#D7A86E', '#D98DA5', '#79A6A3', '#B9A16B', '#9BA9C8']
Page({
@@ -11,11 +10,15 @@ Page({
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
associationSheetVisible: false,
associationLoading: false,
associationApplications: [],
associationItems: [],
associationKeyword: '',
associationSelectedId: '',
form: {
nickname: '',
phone: '',
account: '',
password: DEFAULT_EMPLOYEE_PASSWORD,
wechatId: '',
color: '#8FB89A',
avatar: '',
@@ -39,10 +42,7 @@ Page({
onInput(event) {
const field = event.currentTarget.dataset.field
const value = event.detail.value
const updates = { [`form.${field}`]: value }
if (field === 'account') this._accountManuallyEdited = true
if (field === 'phone' && !this._accountManuallyEdited) updates['form.account'] = value
this.setData(updates)
this.setData({ [`form.${field}`]: value })
},
selectColor(event) {
@@ -79,10 +79,8 @@ Page({
const form = this.data.form
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
const account = String(form.account || '').trim()
const password = String(form.password || '').trim()
const wechatId = String(form.wechatId || '').trim()
if (!nickname || !phone || !account || !password) {
if (!nickname || !phone) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
return
}
@@ -96,8 +94,6 @@ Page({
nickname,
phone,
contactPhone: phone,
account,
password,
wechatId,
color: form.color,
avatar: form.avatar || undefined,
@@ -105,7 +101,8 @@ Page({
})
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
this.setData({ createdEmployee: employee, onboardingVisible: true })
this.setData({ createdEmployee: employee })
await this.offerPendingAssociation()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
@@ -113,6 +110,70 @@ Page({
}
},
async offerPendingAssociation() {
try {
const data = await employeesApi.unassociatedApplications()
const applications = Array.isArray(data) ? data : []
if (!applications.length) {
this.setData({ onboardingVisible: true })
return
}
const associationItems = applications.map(item => ({
id: item.id,
title: item.applicantNickname || '待审核美甲师申请',
subtitle: [item.applicantMaskedPhone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 16)].filter(Boolean).join(' · ') || '申请资料尚未审核',
meta: item.applicationNo || ''
}))
this.setData({
associationApplications: applications,
associationItems,
associationKeyword: '',
associationSelectedId: '',
associationSheetVisible: true
})
} catch (error) {
wx.showToast({ title: '申请列表暂时不可用,已继续新增员工', icon: 'none' })
this.setData({ onboardingVisible: true })
}
},
onAssociationSearch(event) {
const associationKeyword = String(event.detail.value || '').trim().toLowerCase()
const applications = this.data.associationApplications
const associationItems = applications
.filter(item => !associationKeyword || [item.applicantNickname, item.applicantMaskedPhone, item.applicationNo]
.some(value => String(value || '').toLowerCase().includes(associationKeyword)))
.map(item => ({
id: item.id,
title: item.applicantNickname || '待审核美甲师申请',
subtitle: [item.applicantMaskedPhone, item.createTime && String(item.createTime).replace('T', ' ').slice(0, 16)].filter(Boolean).join(' · ') || '申请资料尚未审核',
meta: item.applicationNo || ''
}))
this.setData({ associationKeyword, associationItems })
},
async selectAssociation(event) {
const application = event.detail && event.detail.item
const employee = this.data.createdEmployee
if (!application || !employee || !employee.id || this.data.associationLoading) return
this.setData({ associationLoading: true, associationSelectedId: application.id })
try {
await employeesApi.preAssociateApplication(application.id, employee.id)
this.setData({ associationSheetVisible: false, onboardingVisible: true })
wx.showToast({ title: '已预关联申请', icon: 'success' })
} catch (error) {
wx.showToast({ title: error.message || '关联失败,请重新选择', icon: 'none' })
this.setData({ associationSelectedId: '' })
} finally {
this.setData({ associationLoading: false })
}
},
skipAssociation() {
if (this.data.associationLoading) return
this.setData({ associationSheetVisible: false, onboardingVisible: true })
},
setupFirstSchedule() {
const employee = this.data.createdEmployee
if (!employee || !employee.id) return
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "新增美甲师"
"navigationBarTitleText": "新增美甲师",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index"
}
}
@@ -33,25 +33,34 @@ const page = {
async function run() {
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13800138000' } })
assert.strictEqual(page.data.form.account, '13800138000')
page.onInput({ currentTarget: { dataset: { field: 'account' } }, detail: { value: 'staff_zhou' } })
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13900139000' } })
assert.strictEqual(page.data.form.account, 'staff_zhou')
assert.strictEqual(page.data.form.phone, '13800138000')
assert.strictEqual(page.data.form.account, undefined)
assert.strictEqual(page.data.form.password, undefined)
assert.strictEqual(page.data.form.color, '#8FB89A')
Object.assign(page.data.form, {
nickname: '小周',
phone: '13800138000',
account: '13800138000',
password: 'Fingertip@123',
wechatId: ''
})
let createPayload
employeesApi.createUser = async payload => {
createPayload = payload
assert.strictEqual(payload.wechatId, '')
assert.strictEqual(payload.color, '#8FB89A')
return 88
}
employeesApi.unassociatedApplications = async () => []
await page.submit()
assert.deepStrictEqual(createPayload, {
nickname: '小周',
phone: '13800138000',
contactPhone: '13800138000',
wechatId: '',
color: '#8FB89A',
avatar: undefined,
type: 3
})
assert.strictEqual(page.data.onboardingVisible, true)
assert.strictEqual(emitted, undefined)
@@ -69,6 +78,25 @@ async function run() {
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: true, scheduleSaved: true })
assert.strictEqual(navigatedBack, true)
let associatedApplication
employeesApi.unassociatedApplications = async () => [{
id: 42,
applicantNickname: '微信昵称',
applicantMaskedPhone: '138****8000',
applicationNo: 'SALON-042'
}]
employeesApi.preAssociateApplication = async (applicationId, employeeId) => {
associatedApplication = { applicationId, employeeId }
}
page.setData({ onboardingVisible: false, associationSheetVisible: false })
await page.offerPendingAssociation()
assert.strictEqual(page.data.associationSheetVisible, true)
assert.strictEqual(page.data.associationItems[0].title, '微信昵称')
await page.selectAssociation({ detail: { item: { id: 42 } } })
assert.deepStrictEqual(associatedApplication, { applicationId: 42, employeeId: 88 })
assert.strictEqual(page.data.associationSheetVisible, false)
assert.strictEqual(page.data.onboardingVisible, true)
page.data.onboardingVisible = true
page.data.createdEmployee = { id: 88, name: '小周' }
page.data.appointmentContext = { date: '2026-10-12', time: '14:00', durationMinutes: '60' }
@@ -1,6 +1,6 @@
<view class="page no-tab employee-create-page">
<view class="create-intro">
<text class="create-title">录入美甲师账号</text>
<text class="create-title">新增美甲师档案</text>
<text class="create-subtitle">{{pickerMode ? '保存后自动选择该美甲师' : '保存后即可用于预约指定和美甲师管理'}}</text>
</view>
@@ -24,13 +24,10 @@
<text class="field-label required">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" />
</view>
<view class="field">
<text class="field-label required">登录账号</text>
<input value="{{form.account}}" data-field="account" bindinput="onInput" placeholder="默认跟随手机号" />
</view>
<view class="field">
<text class="field-label required">初始密码</text>
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="请输入初始密码" />
<view class="login-unlinked">
<text class="login-unlinked-label">微信登录</text>
<text class="login-unlinked-status">未关联</text>
<text class="login-unlinked-note">可在店长审核微信注册申请时快速关联</text>
</view>
<view class="field">
<text class="field-label">微信号</text>
@@ -58,4 +55,5 @@
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(默认全天可约)' : '不设置,使用默认全天排班'}}</button>
</view>
</view>
<entity-selector-sheet visible="{{associationSheetVisible}}" title="关联待审核申请" keyword="{{associationKeyword}}" placeholder="搜索申请昵称、手机号或编号" items="{{associationItems}}" selected-id="{{associationSelectedId}}" loading="{{associationLoading}}" empty-text="暂无可关联申请" action-text="暂不关联,继续" bind:search="onAssociationSearch" bind:select="selectAssociation" bind:action="skipAssociation" bind:close="skipAssociation" />
</view>
@@ -25,6 +25,20 @@
font-size: 23rpx;
}
.login-unlinked {
display: flex;
flex-wrap: wrap;
align-items: center;
margin: 24rpx 0 4rpx;
padding: 22rpx 24rpx;
border-radius: 14rpx;
background: #edf6ef;
}
.login-unlinked-label { color: #536b5d; font-size: 24rpx; font-weight: 700; }
.login-unlinked-status { margin-left: 18rpx; color: #247b63; font-size: 24rpx; font-weight: 700; }
.login-unlinked-note { flex-basis: 100%; margin-top: 10rpx; color: #829287; font-size: 21rpx; }
.avatar-card {
display: flex;
align-items: center;
+128 -6
View File
@@ -31,7 +31,15 @@ Page({
reviewPendingCount: 0,
reviewLoading: false,
reviewError: '',
reviewingId: ''
reviewingId: '',
associationSheetVisible: false,
associationLoading: false,
associationError: '',
associationApplicationId: '',
associationArtists: [],
associationItems: [],
associationKeyword: '',
associationSelectedId: ''
},
onLoad() {
@@ -73,7 +81,7 @@ Page({
const data = await employeesApi.reviewApplications()
const applications = (Array.isArray(data) ? data : []).map(item => ({
...item,
applicantNickname: item.applicantNickname || '待审核美甲师',
applicantDisplayName: item.applicantNickname || '待审核美甲师',
applicantAvatar: item.applicantAvatar || '',
applicantMaskedPhone: item.applicantMaskedPhone || '',
applicationTimeText: formatApplicationTime(item.createTime)
@@ -88,10 +96,124 @@ Page({
async approveApplication(event) {
const id = event.currentTarget.dataset.id
if (!id || this.data.reviewingId) return
const result = await confirmModal({ title: '通过美甲师申请', content: '确认允许该美甲师加入当前门店吗?' })
if (!result.confirm) return
await this.submitReview(id, () => employeesApi.approveApplication(id), '申请已通过')
if (!id || this.data.reviewingId || this.data.associationLoading) return
this.setData({
associationApplicationId: String(id),
associationKeyword: '',
associationSelectedId: '',
associationSheetVisible: true
})
await this.loadApprovalArtists()
},
async loadApprovalArtists() {
const applicationId = this.data.associationApplicationId
if (!applicationId || this.data.associationLoading) return
this.setData({ associationLoading: true, associationError: '' })
try {
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
const data = await employeesApi.unboundArtists(applicationId)
const artists = (Array.isArray(data) ? data : []).map(item => ({
id: item.userId || item.id,
name: item.nickname || item.name || '未命名美甲师',
avatar: item.avatar || ''
}))
const selectedId = application && application.targetArtistUserId
? String(application.targetArtistUserId)
: ''
this.setData({
associationArtists: artists,
associationSelectedId: selectedId,
associationItems: this.filterApprovalArtists(artists, this.data.associationKeyword)
})
if (!artists.length) {
this.setData({ associationSheetVisible: false })
await confirmModal({
title: '暂时无法通过',
content: '当前门店没有未关联微信的美甲师档案,请先新增美甲师,再审核这条申请。',
confirmText: '知道了',
showCancel: false
})
}
} catch (error) {
this.setData({ associationError: error.message || '未关联美甲师加载失败' })
} finally {
this.setData({ associationLoading: false })
}
},
filterApprovalArtists(artists, keywordValue) {
const keyword = String(keywordValue || '').trim().toLowerCase()
return (artists || [])
.filter(item => !keyword || String(item.name || '').toLowerCase().includes(keyword))
.map(item => ({
id: item.id,
title: item.name,
subtitle: '当前门店 · 尚未关联微信登录',
avatar: item.avatar,
badge: '可关联'
}))
},
onApprovalSearch(event) {
const associationKeyword = event.detail.value || ''
this.setData({
associationKeyword,
associationItems: this.filterApprovalArtists(this.data.associationArtists, associationKeyword)
})
},
closeApprovalAssociation() {
if (this.data.associationLoading || this.data.reviewingId) return
this.setData({ associationSheetVisible: false })
},
async selectApprovalArtist(event) {
const artist = event.detail && event.detail.item
const applicationId = this.data.associationApplicationId
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
if (!artist || !application || this.data.reviewingId) return
this.setData({ associationSelectedId: String(artist.id) })
},
async confirmApprovalAssociation() {
const applicationId = this.data.associationApplicationId
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
const artist = this.data.associationArtists.find(item => String(item.id) === String(this.data.associationSelectedId))
if (!artist || !application || this.data.reviewingId) {
wx.showToast({ title: '请选择要关联的美甲师', icon: 'none' })
return
}
const useApplicantNickname = application.applicantNickname
? await this.askProfileAdoption('昵称', application.applicantNickname)
: false
const useApplicantAvatar = application.applicantAvatar
? await this.askProfileAdoption('头像', '已通过内容审核的申请头像')
: false
const summary = [
`关联到:${artist.name || '所选美甲师'}`,
useApplicantNickname ? '采用申请昵称' : '保留门店姓名',
useApplicantAvatar ? '采用申请头像' : '保留门店头像'
].join('\n')
const confirmed = await confirmModal({ title: '确认关联并通过', content: summary, confirmText: '确认通过' })
if (!confirmed.confirm) return
this.setData({ associationSheetVisible: false })
await this.submitReview(applicationId, () => employeesApi.approveApplication(applicationId, {
targetArtistUserId: artist.id,
useApplicantNickname,
useApplicantAvatar
}), '申请已通过')
},
askProfileAdoption(field, value) {
return confirmModal({
title: `采用申请${field}?`,
content: field === '昵称' ? `申请昵称为“${value}”,采用后会替换门店员工姓名。` : '采用后会替换门店员工当前头像。',
confirmText: `采用申请${field}`,
cancelText: `保留门店${field}`
}).then(result => Boolean(result.confirm))
},
async rejectApplication(event) {
+4 -1
View File
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "美甲师"
"navigationBarTitleText": "美甲师",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index"
}
}
+54 -21
View File
@@ -1,20 +1,18 @@
const assert = require('assert')
const modalChoices = []
const toasts = []
const modals = []
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
setStorageSync: () => {},
removeStorageSync: () => {}
}
const appMock = {
globalData: {
userInfo: { type: 2 },
openEmployeeReview: true
showToast: options => toasts.push(options.title),
showModal: options => {
modals.push(options)
options.success({ confirm: modalChoices.shift() !== false })
}
}
global.getApp = () => appMock
global.getApp = () => ({ globalData: { userInfo: { type: 2 }, openEmployeeReview: false } })
let definition
global.Page = value => { definition = value }
@@ -24,26 +22,61 @@ function createPage() {
return {
...definition,
data: { ...definition.data, isManager: true },
setData(values) { Object.assign(this.data, values) }
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) {
target[parts[index]] = target[parts[index]] || {}
target = target[parts[index]]
}
target[parts[parts.length - 1]] = value
})
}
}
}
async function run() {
const employeesApi = require('../../api/employees')
employeesApi.reviewApplications = async () => [{
const planningApi = require('../../api/planning')
const application = {
id: 12,
applicationNo: 'SALON-001',
applicantNickname: '小周',
createTime: '2026-10-12T10:30:00'
}]
applicantNickname: '微信昵称',
applicantAvatar: 'https://example.test/avatar.png',
targetArtistUserId: 22
}
employeesApi.reviewApplications = async () => [application]
employeesApi.unboundArtists = async () => [
{ userId: 22, nickname: '门店员工A', avatar: '/staff-a.png' },
{ userId: 23, nickname: '门店员工B' }
]
employeesApi.list = async () => []
planningApi.calendar = async () => ({ appointments: [], artists: [] })
let submitted
employeesApi.approveApplication = async (id, payload) => { submitted = { id, payload } }
const page = createPage()
await page.onShow()
page.data.reviewApplications = [application]
await page.approveApplication({ currentTarget: { dataset: { id: 12 } } })
assert.strictEqual(page.data.associationSheetVisible, true)
assert.strictEqual(page.data.associationSelectedId, '22')
assert.deepStrictEqual(page.data.associationItems.map(item => item.title), ['门店员工A', '门店员工B'])
assert.strictEqual(appMock.globalData.openEmployeeReview, false)
assert.strictEqual(page.data.reviewExpanded, true)
assert.strictEqual(page.data.reviewPendingCount, 1)
assert.strictEqual(page.data.reviewApplications[0].applicationTimeText, '2026-10-12 10:30')
modalChoices.push(true, false, true)
await page.confirmApprovalAssociation()
assert.deepStrictEqual(submitted, {
id: '12',
payload: { targetArtistUserId: 22, useApplicantNickname: true, useApplicantAvatar: false }
})
assert.strictEqual(page.data.associationSheetVisible, false)
assert.strictEqual(page.data.reviewingId, '')
assert(toasts.includes('申请已通过'))
employeesApi.unboundArtists = async () => []
page.data.reviewApplications = [application]
await page.approveApplication({ currentTarget: { dataset: { id: 12 } } })
assert.strictEqual(page.data.associationSheetVisible, false)
assert(modals.some(item => String(item.content || '').includes('当前门店没有未关联微信的美甲师档案')))
}
run().catch(error => {
+20 -1
View File
@@ -22,7 +22,8 @@
<view wx:for="{{reviewApplications}}" wx:key="id" class="review-item">
<image class="review-avatar" src="{{item.applicantAvatar || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image>
<view class="review-info">
<text class="review-name">{{item.applicantNickname}}</text>
<text class="review-name">{{item.applicantDisplayName}}</text>
<text wx:if="{{item.targetArtistUserId}}" class="review-meta">已预关联美甲师</text>
<text wx:if="{{item.applicantMaskedPhone}}" class="review-meta">{{item.applicantMaskedPhone}}</text>
<text class="review-meta">{{item.shopName || '当前门店'}} · {{item.applicationTimeText}}</text>
<text class="review-number">申请编号 {{item.applicationNo}}</text>
@@ -57,4 +58,22 @@
</view>
</view>
<entity-selector-sheet
visible="{{associationSheetVisible}}"
title="选择要关联的美甲师"
keyword="{{associationKeyword}}"
placeholder="搜索美甲师姓名"
items="{{associationItems}}"
selected-id="{{associationSelectedId}}"
loading="{{associationLoading}}"
error-text="{{associationError}}"
empty-text="没有匹配的未关联美甲师"
action-text="确认关联并通过"
bind:search="onApprovalSearch"
bind:select="selectApprovalArtist"
bind:action="confirmApprovalAssociation"
bind:retry="loadApprovalArtists"
bind:close="closeApprovalAssociation"
/>
</view>
+18 -1
View File
@@ -4,7 +4,7 @@ Page({
data: {
step: 1,
role: 'manager',
form: { shopName: '', shopAddress: '', shopId: '' },
form: { shopName: '', shopAddress: '', shopId: '', applicantNickname: '', applicantAvatarFileId: '', applicantAvatarUrl: '' },
registrationTicket: '',
applicationId: '',
shopOptions: [],
@@ -15,6 +15,7 @@ Page({
shopError: '',
selectedShopName: '',
loading: false,
avatarUploading: false,
ticketInvalid: false
},
@@ -49,6 +50,20 @@ Page({
},
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
async chooseApplicantAvatar(event) {
try {
const filePath = event && event.detail ? event.detail.avatarUrl : ''
if (!filePath) return
this.setData({ avatarUploading: true })
const result = await authApi.uploadRegistrationAvatar(this.data.registrationTicket, filePath)
this.setData({ 'form.applicantAvatarFileId': result.fileId || result.id, 'form.applicantAvatarUrl': filePath })
} catch (error) {
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
} finally {
this.setData({ avatarUploading: false })
}
},
selectRole(event) { this.setData({ role: event.currentTarget.dataset.role }) },
continueFromRole() { if (!this.data.ticketInvalid) this.setData({ step: 2 }) },
@@ -101,6 +116,8 @@ Page({
shopAddress: String(form.shopAddress || '').trim(),
shopId: form.shopId || undefined,
roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF',
applicantNickname: this.data.role === 'staff' ? String(form.applicantNickname || '').trim() || undefined : undefined,
applicantAvatarFileId: this.data.role === 'staff' ? form.applicantAvatarFileId || undefined : undefined,
agreementAccepted: true
})
this.setData({ step: 3, registrationTicket: '' })
+1 -1
View File
@@ -3,7 +3,7 @@
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>选择身份</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>门店资料</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>等待审核</label></view></view>
<view wx:if="{{ticketInvalid}}" class="card result-card"><view class="result-icon">!</view><view class="section-title">申请入口已失效</view><view class="section-desc">请返回登录页重新点击微信快捷登录,获取新的申请凭证。</view><button class="primary-btn" bindtap="back">返回登录</button></view>
<view wx:elif="{{step === 1}}" class="card form-card"><view class="section-title">选择工作身份</view><view class="section-desc">无需手机号和密码,审核人会根据你的身份处理申请</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="请输入门店地址" /></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核,昵称和头像均为可选资料'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="请输入门店地址" /></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">申请昵称(选填)</text><input type="nickname" value="{{form.applicantNickname}}" data-field="applicantNickname" bindinput="onInput" placeholder="可填写希望展示的昵称" /></view><view wx:if="{{role === 'staff'}}" class="field avatar-pick-field"><text class="field-label">申请头像(选填)</text><button class="avatar-pick" open-type="chooseAvatar" bindchooseavatar="chooseApplicantAvatar"><image src="{{form.applicantAvatarUrl || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image><text>{{avatarUploading ? '上传中...' : '主动选择头像'}}</text></button></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" disabled="{{avatarUploading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 3}}" class="card result-card"><view class="result-icon">✓</view><view class="section-title">申请已提交</view><view class="section-desc">{{role === 'manager' ? '平台管理员审核通过后,即可使用快捷登录。' : '店长审核通过后,即可使用快捷登录。'}}</view><view class="result-status">当前状态:<text>等待审核</text></view><button class="primary-btn" bindtap="back">返回登录</button></view>
<entity-selector-sheet visible="{{shopSheetVisible}}" title="选择门店" keyword="{{shopKeyword}}" placeholder="搜索门店名称或地址" items="{{shopSelectorItems}}" selected-id="{{form.shopId}}" loading="{{shopLoading}}" error-text="{{shopError}}" empty-text="暂无匹配门店" bind:search="onShopSearch" bind:select="selectShop" bind:retry="loadShops" bind:close="closeShopSheet" />
<view class="safe-note">OpenID 仅用于识别你的微信身份,不会在页面中展示。</view>
+16
View File
@@ -256,3 +256,19 @@
.result-status { margin-top: 28rpx; padding: 18rpx 28rpx; border-radius: 12rpx; background: #e5f4ed; color: #75887b; font-size: 24rpx; }
.result-status text { color: #c28b47; font-weight: 700; }
.safe-note { margin-top: 28rpx; color: #9aa9a0; font-size: 21rpx; line-height: 1.5; text-align: center; }
.avatar-pick-field { margin-top: 26rpx; }
.avatar-pick {
display: flex;
align-items: center;
width: 100%;
height: 104rpx;
padding: 0 20rpx;
border: 1rpx solid #dfe9e1;
border-radius: 14rpx;
background: #f3f7f4;
color: #4d7660;
font-size: 25rpx;
text-align: left;
}
.avatar-pick::after { border: 0; }
.avatar-pick image { width: 72rpx; height: 72rpx; margin-right: 20rpx; border-radius: 50%; background: #e5f4ed; }
+9 -3
View File
@@ -23,9 +23,14 @@ function preserveResponseId(rawText, payload) {
if (!payload || typeof payload !== 'object' || !payload.data || typeof payload.data !== 'object') {
return payload
}
const match = String(rawText || '').match(/"id"\s*:\s*"?(\d+)"?/)
if (match && match[1]) {
payload.data.id = match[1]
const raw = String(rawText || '')
const idMatch = raw.match(/"id"\s*:\s*"?(\d+)"?/)
if (idMatch && idMatch[1]) {
payload.data.id = idMatch[1]
}
const fileIdMatch = raw.match(/"fileId"\s*:\s*"?(\d+)"?/)
if (fileIdMatch && fileIdMatch[1]) {
payload.data.fileId = fileIdMatch[1]
}
return payload
}
@@ -110,6 +115,7 @@ function uploadProfileImage(filePath) {
}
module.exports = {
uploadFile,
chooseImageFilePath,
uploadObjectFile,
uploadProfileImage
+37
View File
@@ -0,0 +1,37 @@
const assert = require('assert')
global.API_DOMAIN = 'http://127.0.0.1/api'
global.REQUEST_TIMEOUT = 1000
global.ENABLE_REQUEST_SIGNING = false
let uploadOptions
global.wx = {
getStorageSync: () => ({}),
uploadFile(options) {
uploadOptions = options
options.success({
statusCode: 200,
data: '{"code":200,"data":{"fileId":9223372036854775001,"id":9223372036854775002}}'
})
}
}
const { uploadFile } = require('./upload')
async function run() {
const result = await uploadFile({
url: '/user/workbench/register/avatar',
filePath: '/tmp/avatar.png',
name: 'file',
formData: { registrationTicket: 'ticket' }
})
assert.strictEqual(uploadOptions.url, 'http://127.0.0.1:80/api/user/workbench/register/avatar')
assert.strictEqual(result.fileId, '9223372036854775001')
assert.strictEqual(result.id, '9223372036854775002')
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
@@ -88,6 +88,7 @@ MessageHub 的地址、交换机、路由和来源系统放在对应环境 `core
- 初始化 SQL 已包含注册审核表、短信供应商种子、员工审核提醒参数及补单相关字段;已部署数据库不得直接重跑完整初始化脚本。
- 内容审核代码同时提供 DEV 本地确定性 mock 和微信 Provider。当前 DEV 配置使用 mock,未命中模拟标记时默认通过;可用显式标记覆盖通过、拒绝、待复核和故障结果。SIT/PROD 默认 fail-closed;只有在目标环境完成微信资质、回调域名、隐私指引和 Nacos 敏感配置后,才可将 Provider 切换为 `wechat`。微信 Provider 通过统一客户端缓存 access_token,图片审核使用对象存储短时 HTTPS 地址并由加密回调更新,业务模块不得直接调用微信接口。审核数据库变更依次由 Flyway V2(审核结构和存量复审)、V3(存量数据安全修正与协议版本)、V4(门店存量逐图任务完整性校验)和 V5(美甲师资料审核状态及存量资料隔离)管理。V5 对标签 ID 匹配显式统一到 `utf8mb4_unicode_ci`,并对可能在失败前已落库的字段和索引做存在性检查。MySQL 上失败的迁移需先核对部分 DDL,再运行 Flyway `repair` 清理失败历史记录;`repair` 不会撤销已执行的 DDL。具体参数和密钥维护说明见 `docs/scripts/Salon合规整改配置说明_20261021.md`。
- 店长审核模式和新店经营有效期通过 `t_system_parameter_config` 管理;Flyway V6 增加门店有效期字段、店长申请内容审核关联和默认参数,V7 修复无效默认天数并补齐已有门店的空有效期。自动批准仅在绑定的门店资料内容审核通过后生效;过期或未配置有效期的门店不能新增普通预约,补录和查询仍可用。参数默认值、发布验证和业务边界见 `docs/scripts/Salon店长审核与门店有效期配置说明_20261026.md`。
- Flyway V8 增加客户联系方式组合去重和美甲师专属颜色;V9 增加美甲师注册申请与门店员工档案的预关联字段,以及待审核目标员工唯一索引。V9 审核通过时将申请人的微信身份转移到已选员工档案,未关联员工不允许通过手机号登录;头像经注册票据受限上传并通过内容审核后才展示。两个迁移均为向前兼容版本 SQL,不修改初始化 SQL。
## 8. 操作前检查
+9
View File
@@ -1,5 +1,14 @@
# 项目变更记录
## 2026-10-30 Salon 美甲师注册申请与员工微信账号关联
- 店长新增美甲师时创建无登录账号的员工档案,保留排班、预约和业绩使用的员工 ID;新增后可从本店待审核申请中选择并预关联,稍后仍可在审核时处理。
- 店长审核美甲师申请时必须选择本店未关联微信的美甲师;审核通过在事务内转移申请人的 OpenID,支持分别采用申请昵称/头像或保留门店资料,驳回会释放预关联目标。
- 注册页增加主动选择昵称和头像;头像通过带注册票据的受限上传接口提交,内容审核通过前不向审核列表返回原始昵称和头像。
- 未关联登录身份的美甲师档案禁止通过手机号登录、手机号授权或过期的选店登录票据冒用;关联完成后沿用原员工档案 ID,不迁移排班、预约和业绩数据。
- 新增 Flyway `JC-Salon-Core/src/main/resources/db/migration/V9__美甲师注册申请目标员工关联_20261030.sql`,为注册申请增加目标员工、申请昵称和头像文件字段,并通过待审核目标员工唯一索引防止并发占用;脚本可重复执行。
- 小程序 API 路由继续使用 `/api` 业务前缀,不复用后台 `/api/admin`;新增上传 ID 的字符串保真测试,避免雪花 ID 在 JavaScript 中丢失精度。
## 2026-10-29 Salon 客户建档与员工默认排班优化
- 规划日视图时间轴放大为每分钟4rpx,使30分钟预约卡片获得完整信息高度;收紧日期控制区和视图切换区的垂直留白。