Ver Fonte

Merge remote-tracking branch 'origin/sit' into sit

刘云鑫 há 1 mês atrás
pai
commit
c96a53ce0c

+ 18 - 8
alien-store/src/main/java/shop/alien/store/service/impl/UserReservationServiceImpl.java

@@ -255,10 +255,9 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
         }
         Integer reservationId = one.getReservationId();
 
-        // 当订单为未支付且为付费订单时,订单状态变为已关闭(5);否则为已取消(4)
+        // 当订单为未支付时,订单状态变为已关闭
         int orderStatus = 4;
-        if (one.getPaymentStatus() != null && one.getPaymentStatus() == 0
-                && one.getOrderCostType() != null && one.getOrderCostType() == 1) {
+        if (one.getPaymentStatus() != null && one.getPaymentStatus() == 0) {
             orderStatus = 5;
         }
 
@@ -496,13 +495,18 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
     }
 
     /**
-     * 将 "HH:mm" 解析为当日 0 点起的分钟数,解析失败返回 -1。
+     * 将 "HH:mm" 或 "yyyy-MM-dd HH:mm" / "yyyy-MM-dd HH:mm:ss" 解析为当日 0 点起的分钟数,解析失败返回 -1。
+     * 若带年月日(含空格),先去掉日期部分再按时分计算。
      */
     private static int timeToMinutes(String hhmm) {
         if (hhmm == null) {
             return -1;
         }
-        String[] parts = hhmm.trim().split(":");
+        hhmm = hhmm.trim();
+        if (hhmm.contains(" ")) {
+            hhmm = hhmm.substring(hhmm.indexOf(" ") + 1).trim();
+        }
+        String[] parts = hhmm.split(":");
         if (parts.length < 2) {
             return -1;
         }
@@ -527,20 +531,26 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
      */
     private int[] getBookingRangeMinutes(Integer storeId) {
         int[] range = new int[]{0, MINUTES_DAY_END};
+        // 先从 store_booking_settings 按 storeId 查设置,再用 settingsId 关联
         List<StoreBookingSettings> list = storeBookingSettingsService.list(
                 new LambdaQueryWrapper<StoreBookingSettings>().eq(StoreBookingSettings::getStoreId, storeId));
         if (!list.isEmpty()) {
             StoreBookingSettings settings = list.get(0);
-            if (settings.getBookingTimeType() != null && settings.getBookingTimeType() == 1) {
+            List<StoreBookingBusinessHours> businessHoursList = storeBookingBusinessHoursService.getListBySettingsId(settings.getId());
+            if (!businessHoursList.isEmpty()) {
+                StoreBookingBusinessHours businessHours = businessHoursList.get(0);
+
+            if (businessHours.getBookingTimeType() != null && businessHours.getBookingTimeType() == 1) {
                 return range;
             }
-            int start = timeToMinutes(settings.getBookingStartTime());
-            int end = timeToMinutes(settings.getBookingEndTime());
+            int start = timeToMinutes(businessHours.getStartTime());
+            int end = timeToMinutes(businessHours.getEndTime());
             if (start >= 0 && end > start) {
                 range[0] = start;
                 range[1] = end;
                 return range;
             }
+            }
         }
         // 预订开始/结束时间为空或无效时,取商户运营时间(营业时间)
         StoreMainInfoVo storeInfo = storeInfoService.getStoreInfo(storeId);