From f44e787f72c55a49ad0b07c3f7f31b27540dc3f8 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 10 Sep 2021 10:36:27 +0800 Subject: [PATCH] fix seckill abnormal open --- .../modules/promotion/serviceimpl/SeckillServiceImpl.java | 1 + .../cn/lili/modules/promotion/tools/PromotionTools.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index 5ccbb7c5..c7195eaa 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -188,6 +188,7 @@ public class SeckillServiceImpl extends ServiceImpl impl if (PromotionStatusEnum.START.name().equals(seckillVO.getPromotionStatus())) { throw new ServiceException(ResultCode.PROMOTION_UPDATE_ERROR); } + PromotionTools.checkPromotionTime(seckillVO.getStartTime().getTime(), seckillVO.getEndTime().getTime()); //更新到MYSQL中 boolean result = this.updateById(seckillVO); //保存到MONGO中 diff --git a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java index d597b775..cab5edfe 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java +++ b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java @@ -1,10 +1,10 @@ package cn.lili.modules.promotion.tools; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.utils.DateUtil; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.BasePromotion; @@ -56,10 +56,10 @@ public class PromotionTools { */ public static void checkPromotionTime(Long startTime, Long endTime) { - long nowTime = DateUtil.getDateline() * 1000; + long nowTime = DateUtil.current(); //如果活动起始时间小于现在时间 - if (startTime < nowTime) { + if (startTime < nowTime || endTime < nowTime) { throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR); } @@ -92,7 +92,7 @@ public class PromotionTools { i.or(i1 -> i1.le(startTimeColumn, endTime).ge(endTimeColumn, endTime)); }); } else { - queryWrapper.ge(startTimeColumn, cn.hutool.core.date.DateUtil.beginOfDay(startTime)).le(endTimeColumn, cn.hutool.core.date.DateUtil.endOfDay(endTime)); + queryWrapper.ge(startTimeColumn, DateUtil.beginOfDay(startTime)).le(endTimeColumn, DateUtil.endOfDay(endTime)); } if (storeId != null) { queryWrapper.eq("store_id", storeId);