|
|
@@ -14,7 +14,6 @@ import shop.alien.entity.store.UserReservationTable;
|
|
|
import shop.alien.entity.store.UserReservationOrder;
|
|
|
import shop.alien.entity.store.vo.StoreReservationListVo;
|
|
|
import shop.alien.entity.store.StoreBookingBusinessHours;
|
|
|
-import shop.alien.entity.store.StoreBookingSettings;
|
|
|
import shop.alien.entity.store.EssentialHolidayComparison;
|
|
|
import shop.alien.entity.store.vo.StoreBusinessInfoVo;
|
|
|
import shop.alien.mapper.StoreReservationMapper;
|
|
|
@@ -27,8 +26,6 @@ import shop.alien.store.service.StoreInfoService;
|
|
|
import shop.alien.store.service.MerchantPaymentOrderService;
|
|
|
import shop.alien.store.service.StoreReservationService;
|
|
|
import shop.alien.store.service.UserReservationOrderService;
|
|
|
-import shop.alien.store.service.StoreBookingBusinessHoursService;
|
|
|
-import shop.alien.store.service.StoreBookingSettingsService;
|
|
|
import shop.alien.store.strategy.merchantPayment.MerchantPaymentStrategy;
|
|
|
import shop.alien.store.strategy.merchantPayment.MerchantPaymentStrategyFactory;
|
|
|
import shop.alien.store.util.ali.AliSms;
|
|
|
@@ -74,8 +71,6 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
private final LifeUserMapper lifeUserMapper;
|
|
|
private final StoreUserMapper storeUserMapper;
|
|
|
private final MerchantPaymentStrategyFactory merchantPaymentStrategyFactory;
|
|
|
- private final StoreBookingBusinessHoursService storeBookingBusinessHoursService;
|
|
|
- private final StoreBookingSettingsService storeBookingSettingsService;
|
|
|
private final EssentialHolidayComparisonMapper essentialHolidayComparisonMapper;
|
|
|
private final MerchantPaymentOrderService merchantPaymentOrderService;
|
|
|
|
|
|
@@ -712,7 +707,7 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
// 校验:不能超过下一个已确认预约的开始时间
|
|
|
validateAddTimeNotExceedNextReservation(reservation, normalizedAddTimeStart, newEndTime);
|
|
|
|
|
|
- // 校验:不能超过营业时间的结束时间
|
|
|
+ // 校验:不能超过门店营业时间结束时间(store_business_info)
|
|
|
validateAddTimeNotExceedBusinessHours(reservation, normalizedAddTimeStart, newEndTime);
|
|
|
|
|
|
// 更新预约结束时间
|
|
|
@@ -1077,10 +1072,11 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验加时不能超过营业时间的结束时间
|
|
|
- *
|
|
|
+ * 校验加时不能超过门店营业结束时间(数据来源:{@code store_business_info},不再使用预订营业时间 store_booking_business_hours)
|
|
|
+ *
|
|
|
* @param reservation 预约信息
|
|
|
- * @param newEndTime 新的结束时间(yyyy-MM-dd HH:mm:ss格式)
|
|
|
+ * @param addTimeStart 加时开始时间(yyyy-MM-dd HH:mm:ss)
|
|
|
+ * @param newEndTime 新的结束时间(yyyy-MM-dd HH:mm 或 HH:mm:ss 经 normalize 后)
|
|
|
*/
|
|
|
private void validateAddTimeNotExceedBusinessHours(UserReservation reservation, String addTimeStart, String newEndTime) {
|
|
|
try {
|
|
|
@@ -1089,95 +1085,19 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 查询门店的预订设置
|
|
|
- StoreBookingSettings settings = storeBookingSettingsService.getByStoreId(reservation.getStoreId());
|
|
|
- if (settings == null || settings.getId() == null) {
|
|
|
- log.warn("门店未配置预订设置,跳过营业时间校验,storeId={}", reservation.getStoreId());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询营业时间列表
|
|
|
- List<StoreBookingBusinessHours> businessHoursList = storeBookingBusinessHoursService.getListBySettingsId(settings.getId());
|
|
|
- if (businessHoursList == null || businessHoursList.isEmpty()) {
|
|
|
- log.warn("门店未配置营业时间,跳过营业时间校验,storeId={}", reservation.getStoreId());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 解析预约日期
|
|
|
Date reservationDate = reservation.getReservationDate();
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String reservationDateStr = dateFormat.format(reservationDate);
|
|
|
|
|
|
- // 查找匹配的营业时间
|
|
|
- StoreBookingBusinessHours matchedBusinessHours = null;
|
|
|
-
|
|
|
- // 先查找特殊营业时间(business_type=2,兼容旧值1)
|
|
|
- // 特殊营业时间的特征:有 holidayDate 或 essentialId 或 holidayType 不为空
|
|
|
- for (StoreBookingBusinessHours businessHours : businessHoursList) {
|
|
|
- Integer businessType = businessHours.getBusinessType();
|
|
|
- // 判断是否为特殊营业时间:新值2,或旧值1且有关联的节假日信息
|
|
|
- boolean isSpecialBusinessHours = false;
|
|
|
- if (businessType != null) {
|
|
|
- if (businessType == 2) {
|
|
|
- // 新值:2 表示特殊营业时间
|
|
|
- isSpecialBusinessHours = true;
|
|
|
- } else if (businessType == 1) {
|
|
|
- // 旧值:1 可能是特殊营业时间,需要检查是否有节假日信息
|
|
|
- if (businessHours.getEssentialId() != null ||
|
|
|
- businessHours.getHolidayDate() != null ||
|
|
|
- (businessHours.getHolidayType() != null && !businessHours.getHolidayType().trim().isEmpty())) {
|
|
|
- isSpecialBusinessHours = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (isSpecialBusinessHours) {
|
|
|
- // 特殊营业时间:需要匹配 essential_holiday_comparison 表中的日期范围
|
|
|
- if (businessHours.getEssentialId() != null) {
|
|
|
- EssentialHolidayComparison holiday = essentialHolidayComparisonMapper.selectById(businessHours.getEssentialId());
|
|
|
- if (holiday != null && holiday.getStartTime() != null && holiday.getEndTime() != null) {
|
|
|
- // 判断预约日期是否在节假日的日期范围内
|
|
|
- Date startTime = holiday.getStartTime();
|
|
|
- Date endTime = holiday.getEndTime();
|
|
|
- if (!reservationDate.before(startTime) && !reservationDate.after(endTime)) {
|
|
|
- matchedBusinessHours = businessHours;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (businessHours.getHolidayDate() != null) {
|
|
|
- // 如果没有 essentialId,使用 holidayDate 匹配
|
|
|
- if (reservationDateStr.equals(businessHours.getHolidayDate())) {
|
|
|
- matchedBusinessHours = businessHours;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 如果没有匹配到特殊营业时间,使用正常营业时间(business_type=1,兼容旧值0)
|
|
|
- if (matchedBusinessHours == null) {
|
|
|
- matchedBusinessHours = businessHoursList.stream()
|
|
|
- .filter(h -> {
|
|
|
- Integer businessType = h.getBusinessType();
|
|
|
- // 兼容旧值:0 和新值:1 都表示正常营业时间
|
|
|
- return businessType != null && (businessType == 1 || businessType == 0);
|
|
|
- })
|
|
|
- .findFirst()
|
|
|
- .orElse(null);
|
|
|
- }
|
|
|
-
|
|
|
- // 如果 store_booking_business_hours 中没有找到匹配的营业时间,则从 store_business_info 查询
|
|
|
- if (matchedBusinessHours == null) {
|
|
|
- log.info("store_booking_business_hours 中未找到匹配的营业时间,尝试从 store_business_info 查询,storeId={}", reservation.getStoreId());
|
|
|
- matchedBusinessHours = findBusinessHoursFromStoreBusinessInfo(reservation, reservationDate, reservationDateStr);
|
|
|
- }
|
|
|
+ StoreBookingBusinessHours matchedBusinessHours =
|
|
|
+ findBusinessHoursFromStoreBusinessInfo(reservation, reservationDate, reservationDateStr);
|
|
|
|
|
|
if (matchedBusinessHours == null) {
|
|
|
- log.warn("未找到匹配的营业时间,跳过营业时间校验");
|
|
|
+ log.warn("未找到门店营业时间(store_business_info),跳过加时营业结束时间校验,storeId={}", reservation.getStoreId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 如果是全天营业(booking_time_type=1),不限制结束时间
|
|
|
+ // store_business_info 无预订侧「全天」字段;包装对象上 bookingTimeType 恒为 null,此处保留分支以备扩展
|
|
|
if (matchedBusinessHours.getBookingTimeType() != null && matchedBusinessHours.getBookingTimeType() == 1) {
|
|
|
log.info("全天营业,不限制结束时间");
|
|
|
return;
|