소스 검색

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

刘云鑫 1 개월 전
부모
커밋
0205dcbbb7

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreBusinessInfo.java

@@ -68,4 +68,8 @@ public class StoreBusinessInfo {
     @TableField("updated_user_id")
     private Integer updatedUserId;
 
+    @ApiModelProperty(value = "关联essential_holiday_comparison 表id")
+    @TableField("essential_id")
+    private String essentialId;
+
 }

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreBusinessInfoVo.java

@@ -3,6 +3,7 @@ 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.EssentialHolidayComparison;
 import shop.alien.entity.store.StoreBusinessInfo;
 
 import java.util.List;
@@ -19,4 +20,7 @@ public class StoreBusinessInfoVo extends StoreBusinessInfo {
 
     @ApiModelProperty(value = "营业时间基本信息")
     private List<StoreBusinessInfo> businessInfos;
+
+    @ApiModelProperty(value = "关联的节假日信息")
+    private EssentialHolidayComparison holidayInfo;
 }

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

@@ -181,6 +181,9 @@ public class StoreInfoVo extends StoreInfo {
     private StoreBusinessInfo storeBusinessInfo;
     private List<StoreBusinessInfo> storeBusinessInfos;
 
+    @ApiModelProperty(value = "门店营业时间列表(包含节假日信息)")
+    private List<StoreBusinessInfoVo> storeBusinessInfoVos;
+
     @ApiModelProperty(value = "是否营业中(0否1是)")
     private Integer yyFlag;
 

+ 30 - 23
alien-store/src/main/java/shop/alien/store/controller/AiSearchController.java

@@ -23,6 +23,7 @@ import org.springframework.web.client.RestTemplate;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.StoreBannerVo;
+import shop.alien.entity.store.vo.StoreBusinessInfoVo;
 import shop.alien.entity.store.vo.StoreBusinessStatusVo;
 import shop.alien.entity.store.vo.StoreInfoVo;
 import shop.alien.mapper.*;
@@ -389,7 +390,7 @@ public class AiSearchController {
 
     /**
      * 批量填充营业时间到StoreInfoVo列表中
-     * 通过调用storeInfoService.getStoreBusinessStatus方法获取营业时间
+     * 通过调用storeInfoService.getStoreInfoBusinessHours方法获取营业时间(包含节假日信息)
      *
      * @param result StoreInfoVo列表
      */
@@ -398,32 +399,38 @@ public class AiSearchController {
             return;
         }
 
-        // 遍历result集合,为每个门店调用getStoreBusinessStatus方法
+        // 遍历result集合,为每个门店调用getStoreInfoBusinessHours方法
         for (StoreInfoVo storeInfo : result) {
             if (storeInfo.getId() != null) {
                 try {
-                    // 调用getStoreBusinessStatus方法获取营业时间
-                    StoreBusinessStatusVo businessStatus = storeInfoService.getStoreBusinessStatus(String.valueOf(storeInfo.getId()));
-                    if (businessStatus != null) {
-                        // 设置营业时间信息到StoreInfoVo中
-                        if (businessStatus.getStoreBusinessInfos() != null && !businessStatus.getStoreBusinessInfos().isEmpty()) {
-                            storeInfo.setStoreBusinessInfos(businessStatus.getStoreBusinessInfos());
-                            // 同时设置到openTime字段(格式化为字符串列表)
-                            List<String> openTimeList = businessStatus.getStoreBusinessInfos().stream()
-                                    .map(info -> {
-                                        if (info.getBusinessDate() != null && info.getStartTime() != null && info.getEndTime() != null) {
-                                            return info.getBusinessDate() + " " + info.getStartTime() + "-" + info.getEndTime();
-                                        }
-                                        return null;
-                                    })
-                                    .filter(time -> time != null)
-                                    .collect(Collectors.toList());
-                            storeInfo.setOpenTime(openTimeList);
-                        }
-                        // 设置营业状态
-                        if (businessStatus.getYyFlag() != null) {
-                            storeInfo.setYyFlag(businessStatus.getYyFlag());
+                    // 调用getStoreInfoBusinessHours方法获取营业时间(包含节假日信息)
+                    List<StoreBusinessInfoVo> storeBusinessInfoVos = storeInfoService.getStoreInfoBusinessHours(storeInfo.getId());
+                    if (storeBusinessInfoVos != null && !storeBusinessInfoVos.isEmpty()) {
+                        // 设置包含节假日信息的营业时间列表
+                        storeInfo.setStoreBusinessInfoVos(storeBusinessInfoVos);
+                        // 转换为 List<StoreBusinessInfo> 用于兼容原有字段(StoreBusinessInfoVo 继承自 StoreBusinessInfo)
+                        List<StoreBusinessInfo> storeBusinessInfos = new ArrayList<>(storeBusinessInfoVos);
+                        storeInfo.setStoreBusinessInfos(storeBusinessInfos);
+                        // 设置第一个营业时间信息到 storeBusinessInfo 字段
+                        if (!storeBusinessInfos.isEmpty()) {
+                            storeInfo.setStoreBusinessInfo(storeBusinessInfos.get(0));
                         }
+                        // 同时设置到openTime字段(格式化为字符串列表)
+                        List<String> openTimeList = storeBusinessInfoVos.stream()
+                                .map(info -> {
+                                    if (info.getBusinessDate() != null && info.getStartTime() != null && info.getEndTime() != null) {
+                                        return info.getBusinessDate() + " " + info.getStartTime() + "-" + info.getEndTime();
+                                    }
+                                    return null;
+                                })
+                                .filter(time -> time != null)
+                                .collect(Collectors.toList());
+                        storeInfo.setOpenTime(openTimeList);
+                    }
+                    // 获取营业状态(通过getStoreBusinessStatus方法)
+                    StoreBusinessStatusVo businessStatus = storeInfoService.getStoreBusinessStatus(String.valueOf(storeInfo.getId()));
+                    if (businessStatus != null && businessStatus.getYyFlag() != null) {
+                        storeInfo.setYyFlag(businessStatus.getYyFlag());
                     }
                 } catch (Exception e) {
                     log.error("获取门店营业时间失败,storeId: {}", storeInfo.getId(), e);

+ 1 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -756,7 +756,7 @@ public class StoreInfoController {
     @ApiOperation(value = "门店装修-门店营业时间")
     @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "门店id", dataType = "Long", paramType = "query", required = true)})
     @GetMapping("/getStoreInfoBusinessHours")
-    public R<List<StoreBusinessInfo>> getStoreInfoBusinessHours(Integer id) {
+    public R<List<StoreBusinessInfoVo>> getStoreInfoBusinessHours(Integer id) {
         log.info("StoreInfoController.getStoreInfoBusinessHours?id={}", id);
         return R.data(storeInfoService.getStoreInfoBusinessHours(id));
     }

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

@@ -39,7 +39,7 @@ public interface StoreInfoService extends IService<StoreInfo> {
     /**
      *
      */
-    List<StoreBusinessInfo>  getStoreInfoBusinessHours(Integer id);
+    List<shop.alien.entity.store.vo.StoreBusinessInfoVo>  getStoreInfoBusinessHours(Integer id);
 
     /**
      * 门店信息-修改后展示

+ 58 - 11
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -180,6 +180,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
     private final LifeUserViolationMapper lifeUserViolationMapper;
 
+    private final EssentialHolidayComparisonMapper essentialHolidayComparisonMapper;
+
     private final StorePaymentConfigService storePaymentConfigService;
 
 
@@ -439,10 +441,40 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
-    public List<StoreBusinessInfo> getStoreInfoBusinessHours(Integer id) {
-        //营业时间
-        List<StoreBusinessInfo> storeBusinessInfoList = storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id));
-        return storeBusinessInfoList;
+    public List<StoreBusinessInfoVo> getStoreInfoBusinessHours(Integer id) {
+        // 查询营业时间(包含正常时间和特殊时间)
+        List<StoreBusinessInfo> storeBusinessInfoList = storeBusinessInfoMapper.selectList(
+                new LambdaQueryWrapper<StoreBusinessInfo>()
+                        .eq(StoreBusinessInfo::getStoreId, id)
+                        .eq(StoreBusinessInfo::getDeleteFlag, 0)
+                        .orderByAsc(StoreBusinessInfo::getBusinessType) // 先按类型排序:1-正常时间,2-特殊时间
+                        .orderByAsc(StoreBusinessInfo::getBusinessDate) // 再按日期排序
+        );
+        
+        // 转换为 VO 并关联节假日信息
+        List<StoreBusinessInfoVo> resultList = new ArrayList<>();
+        for (StoreBusinessInfo businessInfo : storeBusinessInfoList) {
+            StoreBusinessInfoVo vo = new StoreBusinessInfoVo();
+            // 复制基本信息
+            BeanUtils.copyProperties(businessInfo, vo);
+            
+            // 如果有关联的节假日ID,查询节假日信息
+            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);
+                    }
+                } catch (NumberFormatException e) {
+                    log.warn("门店营业时间关联的节假日ID格式错误,storeId={}, essentialId={}", id, businessInfo.getEssentialId());
+                }
+            }
+            
+            resultList.add(vo);
+        }
+        
+        return resultList;
     }
 
     /**
@@ -1370,6 +1402,21 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             tagStoreRelationMapper.insert(tagStoreRelation);
         }
 
+        // 保存门店营业时间
+        if (storeInfoDto.getStoreBusinessTime() != null && !storeInfoDto.getStoreBusinessTime().isEmpty()) {
+            List<StoreBusinessInfo> storeBusinessTimeList = storeInfoDto.getStoreBusinessTime();
+            for (StoreBusinessInfo businessInfo : storeBusinessTimeList) {
+                // 设置门店ID
+                businessInfo.setStoreId(storeInfo.getId());
+                // 新增门店时,所有营业时间都是新增,清空ID确保是新增
+                businessInfo.setId(null);
+            }
+            // 批量保存营业时间
+            for (StoreBusinessInfo businessInfo : storeBusinessTimeList) {
+                storeBusinessInfoMapper.insert(businessInfo);
+            }
+            log.info("保存门店营业时间成功,门店ID:{},营业时间数量:{}", storeInfo.getId(), storeBusinessTimeList.size());
+        }
 
         // 发送通知
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -6025,13 +6072,13 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 //        // 获取店铺动态总数
 //        result.setTotalDynamicsNum(storeDynamicslist.size());
 
-        //营业时间
-        List<StoreBusinessInfo> storeBusinessInfos = storeBusinessInfoMapper.selectList(
-                new LambdaQueryWrapper<StoreBusinessInfo>()
-                        .eq(StoreBusinessInfo::getStoreId, storeId)
-                        .eq(StoreBusinessInfo::getDeleteFlag, 0)
-        );
-        // 回显所有营业时间信息(特殊营业时间和正常营业时间)
+        //营业时间(通过 getStoreInfoBusinessHours 方法获取,包含节假日信息)
+        List<StoreBusinessInfoVo> storeBusinessInfoVos = this.getStoreInfoBusinessHours(Integer.parseInt(storeId));
+        // 设置包含节假日信息的营业时间列表
+        result.setStoreBusinessInfoVos(storeBusinessInfoVos);
+        // 转换为 List<StoreBusinessInfo> 用于后续判断(StoreBusinessInfoVo 继承自 StoreBusinessInfo)
+        List<StoreBusinessInfo> storeBusinessInfos = new ArrayList<>(storeBusinessInfoVos);
+        // 回显所有营业时间信息(特殊营业时间和正常营业时间,包含节假日信息
         if (ObjectUtils.isNotEmpty(storeBusinessInfos)) {
             result.setStoreBusinessInfo(storeBusinessInfos.get(0));
             result.setStoreBusinessInfos(storeBusinessInfos);