Kaynağa Gözat

代码调整

qinxuyang 1 ay önce
ebeveyn
işleme
01b54d558a

+ 3 - 3
alien-entity/src/main/java/shop/alien/entity/store/StoreBookingBusinessHours.java

@@ -30,15 +30,15 @@ public class StoreBookingBusinessHours {
     @TableField("settings_id")
     private Integer settingsId;
 
-    @ApiModelProperty(value = "营业类型(0:正常营业, 1:特殊营业/节假日)")
+    @ApiModelProperty(value = "营业类型(1:正常营业时间, 2:特殊营业时间)")
     @TableField("business_type")
     private Integer businessType;
 
-    @ApiModelProperty(value = "节假日类型(当business_type=1时使用,如:春节、元旦、国庆节等,为空表示正常营业)")
+    @ApiModelProperty(value = "节假日类型(当business_type=2时使用,如:春节、元旦、国庆节等,为空表示正常营业)")
     @TableField("holiday_type")
     private String holidayType;
 
-    @ApiModelProperty(value = "节假日日期(当business_type=1时使用,用于指定具体日期,可选,格式:yyyy-MM-dd)")
+    @ApiModelProperty(value = "节假日日期(当business_type=2时使用,用于指定具体日期,可选,格式:yyyy-MM-dd)")
     @TableField("holiday_date")
     private String holidayDate;
 

+ 3 - 3
alien-entity/src/main/java/shop/alien/entity/store/dto/StoreBookingBusinessHoursDTO.java

@@ -24,13 +24,13 @@ public class StoreBookingBusinessHoursDTO {
     @ApiModelProperty(value = "关联store_booking_settings表 id", required = true)
     private Integer settingsId;
 
-    @ApiModelProperty(value = "营业类型(0:正常营业, 1:特殊营业/节假日)", required = true)
+    @ApiModelProperty(value = "营业类型(1:正常营业时间, 2:特殊营业时间)", required = true)
     private Integer businessType;
 
-    @ApiModelProperty(value = "节假日类型(当business_type=1时使用,如:春节、元旦、国庆节等)")
+    @ApiModelProperty(value = "节假日类型(当business_type=2时使用,如:春节、元旦、国庆节等)")
     private String holidayType;
 
-    @ApiModelProperty(value = "节假日日期(当business_type=1时使用,用于指定具体日期,可选,格式:yyyy-MM-dd)")
+    @ApiModelProperty(value = "节假日日期(当business_type=2时使用,用于指定具体日期,可选,格式:yyyy-MM-dd)")
     private String holidayDate;
 
     @ApiModelProperty(value = "预订时间类型(0:非全天, 1:全天)", required = true)

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreBookingBusinessHoursVo.java

@@ -22,4 +22,7 @@ public class StoreBookingBusinessHoursVo extends StoreBookingBusinessHours {
 
     @ApiModelProperty(value = "关联的节假日信息")
     private EssentialHolidayComparison holidayInfo;
+
+    @ApiModelProperty(value = "营业日期(从 holidayDate 或 holidayInfo 中获取)")
+    private String businessDate;
 }

+ 3 - 3
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreMainInfoVo.java

@@ -3,10 +3,10 @@ package shop.alien.entity.store.vo;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import shop.alien.entity.store.StoreBusinessInfo;
 import shop.alien.entity.store.StoreImg;
 import shop.alien.entity.store.StoreInfo;
 import shop.alien.entity.store.StoreLabel;
+import shop.alien.entity.store.vo.StoreBusinessInfoVo;
 
 import java.util.Date;
 import java.util.List;
@@ -51,8 +51,8 @@ public class StoreMainInfoVo extends StoreInfo {
     @ApiModelProperty(value = "门店标签")
     StoreLabel storeLabel;
 
-    @ApiModelProperty(value = "营业时间")
-    List<StoreBusinessInfo> storeBusinessInfo;
+    @ApiModelProperty(value = "营业时间(包含节假日信息)")
+    List<StoreBusinessInfoVo> storeBusinessInfo;
 
     @ApiModelProperty(value = "门店头像")
     String headImgUrl;

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

@@ -34,7 +34,7 @@ public class StoreBookingBusinessHoursController {
     @ApiOperation("查询预订服务营业时间列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "settingsId", value = "设置ID(关联store_booking_settings表 id)", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "businessType", value = "营业类型(0:正常营业, 1:特殊营业/节假日,可选,不传则查询全部)", dataType = "Integer", paramType = "query", required = false)
+            @ApiImplicitParam(name = "businessType", value = "营业类型(1:正常营业时间, 2:特殊营业时间,可选,不传则查询全部)", dataType = "Integer", paramType = "query", required = false)
     })
     @GetMapping("/list")
     public R<List<StoreBookingBusinessHours>> getBusinessHoursList(
@@ -103,11 +103,11 @@ public class StoreBookingBusinessHoursController {
         }
         
         // 如果是特殊营业(节假日),验证节假日类型
-        if (dto.getBusinessType() != null && dto.getBusinessType() == 1) {
-            if (!StringUtils.hasText(dto.getHolidayType())) {
-                return R.fail("特殊营业时必须填写节假日类型");
-            }
-        }
+//        if (dto.getBusinessType() != null && dto.getBusinessType() == 1) {
+//            if (!StringUtils.hasText(dto.getHolidayType())) {
+//                return R.fail("特殊营业时必须填写节假日类型");
+//            }
+//        }
         
         // 如果选择非全天,必须填写开始时间和结束时间
         if (dto.getBookingTimeType() != null && dto.getBookingTimeType() == 0) {

+ 0 - 3
alien-store/src/main/java/shop/alien/store/controller/StoreBookingSettingsController.java

@@ -122,9 +122,6 @@ public class StoreBookingSettingsController {
         // 验证特殊营业时间列表
         if (dto.getSpecialBusinessHoursList() != null && !dto.getSpecialBusinessHoursList().isEmpty()) {
             for (StoreBookingBusinessHoursDTO specialHours : dto.getSpecialBusinessHoursList()) {
-                if (!StringUtils.hasText(specialHours.getHolidayType())) {
-                    return R.fail("特殊营业时间必须填写节假日类型");
-                }
                 if (specialHours.getBookingTimeType() == null) {
                     return R.fail("特殊营业时间的预订时间类型不能为空");
                 }

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/StoreBookingBusinessHoursService.java

@@ -26,7 +26,7 @@ public interface StoreBookingBusinessHoursService extends IService<StoreBookingB
      * 根据设置ID和营业类型查询营业时间列表
      *
      * @param settingsId 设置ID
-     * @param businessType 营业类型(0:正常营业, 1:特殊营业/节假日
+     * @param businessType 营业类型(1:正常营业时间, 2:特殊营业时间
      * @return 营业时间列表
      */
     List<StoreBookingBusinessHours> getListBySettingsIdAndType(Integer settingsId, Integer businessType);

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

@@ -96,12 +96,12 @@ public class StoreBookingBusinessHoursServiceImpl extends ServiceImpl<StoreBooki
         }
         
         // 如果是特殊营业(节假日),验证节假日类型
-        if (businessHours.getBusinessType() != null && businessHours.getBusinessType() == 1) {
-            if (!StringUtils.hasText(businessHours.getHolidayType())) {
-                log.warn("保存营业时间失败:特殊营业时必须填写节假日类型");
-                throw new RuntimeException("特殊营业时必须填写节假日类型");
-            }
-        }
+//        if (businessHours.getBusinessType() != null && businessHours.getBusinessType() == 2) {
+//            if (!StringUtils.hasText(businessHours.getHolidayType())) {
+//                log.warn("保存营业时间失败:特殊营业时必须填写节假日类型");
+//                throw new RuntimeException("特殊营业时必须填写节假日类型");
+//            }
+//        }
         
         // 如果选择非全天,必须填写开始时间和结束时间
         if (businessHours.getBookingTimeType() != null && businessHours.getBookingTimeType() == 0) {

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

@@ -223,17 +223,17 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
         // 3. 准备营业时间列表
         List<StoreBookingBusinessHours> businessHoursList = new ArrayList<>();
         
-        // 3.1 处理正常营业时间(business_type=0
+        // 3.1 处理正常营业时间(business_type=1
         if (dto.getNormalBusinessHours() != null) {
-            StoreBookingBusinessHours normalHours = convertToBusinessHours(dto.getNormalBusinessHours(), settingsId, 0);
+            StoreBookingBusinessHours normalHours = convertToBusinessHours(dto.getNormalBusinessHours(), settingsId, 1);
             businessHoursList.add(normalHours);
         }
         
-        // 3.2 处理特殊营业时间列表(business_type=1
+        // 3.2 处理特殊营业时间列表(business_type=2
         if (dto.getSpecialBusinessHoursList() != null && !dto.getSpecialBusinessHoursList().isEmpty()) {
             int sort = 1;
             for (StoreBookingBusinessHoursDTO specialDto : dto.getSpecialBusinessHoursList()) {
-                StoreBookingBusinessHours specialHours = convertToBusinessHours(specialDto, settingsId, 1);
+                StoreBookingBusinessHours specialHours = convertToBusinessHours(specialDto, settingsId, 2);
                 specialHours.setSort(sort++);
                 businessHoursList.add(specialHours);
             }
@@ -275,12 +275,12 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
         
         // 4. 分离正常营业时间和特殊营业时间
         StoreBookingBusinessHours normalHours = businessHoursList.stream()
-                .filter(h -> h.getBusinessType() != null && h.getBusinessType() == 0)
+                .filter(h -> h.getBusinessType() != null && h.getBusinessType() == 1)
                 .findFirst()
                 .orElse(null);
         
         List<StoreBookingBusinessHours> specialHoursList = businessHoursList.stream()
-                .filter(h -> h.getBusinessType() != null && h.getBusinessType() == 1)
+                .filter(h -> h.getBusinessType() != null && h.getBusinessType() == 2)
                 .collect(Collectors.toList());
         
         // 5. 转换为DTO
@@ -317,7 +317,7 @@ public class StoreBookingSettingsServiceImpl extends ServiceImpl<StoreBookingSet
      *
      * @param dto DTO对象
      * @param settingsId 设置ID
-     * @param businessType 营业类型(0:正常营业, 1:特殊营业/节假日
+     * @param businessType 营业类型(1:正常营业时间, 2:特殊营业时间
      * @return StoreBookingBusinessHours
      */
     private StoreBookingBusinessHours convertToBusinessHours(StoreBookingBusinessHoursDTO dto, Integer settingsId, Integer businessType) {

+ 15 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -256,8 +256,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
         //门店标签
         storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
-        //营业时间
-        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id)));
+        //营业时间(包含节假日信息,返回结构要和 storeBookingBusinessHours 一样)
+        List<StoreBusinessInfoVo> storeBusinessInfoVos = this.getStoreInfoBusinessHours(id);
+        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoVos);
         //门店头像
         LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, id);
         StoreImg storeImg = storeImgMapper.selectOne(eq);
@@ -422,9 +423,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         // }
         //门店标签
         storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
-        //营业时间
-        List<StoreBusinessInfo> storeBusinessInfoList = storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id));
-        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoList);
+        //营业时间(包含节假日信息,返回结构要和 storeBookingBusinessHours 一样)
+        List<StoreBusinessInfoVo> storeBusinessInfoVos = this.getStoreInfoBusinessHours(id);
+        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoVos);
         //营业执照
         storeMainInfoVo.setBusinessLicenseList(storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 14).eq(StoreImg::getStoreId, id).eq(StoreImg::getDeleteFlag, 0)));
         //其他资质证明图片(img_type=35)
@@ -453,22 +454,27 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         );
 
         // 转换为 VO 并关联节假日信息
+        // store_business_info 的 essential_id 关联 essential_holiday_comparison 的 id
         List<StoreBusinessInfoVo> resultList = new ArrayList<>();
         for (StoreBusinessInfo businessInfo : storeBusinessInfoList) {
             StoreBusinessInfoVo vo = new StoreBusinessInfoVo();
             // 复制基本信息
             BeanUtils.copyProperties(businessInfo, vo);
 
-            // 如果有关联的节假日ID,查询节假日信息
+            // 如果有关联的节假日ID(essential_id),查询 essential_holiday_comparison 表的节假日信息
             if (businessInfo.getEssentialId() != null && !businessInfo.getEssentialId().trim().isEmpty()) {
                 try {
                     Integer essentialId = Integer.parseInt(businessInfo.getEssentialId().trim());
                     EssentialHolidayComparison holiday = essentialHolidayComparisonMapper.selectById(essentialId);
                     if (holiday != null) {
                         vo.setHolidayInfo(holiday);
+                    } else {
+                        log.warn("门店营业时间关联的节假日信息不存在,storeId={}, essentialId={}", id, essentialId);
                     }
                 } catch (NumberFormatException e) {
                     log.warn("门店营业时间关联的节假日ID格式错误,storeId={}, essentialId={}", id, businessInfo.getEssentialId());
+                } catch (Exception e) {
+                    log.error("查询节假日信息失败,storeId={}, essentialId={}", id, businessInfo.getEssentialId(), e);
                 }
             }
 
@@ -489,8 +495,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         StoreMainInfoVo storeMainInfoVo = storeInfoMapper.getStoreInfo(id);
         //门店标签
         storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
-        //营业时间
-        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id)));
+        //营业时间(包含节假日信息,返回结构要和 storeBookingBusinessHours 一样)
+        List<StoreBusinessInfoVo> storeBusinessInfoVos = this.getStoreInfoBusinessHours(id);
+        storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoVos);
         return storeMainInfoVo;
     }
 

