qinxuyang пре 1 месец
родитељ
комит
a41e78923d

+ 6 - 6
alien-store/src/main/java/shop/alien/store/controller/StoreBookingBusinessHoursController.java

@@ -95,12 +95,12 @@ public class StoreBookingBusinessHoursController {
         if (dto.getSettingsId() == null) {
             return R.fail("设置ID不能为空");
         }
-        if (dto.getBusinessType() == null) {
-            return R.fail("营业类型不能为空");
-        }
-        if (dto.getBookingTimeType() == null) {
-            return R.fail("预订时间类型不能为空");
-        }
+//        if (dto.getBusinessType() == null) {
+//            return R.fail("营业类型不能为空");
+//        }
+//        if (dto.getBookingTimeType() == null) {
+//            return R.fail("预订时间类型不能为空");
+//        }
         
         // 如果是特殊营业(节假日),验证节假日类型
 //        if (dto.getBusinessType() != null && dto.getBusinessType() == 1) {

+ 31 - 31
alien-store/src/main/java/shop/alien/store/service/impl/StoreBookingBusinessHoursServiceImpl.java

@@ -86,14 +86,14 @@ public class StoreBookingBusinessHoursServiceImpl extends ServiceImpl<StoreBooki
             log.warn("保存营业时间失败:设置ID不能为空");
             throw new RuntimeException("设置ID不能为空");
         }
-        if (businessHours.getBusinessType() == null) {
-            log.warn("保存营业时间失败:营业类型不能为空");
-            throw new RuntimeException("营业类型不能为空");
-        }
-        if (businessHours.getBookingTimeType() == null) {
-            log.warn("保存营业时间失败:预订时间类型不能为空");
-            throw new RuntimeException("预订时间类型不能为空");
-        }
+//        if (businessHours.getBusinessType() == null) {
+//            log.warn("保存营业时间失败:营业类型不能为空");
+//            throw new RuntimeException("营业类型不能为空");
+//        }
+//        if (businessHours.getBookingTimeType() == null) {
+//            log.warn("保存营业时间失败:预订时间类型不能为空");
+//            throw new RuntimeException("预订时间类型不能为空");
+//        }
         
         // 如果是特殊营业(节假日),验证节假日类型
 //        if (businessHours.getBusinessType() != null && businessHours.getBusinessType() == 2) {
@@ -104,31 +104,31 @@ public class StoreBookingBusinessHoursServiceImpl extends ServiceImpl<StoreBooki
 //        }
         
         // 如果选择非全天,必须填写开始时间和结束时间
-        if (businessHours.getBookingTimeType() != null && businessHours.getBookingTimeType() == 0) {
-            if (!StringUtils.hasText(businessHours.getStartTime())) {
-                log.warn("保存营业时间失败:非全天时必须填写开始时间");
-                throw new RuntimeException("非全天时必须填写开始时间");
-            }
-            if (!StringUtils.hasText(businessHours.getEndTime())) {
-                log.warn("保存营业时间失败:非全天时必须填写结束时间");
-                throw new RuntimeException("非全天时必须填写结束时间");
-            }
-            // 验证时间格式
-            if (!TIME_PATTERN.matcher(businessHours.getStartTime()).matches()) {
-                log.warn("保存营业时间失败:开始时间格式不正确,应为HH:mm格式");
-                throw new RuntimeException("开始时间格式不正确,应为HH:mm格式");
-            }
-            if (!TIME_PATTERN.matcher(businessHours.getEndTime()).matches()) {
-                log.warn("保存营业时间失败:结束时间格式不正确,应为HH:mm格式");
-                throw new RuntimeException("结束时间格式不正确,应为HH:mm格式");
-            }
+//        if (businessHours.getBookingTimeType() != null && businessHours.getBookingTimeType() == 0) {
+//            if (!StringUtils.hasText(businessHours.getStartTime())) {
+//                log.warn("保存营业时间失败:非全天时必须填写开始时间");
+//                throw new RuntimeException("非全天时必须填写开始时间");
+//            }
+//            if (!StringUtils.hasText(businessHours.getEndTime())) {
+//                log.warn("保存营业时间失败:非全天时必须填写结束时间");
+//                throw new RuntimeException("非全天时必须填写结束时间");
+//            }
+//            // 验证时间格式
+//            if (!TIME_PATTERN.matcher(businessHours.getStartTime()).matches()) {
+//                log.warn("保存营业时间失败:开始时间格式不正确,应为HH:mm格式");
+//                throw new RuntimeException("开始时间格式不正确,应为HH:mm格式");
+//            }
+//            if (!TIME_PATTERN.matcher(businessHours.getEndTime()).matches()) {
+//                log.warn("保存营业时间失败:结束时间格式不正确,应为HH:mm格式");
+//                throw new RuntimeException("结束时间格式不正确,应为HH:mm格式");
+//            }
             // 验证开始时间必须小于结束时间(支持跨天,如22:00到次日02:00)
             // 这里只做基本格式验证,跨天逻辑由业务层处理
-        } else {
-            // 如果是全天,清空开始时间和结束时间
-            businessHours.setStartTime(null);
-            businessHours.setEndTime(null);
-        }
+//        } else {
+//            // 如果是全天,清空开始时间和结束时间
+//            businessHours.setStartTime(null);
+//            businessHours.setEndTime(null);
+//        }
         
         // 设置排序,如果为空则默认为0
         if (businessHours.getSort() == null) {

+ 5 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreBookingSettingsServiceImpl.java

@@ -227,6 +227,7 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
         List<StoreBookingBusinessHours> businessHoursList = new ArrayList<>();
         
         // 3.1 处理正常营业时间(business_type=1)
+        // 如果 normalBusinessHours 为空,则不保存正常营业时间
         if (dto.getNormalBusinessHours() != null) {
             // 校验正常营业时间:预约时间的正常时间不能大于门店营业时间的正常时间
             validateNormalBusinessHours(dto.getStoreId(), dto.getNormalBusinessHours());
@@ -236,6 +237,7 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
         }
         
         // 3.2 处理特殊营业时间列表(business_type=2)
+        // 如果 specialBusinessHoursList 为空或空列表,则不保存特殊营业时间
         if (dto.getSpecialBusinessHoursList() != null && !dto.getSpecialBusinessHoursList().isEmpty()) {
             // 校验特殊营业时间:预约时间的特殊时间不能大于门店营业时间的特殊时间
             validateSpecialBusinessHours(dto.getStoreId(), dto.getSpecialBusinessHoursList());
@@ -249,12 +251,15 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
         }
         
         // 4. 批量保存营业时间(如果列表不为空)
+        // 如果 normalBusinessHours 和 specialBusinessHoursList 都为空,则不保存任何营业时间
         if (!businessHoursList.isEmpty()) {
             boolean businessHoursResult = storeBookingBusinessHoursService.batchSaveBusinessHours(settingsId, businessHoursList);
             if (!businessHoursResult) {
                 log.error("保存营业时间失败");
                 throw new RuntimeException("保存营业时间失败");
             }
+        } else {
+            log.info("normalBusinessHours 和 specialBusinessHoursList 都为空,跳过营业时间保存,settingsId={}", settingsId);
         }
         
         return true;