Przeglądaj źródła

商家端 营业时间

qinxuyang 1 miesiąc temu
rodzic
commit
dc588c0a6f

+ 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;
 }

+ 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);
 
     /**
      * 门店信息-修改后展示

+ 51 - 4
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");