+ 25 - 2
alien-store/src/main/java/shop/alien/store/service/impl/UserReservationServiceImpl.java

@@ -384,19 +384,42 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
                     StoreBookingBusinessHoursVo vo = new StoreBookingBusinessHoursVo();
                     BeanUtils.copyProperties(businessHours, vo);
                     
-                    // 如果是特殊营业时间(business_type = 1)且有关联的节假日ID,查询节假日信息
-                    if (businessHours.getBusinessType() != null && businessHours.getBusinessType() == 1 
+                    // 如果是特殊营业时间(business_type = 2)且有关联的节假日ID,查询节假日信息
+                    if (businessHours.getBusinessType() != null && businessHours.getBusinessType() == 2 
                             && businessHours.getEssentialId() != null) {
                         try {
                             EssentialHolidayComparison holiday = essentialHolidayComparisonMapper.selectById(businessHours.getEssentialId());
                             if (holiday != null) {
                                 vo.setHolidayInfo(holiday);
+                                // 从节假日信息中获取日期作为 businessDate
+                                if (holiday.getFestivalDate() != null) {
+                                    vo.setBusinessDate(holiday.getFestivalDate().toString());
+                                } else if (holiday.getStartTime() != null) {
+                                    // 如果 festivalDate 为空,使用 startTime
+                                    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
+                                    vo.setBusinessDate(sdf.format(holiday.getStartTime()));
+                                }
                             }
                         } catch (Exception e) {
                             log.warn("查询节假日信息失败,essentialId={}", businessHours.getEssentialId(), e);
                         }
                     }
                     
+                    // 设置 businessDate:优先使用 holidayDate,如果没有则使用 holidayInfo 中的日期
+                    if (vo.getBusinessDate() == null && businessHours.getHolidayDate() != null) {
+                        vo.setBusinessDate(businessHours.getHolidayDate());
+                    }
+                    
+                    // 将 holidayType 的值也放到 businessDate 中
+                    if (businessHours.getHolidayType() != null && !businessHours.getHolidayType().trim().isEmpty()) {
+                        vo.setBusinessDate(businessHours.getHolidayType());
+                    }
+                    
+                    // 将 businessDate 的值也设置到 holidayType(用于回显)
+                    if (vo.getBusinessDate() != null) {
+                        vo.setHolidayType(vo.getBusinessDate());
+                    }
+                    
                     storeBookingBusinessHours.add(vo);
                 }
             }