Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

wxd 4 mesi fa
parent
commit
9da8fa4824

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

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
+import shop.alien.entity.store.EssentialHolidayComparison;
 import shop.alien.entity.store.LifeGroupBuyMain;
 import shop.alien.entity.store.StoreImg;
 
@@ -42,4 +43,6 @@ public class LifeGroupBuyMainVo extends LifeGroupBuyMain {
     @ApiModelProperty(value = "图片list")
     private List<StoreImg> storeImgList;
 
+    @ApiModelProperty(value = "不可用日期list")
+    private List<EssentialHolidayComparison> essentialHolidayComparisonList;
 }

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

@@ -3,6 +3,7 @@ package shop.alien.store.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
@@ -14,14 +15,12 @@ import shop.alien.entity.store.LifeGroupBuyMain;
 import shop.alien.entity.store.StoreImg;
 import shop.alien.entity.store.StoreInfo;
 import shop.alien.entity.store.excelVo.LifeUserViolationExcelVO;
+import shop.alien.entity.store.*;
 import shop.alien.entity.store.excelVo.StoreCouponStatusVo;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
 import shop.alien.entity.store.vo.LifeCouponVo;
 import shop.alien.entity.store.vo.LifeGroupBuyMainVo;
-import shop.alien.mapper.PlatformStoreCouponMapper;
-import shop.alien.mapper.PlatformStoreLifeGroupBuyMainMapper;
-import shop.alien.mapper.StoreImgMapper;
-import shop.alien.mapper.StoreInfoMapper;
+import shop.alien.mapper.*;
 import shop.alien.store.service.PlatformStoreCouponService;
 import shop.alien.util.ali.AliOSSUtil;
 
@@ -45,6 +44,7 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
     private final StoreInfoMapper storeInfoMapper;
 
     private final StoreImgMapper storeImgMapper;
+    private final EssentialHolidayComparisonMapper essentialHolidayComparisonMapper;
 
     private final AliOSSUtil aliOSSUtil;
 
@@ -251,7 +251,7 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
             lifeGroupBuyMain.setStatus(status);
             lifeGroupBuyMain.setApprovalComments(comment);
             // 审核后开始
-            if ("0".equals(lifeGroupBuyMain.getStartTimeType())) {
+            if (lifeGroupBuyMain.getStartTimeType()==0) {
                 lifeGroupBuyMain.setStartTimeValue(new Date());
             }
             return platformStoreLifeGroupBuyMainMapper.updateById(lifeGroupBuyMain);
@@ -487,7 +487,7 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
         LifeGroupBuyMain lifeGroupBuyMain = platformStoreLifeGroupBuyMainMapper.selectById(id);
         // 添加商户信息
         StoreInfo storeUser = storeInfoMapper.selectById(lifeGroupBuyMain.getStoreId());
-
+        // 图片
         List<String> collect = Arrays.stream(lifeGroupBuyMain.getImageId().split(","))
                 .map(String::trim)
                 .collect(Collectors.toList());
@@ -519,6 +519,25 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
             lifeGroupBuyMainVo.setExpiredState("1"); // 当前时间超过 endDate → 已到期
         }
 
+            // 核心逻辑:未过期时赋 0,已过期赋 1(与前端枚举定义一致)
+            if (nowDate.isBefore(endDateTime)) {
+                // 计算剩余天数
+                long remainingDays = ChronoUnit.DAYS.between(nowDate, endDateTime);
+                lifeGroupBuyMainVo.setDaysToExpire(remainingDays + "天");
+                lifeGroupBuyMainVo.setExpiredState("0"); // 当前时间未超过 endDate → 未到期
+            } else {
+                lifeGroupBuyMainVo.setDaysToExpire("0天");
+                lifeGroupBuyMainVo.setExpiredState("1"); // 当前时间超过 endDate → 已到期
+            }
+        // 不可用日期
+        String afterSemicolon = lifeGroupBuyMain.getDisableDateValue().split(";")[1];
+        if(StringUtils.isNotEmpty(afterSemicolon)){
+            List<String> collectUnavailableDate = Arrays.stream(afterSemicolon.split(",")).map(String::trim).collect(Collectors.toList());
+            if(CollectionUtils.isNotEmpty(collectUnavailableDate)){
+                List<EssentialHolidayComparison> essentialHolidayComparisons = essentialHolidayComparisonMapper.selectList(new LambdaQueryWrapper<EssentialHolidayComparison>().in(EssentialHolidayComparison::getId,collectUnavailableDate));
+                lifeGroupBuyMainVo.setEssentialHolidayComparisonList(essentialHolidayComparisons);
+            }
+        }
         return lifeGroupBuyMainVo;
     }
 }