diff --git a/yshop-shop/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java b/yshop-shop/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java index 2cc614b5..55178a1c 100644 --- a/yshop-shop/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java +++ b/yshop-shop/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java @@ -114,4 +114,6 @@ public class YxStoreBargainDto implements Serializable { private Timestamp endTimeDate; private Timestamp startTimeDate; + + private String statusStr; } diff --git a/yshop-shop/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java b/yshop-shop/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java index dde82667..ac412c68 100644 --- a/yshop-shop/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java +++ b/yshop-shop/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java @@ -1,7 +1,6 @@ /** * Copyright (C) 2018-2020 * All rights reserved, Designed By www.yixiang.co - */ package co.yixiang.modules.activity.service.impl; @@ -12,8 +11,10 @@ import co.yixiang.modules.activity.domain.YxStoreBargain; import co.yixiang.modules.activity.service.YxStoreBargainService; import co.yixiang.modules.activity.service.dto.YxStoreBargainDto; import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto; import co.yixiang.modules.activity.service.mapper.YxStoreBargainMapper; import co.yixiang.utils.FileUtil; +import co.yixiang.utils.OrderUtil; import com.github.pagehelper.PageInfo; import lombok.AllArgsConstructor; import org.springframework.data.domain.Pageable; @@ -34,9 +35,9 @@ import java.util.Map; //import org.springframework.cache.annotation.Cacheable; /** -* @author hupeng -* @date 2020-05-13 -*/ + * @author hupeng + * @date 2020-05-13 + */ @Service @AllArgsConstructor //@CacheConfig(cacheNames = "yxStoreBargain") @@ -51,7 +52,14 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl page = new PageInfo<>(queryAll(criteria)); Map map = new LinkedHashMap<>(2); - map.put("content", generator.convert(page.getList(), YxStoreBargainDto.class)); + List storeBargainDtoList = generator.convert(page.getList(), YxStoreBargainDto.class); + for (YxStoreBargainDto storeBargainDto : storeBargainDtoList) { + + String statusStr = OrderUtil.checkActivityStatus(storeBargainDto.getStartTime(), + storeBargainDto.getStopTime(), storeBargainDto.getStatus()); + storeBargainDto.setStatusStr(statusStr); + } + map.put("content", storeBargainDtoList); map.put("totalElements", page.getTotal()); return map; } @@ -59,7 +67,7 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl queryAll(YxStoreBargainQueryCriteria criteria){ + public List queryAll(YxStoreBargainQueryCriteria criteria) { return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreBargain.class, criteria)); } @@ -68,7 +76,7 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (YxStoreBargainDto yxStoreBargain : all) { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put("关联产品ID", yxStoreBargain.getProductId()); map.put("砍价活动名称", yxStoreBargain.getTitle()); map.put("砍价活动图片", yxStoreBargain.getImage()); @@ -99,8 +107,8 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl page = new PageInfo<>(queryAll(criteria)); List storeSeckillDTOS = generator.convert(page.getList(),YxStoreSeckillDto.class); - int nowTime = OrderUtil.getSecondTimestampTwo(); for (YxStoreSeckillDto storeSeckillDTO : storeSeckillDTOS){ - if(storeSeckillDTO.getStatus() > 0){ - if(storeSeckillDTO.getStartTime() > nowTime){ - storeSeckillDTO.setStatusStr("活动未开始"); - }else if(storeSeckillDTO.getStopTime() < nowTime){ - storeSeckillDTO.setStatusStr("活动已结束"); - }else if(storeSeckillDTO.getStopTime() > nowTime && storeSeckillDTO.getStartTime() < nowTime){ - storeSeckillDTO.setStatusStr("正在进行中"); - } - }else { - storeSeckillDTO.setStatusStr("关闭"); - } - + String statusStr = OrderUtil.checkActivityStatus(storeSeckillDTO.getStartTime(), + storeSeckillDTO.getStopTime(), storeSeckillDTO.getStatus()); + storeSeckillDTO.setStatusStr(statusStr); } Map map = new LinkedHashMap<>(2); map.put("content",storeSeckillDTOS);