补充门店周排班与预约营业校验
This commit is contained in:
+20
-9
@@ -23,6 +23,8 @@ 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.shop.service.ShopBusinessScheduleService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessHoursDayVO;
|
||||
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;
|
||||
@@ -95,6 +97,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private final ProductMapper productMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final ShopBusinessScheduleService shopBusinessScheduleService;
|
||||
private final AppointmentCapacityService appointmentCapacityService;
|
||||
private final OrderService orderService;
|
||||
private final WechatSubscribeMessageService wechatSubscribeMessageService;
|
||||
@@ -117,6 +120,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
PlanningCalendarSupport.BusinessHours businessHours = parseConfiguredBusinessHours(
|
||||
shop == null ? null : (StringUtils.hasText(shop.getAppointmentBusinessHours())
|
||||
? shop.getAppointmentBusinessHours() : shop.getBusinessHours()));
|
||||
Map<Integer, ShopBusinessHoursDayVO> weeklyHours = shopBusinessScheduleService.mapByDay(
|
||||
shopId, shop == null ? null : (StringUtils.hasText(shop.getAppointmentBusinessHours())
|
||||
? shop.getAppointmentBusinessHours() : shop.getBusinessHours()));
|
||||
|
||||
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
|
||||
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
|
||||
@@ -146,7 +152,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setArtists(artists);
|
||||
vo.setSchedules(scheduleVos);
|
||||
vo.setAppointments(appointments);
|
||||
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments));
|
||||
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments, weeklyHours));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -641,7 +647,8 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
}
|
||||
|
||||
private List<PlanningDaySummaryVO> buildDaySummaries(LocalDate start, LocalDate end, List<PlanningArtistVO> artists,
|
||||
List<ArtistScheduleDO> schedules, List<PlanningAppointmentVO> appointments) {
|
||||
List<ArtistScheduleDO> schedules, List<PlanningAppointmentVO> appointments,
|
||||
Map<Integer, ShopBusinessHoursDayVO> weeklyHours) {
|
||||
Map<String, List<PlanningAppointmentVO>> appointmentsByDate = appointments.stream()
|
||||
.filter(appointment -> appointment.getDate() != null)
|
||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getDate));
|
||||
@@ -699,7 +706,12 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
summary.setTotalCount(total);
|
||||
summary.setUnassignedCount(unassignedCount);
|
||||
summary.setArtistCounts(artistCounts);
|
||||
summary.setDayStatus(PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull));
|
||||
ShopBusinessHoursDayVO shopDay = weeklyHours == null ? null : weeklyHours.get(cursor.getDayOfWeek().getValue());
|
||||
boolean shopOpen = shopDay == null || Boolean.TRUE.equals(shopDay.getOpen());
|
||||
summary.setShopOpen(shopOpen);
|
||||
summary.setShopStartTime(shopDay == null ? null : shopDay.getStartTime());
|
||||
summary.setShopEndTime(shopDay == null ? null : shopDay.getEndTime());
|
||||
summary.setDayStatus(!shopOpen ? "rest" : PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull));
|
||||
summaries.add(summary);
|
||||
cursor = cursor.plusDays(1);
|
||||
}
|
||||
@@ -884,12 +896,11 @@ 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 = parseConfiguredBusinessHours(configuredHours);
|
||||
if (hours == null) {
|
||||
throw new RuntimeException(StringUtils.hasText(configuredHours)
|
||||
? "门店营业时间格式无效,请先完成设置"
|
||||
: "门店营业时间未设置,请先完成设置");
|
||||
}
|
||||
ShopBusinessHoursDayVO shopDay = shopBusinessScheduleService.forDate(shopId, startTime.toLocalDate(), configuredHours);
|
||||
if (shopDay == null || !Boolean.TRUE.equals(shopDay.getOpen())) throw new RuntimeException("预约日期门店休息,暂不可新建普通预约");
|
||||
PlanningCalendarSupport.BusinessHours hours = parseConfiguredBusinessHours(
|
||||
shopDay.getStartTime() + "-" + shopDay.getEndTime());
|
||||
if (hours == null) throw new RuntimeException("门店营业时间未设置,请先完成设置");
|
||||
LocalTime start = startTime.toLocalTime();
|
||||
LocalTime end = endTime.toLocalTime();
|
||||
if (start.isBefore(hours.start()) || end.isAfter(hours.end()) || !startTime.toLocalDate().equals(endTime.toLocalDate())) {
|
||||
|
||||
-3
@@ -66,9 +66,6 @@ public final class PlanningCalendarSupport {
|
||||
}
|
||||
|
||||
public static String resolveDayStatus(int totalCount, boolean hasWorkingSchedule, boolean allWorkingArtistsBusy) {
|
||||
if (!hasWorkingSchedule) {
|
||||
return "rest";
|
||||
}
|
||||
if (allWorkingArtistsBusy) {
|
||||
return "full";
|
||||
}
|
||||
|
||||
+3
@@ -11,4 +11,7 @@ public class PlanningDaySummaryVO {
|
||||
private Integer unassignedCount;
|
||||
private List<PlanningArtistCountVO> artistCounts;
|
||||
private String dayStatus;
|
||||
private Boolean shopOpen;
|
||||
private String shopStartTime;
|
||||
private String shopEndTime;
|
||||
}
|
||||
|
||||
+4
@@ -3,6 +3,8 @@ package com.xiaowang.jayucloud.salon.core.modules.registration.dto;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class WorkbenchRegistrationRequestDTO {
|
||||
@@ -12,6 +14,8 @@ public class WorkbenchRegistrationRequestDTO {
|
||||
private Long shopId;
|
||||
private String shopName;
|
||||
private String shopAddress;
|
||||
private BigDecimal shopLongitude;
|
||||
private BigDecimal shopLatitude;
|
||||
private Boolean agreementAccepted;
|
||||
private String applicantNickname;
|
||||
private Long applicantAvatarFileId;
|
||||
|
||||
+12
@@ -22,6 +22,7 @@ import com.xiaowang.jayucloud.salon.core.modules.shop.support.UserShopBindingSup
|
||||
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.shop.service.ShopBusinessScheduleService;
|
||||
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;
|
||||
@@ -62,6 +63,7 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
private final ContentModerationService contentModerationService;
|
||||
private final ContentModerationRecordMapper contentModerationRecordMapper;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final ShopBusinessScheduleService shopBusinessScheduleService;
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
private final WechatMiniBindingMapper wechatMiniBindingMapper;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
@@ -111,6 +113,13 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
|
||||
String managerShopName = WorkbenchRegistrationRole.MANAGER.equals(roleType)
|
||||
? requireText(request.getShopName(), "店铺名称不能为空") : null;
|
||||
if ((request.getShopLongitude() == null) != (request.getShopLatitude() == null)) {
|
||||
throw new IllegalArgumentException("地图坐标信息不完整,请重新选点");
|
||||
}
|
||||
if (request.getShopLongitude() != null && (request.getShopLongitude().abs().compareTo(java.math.BigDecimal.valueOf(180)) > 0
|
||||
|| request.getShopLatitude().abs().compareTo(java.math.BigDecimal.valueOf(90)) > 0)) {
|
||||
throw new IllegalArgumentException("地图坐标超出有效范围");
|
||||
}
|
||||
ShopDO selectedStaffShop = null;
|
||||
if (WorkbenchRegistrationRole.STAFF.equals(roleType)) {
|
||||
require(request.getShopId() != null, "请选择要加入的店铺");
|
||||
@@ -144,6 +153,8 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
}
|
||||
shop.setShopName(managerShopName);
|
||||
shop.setAddress(request.getShopAddress());
|
||||
shop.setLongitude(request.getShopLongitude());
|
||||
shop.setLatitude(request.getShopLatitude());
|
||||
shop.setDescription("Salon店务工作台注册申请");
|
||||
shop.setBusinessHours("10:00-22:00");
|
||||
shop.setStatus(0);
|
||||
@@ -154,6 +165,7 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
} else {
|
||||
shopMapper.updateById(shop);
|
||||
}
|
||||
shopBusinessScheduleService.initializeDefault(shop.getId(), "10:00-22:00");
|
||||
} else {
|
||||
shop = selectedStaffShop;
|
||||
}
|
||||
|
||||
+2
@@ -1,9 +1,11 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ShopAppointmentSettingsDTO {
|
||||
private String businessHours;
|
||||
private Integer defaultAppointmentDurationMinutes;
|
||||
private List<ShopBusinessHoursDayDTO> weeklyHours;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ShopBusinessHoursDayDTO {
|
||||
private Integer dayOfWeek;
|
||||
private Boolean open;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.service;
|
||||
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.dto.ShopBusinessHoursDayDTO;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessHoursDayVO;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ShopBusinessScheduleService {
|
||||
private static final LocalTime DEFAULT_START = LocalTime.of(10, 0);
|
||||
private static final LocalTime DEFAULT_END = LocalTime.of(22, 0);
|
||||
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm");
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public ShopBusinessScheduleService(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public List<ShopBusinessHoursDayVO> list(Long shopId, String legacyHours) {
|
||||
ensureDefaultSchedule(shopId, legacyHours);
|
||||
return jdbcTemplate.query(
|
||||
"SELECT day_of_week, is_open, start_time, end_time FROM t_shop_weekly_schedule WHERE shop_id = ? ORDER BY day_of_week",
|
||||
(rs, rowNum) -> {
|
||||
ShopBusinessHoursDayVO day = new ShopBusinessHoursDayVO();
|
||||
day.setDayOfWeek(rs.getInt("day_of_week"));
|
||||
day.setOpen(rs.getInt("is_open") == 1);
|
||||
Time start = rs.getTime("start_time");
|
||||
Time end = rs.getTime("end_time");
|
||||
day.setStartTime(start == null ? null : start.toLocalTime().format(TIME_FORMAT));
|
||||
day.setEndTime(end == null ? null : end.toLocalTime().format(TIME_FORMAT));
|
||||
return day;
|
||||
}, shopId
|
||||
);
|
||||
}
|
||||
|
||||
public Map<Integer, ShopBusinessHoursDayVO> mapByDay(Long shopId, String legacyHours) {
|
||||
Map<Integer, ShopBusinessHoursDayVO> result = new HashMap<>();
|
||||
list(shopId, legacyHours).forEach(day -> result.put(day.getDayOfWeek(), day));
|
||||
return result;
|
||||
}
|
||||
|
||||
public ShopBusinessHoursDayVO forDate(Long shopId, LocalDate date, String legacyHours) {
|
||||
if (date == null) return null;
|
||||
return mapByDay(shopId, legacyHours).get(date.getDayOfWeek().getValue());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void initializeDefault(Long shopId, String legacyHours) {
|
||||
ensureDefaultSchedule(shopId, legacyHours);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void save(Long shopId, List<ShopBusinessHoursDayDTO> requested, String legacyHours) {
|
||||
List<ShopBusinessHoursDayDTO> days = requested;
|
||||
if (days == null || days.isEmpty()) {
|
||||
days = legacySchedule(legacyHours);
|
||||
}
|
||||
if (days.size() != 7) throw new IllegalArgumentException("请设置周一至周日的营业状态");
|
||||
Map<Integer, ShopBusinessHoursDayDTO> byDay = new HashMap<>();
|
||||
for (ShopBusinessHoursDayDTO day : days) {
|
||||
if (day == null || day.getDayOfWeek() == null || day.getDayOfWeek() < 1 || day.getDayOfWeek() > 7
|
||||
|| byDay.putIfAbsent(day.getDayOfWeek(), day) != null) {
|
||||
throw new IllegalArgumentException("每周营业设置必须包含周一至周日且不能重复");
|
||||
}
|
||||
if (!Boolean.TRUE.equals(day.getOpen())) {
|
||||
day.setOpen(false);
|
||||
day.setStartTime(null);
|
||||
day.setEndTime(null);
|
||||
continue;
|
||||
}
|
||||
LocalTime start = parseTime(day.getStartTime(), "营业开始时间");
|
||||
LocalTime end = parseTime(day.getEndTime(), "营业结束时间");
|
||||
if (!start.isBefore(end)) throw new IllegalArgumentException("营业开始时间必须早于结束时间");
|
||||
day.setStartTime(start.format(TIME_FORMAT));
|
||||
day.setEndTime(end.format(TIME_FORMAT));
|
||||
}
|
||||
if (byDay.size() != 7) throw new IllegalArgumentException("请完整设置周一至周日");
|
||||
|
||||
ensureDefaultSchedule(shopId, legacyHours);
|
||||
for (int dayOfWeek = 1; dayOfWeek <= 7; dayOfWeek++) {
|
||||
ShopBusinessHoursDayDTO day = byDay.get(dayOfWeek);
|
||||
jdbcTemplate.update(
|
||||
"UPDATE t_shop_weekly_schedule SET is_open = ?, start_time = ?, end_time = ?, update_time = CURRENT_TIMESTAMP WHERE shop_id = ? AND day_of_week = ?",
|
||||
Boolean.TRUE.equals(day.getOpen()) ? 1 : 0,
|
||||
day.getStartTime() == null ? null : Time.valueOf(day.getStartTime() + ":00"),
|
||||
day.getEndTime() == null ? null : Time.valueOf(day.getEndTime() + ":00"),
|
||||
shopId,
|
||||
dayOfWeek
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureDefaultSchedule(Long shopId, String legacyHours) {
|
||||
if (shopId == null) throw new IllegalArgumentException("门店不能为空");
|
||||
LocalTime[] parsed = parseLegacyHours(legacyHours);
|
||||
LocalTime start = parsed == null ? DEFAULT_START : parsed[0];
|
||||
LocalTime end = parsed == null ? DEFAULT_END : parsed[1];
|
||||
for (int day = 1; day <= 7; day++) {
|
||||
jdbcTemplate.update(
|
||||
"INSERT IGNORE INTO t_shop_weekly_schedule (shop_id, day_of_week, is_open, start_time, end_time, create_time, update_time) VALUES (?, ?, 1, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)",
|
||||
shopId, day, Time.valueOf(start), Time.valueOf(end)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ShopBusinessHoursDayDTO> legacySchedule(String legacyHours) {
|
||||
LocalTime[] times = parseLegacyHours(legacyHours);
|
||||
LocalTime start = times == null ? DEFAULT_START : times[0];
|
||||
LocalTime end = times == null ? DEFAULT_END : times[1];
|
||||
List<ShopBusinessHoursDayDTO> result = new ArrayList<>();
|
||||
for (int day = 1; day <= 7; day++) {
|
||||
ShopBusinessHoursDayDTO item = new ShopBusinessHoursDayDTO();
|
||||
item.setDayOfWeek(day);
|
||||
item.setOpen(true);
|
||||
item.setStartTime(start.format(TIME_FORMAT));
|
||||
item.setEndTime(end.format(TIME_FORMAT));
|
||||
result.add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private LocalTime[] parseLegacyHours(String value) {
|
||||
if (!StringUtils.hasText(value)) return null;
|
||||
String[] parts = value.trim().split("-");
|
||||
if (parts.length != 2) return null;
|
||||
try {
|
||||
LocalTime start = parseTime(parts[0], "营业开始时间");
|
||||
LocalTime end = parseTime(parts[1], "营业结束时间");
|
||||
return start.isBefore(end) ? new LocalTime[]{start, end} : null;
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private LocalTime parseTime(String value, String label) {
|
||||
if (!StringUtils.hasText(value)) throw new IllegalArgumentException(label + "不能为空");
|
||||
try {
|
||||
String normalized = value.trim();
|
||||
return LocalTime.parse(normalized.length() == 5 ? normalized : normalized.substring(0, 5), TIME_FORMAT);
|
||||
} catch (DateTimeParseException | IndexOutOfBoundsException e) {
|
||||
throw new IllegalArgumentException(label + "格式不正确");
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -26,6 +26,7 @@ import com.xiaowang.jayucloud.salon.core.modules.artist.service.NailArtistInfoSe
|
||||
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageFileService;
|
||||
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.service.ShopBusinessScheduleService;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.support.ShopThemeSupport;
|
||||
import com.xiaowang.jayucloud.salon.core.modules.shop.support.UserShopBindingSupport;
|
||||
@@ -97,6 +98,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
private final ShopMapper shopMapper;
|
||||
private final ContentModerationRecordMapper contentModerationRecordMapper;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final ShopBusinessScheduleService shopBusinessScheduleService;
|
||||
/**
|
||||
* Variable `couponService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -180,6 +182,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
shopDO.setStatus(normalizeStatus(shopDTO.getStatus()));
|
||||
shopDO.setIsDelete(0);
|
||||
shopMapper.insert(shopDO);
|
||||
shopBusinessScheduleService.initializeDefault(shopDO.getId(), "10:00-22:00");
|
||||
submitShopSnapshot(shopDO, shopDTO);
|
||||
couponService.initializeDefaultVipAutoCoupons(shopDO.getId());
|
||||
evictShopCaches(shopDO.getId());
|
||||
@@ -239,6 +242,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
}
|
||||
result.setBusinessHours(StringUtils.hasText(shop.getAppointmentBusinessHours())
|
||||
? shop.getAppointmentBusinessHours() : shop.getBusinessHours());
|
||||
result.setWeeklyHours(shopBusinessScheduleService.list(id, result.getBusinessHours()));
|
||||
result.setDefaultAppointmentDurationMinutes(shop.getDefaultAppointmentDurationMinutes() == null
|
||||
|| shop.getDefaultAppointmentDurationMinutes() <= 0 ? 60 : shop.getDefaultAppointmentDurationMinutes());
|
||||
return result;
|
||||
@@ -252,12 +256,17 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
if (shop == null || Integer.valueOf(1).equals(shop.getIsDelete())) {
|
||||
throw new IllegalArgumentException("门店不存在");
|
||||
}
|
||||
String businessHours = normalizeAppointmentBusinessHours(settings.getBusinessHours());
|
||||
Integer duration = settings.getDefaultAppointmentDurationMinutes();
|
||||
if (duration == null || duration < 15 || duration > 720) {
|
||||
throw new IllegalArgumentException("默认预约时长需在15至720分钟之间");
|
||||
}
|
||||
shop.setAppointmentBusinessHours(businessHours);
|
||||
shopBusinessScheduleService.save(id, settings.getWeeklyHours(), settings.getBusinessHours());
|
||||
List<com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessHoursDayVO> weeklyHours = shopBusinessScheduleService.list(
|
||||
id, StringUtils.hasText(settings.getBusinessHours()) ? settings.getBusinessHours() : shop.getBusinessHours());
|
||||
String firstOpenHours = weeklyHours.stream().filter(day -> Boolean.TRUE.equals(day.getOpen()))
|
||||
.sorted(java.util.Comparator.comparing(com.xiaowang.jayucloud.salon.core.modules.shop.vo.ShopBusinessHoursDayVO::getDayOfWeek))
|
||||
.map(day -> day.getStartTime() + "-" + day.getEndTime()).findFirst().orElse(null);
|
||||
shop.setAppointmentBusinessHours(firstOpenHours);
|
||||
shop.setDefaultAppointmentDurationMinutes(duration);
|
||||
return shopMapper.updateById(shop) > 0;
|
||||
}
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ShopAppointmentSettingsVO {
|
||||
@@ -9,4 +10,5 @@ public class ShopAppointmentSettingsVO {
|
||||
private String pendingShopName;
|
||||
private String businessHours;
|
||||
private Integer defaultAppointmentDurationMinutes;
|
||||
private List<ShopBusinessHoursDayVO> weeklyHours;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.xiaowang.jayucloud.salon.core.modules.shop.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ShopBusinessHoursDayVO {
|
||||
private Integer dayOfWeek;
|
||||
private Boolean open;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
}
|
||||
+3
@@ -27,6 +27,7 @@ import com.xiaowang.jayucloud.salon.core.modules.integration.mapper.WechatMiniBi
|
||||
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.shop.service.ShopBusinessScheduleService;
|
||||
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;
|
||||
@@ -157,6 +158,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
*/
|
||||
private final ShopService shopService;
|
||||
private final ShopBusinessExpiryService shopBusinessExpiryService;
|
||||
private final ShopBusinessScheduleService shopBusinessScheduleService;
|
||||
/**
|
||||
* Variable `userPermissionMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -1795,6 +1797,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
shop.setBusinessExpireTime(shopBusinessExpiryService.defaultExpireTime(LocalDate.now()));
|
||||
shop.setIsDelete(0);
|
||||
shopMapper.insert(shop);
|
||||
shopBusinessScheduleService.initializeDefault(shop.getId(), shop.getBusinessHours());
|
||||
|
||||
UserDO manager = new UserDO();
|
||||
manager.setShopId(shop.getId());
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
-- 门店逐周营业安排,旧营业区间完整回填到周一至周日。
|
||||
CREATE TABLE IF NOT EXISTS t_shop_weekly_schedule
|
||||
(
|
||||
shop_id bigint unsigned NOT NULL COMMENT '门店ID',
|
||||
day_of_week tinyint unsigned NOT NULL COMMENT '星期:1周一至7周日',
|
||||
is_open tinyint NOT NULL DEFAULT 1 COMMENT '营业状态:1营业,0休息',
|
||||
start_time time NULL COMMENT '营业开始时间',
|
||||
end_time time NULL COMMENT '营业结束时间',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (shop_id, day_of_week),
|
||||
KEY idx_shop_weekly_schedule_open (shop_id, is_open)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '门店每周营业安排';
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_salon_weekly_hours;
|
||||
CREATE TEMPORARY TABLE tmp_salon_weekly_hours
|
||||
(
|
||||
shop_id bigint unsigned NOT NULL PRIMARY KEY,
|
||||
start_time time NOT NULL,
|
||||
end_time time NOT NULL
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp_salon_weekly_hours (shop_id, start_time, end_time)
|
||||
SELECT source.id,
|
||||
CASE
|
||||
WHEN source.legacy_hours REGEXP '^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$'
|
||||
AND STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', 1), '%H:%i')
|
||||
< STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', -1), '%H:%i')
|
||||
THEN STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', 1), '%H:%i')
|
||||
ELSE '10:00:00'
|
||||
END,
|
||||
CASE
|
||||
WHEN source.legacy_hours REGEXP '^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$'
|
||||
AND STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', 1), '%H:%i')
|
||||
< STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', -1), '%H:%i')
|
||||
THEN STR_TO_DATE(SUBSTRING_INDEX(source.legacy_hours, '-', -1), '%H:%i')
|
||||
ELSE '22:00:00'
|
||||
END
|
||||
FROM (
|
||||
SELECT id, COALESCE(NULLIF(appointment_business_hours, ''), NULLIF(business_hours, ''), '10:00-22:00') AS legacy_hours
|
||||
FROM t_shop
|
||||
WHERE is_delete = 0
|
||||
) source;
|
||||
|
||||
INSERT IGNORE INTO t_shop_weekly_schedule (shop_id, day_of_week, is_open, start_time, end_time)
|
||||
SELECT legacy.shop_id, days.day_of_week, 1, legacy.start_time, legacy.end_time
|
||||
FROM tmp_salon_weekly_hours legacy
|
||||
CROSS JOIN (
|
||||
SELECT 1 AS day_of_week UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
|
||||
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7
|
||||
) days;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_salon_weekly_hours;
|
||||
@@ -148,7 +148,6 @@ Page({
|
||||
if (this.data.loading || !(await this.ensureCanLogin())) return
|
||||
this._presentedLoginState = ''
|
||||
// 订阅授权是可选的,拒绝时仍继续登录;调用必须发生在用户点击登录链路中。
|
||||
await requestSubscribeMessages()
|
||||
const rememberMe = await this.chooseRememberMode()
|
||||
if (rememberMe === null) return
|
||||
this.setData({ rememberMe, loading: true })
|
||||
@@ -239,7 +238,7 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
finishLogin(result) {
|
||||
async finishLogin(result, requestSubscription = true) {
|
||||
this._presentedLoginState = ''
|
||||
getApp().setSession(result, true)
|
||||
auth.setLoginPreference(this.data.rememberMe ? {
|
||||
@@ -247,6 +246,7 @@ Page({
|
||||
preferredShopId: result.userInfo && result.userInfo.shopId,
|
||||
agreementVersions: this.agreementPayload().agreementVersions
|
||||
} : { rememberMe: false })
|
||||
if (requestSubscription) await requestSubscribeMessages()
|
||||
wx.reLaunch({ url: '/pages/planning/index' })
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user