|
|
@@ -1072,7 +1072,8 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验加时不能超过门店营业结束时间(数据来源:{@code store_business_info},不再使用预订营业时间 store_booking_business_hours)
|
|
|
+ * 校验加时:非「门店全天」时,新结束时间不得超过 {@code store_business_info} 的营业结束时间。
|
|
|
+ * 「门店全天」由当日匹配的 {@code store_business_info.start_time}、{@code end_time} 均为 {@code 00:00} 判定(与数据库约定一致)。
|
|
|
*
|
|
|
* @param reservation 预约信息
|
|
|
* @param addTimeStart 加时开始时间(yyyy-MM-dd HH:mm:ss)
|
|
|
@@ -1089,22 +1090,21 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String reservationDateStr = dateFormat.format(reservationDate);
|
|
|
|
|
|
- StoreBookingBusinessHours matchedBusinessHours =
|
|
|
+ StoreBookingBusinessHours matchedStoreBusiness =
|
|
|
findBusinessHoursFromStoreBusinessInfo(reservation, reservationDate, reservationDateStr);
|
|
|
|
|
|
- if (matchedBusinessHours == null) {
|
|
|
+ if (matchedStoreBusiness == null) {
|
|
|
log.warn("未找到门店营业时间(store_business_info),跳过加时营业结束时间校验,storeId={}", reservation.getStoreId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // store_business_info 无预订侧「全天」字段;包装对象上 bookingTimeType 恒为 null,此处保留分支以备扩展
|
|
|
- if (matchedBusinessHours.getBookingTimeType() != null && matchedBusinessHours.getBookingTimeType() == 1) {
|
|
|
- log.info("全天营业,不限制结束时间");
|
|
|
+ if (isStoreBusinessInfoAllDay(matchedStoreBusiness.getStartTime(), matchedStoreBusiness.getEndTime())) {
|
|
|
+ log.info("store_business_info 为 00:00–00:00 全天,加时忽略营业结束时间,storeId={}", reservation.getStoreId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 获取营业时间的结束时间
|
|
|
- String businessEndTime = matchedBusinessHours.getEndTime();
|
|
|
+ // 获取门店营业结束时间(store_business_info)
|
|
|
+ String businessEndTime = matchedStoreBusiness.getEndTime();
|
|
|
if (businessEndTime == null || businessEndTime.trim().isEmpty()) {
|
|
|
log.warn("营业时间结束时间为空,跳过校验");
|
|
|
return;
|
|
|
@@ -1158,6 +1158,38 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * {@code store_business_info} 约定:开始、结束均为 00:00 表示全天营业,商家加时可超过当日配置的「结束时间」限制。
|
|
|
+ */
|
|
|
+ private boolean isStoreBusinessInfoAllDay(String startTimeHm, String endTimeHm) {
|
|
|
+ return "00:00".equals(normalizeBusinessHm(startTimeHm)) && "00:00".equals(normalizeBusinessHm(endTimeHm));
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 将 HH:mm(或带秒)规范为 HH:mm,便于与 00:00 比较 */
|
|
|
+ private String normalizeBusinessHm(String hm) {
|
|
|
+ if (hm == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ hm = hm.trim();
|
|
|
+ if (hm.isEmpty()) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ String[] parts = hm.split(":");
|
|
|
+ if (parts.length < 2) {
|
|
|
+ return hm;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ int h = Integer.parseInt(parts[0].trim());
|
|
|
+ int m = Integer.parseInt(parts[1].trim());
|
|
|
+ if (h < 0 || h > 23 || m < 0 || m > 59) {
|
|
|
+ return hm;
|
|
|
+ }
|
|
|
+ return String.format("%02d:%02d", h, m);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return hm;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 从 store_business_info 表中查找匹配的营业时间
|
|
|
*
|
|
|
* @param reservation 预约信息
|
|
|
@@ -1221,11 +1253,12 @@ public class StoreReservationServiceImpl extends ServiceImpl<StoreReservationMap
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- // 将 StoreBusinessInfoVo 转换为 StoreBookingBusinessHours 格式(仅用于返回 endTime)
|
|
|
+ // 转为载体:加时上限用 endTime;是否全天用 startTime/endTime
|
|
|
StoreBookingBusinessHours result = new StoreBookingBusinessHours();
|
|
|
+ result.setStartTime(matchedBusinessInfo.getStartTime());
|
|
|
result.setEndTime(matchedBusinessInfo.getEndTime());
|
|
|
- result.setBookingTimeType(null); // store_business_info 没有 booking_time_type,设为 null 表示非全天
|
|
|
- log.info("从 store_business_info 找到匹配的营业时间,endTime={}", matchedBusinessInfo.getEndTime());
|
|
|
+ log.info("从 store_business_info 找到匹配的营业时间,startTime={}, endTime={}",
|
|
|
+ matchedBusinessInfo.getStartTime(), matchedBusinessInfo.getEndTime());
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error("从 store_business_info 查询营业时间失败", e);
|