实现Salon工作台注册审核闭环
This commit is contained in:
@@ -45,6 +45,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
"/user/send-verification-code",
|
||||
"/user/phone-login",
|
||||
"/user/wechat-mini/**",
|
||||
"/user/workbench/register/**",
|
||||
"/user/workbench/shops/available",
|
||||
"/user/reset-password-by-phone",
|
||||
"/legal-agreement/current",
|
||||
"/legal-agreement/current/**",
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiaowang.jacyucloudsalon.core.common.Result;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRejectDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRequestDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.service.WorkbenchRegistrationService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/workbench")
|
||||
public class WorkbenchRegistrationController {
|
||||
private final WorkbenchRegistrationService registrationService;
|
||||
private final UserMapper userMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
|
||||
public WorkbenchRegistrationController(WorkbenchRegistrationService registrationService, UserMapper userMapper, ShopMapper shopMapper) {
|
||||
this.registrationService = registrationService;
|
||||
this.userMapper = userMapper;
|
||||
this.shopMapper = shopMapper;
|
||||
}
|
||||
|
||||
@PostMapping("/register/phone")
|
||||
public Result<WorkbenchRegistrationStatusVO> registerByPhone(@RequestBody WorkbenchRegistrationRequestDTO request) {
|
||||
return Result.success(registrationService.register(request));
|
||||
}
|
||||
|
||||
@GetMapping("/register/status")
|
||||
public Result<WorkbenchRegistrationStatusVO> status(@RequestParam String phone) {
|
||||
UserDO user = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class).eq(UserDO::getPhone, phone).eq(UserDO::getIsDelete, 0).last("limit 1"));
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("未找到注册申请");
|
||||
}
|
||||
return Result.success(registrationService.getStatus(user.getId()));
|
||||
}
|
||||
|
||||
@GetMapping("/shops/available")
|
||||
public Result<List<ShopDO>> availableShops() {
|
||||
return Result.success(shopMapper.selectList(Wrappers.lambdaQuery(ShopDO.class).eq(ShopDO::getStatus, 1).eq(ShopDO::getIsDelete, 0).select(ShopDO::getId, ShopDO::getShopName, ShopDO::getAddress).orderByAsc(ShopDO::getShopName)));
|
||||
}
|
||||
|
||||
@GetMapping("/registration/list")
|
||||
public Result<List<WorkbenchRegistrationApplicationDO>> list(HttpServletRequest request) {
|
||||
Long userId = requireUserId(request);
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
return Result.success(registrationService.listForReviewer(userId, user != null && Integer.valueOf(4).equals(user.getType())));
|
||||
}
|
||||
|
||||
@PostMapping("/registration/{id}/approve")
|
||||
public Result<Boolean> approve(HttpServletRequest request, @PathVariable Long id) {
|
||||
Long userId = requireUserId(request);
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
return Result.success(registrationService.approve(userId, user != null && Integer.valueOf(4).equals(user.getType()), id));
|
||||
}
|
||||
|
||||
@PostMapping("/registration/{id}/reject")
|
||||
public Result<Boolean> reject(HttpServletRequest request, @PathVariable Long id, @RequestBody WorkbenchRegistrationRejectDTO requestDTO) {
|
||||
Long userId = requireUserId(request);
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
return Result.success(registrationService.reject(userId, user != null && Integer.valueOf(4).equals(user.getType()), id, requestDTO == null ? null : requestDTO.getReason()));
|
||||
}
|
||||
|
||||
private Long requireUserId(HttpServletRequest request) {
|
||||
Object userId = request.getAttribute("userId");
|
||||
if (!(userId instanceof Long)) {
|
||||
throw new IllegalArgumentException("登录状态已失效");
|
||||
}
|
||||
return (Long) userId;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class WorkbenchRegistrationRejectDTO {
|
||||
private String reason;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class WorkbenchRegistrationRequestDTO {
|
||||
private String phone;
|
||||
private String verificationCode;
|
||||
private String password;
|
||||
private String confirmPassword;
|
||||
private String roleType;
|
||||
private Long shopId;
|
||||
private String shopName;
|
||||
private String shopAddress;
|
||||
private Boolean agreementAccepted;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.xiaowang.jacyucloudsalon.core.common.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("t_workbench_registration_application")
|
||||
public class WorkbenchRegistrationApplicationDO extends BaseEntity {
|
||||
|
||||
@TableField("application_no")
|
||||
private String applicationNo;
|
||||
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
@TableField("role_type")
|
||||
private String roleType;
|
||||
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
|
||||
@TableField("shop_name")
|
||||
private String shopName;
|
||||
|
||||
@TableField("shop_address")
|
||||
private String shopAddress;
|
||||
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@TableField("reviewer_id")
|
||||
private Long reviewerId;
|
||||
|
||||
@TableField("reviewed_at")
|
||||
private LocalDateTime reviewedAt;
|
||||
|
||||
@TableField("reject_reason")
|
||||
private String rejectReason;
|
||||
|
||||
@TableField("is_delete")
|
||||
private Integer isDelete;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.entity;
|
||||
|
||||
public final class WorkbenchRegistrationRole {
|
||||
public static final String MANAGER = "MANAGER";
|
||||
public static final String STAFF = "STAFF";
|
||||
|
||||
private WorkbenchRegistrationRole() {
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.entity;
|
||||
|
||||
public final class WorkbenchRegistrationStatus {
|
||||
public static final String PENDING_ADMIN = "PENDING_ADMIN";
|
||||
public static final String PENDING_MANAGER = "PENDING_MANAGER";
|
||||
public static final String APPROVED = "APPROVED";
|
||||
public static final String REJECTED = "REJECTED";
|
||||
|
||||
private WorkbenchRegistrationStatus() {
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
|
||||
public interface WorkbenchRegistrationApplicationMapper extends BaseMapper<WorkbenchRegistrationApplicationDO> {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.service;
|
||||
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRequestDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface WorkbenchRegistrationService {
|
||||
WorkbenchRegistrationStatusVO register(WorkbenchRegistrationRequestDTO request);
|
||||
WorkbenchRegistrationStatusVO getStatus(Long userId);
|
||||
List<WorkbenchRegistrationApplicationDO> listForReviewer(Long reviewerId, boolean platformAdmin);
|
||||
boolean approve(Long reviewerId, boolean platformAdmin, Long applicationId);
|
||||
boolean reject(Long reviewerId, boolean platformAdmin, Long applicationId, String reason);
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.VerificationCodeService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRequestDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationRole;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationStatus;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.mapper.WorkbenchRegistrationApplicationMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.service.WorkbenchRegistrationService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.support.UserShopBindingSupport;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.service.UserService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationService {
|
||||
private static final String REGISTER_SCENE = "PLANNING_MANAGER_REGISTER";
|
||||
private final WorkbenchRegistrationApplicationMapper applicationMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
private final UserService userService;
|
||||
private final VerificationCodeService verificationCodeService;
|
||||
private final UserShopBindingSupport userShopBindingSupport;
|
||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
|
||||
public WorkbenchRegistrationServiceImpl(
|
||||
WorkbenchRegistrationApplicationMapper applicationMapper,
|
||||
UserMapper userMapper,
|
||||
ShopMapper shopMapper,
|
||||
UserService userService,
|
||||
VerificationCodeService verificationCodeService,
|
||||
UserShopBindingSupport userShopBindingSupport
|
||||
) {
|
||||
this.applicationMapper = applicationMapper;
|
||||
this.userMapper = userMapper;
|
||||
this.shopMapper = shopMapper;
|
||||
this.userService = userService;
|
||||
this.verificationCodeService = verificationCodeService;
|
||||
this.userShopBindingSupport = userShopBindingSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WorkbenchRegistrationStatusVO register(WorkbenchRegistrationRequestDTO request) {
|
||||
require(request != null, "注册信息不能为空");
|
||||
String phone = requireText(request.getPhone(), "手机号不能为空");
|
||||
String roleType = requireText(request.getRoleType(), "请选择注册身份").toUpperCase();
|
||||
require(WorkbenchRegistrationRole.MANAGER.equals(roleType) || WorkbenchRegistrationRole.STAFF.equals(roleType), "注册身份不合法");
|
||||
require(verificationCodeService.verifyCode(phone, request.getVerificationCode()), "验证码错误或已过期");
|
||||
require(request.getAgreementAccepted() == null || request.getAgreementAccepted(), "请先同意用户协议和隐私政策");
|
||||
UserDO existing = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class).eq(UserDO::getPhone, phone).eq(UserDO::getIsDelete, 0).last("limit 1"));
|
||||
require(existing == null, "该手机号已注册,请直接登录或查看审核状态");
|
||||
require(StringUtils.hasText(request.getPassword()), "密码不能为空");
|
||||
require(request.getPassword().equals(request.getConfirmPassword()), "两次密码不一致");
|
||||
|
||||
ShopDO shop = null;
|
||||
if (WorkbenchRegistrationRole.MANAGER.equals(roleType)) {
|
||||
String shopName = requireText(request.getShopName(), "店铺名称不能为空");
|
||||
shop = new ShopDO();
|
||||
shop.setShopName(shopName);
|
||||
shop.setAddress(request.getShopAddress());
|
||||
shop.setDescription("Salon店务工作台注册申请");
|
||||
shop.setBusinessHours("10:00-22:00");
|
||||
shop.setStatus(0);
|
||||
shop.setIsDelete(0);
|
||||
shopMapper.insert(shop);
|
||||
} else {
|
||||
require(request.getShopId() != null, "请选择要加入的店铺");
|
||||
shop = shopMapper.selectOne(Wrappers.lambdaQuery(ShopDO.class).eq(ShopDO::getId, request.getShopId()).eq(ShopDO::getStatus, 1).eq(ShopDO::getIsDelete, 0));
|
||||
require(shop != null, "店铺不存在或暂未营业");
|
||||
}
|
||||
|
||||
UserDO user = new UserDO();
|
||||
user.setShopId(shop.getId());
|
||||
user.setNickname((WorkbenchRegistrationRole.MANAGER.equals(roleType) ? shop.getShopName() + "店长" : "Salon店员"));
|
||||
user.setAccount(phone);
|
||||
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
user.setPhone(phone);
|
||||
user.setContactPhone(phone);
|
||||
user.setPhoneVerified(1);
|
||||
user.setType(WorkbenchRegistrationRole.MANAGER.equals(roleType) ? 2 : 3);
|
||||
user.setStatus(0);
|
||||
user.setIsDelete(0);
|
||||
userMapper.insert(user);
|
||||
userShopBindingSupport.syncUserShopBindings(user.getId(), List.of(shop.getId()));
|
||||
userShopBindingSupport.updateBindingStatus(user.getId(), shop.getId(), 0);
|
||||
|
||||
WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO();
|
||||
application.setApplicationNo("SALON-" + UUID.randomUUID().toString().replace("-", "").substring(0, 20).toUpperCase());
|
||||
application.setUserId(user.getId());
|
||||
application.setRoleType(roleType);
|
||||
application.setShopId(shop.getId());
|
||||
application.setShopName(shop.getShopName());
|
||||
application.setShopAddress(shop.getAddress());
|
||||
application.setStatus(WorkbenchRegistrationRole.MANAGER.equals(roleType) ? WorkbenchRegistrationStatus.PENDING_ADMIN : WorkbenchRegistrationStatus.PENDING_MANAGER);
|
||||
application.setIsDelete(0);
|
||||
applicationMapper.insert(application);
|
||||
return toStatus(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbenchRegistrationStatusVO getStatus(Long userId) {
|
||||
WorkbenchRegistrationApplicationDO application = findLatest(userId);
|
||||
require(application != null, "未找到注册申请");
|
||||
return toStatus(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkbenchRegistrationApplicationDO> listForReviewer(Long reviewerId, boolean platformAdmin) {
|
||||
if (platformAdmin) {
|
||||
return applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
}
|
||||
UserDO reviewer = userMapper.selectById(reviewerId);
|
||||
require(reviewer != null && Integer.valueOf(2).equals(reviewer.getType()), "仅店长可以审核店员申请");
|
||||
return applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER).eq(WorkbenchRegistrationApplicationDO::getShopId, reviewer.getShopId()).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean approve(Long reviewerId, boolean platformAdmin, Long applicationId) {
|
||||
WorkbenchRegistrationApplicationDO application = loadReviewable(reviewerId, platformAdmin, applicationId);
|
||||
UserDO user = userMapper.selectById(application.getUserId());
|
||||
require(user != null, "申请用户不存在");
|
||||
if (WorkbenchRegistrationRole.MANAGER.equals(application.getRoleType())) {
|
||||
require(platformAdmin && WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus()), "无权审核该申请");
|
||||
ShopDO shop = shopMapper.selectById(application.getShopId());
|
||||
require(shop != null, "申请店铺不存在");
|
||||
shop.setStatus(1);
|
||||
shopMapper.updateById(shop);
|
||||
}
|
||||
user.setStatus(1);
|
||||
userMapper.updateById(user);
|
||||
userShopBindingSupport.updateBindingStatus(user.getId(), application.getShopId(), 1);
|
||||
userService.syncManagedPermissions(user.getId());
|
||||
application.setStatus(WorkbenchRegistrationStatus.APPROVED);
|
||||
application.setReviewerId(reviewerId);
|
||||
application.setReviewedAt(LocalDateTime.now());
|
||||
applicationMapper.updateById(application);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean reject(Long reviewerId, boolean platformAdmin, Long applicationId, String reason) {
|
||||
WorkbenchRegistrationApplicationDO application = loadReviewable(reviewerId, platformAdmin, applicationId);
|
||||
application.setStatus(WorkbenchRegistrationStatus.REJECTED);
|
||||
application.setReviewerId(reviewerId);
|
||||
application.setReviewedAt(LocalDateTime.now());
|
||||
application.setRejectReason(requireText(reason, "驳回原因不能为空"));
|
||||
applicationMapper.updateById(application);
|
||||
return true;
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationApplicationDO loadReviewable(Long reviewerId, boolean platformAdmin, Long applicationId) {
|
||||
WorkbenchRegistrationApplicationDO application = applicationMapper.selectById(applicationId);
|
||||
require(application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus()) == false, "审核申请不存在或已处理");
|
||||
if (platformAdmin) {
|
||||
require(WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus()), "管理员只能审核店长申请");
|
||||
} else {
|
||||
UserDO reviewer = userMapper.selectById(reviewerId);
|
||||
require(reviewer != null && Integer.valueOf(2).equals(reviewer.getType()) && reviewer.getShopId().equals(application.getShopId()), "无权审核该店铺申请");
|
||||
require(WorkbenchRegistrationStatus.PENDING_MANAGER.equals(application.getStatus()), "店长只能审核店员申请");
|
||||
}
|
||||
return application;
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationApplicationDO findLatest(Long userId) {
|
||||
return applicationMapper.selectOne(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getUserId, userId).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByDesc(WorkbenchRegistrationApplicationDO::getCreateTime).last("limit 1"));
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationStatusVO toStatus(WorkbenchRegistrationApplicationDO application) {
|
||||
return new WorkbenchRegistrationStatusVO(application.getId(), application.getApplicationNo(), application.getRoleType(), application.getStatus(), application.getRejectReason(), application.getShopId(), application.getShopName());
|
||||
}
|
||||
|
||||
private String requireText(String value, String message) {
|
||||
require(StringUtils.hasText(value), message);
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
private void require(boolean condition, String message) {
|
||||
if (!condition) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class WorkbenchRegistrationStatusVO {
|
||||
private Long applicationId;
|
||||
private String applicationNo;
|
||||
private String roleType;
|
||||
private String status;
|
||||
private String rejectReason;
|
||||
private Long shopId;
|
||||
private String shopName;
|
||||
}
|
||||
@@ -1972,5 +1972,30 @@ export const adminSystemParameterConfigApi = {
|
||||
}
|
||||
}
|
||||
|
||||
export interface WorkbenchRegistrationApplication {
|
||||
id: IdType
|
||||
applicationNo: string
|
||||
userId: IdType
|
||||
roleType: 'MANAGER' | 'STAFF'
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
shopAddress?: string
|
||||
status: 'PENDING_ADMIN' | 'PENDING_MANAGER' | 'APPROVED' | 'REJECTED'
|
||||
rejectReason?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
export const adminWorkbenchRegistrationApi = {
|
||||
list() {
|
||||
return adminApi.get<WorkbenchRegistrationApplication[]>('/user/workbench/registration/list') as unknown as Promise<WorkbenchRegistrationApplication[]>
|
||||
},
|
||||
approve(id: IdType) {
|
||||
return adminApi.post<boolean>(`/user/workbench/registration/${id}/approve`)
|
||||
},
|
||||
reject(id: IdType, reason: string) {
|
||||
return adminApi.post<boolean>(`/user/workbench/registration/${id}/reject`, { reason })
|
||||
}
|
||||
}
|
||||
|
||||
export { adminApi }
|
||||
export default adminApi
|
||||
|
||||
@@ -25,6 +25,7 @@ export const ADMIN_DASHBOARD_PATH = '/admin/dashboard'
|
||||
export const adminNavigationItems: AdminNavigationItem[] = [
|
||||
{ path: ADMIN_HOME_PATH, iconKey: 'home', label: '首页', permissionCode: '' },
|
||||
{ path: '/admin/users', iconKey: 'user', label: '店长账号', permissionCode: 'user:view' },
|
||||
{ path: '/admin/registrations', iconKey: 'team', label: '注册审核', permissionCode: 'user:view' },
|
||||
{ path: '/admin/shops', iconKey: 'home', label: '店铺管理', permissionCode: 'shop:view' },
|
||||
{ path: '/admin/settings', iconKey: 'tool', label: '系统设置', permissionCode: 'messagehub:config:manage' },
|
||||
{ path: '/admin/profile', iconKey: 'user', label: '个人设置', permissionCode: '' }
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
|
||||
const pageNames = [
|
||||
['', 'HomeView', 'admin', undefined],
|
||||
['users', 'UsersView', 'admin-users', 'user:view'], ['shops', 'ShopsView', 'admin-shops', 'shop:view'],
|
||||
['users', 'UsersView', 'admin-users', 'user:view'], ['registrations', 'WorkbenchRegistrationView', 'admin-registrations', 'user:view'], ['shops', 'ShopsView', 'admin-shops', 'shop:view'],
|
||||
['profile', 'ProfileView', 'admin-profile', undefined], ['settings', 'SystemSettingsView', 'admin-settings', 'messagehub:config:manage']
|
||||
] as const
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ const visibleModules = computed(() => {
|
||||
{
|
||||
key: 'products',
|
||||
title: '作品管理',
|
||||
description: '维护作品、标签、可预约美甲师和优惠券。',
|
||||
description: '维护作品、标签、可预约员工和优惠券。',
|
||||
path: '/admin/products',
|
||||
icon: ShopOutlined,
|
||||
permissionCode: 'product:view',
|
||||
@@ -134,8 +134,8 @@ const visibleModules = computed(() => {
|
||||
},
|
||||
{
|
||||
key: 'artists',
|
||||
title: '美甲师',
|
||||
description: '查看状态、技能与作品挂载关系。',
|
||||
title: '员工',
|
||||
description: '查看员工状态、技能与排班关系。',
|
||||
path: '/admin/nail-artists',
|
||||
icon: TeamOutlined,
|
||||
permissionCode: 'nail_artist:view',
|
||||
|
||||
@@ -548,7 +548,7 @@ const getUserTypeText = (type: number) => {
|
||||
const map: Record<number, string> = {
|
||||
0: '用户',
|
||||
2: '店长',
|
||||
3: '美甲师',
|
||||
3: '店员',
|
||||
4: '管理员'
|
||||
}
|
||||
return map[type] || '未知'
|
||||
@@ -565,12 +565,12 @@ const filteredUserList = computed(() => {
|
||||
return userList.value.filter(user => user.type !== 0 && !sameId(user.id, currentUserId))
|
||||
}
|
||||
|
||||
// 店长只能看到美甲师(除了自己)
|
||||
// 店长只能看到店员(除了自己)
|
||||
if (currentLoginUser.value.type === 2) {
|
||||
return userList.value.filter(user => user.type === 3 && !sameId(user.id, currentUserId))
|
||||
}
|
||||
|
||||
// 其他用户类型(如美甲师)不能管理权限
|
||||
// 其他用户类型(如店员)不能管理权限
|
||||
return []
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<div class="registration-page">
|
||||
<a-page-header title="工作台注册审核" sub-title="审核店长注册申请" />
|
||||
<a-card :bordered="false">
|
||||
<a-table :columns="columns" :data-source="applications" :loading="loading" row-key="id">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'roleType'">{{ record.roleType === 'MANAGER' ? '店长' : '店员' }}</template>
|
||||
<template v-else-if="column.key === 'status'">{{ statusLabel(record.status) }}</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-space v-if="record.status === 'PENDING_ADMIN'">
|
||||
<a-button type="link" size="small" @click="approve(record.id)">通过</a-button>
|
||||
<a-button type="link" danger size="small" @click="reject(record.id)">驳回</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminWorkbenchRegistrationApi, type WorkbenchRegistrationApplication } from '@/api/admin'
|
||||
|
||||
const loading = ref(false)
|
||||
const applications = ref<WorkbenchRegistrationApplication[]>([])
|
||||
const columns = [
|
||||
{ title: '申请编号', dataIndex: 'applicationNo', key: 'applicationNo' },
|
||||
{ title: '身份', key: 'roleType' },
|
||||
{ title: '店铺', dataIndex: 'shopName', key: 'shopName' },
|
||||
{ title: '地址', dataIndex: 'shopAddress', key: 'shopAddress' },
|
||||
{ title: '状态', key: 'status' },
|
||||
{ title: '操作', key: 'action', width: 150 }
|
||||
]
|
||||
|
||||
const statusLabel = (status: string) => ({ PENDING_ADMIN: '待管理员审核', PENDING_MANAGER: '待店长审核', APPROVED: '已通过', REJECTED: '已驳回' }[status] || status)
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try { applications.value = await adminWorkbenchRegistrationApi.list() } catch (error) { message.error(error instanceof Error ? error.message : '获取注册申请失败') } finally { loading.value = false }
|
||||
}
|
||||
|
||||
const approve = async (id: string | number) => {
|
||||
await adminWorkbenchRegistrationApi.approve(id)
|
||||
message.success('申请已通过')
|
||||
await load()
|
||||
}
|
||||
|
||||
const reject = (id: string | number) => {
|
||||
const reason = window.prompt('请输入驳回原因') || ''
|
||||
if (!reason.trim()) return
|
||||
adminWorkbenchRegistrationApi.reject(id, reason).then(async () => { message.success('申请已驳回'); await load() }).catch(error => message.error(error instanceof Error ? error.message : '驳回失败'))
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
@@ -18,7 +18,7 @@ export const getAdminRoleLabel = (type?: number) => {
|
||||
case 2:
|
||||
return '店长'
|
||||
case 3:
|
||||
return '美甲师'
|
||||
return '店员'
|
||||
default:
|
||||
return '后台账号'
|
||||
}
|
||||
|
||||
@@ -19,12 +19,29 @@ module.exports = {
|
||||
|
||||
register(data) {
|
||||
return request({
|
||||
url: '/auth/register',
|
||||
url: '/user/workbench/register/phone',
|
||||
method: 'POST',
|
||||
params: { __baseUrl: API_DOMAIN },
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
getAvailableRegistrationShops() {
|
||||
return request({
|
||||
url: '/user/workbench/shops/available',
|
||||
method: 'GET',
|
||||
params: { __baseUrl: API_DOMAIN }
|
||||
})
|
||||
},
|
||||
|
||||
getRegistrationStatus(phone) {
|
||||
return request({
|
||||
url: `/user/workbench/register/status?phone=${encodeURIComponent(phone)}`,
|
||||
method: 'GET',
|
||||
params: { __baseUrl: API_DOMAIN }
|
||||
})
|
||||
},
|
||||
|
||||
sendCode(phone) {
|
||||
return request({
|
||||
url: '/user/send-verification-code',
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
"pages/schedule-setting/index",
|
||||
"pages/leave-management/index",
|
||||
"pages/color-setting/index",
|
||||
"pages/employee-orders/index",
|
||||
"pages/profile/index",
|
||||
"pages/shop-settings/index",
|
||||
"pages/export/index",
|
||||
|
||||
@@ -294,7 +294,7 @@ Page({
|
||||
draftSavedAtText: draftForm ? '已恢复本机草稿' : ''
|
||||
})
|
||||
if (!creatable) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.loadOptions()
|
||||
@@ -683,7 +683,7 @@ Page({
|
||||
|
||||
async submit() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
|
||||
@@ -68,7 +68,7 @@ Page({
|
||||
|
||||
createAppointment() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const customer = this.data.customer || {}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
<view class="card menu-card" data-url="/pages/schedule-setting/index" bindtap="go">排班设置</view>
|
||||
<view class="card menu-card" data-url="/pages/leave-management/index" bindtap="go">请假管理</view>
|
||||
<view class="card menu-card" data-url="/pages/color-setting/index" bindtap="go">颜色设置</view>
|
||||
<view class="card menu-card" data-url="/pages/employee-orders/index" bindtap="go">订单记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -441,6 +441,10 @@ Page({
|
||||
this.saveLoginPreference()
|
||||
wx.reLaunch({ url: '/pages/planning/index' })
|
||||
} catch (error) {
|
||||
if (String(error.message || '').indexOf('禁用') !== -1) {
|
||||
await this.showRegistrationStatus()
|
||||
return
|
||||
}
|
||||
if (isShopSelectionRequiredError(error)) {
|
||||
try {
|
||||
if (!this.data.shopSelectVisible) {
|
||||
@@ -457,6 +461,22 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async showRegistrationStatus() {
|
||||
try {
|
||||
const phone = this.data.loginMode === 'phone' ? this.data.form.phone : this.data.form.account
|
||||
const status = await authApi.getRegistrationStatus(String(phone || '').trim())
|
||||
const statusText = {
|
||||
PENDING_ADMIN: '管理员审核中',
|
||||
PENDING_MANAGER: '店长审核中',
|
||||
REJECTED: `申请已驳回:${status.rejectReason || '请修改资料后重新提交'}`,
|
||||
APPROVED: '账号已审核,请稍后重试登录'
|
||||
}[status.status] || '账号暂不可用'
|
||||
wx.showToast({ title: statusText, icon: 'none', duration: 3000 })
|
||||
} catch (statusError) {
|
||||
wx.showToast({ title: statusError.message || '账号已被禁用', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
goRegister() {
|
||||
wx.navigateTo({ url: '/pages/register/index' })
|
||||
},
|
||||
|
||||
@@ -406,7 +406,7 @@ Page({
|
||||
|
||||
createAppointment() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
|
||||
@@ -17,6 +17,15 @@ Page({
|
||||
countdownTimer: null
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
try {
|
||||
const shopOptions = await authApi.getAvailableRegistrationShops()
|
||||
this.setData({ shopOptions: Array.isArray(shopOptions) ? shopOptions : [] })
|
||||
} catch (error) {
|
||||
this.setData({ shopOptions: [] })
|
||||
}
|
||||
},
|
||||
|
||||
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
|
||||
|
||||
togglePasswordMode() { this.setData({ passwordMode: !this.data.passwordMode }) },
|
||||
@@ -56,7 +65,7 @@ Page({
|
||||
if (this.data.role === 'staff') { wx.showToast({ title: '店员申请功能即将开放', icon: 'none' }); return }
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
await authApi.register({ phone: form.phone, code: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, role: this.data.role })
|
||||
await authApi.register({ phone: form.phone, verificationCode: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true })
|
||||
this.setData({ step: 4 })
|
||||
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
|
||||
},
|
||||
|
||||
@@ -140,9 +140,9 @@ const BASE_DOMAIN = resolveDomain(DOMAIN_MAP, ENV_VERSION, DEVELOP_TARGET)
|
||||
const brandOverride = localOverride.brand || {}
|
||||
const BRAND_CONFIG = {
|
||||
appName: String(brandOverride.appName || '甲屿店务'),
|
||||
productName: String(brandOverride.productName || '甲屿设计师'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || '甲屿设计师'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:甲屿设计师')
|
||||
productName: String(brandOverride.productName || 'Salon'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || 'Salon'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:Salon中心店')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -4,9 +4,9 @@ module.exports = {
|
||||
enableRequestSigning: true,
|
||||
brand: {
|
||||
appName: '甲屿店务',
|
||||
productName: '甲屿设计师',
|
||||
defaultShopName: '甲屿设计师',
|
||||
registerShopPlaceholder: '例如:甲屿设计师'
|
||||
productName: 'Salon',
|
||||
defaultShopName: 'Salon',
|
||||
registerShopPlaceholder: '例如:Salon中心店'
|
||||
},
|
||||
domains: {
|
||||
local: 'http://127.0.0.1:80',
|
||||
|
||||
@@ -112,6 +112,8 @@ function isAuthFreePath(url) {
|
||||
return [
|
||||
'/auth/login',
|
||||
'/auth/register',
|
||||
'/user/workbench/register/',
|
||||
'/user/workbench/shops/available',
|
||||
'/user/send-verification-code',
|
||||
'/user/phone-login',
|
||||
'/user/check/login-shops/',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE IF NOT EXISTS `t_workbench_registration_application` (
|
||||
`id` bigint NOT NULL COMMENT '申请ID',
|
||||
`application_no` varchar(40) NOT NULL COMMENT '申请编号',
|
||||
`user_id` bigint NOT NULL COMMENT '申请用户ID',
|
||||
`role_type` varchar(20) NOT NULL COMMENT '申请身份:MANAGER/STAFF',
|
||||
`shop_id` bigint DEFAULT NULL COMMENT '目标店铺ID',
|
||||
`shop_name` varchar(120) DEFAULT NULL COMMENT '店铺名称快照',
|
||||
`shop_address` varchar(255) DEFAULT NULL COMMENT '店铺地址快照',
|
||||
`status` varchar(30) NOT NULL COMMENT '状态:PENDING_ADMIN/PENDING_MANAGER/APPROVED/REJECTED',
|
||||
`reviewer_id` bigint DEFAULT NULL COMMENT '审核人ID',
|
||||
`reviewed_at` datetime DEFAULT NULL COMMENT '审核时间',
|
||||
`reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
|
||||
`is_delete` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_workbench_registration_application_no` (`application_no`),
|
||||
KEY `idx_workbench_registration_user` (`user_id`),
|
||||
KEY `idx_workbench_registration_shop_status` (`shop_id`, `status`),
|
||||
KEY `idx_workbench_registration_status` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Salon店务工作台注册审核申请';
|
||||
Reference in New Issue
Block a user