feat: 增加店长审核模式与门店经营有效期
This commit is contained in:
+3
@@ -95,6 +95,9 @@ public class LoginResponseVO {
|
||||
* Field `shopAuthorizationExpired` (Boolean): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private Boolean shopAuthorizationExpired;
|
||||
private LocalDateTime shopBusinessExpireTime;
|
||||
private Boolean shopBusinessExpired;
|
||||
private Integer shopBusinessRemainingDays;
|
||||
@JsonSerialize(contentUsing = ToStringSerializer.class)
|
||||
/**
|
||||
* Field `shopIds` (List<Long>): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
|
||||
+6
-2
@@ -113,7 +113,9 @@ public class WechatMiniAuthServiceImpl implements WechatMiniAuthService {
|
||||
}
|
||||
WorkbenchRegistrationApplicationDO application = findLatestApplication(user.getId());
|
||||
if (application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus())) {
|
||||
return applicationState(WechatMiniLoginResultVO.STATUS_REJECTED, "申请已被驳回,可修改后重新提交", application);
|
||||
WechatMiniLoginResultVO result = registrationResult(user.getId(), sessionInfo.openId(), application);
|
||||
result.setStatus(WechatMiniLoginResultVO.STATUS_REJECTED);
|
||||
return result;
|
||||
}
|
||||
if (application != null && (WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus())
|
||||
|| WorkbenchRegistrationStatus.PENDING_MANAGER.equals(application.getStatus()))) {
|
||||
@@ -155,7 +157,9 @@ public class WechatMiniAuthServiceImpl implements WechatMiniAuthService {
|
||||
}
|
||||
WorkbenchRegistrationApplicationDO application = findLatestApplication(user.getId());
|
||||
if (application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus())) {
|
||||
return registrationResult(user.getId(), sessionInfo.openId(), application);
|
||||
WechatMiniLoginResultVO result = registrationResult(user.getId(), sessionInfo.openId(), application);
|
||||
result.setStatus(WechatMiniLoginResultVO.STATUS_REJECTED);
|
||||
return result;
|
||||
}
|
||||
if (application != null && (WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus())
|
||||
|| WorkbenchRegistrationStatus.PENDING_MANAGER.equals(application.getStatus()))) {
|
||||
|
||||
+3
@@ -22,6 +22,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.order.mapper.OrderMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.service.AppointmentCapacityService;
|
||||
@@ -90,6 +91,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
private final ProductMapper productMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final AppointmentCapacityService appointmentCapacityService;
|
||||
private final OrderService orderService;
|
||||
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
@@ -172,6 +174,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
throw new RuntimeException("美甲师账号只能查看预约,不能新建预约");
|
||||
}
|
||||
Long shopId = requirePlanningShopId(currentUser);
|
||||
shopBusinessExpiryService.assertShopActive(shopId);
|
||||
requireAppointmentDuration(dto.getDurationMinutes());
|
||||
ProductDO product = resolveAppointmentProduct(dto, shopId);
|
||||
UserDO artist = dto.getArtistId() == null ? null : requireActiveArtist(dto.getArtistId(), shopId);
|
||||
|
||||
+3
@@ -43,6 +43,9 @@ public class WorkbenchRegistrationApplicationDO extends BaseEntity {
|
||||
@TableField("reject_reason")
|
||||
private String rejectReason;
|
||||
|
||||
@TableField("content_moderation_record_id")
|
||||
private Long contentModerationRecordId;
|
||||
|
||||
@TableField("is_delete")
|
||||
private Integer isDelete;
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.registration.scheduler;
|
||||
|
||||
import com.xiaowang.jayucloud.salon.core.modules.registration.service.WorkbenchRegistrationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ManagerRegistrationModerationScheduler {
|
||||
private final WorkbenchRegistrationService registrationService;
|
||||
|
||||
@Scheduled(fixedDelay = 30000L)
|
||||
public void processPendingApplications() {
|
||||
try {
|
||||
registrationService.processPendingManagerModeration();
|
||||
} catch (RuntimeException exception) {
|
||||
log.warn("店长注册内容审核补偿处理失败", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -15,4 +15,5 @@ public interface WorkbenchRegistrationService {
|
||||
WorkbenchRegistrationReviewSummaryVO getReviewSummary(Long reviewerId);
|
||||
boolean approve(Long reviewerId, boolean platformAdmin, Long applicationId);
|
||||
boolean reject(Long reviewerId, boolean platformAdmin, Long applicationId, String reason);
|
||||
void processPendingManagerModeration();
|
||||
}
|
||||
|
||||
+103
-4
@@ -17,16 +17,24 @@ import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.support.UserShopBindingSupport;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.entity.UserShopBindingDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.UserShopBindingMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.privacy.entity.ContentModerationRecordDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.privacy.mapper.ContentModerationRecordMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.privacy.service.ContentModerationService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.privacy.vo.ContentModerationResultVO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.system.service.SystemParameterConfigService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -44,6 +52,10 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
private final UserShopBindingMapper userShopBindingMapper;
|
||||
private final WechatMiniAuthService wechatMiniAuthService;
|
||||
private final SystemParameterConfigService systemParameterConfigService;
|
||||
private final ContentModerationService contentModerationService;
|
||||
private final ContentModerationRecordMapper contentModerationRecordMapper;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
|
||||
public WorkbenchRegistrationServiceImpl(
|
||||
WorkbenchRegistrationApplicationMapper applicationMapper,
|
||||
@@ -53,7 +65,11 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
UserShopBindingSupport userShopBindingSupport,
|
||||
UserShopBindingMapper userShopBindingMapper,
|
||||
WechatMiniAuthService wechatMiniAuthService,
|
||||
SystemParameterConfigService systemParameterConfigService
|
||||
SystemParameterConfigService systemParameterConfigService,
|
||||
ContentModerationService contentModerationService,
|
||||
ContentModerationRecordMapper contentModerationRecordMapper,
|
||||
ShopBusinessExpiryService shopBusinessExpiryService,
|
||||
PlatformTransactionManager transactionManager
|
||||
) {
|
||||
this.applicationMapper = applicationMapper;
|
||||
this.userMapper = userMapper;
|
||||
@@ -63,6 +79,10 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
this.userShopBindingMapper = userShopBindingMapper;
|
||||
this.wechatMiniAuthService = wechatMiniAuthService;
|
||||
this.systemParameterConfigService = systemParameterConfigService;
|
||||
this.contentModerationService = contentModerationService;
|
||||
this.contentModerationRecordMapper = contentModerationRecordMapper;
|
||||
this.shopBusinessExpiryService = shopBusinessExpiryService;
|
||||
this.transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,6 +171,15 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
} else {
|
||||
applicationMapper.updateById(application);
|
||||
}
|
||||
if (WorkbenchRegistrationRole.MANAGER.equals(roleType)) {
|
||||
String reviewText = "门店名称:" + shop.getShopName() + "\n门店地址:" + (shop.getAddress() == null ? "未填写" : shop.getAddress());
|
||||
ContentModerationResultVO moderation = contentModerationService.assessVersion(
|
||||
"SHOP", null, user.getId(), reviewText, null, Collections.emptyList());
|
||||
application.setContentModerationRecordId(moderation.getRecordId());
|
||||
applicationMapper.updateById(application);
|
||||
processManagerModeration(application.getId());
|
||||
application = applicationMapper.selectById(application.getId());
|
||||
}
|
||||
return toStatus(application);
|
||||
}
|
||||
|
||||
@@ -186,8 +215,26 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
? Map.of()
|
||||
: userMapper.selectBatchIds(applicantIds).stream()
|
||||
.collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
List<Long> moderationIds = applications.stream()
|
||||
.map(WorkbenchRegistrationApplicationDO::getContentModerationRecordId)
|
||||
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
Map<Long, ContentModerationRecordDO> moderationById = moderationIds.isEmpty()
|
||||
? Map.of()
|
||||
: contentModerationRecordMapper.selectBatchIds(moderationIds).stream()
|
||||
.collect(Collectors.toMap(ContentModerationRecordDO::getId, Function.identity()));
|
||||
if (platformAdmin) {
|
||||
applications = applications.stream()
|
||||
.filter(application -> {
|
||||
ContentModerationRecordDO moderation = application.getContentModerationRecordId() == null
|
||||
? null : moderationById.get(application.getContentModerationRecordId());
|
||||
return moderation != null && "APPROVED".equals(moderation.getStatus());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return applications.stream()
|
||||
.map(application -> toReviewVO(application, applicants.get(application.getUserId())))
|
||||
.map(application -> toReviewVO(application, applicants.get(application.getUserId()),
|
||||
application.getContentModerationRecordId() == null
|
||||
? null : moderationById.get(application.getContentModerationRecordId())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -207,14 +254,23 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean approve(Long reviewerId, boolean platformAdmin, Long applicationId) {
|
||||
WorkbenchRegistrationApplicationDO application = loadReviewable(reviewerId, platformAdmin, applicationId);
|
||||
if (WorkbenchRegistrationRole.MANAGER.equals(application.getRoleType())) {
|
||||
ContentModerationRecordDO moderation = application.getContentModerationRecordId() == null
|
||||
? null : contentModerationRecordMapper.selectById(application.getContentModerationRecordId());
|
||||
require(moderation != null && "APPROVED".equals(moderation.getStatus()), "门店资料内容审核通过后才能审核注册申请");
|
||||
}
|
||||
return approveApplication(application, reviewerId);
|
||||
}
|
||||
|
||||
private boolean approveApplication(WorkbenchRegistrationApplicationDO application, Long reviewerId) {
|
||||
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);
|
||||
shopBusinessExpiryService.startDefaultValidity(shop.getId(), LocalDateTime.now().toLocalDate());
|
||||
}
|
||||
user.setStatus(1);
|
||||
userMapper.updateById(user);
|
||||
@@ -227,6 +283,46 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processPendingManagerModeration() {
|
||||
List<WorkbenchRegistrationApplicationDO> pending = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class)
|
||||
.eq(WorkbenchRegistrationApplicationDO::getRoleType, WorkbenchRegistrationRole.MANAGER)
|
||||
.eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN)
|
||||
.eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0)
|
||||
.isNotNull(WorkbenchRegistrationApplicationDO::getContentModerationRecordId)
|
||||
.orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime)
|
||||
.last("LIMIT 100"));
|
||||
for (WorkbenchRegistrationApplicationDO application : pending) {
|
||||
try {
|
||||
transactionTemplate.executeWithoutResult(status -> processManagerModeration(application.getId()));
|
||||
} catch (RuntimeException ignored) {
|
||||
// Roll back only this application; the next pass retries it independently.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void processManagerModeration(Long applicationId) {
|
||||
WorkbenchRegistrationApplicationDO application = applicationMapper.selectByIdForUpdate(applicationId);
|
||||
if (application == null || !WorkbenchRegistrationRole.MANAGER.equals(application.getRoleType())
|
||||
|| !WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus())
|
||||
|| application.getContentModerationRecordId() == null) return;
|
||||
ContentModerationRecordDO moderation = contentModerationRecordMapper.selectById(application.getContentModerationRecordId());
|
||||
if (moderation == null || !"SHOP".equals(moderation.getContentType()) || moderation.getBusinessId() != null
|
||||
|| !Objects.equals(moderation.getUserId(), application.getUserId())) return;
|
||||
if ("REJECTED".equals(moderation.getStatus())) {
|
||||
application.setStatus(WorkbenchRegistrationStatus.REJECTED);
|
||||
application.setRejectReason(StringUtils.hasText(moderation.getReason()) ? moderation.getReason() : "门店资料内容未通过审核");
|
||||
application.setReviewedAt(LocalDateTime.now());
|
||||
applicationMapper.updateById(application);
|
||||
return;
|
||||
}
|
||||
boolean autoApproveEnabled = "true".equalsIgnoreCase(systemParameterConfigService.getEnabledValue(
|
||||
"WORKBENCH", "MANAGER_REGISTRATION_AUTO_APPROVE"));
|
||||
if (autoApproveEnabled && "APPROVED".equals(moderation.getStatus())) {
|
||||
approveApplication(application, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean reject(Long reviewerId, boolean platformAdmin, Long applicationId, String reason) {
|
||||
@@ -262,7 +358,8 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
return new WorkbenchRegistrationStatusVO(application.getId(), application.getApplicationNo(), application.getRoleType(), application.getStatus(), application.getRejectReason(), application.getShopId(), application.getShopName());
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationReviewVO toReviewVO(WorkbenchRegistrationApplicationDO application, UserDO applicant) {
|
||||
private WorkbenchRegistrationReviewVO toReviewVO(WorkbenchRegistrationApplicationDO application, UserDO applicant,
|
||||
ContentModerationRecordDO moderation) {
|
||||
WorkbenchRegistrationReviewVO review = new WorkbenchRegistrationReviewVO();
|
||||
BeanUtils.copyProperties(application, review);
|
||||
if (applicant != null) {
|
||||
@@ -270,6 +367,8 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
review.setApplicantAvatar(applicant.getAvatar());
|
||||
review.setApplicantMaskedPhone(maskPhone(applicant.getPhone()));
|
||||
}
|
||||
review.setContentModerationStatus(moderation == null ? "MISSING" : moderation.getStatus());
|
||||
review.setContentModerationReason(moderation == null ? "未关联内容审核记录" : moderation.getReason());
|
||||
return review;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -24,4 +24,6 @@ public class WorkbenchRegistrationReviewVO {
|
||||
private String applicantNickname;
|
||||
private String applicantAvatar;
|
||||
private String applicantMaskedPhone;
|
||||
private String contentModerationStatus;
|
||||
private String contentModerationReason;
|
||||
}
|
||||
|
||||
+36
@@ -6,6 +6,8 @@ import com.xiaowang.jayucloud.salon.core.common.Result;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.dto.ShopDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessExpiryVO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.security.support.AdminScopeHelper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.security.support.SecurityAuditActions;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.security.support.SecurityAuditSupport;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/shops")
|
||||
@@ -39,6 +42,7 @@ public class AdminShopController {
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("shop:view")
|
||||
@@ -180,6 +184,33 @@ public class AdminShopController {
|
||||
return Result.success(shop);
|
||||
}
|
||||
|
||||
@GetMapping("/business-expiries")
|
||||
@RequirePermission("shop:view")
|
||||
public Result<List<ShopBusinessExpiryVO>> listBusinessExpiries(
|
||||
HttpServletRequest request, @RequestParam String shopIds) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "仅平台管理员可以管理门店经营有效期");
|
||||
List<Long> ids = java.util.Arrays.stream(shopIds.split(","))
|
||||
.map(String::trim)
|
||||
.filter(value -> !value.isEmpty())
|
||||
.map(Long::valueOf)
|
||||
.distinct()
|
||||
.limit(100)
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
return Result.success(shopBusinessExpiryService.listExpiries(ids));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/business-expiry")
|
||||
@RequirePermission("shop:edit")
|
||||
@OperationGuard(action = "admin-shop-business-expiry", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
public Result<ShopBusinessExpiryVO> updateBusinessExpiry(
|
||||
HttpServletRequest request, @PathVariable Long id, @RequestBody BusinessExpiryRequest body) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "仅平台管理员可以管理门店经营有效期");
|
||||
return Result.success(shopBusinessExpiryService.updateExpiry(id,
|
||||
body == null || body.getExpireDate() == null ? null : LocalDate.parse(body.getExpireDate())));
|
||||
}
|
||||
|
||||
@Data
|
||||
/**
|
||||
* Purpose: StatusRequest supports AdminShopController.java by holding or executing the status request business role.
|
||||
@@ -192,4 +223,9 @@ public class AdminShopController {
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BusinessExpiryRequest {
|
||||
private String expireDate;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -159,6 +159,9 @@ public class ShopDO extends BaseEntity {
|
||||
@TableField("authorization_expire_time")
|
||||
private LocalDateTime authorizationExpireTime;
|
||||
|
||||
@TableField("business_expire_time")
|
||||
private LocalDateTime businessExpireTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除:0-未删,1-已删
|
||||
*/
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.service;
|
||||
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessExpiryVO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public interface ShopBusinessExpiryService {
|
||||
int getDefaultValidDays();
|
||||
java.time.LocalDateTime defaultExpireTime(LocalDate startDate);
|
||||
void startDefaultValidity(Long shopId, LocalDate startDate);
|
||||
void assertShopActive(Long shopId);
|
||||
ShopBusinessExpiryVO getExpiry(Long shopId);
|
||||
List<ShopBusinessExpiryVO> listExpiries(List<Long> shopIds);
|
||||
ShopBusinessExpiryVO updateExpiry(Long shopId, LocalDate expireDate);
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessExpiryVO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.system.service.SystemParameterConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ShopBusinessExpiryServiceImpl implements ShopBusinessExpiryService {
|
||||
private static final int DEFAULT_VALID_DAYS = 30;
|
||||
private static final String EXPIRED_MESSAGE = "门店经营有效期已到期,暂不能新增预约,请联系平台管理员办理续期";
|
||||
|
||||
private final ShopMapper shopMapper;
|
||||
private final SystemParameterConfigService systemParameterConfigService;
|
||||
|
||||
@Override
|
||||
public int getDefaultValidDays() {
|
||||
String value = systemParameterConfigService.getEnabledValue("SHOP", "SHOP_DEFAULT_VALID_DAYS");
|
||||
if (!StringUtils.hasText(value)) return DEFAULT_VALID_DAYS;
|
||||
try {
|
||||
int days = Integer.parseInt(value.trim());
|
||||
return days > 0 && days <= 3650 ? days : DEFAULT_VALID_DAYS;
|
||||
} catch (NumberFormatException ignored) {
|
||||
return DEFAULT_VALID_DAYS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime defaultExpireTime(LocalDate startDate) {
|
||||
LocalDate start = startDate == null ? LocalDate.now() : startDate;
|
||||
return start.plusDays(getDefaultValidDays() - 1L).atTime(23, 59, 59);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void startDefaultValidity(Long shopId, LocalDate startDate) {
|
||||
ShopDO shop = requireShop(shopId);
|
||||
shop.setBusinessExpireTime(defaultExpireTime(startDate));
|
||||
shopMapper.updateById(shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertShopActive(Long shopId) {
|
||||
ShopDO shop = requireShop(shopId);
|
||||
if (shop.getBusinessExpireTime() == null) {
|
||||
throw new IllegalStateException("门店经营有效期未设置,暂不能新增预约,请联系平台管理员设置有效期");
|
||||
}
|
||||
if (LocalDateTime.now().isAfter(shop.getBusinessExpireTime())) {
|
||||
throw new IllegalStateException(EXPIRED_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopBusinessExpiryVO getExpiry(Long shopId) {
|
||||
return toVO(requireShop(shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopBusinessExpiryVO> listExpiries(List<Long> shopIds) {
|
||||
if (shopIds == null || shopIds.isEmpty()) return Collections.emptyList();
|
||||
List<Long> ids = shopIds.stream().filter(Objects::nonNull).distinct().limit(100).toList();
|
||||
if (ids.isEmpty()) return Collections.emptyList();
|
||||
return shopMapper.selectList(Wrappers.lambdaQuery(ShopDO.class)
|
||||
.in(ShopDO::getId, ids)
|
||||
.eq(ShopDO::getIsDelete, 0))
|
||||
.stream().map(this::toVO).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ShopBusinessExpiryVO updateExpiry(Long shopId, LocalDate expireDate) {
|
||||
if (expireDate == null) throw new IllegalArgumentException("请选择门店到期日期");
|
||||
if (expireDate.isBefore(LocalDate.now())) throw new IllegalArgumentException("到期日期不能早于今天");
|
||||
ShopDO shop = requireShop(shopId);
|
||||
shop.setBusinessExpireTime(expireDate.atTime(23, 59, 59));
|
||||
shopMapper.updateById(shop);
|
||||
return toVO(shop);
|
||||
}
|
||||
|
||||
private ShopDO requireShop(Long shopId) {
|
||||
ShopDO shop = shopId == null ? null : shopMapper.selectById(shopId);
|
||||
if (shop == null || Integer.valueOf(1).equals(shop.getIsDelete())) {
|
||||
throw new IllegalArgumentException("门店不存在或已删除");
|
||||
}
|
||||
return shop;
|
||||
}
|
||||
|
||||
private ShopBusinessExpiryVO toVO(ShopDO shop) {
|
||||
ShopBusinessExpiryVO vo = new ShopBusinessExpiryVO();
|
||||
vo.setShopId(shop.getId());
|
||||
vo.setBusinessExpireTime(shop.getBusinessExpireTime());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
boolean expired = shop.getBusinessExpireTime() != null && now.isAfter(shop.getBusinessExpireTime());
|
||||
vo.setBusinessExpired(expired);
|
||||
vo.setBusinessRemainingDays(shop.getBusinessExpireTime() == null ? null
|
||||
: expired ? 0 : (int) Math.max(1, ChronoUnit.DAYS.between(now.toLocalDate(), shop.getBusinessExpireTime().toLocalDate()) + 1));
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ShopBusinessExpiryVO {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long shopId;
|
||||
private LocalDateTime businessExpireTime;
|
||||
private Boolean businessExpired;
|
||||
private Integer businessRemainingDays;
|
||||
}
|
||||
+21
-1
@@ -25,6 +25,7 @@ import com.xiaowang.jayucloud.salon.core.modules.security.mapper.UserShopRoleMap
|
||||
import com.xiaowang.jayucloud.salon.core.modules.integration.mapper.WechatMiniBindingMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.artist.service.NailArtistInfoService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.system.service.SystemParameterConfigService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.auth.service.VerificationCodeService;
|
||||
@@ -152,6 +153,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
* Variable `shopService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopService shopService;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
/**
|
||||
* Variable `userPermissionMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -1775,7 +1777,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
org.springframework.web.context.request.ServletRequestAttributes attributes =
|
||||
(org.springframework.web.context.request.ServletRequestAttributes) org.springframework.web.context.request.RequestContextHolder.getRequestAttributes();
|
||||
Long userId = attributes == null ? null : (Long) attributes.getRequest().getAttribute("userId");
|
||||
return userId == null ? null : getUserById(userId);
|
||||
if (userId == null) return null;
|
||||
UserVO userInfo = getUserById(userId);
|
||||
Long currentShopId = RequestShopContext.getCurrentShopId();
|
||||
Long expiryShopId = currentShopId == null && userInfo != null ? userInfo.getShopId() : currentShopId;
|
||||
if (userInfo != null && expiryShopId != null) {
|
||||
com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessExpiryVO expiry =
|
||||
shopBusinessExpiryService.getExpiry(expiryShopId);
|
||||
userInfo.setShopBusinessExpireTime(expiry.getBusinessExpireTime());
|
||||
userInfo.setShopBusinessExpired(expiry.getBusinessExpired());
|
||||
userInfo.setShopBusinessRemainingDays(expiry.getBusinessRemainingDays());
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3009,6 +3022,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
ShopVO currentShop = normalizedCurrentShopId == null ? null : shopService.getShopById(normalizedCurrentShopId);
|
||||
userInfo.setShopAuthorizationExpireTime(currentShop == null ? null : currentShop.getAuthorizationExpireTime());
|
||||
userInfo.setShopAuthorizationExpired(currentShop != null && Boolean.TRUE.equals(currentShop.getAuthorizationExpired()));
|
||||
if (currentShop != null) {
|
||||
com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessExpiryVO businessExpiry =
|
||||
shopBusinessExpiryService.getExpiry(currentShop.getId());
|
||||
userInfo.setShopBusinessExpireTime(businessExpiry.getBusinessExpireTime());
|
||||
userInfo.setShopBusinessExpired(businessExpiry.getBusinessExpired());
|
||||
userInfo.setShopBusinessRemainingDays(businessExpiry.getBusinessRemainingDays());
|
||||
}
|
||||
userInfo.setShopIds(activeShopOptions.stream().map(ShopSimpleVO::getId).collect(Collectors.toList()));
|
||||
userInfo.setShopNames(activeShopOptions.stream().map(ShopSimpleVO::getShopName).collect(Collectors.toList()));
|
||||
userInfo.setCreateTime(userDO.getCreateTime());
|
||||
|
||||
+4
@@ -35,6 +35,10 @@ public class UserVO {
|
||||
*/
|
||||
private String shopName;
|
||||
|
||||
private LocalDateTime shopBusinessExpireTime;
|
||||
private Boolean shopBusinessExpired;
|
||||
private Integer shopBusinessRemainingDays;
|
||||
|
||||
/**
|
||||
* 绑定店铺ID列表
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
-- 店长申请内容审核关联与门店经营有效期。
|
||||
-- 当前没有存量门店,不执行任何门店数据回填。
|
||||
|
||||
SET @salon_v6_ddl = IF(
|
||||
EXISTS (
|
||||
SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_shop'
|
||||
AND COLUMN_NAME = 'business_expire_time'
|
||||
),
|
||||
'SELECT 1',
|
||||
'ALTER TABLE t_shop ADD COLUMN business_expire_time datetime NULL COMMENT ''门店经营有效期,空表示未设置'' AFTER authorization_expire_time'
|
||||
);
|
||||
PREPARE salon_v6_stmt FROM @salon_v6_ddl;
|
||||
EXECUTE salon_v6_stmt;
|
||||
DEALLOCATE PREPARE salon_v6_stmt;
|
||||
|
||||
SET @salon_v6_ddl = IF(
|
||||
EXISTS (
|
||||
SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_workbench_registration_application'
|
||||
AND COLUMN_NAME = 'content_moderation_record_id'
|
||||
),
|
||||
'SELECT 1',
|
||||
'ALTER TABLE t_workbench_registration_application ADD COLUMN content_moderation_record_id bigint NULL COMMENT ''店长申请关联的确切内容审核记录ID'' AFTER reject_reason'
|
||||
);
|
||||
PREPARE salon_v6_stmt FROM @salon_v6_ddl;
|
||||
EXECUTE salon_v6_stmt;
|
||||
DEALLOCATE PREPARE salon_v6_stmt;
|
||||
|
||||
SET @salon_v6_ddl = IF(
|
||||
EXISTS (
|
||||
SELECT 1 FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_workbench_registration_application'
|
||||
AND INDEX_NAME = 'idx_registration_moderation_record'
|
||||
),
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_registration_moderation_record ON t_workbench_registration_application (content_moderation_record_id)'
|
||||
);
|
||||
PREPARE salon_v6_stmt FROM @salon_v6_ddl;
|
||||
EXECUTE salon_v6_stmt;
|
||||
DEALLOCATE PREPARE salon_v6_stmt;
|
||||
|
||||
INSERT INTO t_system_parameter_config
|
||||
(id, config_group, config_key, config_name, config_value, enabled, remark, create_time, update_time, is_delete)
|
||||
VALUES
|
||||
(CAST(CONV(SUBSTR(SHA2('SALON:WORKBENCH:MANAGER_REGISTRATION_AUTO_APPROVE', 256), 1, 15), 16, 10) AS UNSIGNED),
|
||||
'WORKBENCH', 'MANAGER_REGISTRATION_AUTO_APPROVE', '店长注册自动审核', 'false', 1,
|
||||
'开启后仅在申请关联的门店资料内容审核通过时自动批准店长注册;关闭后由平台管理员人工复核', NOW(), NOW(), 0),
|
||||
(CAST(CONV(SUBSTR(SHA2('SALON:SHOP:SHOP_DEFAULT_VALID_DAYS', 256), 1, 15), 16, 10) AS UNSIGNED),
|
||||
'SHOP', 'SHOP_DEFAULT_VALID_DAYS', '新门店默认有效期天数', '30', 1,
|
||||
'店长注册审核通过后新门店的默认经营有效期天数,范围1-3650', NOW(), NOW(), 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
config_name = VALUES(config_name),
|
||||
remark = VALUES(remark),
|
||||
update_time = NOW();
|
||||
+61
-1
@@ -12,6 +12,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.service.OrderService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.order.support.OrderStatus;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.planning.service.AppointmentCapacityService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.product.mapper.ProductMapper;
|
||||
@@ -19,6 +20,7 @@ import com.xiaowang.jayucloud.salon.core.modules.product.entity.ProductDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.security.support.AdminScopeHelper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.service.ShopBusinessExpiryService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService;
|
||||
@@ -55,6 +57,7 @@ class PlanningServiceImplTest {
|
||||
@Mock private OrderItemMapper orderItemMapper;
|
||||
@Mock private ProductMapper productMapper;
|
||||
@Mock private ShopMapper shopMapper;
|
||||
@Mock private ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
@Mock private AppointmentCapacityService appointmentCapacityService;
|
||||
@Mock private OrderService orderService;
|
||||
@Mock private TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
@@ -65,7 +68,7 @@ class PlanningServiceImplTest {
|
||||
void setUp() {
|
||||
service = new PlanningServiceImpl(adminScopeHelper, userMapper, userService, nailArtistInfoMapper, artistScheduleMapper,
|
||||
artistScheduleExceptionMapper, appointmentReservationMapper, orderMapper, orderItemMapper,
|
||||
productMapper, shopMapper, appointmentCapacityService, orderService, snowflakeIdGenerator);
|
||||
productMapper, shopMapper, shopBusinessExpiryService, appointmentCapacityService, orderService, snowflakeIdGenerator);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,6 +86,63 @@ class PlanningServiceImplTest {
|
||||
verify(orderService, never()).processOrder(11L, OrderStatus.COMPLETED.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsAppointmentCreationWhenShopValidityHasExpired() {
|
||||
UserDO operator = new UserDO();
|
||||
operator.setType(2);
|
||||
PlanningAppointmentCreateDTO dto = new PlanningAppointmentCreateDTO();
|
||||
when(adminScopeHelper.resolveShopScope(operator, null)).thenReturn(21L);
|
||||
org.mockito.Mockito.doThrow(new IllegalStateException("门店经营有效期已到期"))
|
||||
.when(shopBusinessExpiryService).assertShopActive(21L);
|
||||
|
||||
RuntimeException error = assertThrows(RuntimeException.class, () -> service.createAppointment(operator, dto));
|
||||
|
||||
assertEquals("门店经营有效期已到期", error.getMessage());
|
||||
verify(orderMapper, never()).insert(any(OrderDO.class));
|
||||
verify(orderItemMapper, never()).insert(any(OrderItemDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void backfillOrderDoesNotCheckShopBusinessExpiry() {
|
||||
service = spy(service);
|
||||
UserDO operator = new UserDO();
|
||||
operator.setType(2);
|
||||
UserDO artist = new UserDO();
|
||||
artist.setId(31L);
|
||||
artist.setType(3);
|
||||
artist.setShopId(21L);
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(41L);
|
||||
product.setShopId(21L);
|
||||
product.setIsDelete(0);
|
||||
when(adminScopeHelper.resolveShopScope(operator, null)).thenReturn(21L);
|
||||
when(userMapper.selectById(31L)).thenReturn(artist);
|
||||
when(productMapper.selectById(41L)).thenReturn(product);
|
||||
when(snowflakeIdGenerator.nextIdString()).thenReturn("10004");
|
||||
doAnswer(invocation -> {
|
||||
OrderDO value = invocation.getArgument(0);
|
||||
value.setId(54L);
|
||||
return 1;
|
||||
}).when(orderMapper).insert(any(OrderDO.class));
|
||||
doAnswer(invocation -> {
|
||||
OrderItemDO value = invocation.getArgument(0);
|
||||
value.setId(64L);
|
||||
return 1;
|
||||
}).when(orderItemMapper).insert(any(OrderItemDO.class));
|
||||
doReturn(new com.xiaowang.jayucloud.salon.core.modules.planning.vo.PlanningAppointmentVO())
|
||||
.when(service).getAppointment(operator, 64L);
|
||||
PlanningBackfillOrderCreateDTO dto = new PlanningBackfillOrderCreateDTO();
|
||||
dto.setServiceDate("2025-01-01");
|
||||
dto.setProductId(41L);
|
||||
dto.setArtistId(31L);
|
||||
dto.setAmount(java.math.BigDecimal.valueOf(80));
|
||||
dto.setStatus(OrderStatus.COMPLETED.getCode());
|
||||
|
||||
service.createBackfillOrder(operator, dto);
|
||||
|
||||
verify(shopBusinessExpiryService, never()).assertShopActive(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void allowsCancellingUnassignedAppointment() {
|
||||
UserDO operator = new UserDO();
|
||||
|
||||
@@ -804,6 +804,9 @@ export interface Shop {
|
||||
authorizationExpireTime?: string
|
||||
authorizationExpired?: boolean
|
||||
authorizationStatusText?: string
|
||||
businessExpireTime?: string
|
||||
businessExpired?: boolean
|
||||
businessRemainingDays?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
@@ -819,6 +822,13 @@ export interface ShopListResponse {
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface ShopBusinessExpiry {
|
||||
shopId: IdType
|
||||
businessExpireTime?: string
|
||||
businessExpired?: boolean
|
||||
businessRemainingDays?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: CreateShopRequest supports admin.ts by holding or executing the create shop request page or API role.
|
||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -865,6 +875,12 @@ export const adminShopApi = {
|
||||
listAllShops: () => {
|
||||
return adminApi.get<Shop[]>('/shops/list/all') as unknown as Promise<Shop[]>
|
||||
},
|
||||
listBusinessExpiries: (shopIds: IdType[]) => {
|
||||
return adminApi.get<ShopBusinessExpiry[]>('/shops/business-expiries', { params: { shopIds: shopIds.join(',') } }) as unknown as Promise<ShopBusinessExpiry[]>
|
||||
},
|
||||
updateBusinessExpiry: (id: IdType, expireDate: string) => {
|
||||
return adminApi.put<ShopBusinessExpiry>(`/shops/${id}/business-expiry`, { expireDate })
|
||||
},
|
||||
/**
|
||||
* `createShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||
@@ -1934,6 +1950,8 @@ export interface WorkbenchRegistrationApplication {
|
||||
applicantNickname?: string
|
||||
applicantAvatar?: string
|
||||
applicantMaskedPhone?: string
|
||||
contentModerationStatus?: string
|
||||
contentModerationReason?: string
|
||||
}
|
||||
|
||||
export const adminWorkbenchRegistrationApi = {
|
||||
|
||||
@@ -131,6 +131,14 @@
|
||||
<TableEllipsisText :text="record.businessHours" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'businessExpiry'">
|
||||
<a-space direction="vertical" size="small">
|
||||
<a-tag :color="record.businessExpired ? 'red' : 'green'">
|
||||
{{ record.businessExpired ? '已过期' : record.businessExpireTime ? `剩余 ${record.businessRemainingDays ?? 0} 天` : '未设置' }}
|
||||
</a-tag>
|
||||
<span>{{ record.businessExpireTime ? record.businessExpireTime.slice(0, 10) : '未设置' }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
@@ -139,6 +147,9 @@
|
||||
<a-button v-if="hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('shop:edit') && isAdmin" type="link" size="small" @click="openBusinessExpiry(record as Shop)">
|
||||
有效期
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@@ -172,10 +183,15 @@
|
||||
<span>地址</span>
|
||||
<strong>{{ item.address || '--' }}</strong>
|
||||
</div>
|
||||
<div class="admin-mobile-card__row">
|
||||
<span>经营有效期</span>
|
||||
<strong :class="{ 'expiry-danger': item.businessExpired }">{{ item.businessExpired ? '已过期' : item.businessExpireTime ? `${item.businessExpireTime.slice(0, 10)} · 剩余 ${item.businessRemainingDays ?? 0} 天` : '未设置' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-mobile-card__actions">
|
||||
<a-button size="small" @click="showViewModal(item)">查看</a-button>
|
||||
<a-button v-if="hasPermission('shop:edit')" size="small" @click="showEditModal(item)">编辑</a-button>
|
||||
<a-button v-if="hasPermission('shop:edit') && isAdmin" size="small" @click="openBusinessExpiry(item)">有效期</a-button>
|
||||
<a-button
|
||||
v-if="hasPermission('shop:edit')"
|
||||
size="small"
|
||||
@@ -559,6 +575,29 @@
|
||||
</a-form>
|
||||
</AdminResponsiveModal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="businessExpiryModalVisible"
|
||||
title="设置门店经营有效期"
|
||||
ok-text="保存到期日"
|
||||
cancel-text="取消"
|
||||
:confirm-loading="savingBusinessExpiry"
|
||||
:mask-closable="false"
|
||||
@ok="saveBusinessExpiry"
|
||||
@cancel="businessExpiryModalVisible = false"
|
||||
>
|
||||
<div class="business-expiry-editor">
|
||||
<strong>{{ expiryShop?.shopName || '门店' }}</strong>
|
||||
<a-date-picker
|
||||
v-model:value="businessExpiryDate"
|
||||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
:disabled-date="disablePastExpiryDate"
|
||||
placeholder="选择到期日期"
|
||||
/>
|
||||
<p>到期日期当天 23:59 前仍可新增预约。到期后只限制新增普通预约,不影响补录历史订单和查询。</p>
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="mapPickerVisible"
|
||||
:title="mapPickerTitle"
|
||||
@@ -801,6 +840,10 @@ const searchText = ref('')
|
||||
const shopList = ref<Shop[]>([])
|
||||
/** modalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const modalVisible = ref(false)
|
||||
const businessExpiryModalVisible = ref(false)
|
||||
const businessExpiryDate = ref<string>()
|
||||
const savingBusinessExpiry = ref(false)
|
||||
const expiryShop = ref<Shop | null>(null)
|
||||
/** viewModalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const viewModalVisible = ref(false)
|
||||
/** modalLoading is a reactive state variable used by the template and event handlers. */
|
||||
@@ -1240,6 +1283,7 @@ const columns = [
|
||||
{ title: '店铺描述', dataIndex: 'description', key: 'description' },
|
||||
{ title: '店铺地址', dataIndex: 'address', key: 'address' },
|
||||
{ title: '营业时间', dataIndex: 'businessHours', key: 'businessHours' },
|
||||
{ title: '经营有效期', key: 'businessExpiry', width: 180 },
|
||||
{ title: '状态', key: 'status', width: 120 },
|
||||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
@@ -1419,6 +1463,36 @@ const formatAuthorizationExpireTime = (value?: string) => {
|
||||
return value.replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
const openBusinessExpiry = (shop: Shop) => {
|
||||
expiryShop.value = shop
|
||||
businessExpiryDate.value = shop.businessExpireTime ? shop.businessExpireTime.slice(0, 10) : undefined
|
||||
businessExpiryModalVisible.value = true
|
||||
}
|
||||
|
||||
const disablePastExpiryDate = (date: any) => {
|
||||
const today = new Date()
|
||||
const localToday = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`
|
||||
return date.format('YYYY-MM-DD') < localToday
|
||||
}
|
||||
|
||||
const saveBusinessExpiry = async () => {
|
||||
if (!expiryShop.value || !businessExpiryDate.value) {
|
||||
message.warning('请选择门店到期日期')
|
||||
return
|
||||
}
|
||||
savingBusinessExpiry.value = true
|
||||
try {
|
||||
await adminShopApi.updateBusinessExpiry(expiryShop.value.id, businessExpiryDate.value)
|
||||
message.success('门店经营有效期已更新')
|
||||
businessExpiryModalVisible.value = false
|
||||
await fetchShopList()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '有效期更新失败')
|
||||
} finally {
|
||||
savingBusinessExpiry.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatLocation supports ShopsView.vue by holding or executing the format location page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -1658,7 +1732,17 @@ const fetchShopList = async () => {
|
||||
|
||||
const response = await adminShopApi.listShops(params)
|
||||
const res = typeof response === 'object' && 'list' in response ? response : (response as any).data
|
||||
shopList.value = res.list || []
|
||||
const rows = res.list || []
|
||||
let expiryById = new Map<string, Awaited<ReturnType<typeof adminShopApi.listBusinessExpiries>>[number]>()
|
||||
if (rows.length) {
|
||||
try {
|
||||
const expiries = await adminShopApi.listBusinessExpiries(rows.map((shop: Shop) => shop.id))
|
||||
expiryById = new Map(expiries.map(expiry => [String(expiry.shopId), expiry]))
|
||||
} catch {
|
||||
message.warning('门店有效期信息暂时不可用,稍后可刷新重试')
|
||||
}
|
||||
}
|
||||
shopList.value = rows.map((shop: Shop) => ({ ...shop, ...expiryById.get(String(shop.id)) }))
|
||||
pagination.total = res.total || 0
|
||||
|
||||
// 预加载所有图片签名链接
|
||||
@@ -2392,6 +2476,10 @@ onMounted(async () => {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.business-expiry-editor { display: grid; gap: 14px; padding-top: 8px; }
|
||||
.business-expiry-editor p { margin: 0; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.6; }
|
||||
.expiry-danger { color: #a54141; }
|
||||
|
||||
.shop-images {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -66,7 +66,36 @@
|
||||
<span :class="['status-pill', { 'is-muted': !reviewNoticeEnabled }]">{{ reviewNoticeEnabled ? '启用' : '停用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="section-footnote">默认密码的强度规则仍按后台账号接口校验;审核入口和数量角标不会受提醒开关影响。</p>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>店长注册审核</strong><span>WORKBENCH</span><a-button size="small" type="primary" :loading="savingManagerReviewMode" @click="saveManagerReviewMode">保存审核模式</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy">
|
||||
<strong>内容审核通过后自动批准</strong>
|
||||
<span>开启后仅在店长申请绑定的门店资料内容审核通过时自动通过;关闭后由管理员人工复核。</span>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<a-switch v-model:checked="managerAutoApproveEnabled" checked-children="自动" un-checked-children="人工" />
|
||||
<span class="control-note">{{ managerAutoApproveEnabled ? '自动批准' : '人工复核' }}</span>
|
||||
</div>
|
||||
<span :class="['status-pill', { 'is-muted': !managerAutoApproveEnabled }]">{{ managerAutoApproveEnabled ? '自动审核' : '人工审核' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>门店经营有效期</strong><span>SHOP</span><a-button size="small" type="primary" :loading="savingShopValidity" @click="saveShopValidity">保存有效期</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy">
|
||||
<strong>新门店默认有效期</strong>
|
||||
<span>店长注册审核通过当天计为第 1 天;单个门店可在门店管理中单独调整到期日。</span>
|
||||
</div>
|
||||
<div class="setting-control setting-control--number">
|
||||
<a-input v-model:value="shopDefaultValidDays" type="number" :min="1" :max="3650" addon-after="天" />
|
||||
</div>
|
||||
<span class="control-note">1–3650 天</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="section-footnote">默认密码仍按后台账号接口校验;员工审核入口和数量角标不受登录提醒开关影响。门店到期只限制新增普通预约。</p>
|
||||
</section>
|
||||
|
||||
<section v-else-if="activeSection === 'services'" class="settings-section-panel">
|
||||
@@ -156,10 +185,14 @@ const activeSection = ref<SettingsSection>(route.query.section === 'account' ? '
|
||||
const loading = ref(false)
|
||||
const savingDefaultPassword = ref(false)
|
||||
const savingReviewNotice = ref(false)
|
||||
const savingManagerReviewMode = ref(false)
|
||||
const savingShopValidity = ref(false)
|
||||
const savingMap = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const defaultPasswordEnabled = ref(true)
|
||||
const reviewNoticeEnabled = ref(true)
|
||||
const managerAutoApproveEnabled = ref(false)
|
||||
const shopDefaultValidDays = ref('30')
|
||||
const mapEnabled = ref(true)
|
||||
const smsProviderOptions = [
|
||||
{ label: 'Spug 短信', value: 'SPUG' },
|
||||
@@ -188,6 +221,14 @@ const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'WORKBENCH', configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE', configName: '店长员工审核提醒', configValue: 'true', enabled: 1,
|
||||
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
|
||||
})
|
||||
const managerReviewModeForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'WORKBENCH', configKey: 'MANAGER_REGISTRATION_AUTO_APPROVE', configName: '店长注册自动审核', configValue: 'false', enabled: 1,
|
||||
remark: '开启后仅在店长申请关联的门店资料内容审核通过时自动批准;关闭后由管理员人工复核'
|
||||
})
|
||||
const shopValidityForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'SHOP', configKey: 'SHOP_DEFAULT_VALID_DAYS', configName: '新门店默认有效期天数', configValue: '30', enabled: 1,
|
||||
remark: '店长注册审核通过后新门店的默认经营有效期天数,范围1-3650'
|
||||
})
|
||||
const smsProviderForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
|
||||
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
|
||||
@@ -204,10 +245,11 @@ const userInfo = ref(loadCachedAdminUserInfo())
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [userConfigs, smsConfigs, workbenchConfigs, mapConfigs] = await Promise.all([
|
||||
const [userConfigs, smsConfigs, workbenchConfigs, shopConfigs, mapConfigs] = await Promise.all([
|
||||
adminSystemParameterConfigApi.listConfigs('USER'),
|
||||
adminSystemParameterConfigApi.listConfigs('SMS'),
|
||||
adminSystemParameterConfigApi.listConfigs('WORKBENCH'),
|
||||
adminSystemParameterConfigApi.listConfigs('SHOP'),
|
||||
adminSystemParameterConfigApi.listConfigs('MAP')
|
||||
])
|
||||
const defaultPassword = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
@@ -222,6 +264,16 @@ const load = async () => {
|
||||
Object.assign(reviewNoticeForm, reviewNotice)
|
||||
reviewNoticeEnabled.value = reviewNotice.enabled === 1 && String(reviewNotice.configValue).toLowerCase() === 'true'
|
||||
}
|
||||
const managerReviewMode = workbenchConfigs.find(item => item.configKey === 'MANAGER_REGISTRATION_AUTO_APPROVE')
|
||||
if (managerReviewMode) {
|
||||
Object.assign(managerReviewModeForm, managerReviewMode)
|
||||
managerAutoApproveEnabled.value = managerReviewMode.enabled === 1 && String(managerReviewMode.configValue).toLowerCase() === 'true'
|
||||
}
|
||||
const shopValidity = shopConfigs.find(item => item.configKey === 'SHOP_DEFAULT_VALID_DAYS')
|
||||
if (shopValidity) {
|
||||
Object.assign(shopValidityForm, shopValidity)
|
||||
shopDefaultValidDays.value = String(shopValidity.configValue || '30')
|
||||
}
|
||||
const mapByKey = Object.fromEntries(mapConfigs.map(item => [item.configKey, item])) as Record<string, SystemParameterConfigVO | undefined>
|
||||
if (mapByKey.MAP_PROVIDER) Object.assign(mapForms.provider, mapByKey.MAP_PROVIDER)
|
||||
if (mapByKey.TENCENT_MAP_KEY) Object.assign(mapForms.tencentWeb, mapByKey.TENCENT_MAP_KEY)
|
||||
@@ -276,6 +328,39 @@ const saveReviewNotice = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const saveManagerReviewMode = async () => {
|
||||
savingManagerReviewMode.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...managerReviewModeForm,
|
||||
configValue: managerAutoApproveEnabled.value ? 'true' : 'false',
|
||||
enabled: 1
|
||||
})
|
||||
message.success(managerAutoApproveEnabled.value ? '店长注册自动审核已开启' : '店长注册将由管理员人工复核')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '审核模式保存失败')
|
||||
} finally {
|
||||
savingManagerReviewMode.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveShopValidity = async () => {
|
||||
const days = Number(shopDefaultValidDays.value)
|
||||
if (!Number.isInteger(days) || days < 1 || days > 3650) {
|
||||
message.warning('有效期请填写 1–3650 的整数天数')
|
||||
return
|
||||
}
|
||||
savingShopValidity.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...shopValidityForm, configValue: String(days), enabled: 1 })
|
||||
message.success('新门店默认有效期已保存')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '有效期设置保存失败')
|
||||
} finally {
|
||||
savingShopValidity.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveMapConfig = async () => {
|
||||
savingMap.value = true
|
||||
try {
|
||||
@@ -344,6 +429,7 @@ onMounted(() => {
|
||||
.setting-control > :deep(.ant-select) { width: 100%; }
|
||||
.setting-control--password > :deep(.ant-input-affix-wrapper) { flex: 1; width: auto; min-width: 100px; }
|
||||
.setting-control--password { min-width: 0; }
|
||||
.setting-control--number { width: min(220px, 100%); }
|
||||
.control-note { color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
||||
.setting-row > .control-note { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
|
||||
.setting-value { min-width: 0; color: var(--admin-mobile-ink); font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
{{ statusLabel(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'contentModerationStatus'">
|
||||
<a-tag :color="moderationColor(record.contentModerationStatus)">
|
||||
{{ moderationLabel(record.contentModerationStatus) }}
|
||||
</a-tag>
|
||||
<div v-if="record.contentModerationReason" class="moderation-reason">{{ record.contentModerationReason }}</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-space v-if="record.status === 'PENDING_ADMIN'">
|
||||
<a-button type="primary" size="small" @click="approve(record.id)">通过</a-button>
|
||||
@@ -49,11 +55,14 @@ const columns = [
|
||||
{ title: '身份', key: 'roleType' },
|
||||
{ title: '店铺', dataIndex: 'shopName', key: 'shopName' },
|
||||
{ title: '地址', dataIndex: 'shopAddress', key: 'shopAddress' },
|
||||
{ title: '资料内容审核', key: 'contentModerationStatus', width: 150 },
|
||||
{ title: '状态', key: 'status' },
|
||||
{ title: '操作', key: 'action', width: 150 }
|
||||
]
|
||||
|
||||
const statusLabel = (status: string) => ({ PENDING_ADMIN: '待管理员审核', PENDING_MANAGER: '待店长审核', APPROVED: '已通过', REJECTED: '已驳回' }[status] || status)
|
||||
const moderationLabel = (status?: string) => ({ APPROVED: '已通过', PENDING: '待审核', RETRY: '重试中', REJECTED: '未通过', MISSING: '未提交' }[status || ''] || '审核中')
|
||||
const moderationColor = (status?: string) => ({ APPROVED: 'green', PENDING: 'processing', RETRY: 'orange', REJECTED: 'red', MISSING: 'default' }[status || ''] || 'processing')
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
@@ -74,3 +83,7 @@ const reject = (id: string | number) => {
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.moderation-reason { max-width: 240px; margin-top: 4px; color: #9a5147; font-size: 12px; line-height: 1.5; }
|
||||
</style>
|
||||
|
||||
@@ -14,7 +14,9 @@ Page({
|
||||
timer: null,
|
||||
smsExpanded: false,
|
||||
unbindMode: false,
|
||||
closureRequest: null
|
||||
closureRequest: null,
|
||||
businessExpireDateText: '',
|
||||
businessExpiryStatusText: ''
|
||||
},
|
||||
|
||||
onShow() { this.loadProfile(); this.loadClosureRequest() },
|
||||
@@ -62,7 +64,13 @@ Page({
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const profile = await profileCache.getProfile(options)
|
||||
this.setData({ profile, 'smsForm.phone': profile.phone || '' })
|
||||
const businessExpireDateText = profile.shopBusinessExpireTime ? String(profile.shopBusinessExpireTime).slice(0, 10) : '未设置'
|
||||
const businessExpiryStatusText = profile.shopBusinessExpired
|
||||
? '已过期,暂不能新增预约'
|
||||
: Number.isFinite(Number(profile.shopBusinessRemainingDays))
|
||||
? `剩余 ${profile.shopBusinessRemainingDays} 天`
|
||||
: '有效期未设置'
|
||||
this.setData({ profile, businessExpireDateText, businessExpiryStatusText, 'smsForm.phone': profile.phone || '' })
|
||||
const app = getApp()
|
||||
const session = auth.getSession()
|
||||
app.setSession({ ...session, userInfo: { ...(session.userInfo || {}), ...profile } })
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<view class="page settings-page">
|
||||
<view class="card identity-card"><view class="identity-mark">微</view><view class="identity-copy"><text class="identity-title">微信身份</text><text class="identity-status">已安全关联当前账号</text></view><text class="linked-badge">已关联</text></view>
|
||||
<view wx:if="{{profile.type == 2}}" class="card business-expiry-card">
|
||||
<view class="business-expiry-head"><text class="section-title">门店经营有效期</text><text class="business-expiry-status {{profile.shopBusinessExpired ? 'expired' : ''}}">{{businessExpiryStatusText}}</text></view>
|
||||
<view class="business-expiry-date"><text>有效期至</text><strong>{{businessExpireDateText}}</strong></view>
|
||||
<text wx:if="{{profile.shopBusinessExpired}}" class="business-expiry-note">到期后暂不可新增普通预约,历史订单、查询和补录不受影响。请联系平台管理员办理续期。</text>
|
||||
</view>
|
||||
<view class="card phone-card">
|
||||
<view class="section-title">手机号</view>
|
||||
<view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.settings-page { padding-top:24rpx; }.identity-card { display:flex; align-items:center; padding:26rpx; }.identity-mark { display:flex; align-items:center; justify-content:center; width:68rpx; height:68rpx; border-radius:20rpx; background:#e5f4ed; color:#247b63; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#17211f; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#71807a; font-size:21rpx; }.linked-badge,.status-tag { padding:7rpx 14rpx; border-radius:999rpx; background:#e5f2e8; color:#397055; font-size:20rpx; }
|
||||
.business-expiry-card { margin-top:20rpx; padding:26rpx; }.business-expiry-head,.business-expiry-date { display:flex; align-items:center; justify-content:space-between; gap:16rpx; }.business-expiry-status { color:#397055; font-size:22rpx; }.business-expiry-status.expired { color:#a24f42; }.business-expiry-date { margin-top:20rpx; padding-top:18rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.business-expiry-date strong { color:#17211f; font-size:25rpx; }.business-expiry-note { display:block; margin-top:14rpx; color:#a24f42; font-size:21rpx; line-height:1.6; }
|
||||
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f3f7f4; color:#71807a; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#247b63; color:#fff; font-size:26rpx; line-height:80rpx; }.sms-entry { display:flex; min-height:82rpx; align-items:center; margin-top:22rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.sms-arrow { margin-left:auto; color:#95a198; font-size:36rpx; transition:transform 180ms ease; }.sms-arrow.expanded { transform:rotate(90deg); }.sms-panel { padding-top:2rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#247b63; }.account-note { margin:24rpx 18rpx; color:#71807a; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
|
||||
.privacy-note {
|
||||
margin: 12rpx 0;
|
||||
|
||||
@@ -26,6 +26,22 @@ function canCreateAppointment() {
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
function isShopBusinessExpired() {
|
||||
const userInfo = getApp().globalData.userInfo || {}
|
||||
return Number(userInfo.type) === 2 && userInfo.shopBusinessExpired === true
|
||||
}
|
||||
|
||||
function showBusinessExpiryNotice() {
|
||||
return new Promise(resolve => wx.showModal({
|
||||
title: '门店经营有效期已到期',
|
||||
content: '当前门店暂不能新增普通预约。历史订单、查询和补录不受影响,请联系平台管理员办理续期。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了',
|
||||
success: () => resolve(),
|
||||
fail: () => resolve()
|
||||
}))
|
||||
}
|
||||
|
||||
function buildDraftKey() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
@@ -1399,6 +1415,10 @@ Page({
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (isShopBusinessExpired()) {
|
||||
await showBusinessExpiryNotice()
|
||||
return
|
||||
}
|
||||
let form = this.data.form
|
||||
const manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
const manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim()
|
||||
@@ -1480,7 +1500,11 @@ Page({
|
||||
markPlanningRefresh()
|
||||
wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '提交失败', icon: 'none' })
|
||||
if ((error.message || '').includes('有效期') || (error.message || '').includes('到期')) {
|
||||
await showBusinessExpiryNotice()
|
||||
} else {
|
||||
wx.showToast({ title: error.message || '提交失败', icon: 'none' })
|
||||
}
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
|
||||
@@ -2,16 +2,18 @@ const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
|
||||
let redirectedTo = ''
|
||||
let appGlobalData = {}
|
||||
let lastModal = null
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
removeStorageSync: () => {},
|
||||
setStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: ({ success }) => success({ confirm: true }),
|
||||
showModal: options => { lastModal = options; if (options.success) options.success({ confirm: true }) },
|
||||
redirectTo: ({ url }) => { redirectedTo = url }
|
||||
}
|
||||
global.getApp = () => ({ globalData: {} })
|
||||
global.getApp = () => ({ globalData: appGlobalData })
|
||||
global.getCurrentPages = () => []
|
||||
|
||||
let definition
|
||||
@@ -34,6 +36,14 @@ function createPage() {
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const expiredPage = createPage()
|
||||
expiredPage.data.canCreateAppointment = true
|
||||
appGlobalData.userInfo = { type: 2, shopBusinessExpired: true }
|
||||
await expiredPage.submit()
|
||||
assert.strictEqual(lastModal.title, '门店经营有效期已到期')
|
||||
assert.strictEqual(lastModal.showCancel, false)
|
||||
appGlobalData = {}
|
||||
|
||||
const page = createPage()
|
||||
Object.assign(page.data.form, {
|
||||
customerUserId: '31',
|
||||
|
||||
@@ -57,6 +57,7 @@ Page({
|
||||
return
|
||||
}
|
||||
this.setData({ loginState: state })
|
||||
this.handleResult(state)
|
||||
},
|
||||
|
||||
async loadAgreements() {
|
||||
@@ -144,6 +145,7 @@ Page({
|
||||
|
||||
async quickLogin() {
|
||||
if (this.data.loading || !(await this.ensureCanLogin())) return
|
||||
this._presentedLoginState = ''
|
||||
const rememberMe = await this.chooseRememberMode()
|
||||
if (rememberMe === null) return
|
||||
this.setData({ rememberMe, loading: true })
|
||||
@@ -152,7 +154,9 @@ Page({
|
||||
this.setData({ loginState: result })
|
||||
await this.handleResult(result)
|
||||
} catch (error) {
|
||||
this.setData({ loginState: { status: 'ERROR', message: error.message || '快捷登录失败,请重试' } })
|
||||
const state = { status: 'ERROR', message: error.message || '快捷登录失败,请重试' }
|
||||
this.setData({ loginState: state })
|
||||
this.handleResult(state)
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
@@ -160,6 +164,11 @@ Page({
|
||||
|
||||
async handleResult(result) {
|
||||
if (result.status === 'SUCCESS' && result.accessToken) return this.finishLogin(result)
|
||||
if (result.status === 'REJECTED' && this._resumeRegistrationAfterRejected && result.registrationTicket) {
|
||||
this._resumeRegistrationAfterRejected = false
|
||||
this.navigateToRegistration(result)
|
||||
return
|
||||
}
|
||||
if (result.status === 'SELECT_SHOP') {
|
||||
this.setData({ shopOptions: shopOptions(result), loginTicket: result.ticket, shopSelectVisible: true })
|
||||
return
|
||||
@@ -172,7 +181,41 @@ Page({
|
||||
wx.navigateTo({ url: `/pages/register/index?${query}` })
|
||||
return
|
||||
}
|
||||
wx.showToast({ title: result.message || '当前账号暂不能登录', icon: 'none', duration: 2500 })
|
||||
const status = result.status
|
||||
if (!['PENDING_REVIEW', 'REJECTED', 'DISABLED', 'ERROR', 'NEED_MANUAL_LOGIN'].includes(status)) return
|
||||
const stateKey = `${status}:${result.registrationApplicationId || ''}:${result.message || ''}:${result.registrationRejectReason || ''}`
|
||||
if (this._presentedLoginState === stateKey) return
|
||||
this._presentedLoginState = stateKey
|
||||
const title = status === 'PENDING_REVIEW' ? '申请审核中'
|
||||
: status === 'REJECTED' ? '申请需要修改'
|
||||
: status === 'DISABLED' ? '账号暂不可用'
|
||||
: status === 'NEED_MANUAL_LOGIN' ? '需要完成注册' : '登录失败'
|
||||
const content = result.registrationRejectReason || result.message || '请稍后重试'
|
||||
const canRetry = status === 'ERROR' || status === 'NEED_MANUAL_LOGIN' || status === 'REJECTED'
|
||||
wx.showModal({
|
||||
title,
|
||||
content,
|
||||
showCancel: canRetry,
|
||||
confirmText: status === 'REJECTED' ? '重新提交' : canRetry ? '重新登录' : '知道了',
|
||||
cancelText: '取消',
|
||||
success: choice => {
|
||||
if (!choice.confirm) return
|
||||
if (status === 'REJECTED' && result.registrationTicket) this.navigateToRegistration(result)
|
||||
else if (status === 'REJECTED') {
|
||||
this._resumeRegistrationAfterRejected = true
|
||||
this.quickLogin()
|
||||
}
|
||||
else if (status === 'ERROR' || status === 'NEED_MANUAL_LOGIN') this.quickLogin()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
navigateToRegistration(result) {
|
||||
const query = [
|
||||
`registrationTicket=${encodeURIComponent(result.registrationTicket)}`,
|
||||
result.registrationApplicationId ? `applicationId=${encodeURIComponent(result.registrationApplicationId)}` : ''
|
||||
].filter(Boolean).join('&')
|
||||
wx.navigateTo({ url: `/pages/register/index?${query}` })
|
||||
},
|
||||
|
||||
async selectShop(event) {
|
||||
@@ -194,6 +237,7 @@ Page({
|
||||
},
|
||||
|
||||
finishLogin(result) {
|
||||
this._presentedLoginState = ''
|
||||
getApp().setSession(result, true)
|
||||
auth.setLoginPreference(this.data.rememberMe ? {
|
||||
rememberMe: true,
|
||||
|
||||
@@ -5,6 +5,10 @@ const path = require('path')
|
||||
let definition
|
||||
let exitOptions
|
||||
let toastOptions
|
||||
let modalOptions
|
||||
let navigatedTo
|
||||
let modalChoice = { confirm: false, cancel: true }
|
||||
let modalCount = 0
|
||||
|
||||
global.Page = value => { definition = value }
|
||||
global.wx = {
|
||||
@@ -13,6 +17,14 @@ global.wx = {
|
||||
},
|
||||
showToast(options) {
|
||||
toastOptions = options
|
||||
},
|
||||
showModal(options) {
|
||||
modalOptions = options
|
||||
modalCount += 1
|
||||
if (options.success) options.success(modalChoice)
|
||||
},
|
||||
navigateTo(options) {
|
||||
navigatedTo = options.url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +66,32 @@ async function run() {
|
||||
exitOptions.fail()
|
||||
assert.strictEqual(toastOptions.title, '请同意协议后使用')
|
||||
|
||||
const statePage = createPage()
|
||||
statePage.handleResult({ status: 'PENDING_REVIEW', message: '申请审核中' })
|
||||
assert.strictEqual(modalOptions.title, '申请审核中')
|
||||
assert.strictEqual(modalOptions.showCancel, false)
|
||||
assert.strictEqual(statePage._presentedLoginState.startsWith('PENDING_REVIEW:'), true)
|
||||
|
||||
const modalCountBeforeError = modalCount
|
||||
const errorPage = createPage()
|
||||
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
|
||||
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
|
||||
assert.strictEqual(modalOptions.title, '登录失败')
|
||||
assert.strictEqual(modalCount, modalCountBeforeError + 1)
|
||||
|
||||
modalChoice = { confirm: true, cancel: false }
|
||||
const rejectedPage = createPage()
|
||||
rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23 })
|
||||
assert.match(navigatedTo, /registrationTicket=ticket-1/)
|
||||
assert.match(navigatedTo, /applicationId=23/)
|
||||
|
||||
const template = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
assert.match(template, /用户协议与隐私政策提示/)
|
||||
assert.match(template, /不同意并退出/)
|
||||
assert.match(template, /同意并继续/)
|
||||
assert.match(template, /data-type="USER_TERMS" catchtap="openAgreement"/)
|
||||
assert.match(template, /data-type="PRIVACY_POLICY" catchtap="openAgreement"/)
|
||||
assert.doesNotMatch(template, /class="state-line"/)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<view class="brand-area">
|
||||
<image class="login-logo" src="/assets/images/app-icon.png" mode="aspectFill"></image><text class="brand-name">{{appName}}</text><text class="brand-sub">Salon 门店工作台</text>
|
||||
</view>
|
||||
<view wx:if="{{loginState && loginState.status !== 'READY' && loginState.status !== 'NEW_USER'}}" class="state-line"><text class="state-title">{{loginState.status === 'PENDING_REVIEW' ? '申请审核中' : loginState.status === 'REJECTED' ? '申请需要修改' : loginState.status === 'DISABLED' ? '账号暂不可用' : loginState.status === 'ERROR' ? '连接失败' : '账号状态'}}</text><text class="state-message">{{loginState.registrationRejectReason || loginState.message}}</text></view>
|
||||
<view class="action-area">
|
||||
<button class="quick-btn" loading="{{loading}}" disabled="{{loading || agreementLoading}}" bindtap="quickLogin"><text>快捷登录</text></button>
|
||||
<view class="remember-row" bindtap="toggleRememberMe">
|
||||
|
||||
@@ -112,26 +112,6 @@
|
||||
background: #247b63;
|
||||
}
|
||||
|
||||
.state-line {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 34rpx;
|
||||
}
|
||||
|
||||
.state-title {
|
||||
color: #765b32;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.state-message {
|
||||
margin-top: 7rpx;
|
||||
color: #9a8260;
|
||||
font-size: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.agreement-footer {
|
||||
padding-top: 50rpx;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Salon 店长审核与门店经营有效期配置说明
|
||||
|
||||
更新时间:2026-10-26
|
||||
|
||||
本说明适用于 Salon Core、后台管理和微信小程序的店长注册审核及门店经营有效期功能。不连接或修改实际数据库、Nacos、微信后台。
|
||||
|
||||
## 配置项
|
||||
|
||||
配置保存在 `t_system_parameter_config`,由 Flyway V6 为空库幂等写入;后台“系统设置”可即时调整。
|
||||
|
||||
| 分组 | 键 | 默认值 | 用途 |
|
||||
| --- | --- | --- | --- |
|
||||
| `WORKBENCH` | `MANAGER_REGISTRATION_AUTO_APPROVE` | `false` | 开启后,店长申请关联的门店资料内容审核通过时自动批准;关闭后转平台管理员人工复核。 |
|
||||
| `SHOP` | `SHOP_DEFAULT_VALID_DAYS` | `30` | 新店长申请审核通过时,新门店有效天数,允许 1–3650 的整数。 |
|
||||
|
||||
店长自动审核不绕过内容审核。内容审核中的店长申请不会出现在可审批列表;拒绝的内容会使申请退回并显示原因。店员申请仍由店长按原流程审核。
|
||||
|
||||
审核通过日计为第 1 天,到期日期当天 23:59:59 前仍有效。管理员可以在“门店管理”中单独设置到期日。已过期或未设置有效期的门店不能新增普通预约;补录历史订单、查询和其他门店业务不受限制。新店默认有效期由审核通过时的参数确定,修改参数不追溯调整已创建门店。
|
||||
|
||||
## 迁移与发布
|
||||
|
||||
- 新增迁移:`JC-Salon-Core/src/main/resources/db/migration/V6__Salon店长审核模式与门店经营有效期_20261026.sql`。
|
||||
- 迁移增加 `t_shop.business_expire_time`、注册申请内容审核记录关联字段/索引和两条系统参数种子;字段、索引与参数种子均按存在性/组合键幂等处理。
|
||||
- 当前没有存量门店,不做历史门店回填。冻结的初始化 SQL 和 V1–V5 不修改。
|
||||
- DEV 先部署 Core,由 Flyway 启动时执行 V6;验证启动、后台配置读写、申请审批和过期预约拦截,再按 `dev -> sit -> prod` 晋级。
|
||||
- 不在 Gitea 工作流直接执行 SQL;不运行 `flyway clean`,应用回退不回滚迁移。修复迁移只能追加向前兼容版本。
|
||||
|
||||
## 操作验证
|
||||
|
||||
1. 后台把自动审核关闭,提交店长申请;确认内容审核通过后仍等待平台管理员审核。
|
||||
2. 开启自动审核后重新提交店长申请;确认只有内容审核通过才自动批准,申请状态和账号、门店关系一致。
|
||||
3. 修改默认有效天数,完成新申请;确认新门店的到期日按“通过日 + 天数 - 1”计算。
|
||||
4. 在门店管理延长或提前设置到期日;到期前新增预约成功,到期/未配置时服务端拒绝普通预约;补录历史订单仍可使用。
|
||||
5. 通过多门店账号切换门店,确认小程序账号资料展示当前门店的有效期。
|
||||
@@ -87,6 +87,7 @@ MessageHub 的地址、交换机、路由和来源系统放在对应环境 `core
|
||||
- 历史补单使用订单来源 `HISTORICAL_BACKFILL`;状态 `4` 为“服务中”。补单必须归属员工,可不填写客户和具体服务时间,不创建预约占用。
|
||||
- 初始化 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 增加门店有效期字段、店长申请内容审核关联和默认参数。自动批准仅在绑定的门店资料内容审核通过后生效;过期或未配置有效期的门店不能新增普通预约,补录和查询仍可用。参数默认值、发布验证和业务边界见 `docs/scripts/Salon店长审核与门店有效期配置说明_20261026.md`。
|
||||
|
||||
## 8. 操作前检查
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# 项目变更记录
|
||||
|
||||
## 2026-10-26 Salon 店长注册审核模式与门店经营有效期
|
||||
|
||||
- 店长注册审核支持后台配置自动批准或人工复核;自动批准仅在该申请关联的门店资料内容审核通过后执行,店员原审核流程保持不变,并增加独立事务补偿检查。
|
||||
- 门店新增经营到期日与默认有效天数参数;管理员可在门店管理单独设置到期日,小程序店长账号信息展示当前门店有效期。
|
||||
- 普通预约创建服务端校验门店有效期,到期或未设置时拒绝新增;历史补录、查询等流程不受影响。
|
||||
- 登录状态由页面内嵌文字调整为一次性弹窗;后台注册审核展示门店资料内容审核状态;门店有效期批量接口使用逗号分隔 ID。
|
||||
- 新增 Flyway V6 迁移及配置说明文档,不修改冻结初始化 SQL、V1–V5,不回填存量门店,不操作实际数据库/Nacos/微信后台。
|
||||
- GitNexus 索引更新成功但全文索引构建失败;普通预约服务入口影响评估为低风险,门店通用资料更新链评估为高风险,因此采用独立有效期管理接口避开该共享链。通过静态调用检查和专项测试补足其余登录、审批与有效期流程。
|
||||
|
||||
## 2026-10-26 Salon 后台七页紧凑操作台重构
|
||||
|
||||
- 首页、账号管理、注册审核、隐私与内容复核、门店管理、系统设置和个人设置统一到浅薄荷工作台视觉:页面内容铺开,使用紧凑标题、工具带、表格表头和行式分区,减少圆角卡片与阴影。
|
||||
|
||||
Reference in New Issue
Block a user