修复Salon注册预约客户流程

This commit is contained in:
2026-10-30 15:13:38 +08:00
parent 53b6fcaa11
commit 7b9a5e4d1c
20 changed files with 748 additions and 67 deletions
@@ -110,10 +110,9 @@ public class PlanningServiceImpl implements PlanningService {
Long shopId = requirePlanningShopId(currentUser);
ShopDO shop = shopMapper.selectById(shopId);
PlanningCalendarSupport.BusinessHours businessHours = PlanningCalendarSupport.parseBusinessHours(
PlanningCalendarSupport.BusinessHours businessHours = parseConfiguredBusinessHours(
shop == null ? null : (StringUtils.hasText(shop.getAppointmentBusinessHours())
? shop.getAppointmentBusinessHours() : shop.getBusinessHours())
);
? shop.getAppointmentBusinessHours() : shop.getBusinessHours()));
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
@@ -135,8 +134,8 @@ public class PlanningServiceImpl implements PlanningService {
artists.forEach(artist -> artist.setRangeCount(countByArtist.getOrDefault(artist.getId(), 0L).intValue()));
PlanningCalendarVO vo = new PlanningCalendarVO();
vo.setBusinessStartTime(businessHours.start().toString());
vo.setBusinessEndTime(businessHours.end().toString());
vo.setBusinessStartTime(businessHours == null ? null : businessHours.start().toString());
vo.setBusinessEndTime(businessHours == null ? null : businessHours.end().toString());
vo.setDefaultAppointmentDurationMinutes(shop == null || shop.getDefaultAppointmentDurationMinutes() == null
|| shop.getDefaultAppointmentDurationMinutes() <= 0 ? DEFAULT_DURATION_MINUTES : shop.getDefaultAppointmentDurationMinutes());
vo.setSlotMinutes(DEFAULT_SLOT_MINUTES);
@@ -862,7 +861,12 @@ public class PlanningServiceImpl implements PlanningService {
ShopDO shop = shopMapper.selectById(shopId);
String configuredHours = shop == null ? null : (StringUtils.hasText(shop.getAppointmentBusinessHours())
? shop.getAppointmentBusinessHours() : shop.getBusinessHours());
PlanningCalendarSupport.BusinessHours hours = PlanningCalendarSupport.parseBusinessHours(configuredHours);
PlanningCalendarSupport.BusinessHours hours = parseConfiguredBusinessHours(configuredHours);
if (hours == null) {
throw new RuntimeException(StringUtils.hasText(configuredHours)
? "门店营业时间格式无效,请先完成设置"
: "门店营业时间未设置,请先完成设置");
}
LocalTime start = startTime.toLocalTime();
LocalTime end = endTime.toLocalTime();
if (start.isBefore(hours.start()) || end.isAfter(hours.end()) || !startTime.toLocalDate().equals(endTime.toLocalDate())) {
@@ -870,6 +874,19 @@ public class PlanningServiceImpl implements PlanningService {
}
}
private PlanningCalendarSupport.BusinessHours parseConfiguredBusinessHours(String value) {
if (!StringUtils.hasText(value)) return null;
String[] parts = value.trim().split("-");
if (parts.length != 2) return null;
try {
LocalTime start = LocalTime.parse(parts[0].trim());
LocalTime end = LocalTime.parse(parts[1].trim());
return start.isBefore(end) ? new PlanningCalendarSupport.BusinessHours(start, end) : null;
} catch (RuntimeException ignored) {
return null;
}
}
private void ensureFutureAppointmentTime(LocalDateTime startTime) {
LocalDate today = LocalDate.now();
if (startTime.toLocalDate().isBefore(today)) {
@@ -227,7 +227,6 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
ContentModerationRecordDO latestReview = contentModerationRecordMapper.selectOne(Wrappers.lambdaQuery(ContentModerationRecordDO.class)
.eq(ContentModerationRecordDO::getContentType, "SHOP")
.eq(ContentModerationRecordDO::getBusinessId, id)
.eq(ContentModerationRecordDO::getIsDelete, 0)
.orderByDesc(ContentModerationRecordDO::getVersionNo)
.last("limit 1"));
result.setShopNameModerationStatus(latestReview == null ? shop.getModerationStatus() : latestReview.getStatus());
@@ -621,13 +621,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
return userMapper.selectList(wrapper).stream()
.filter(user -> Objects.equals(normalizedName, user.getNickname()))
.filter(user -> Objects.equals(normalizedWechatId, UserProfileFieldSupport.normalizeOptionalText(user.getWechatId())))
.filter(user -> Objects.equals(normalizedPhone, decryptPhone(user.getPhone())))
.filter(user -> Objects.equals(normalizedPhone, resolveCustomerPhone(user)))
.map(user -> {
AppointmentCustomerOptionVO customer = new AppointmentCustomerOptionVO();
customer.setId(user.getId());
customer.setName(user.getNickname());
String contactPhone = decryptPhone(user.getContactPhone());
customer.setPhone(StringUtils.hasText(contactPhone) ? contactPhone : decryptPhone(user.getPhone()));
customer.setPhone(resolveCustomerPhone(user));
customer.setAvatar(resolveAccessibleAvatar(user.getAvatar()));
customer.setCreatedAt(user.getCreateTime());
return customer;
@@ -656,9 +655,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
AppointmentCustomerOptionVO option = new AppointmentCustomerOptionVO();
option.setId(user.getId());
option.setName(user.getNickname());
String contactPhone = decryptPhone(user.getContactPhone());
String phone = StringUtils.hasText(contactPhone) ? contactPhone : decryptPhone(user.getPhone());
option.setPhone(phone);
option.setPhone(resolveCustomerPhone(user));
option.setAvatar(resolveAccessibleAvatar(user.getAvatar()));
option.setCreatedAt(user.getCreateTime());
return option;
@@ -676,6 +673,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
else wrapper.and(query -> query.eq(UserDO::getShopId, shopId).or().in(UserDO::getId, shopUserIds));
}
private String resolveCustomerPhone(UserDO customer) {
String contactPhone = decryptPhone(customer.getContactPhone());
return StringUtils.hasText(contactPhone) ? contactPhone : decryptPhone(customer.getPhone());
}
/**
* 分配默认权限
* @param userId 用户ID