fix seckill error

This commit is contained in:
paulGao 2021-09-13 15:22:38 +08:00
parent f99b65b2e6
commit 36528ae416
4 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,8 @@ import cn.lili.modules.promotion.entity.dos.Seckill;
import cn.lili.modules.promotion.entity.dos.SeckillApply;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@ -13,7 +15,9 @@ import java.util.List;
* @author paulG
* @since 2020/8/20
**/
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(callSuper = true)
public class SeckillVO extends Seckill {
private static final long serialVersionUID = 2891461638257152270L;

View File

@ -391,11 +391,13 @@ public class PromotionServiceImpl implements PromotionService {
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
return false;
}
if (seckill.getEndTime() == null) {
seckill.setEndTime(DateUtil.endOfDay(seckill.getStartTime()));
}
//修改活动状态
seckill.setPromotionStatus(promotionMessage.getPromotionStatus());
result = this.seckillService.update(updateWrapper(promotionMessage));
log.info("更新限时抢购活动状态:{}", seckill);
//判断参与活动的商品是否为空如果为空则返回
if (seckill.getSeckillApplyList() == null) {
return result;
@ -428,6 +430,7 @@ public class PromotionServiceImpl implements PromotionService {
seckill1.setStartTime(parseStartTime);
//当时商品的秒杀活动活动结束时间为下个时间段的开始
seckill1.setEndTime(parseEndTime);
log.info("更新限时抢购商品状态:{}", seckill1);
this.goodsIndexService.updateEsGoodsIndex(seckillApply.getSkuId(), seckill1, promotionTypeEnum.name() + "-" + seckillApply.getTimeLine(), seckillApply.getPrice());
}
}

View File

@ -240,6 +240,9 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
@Override
public void openSeckill(String id) {
SeckillVO seckillVO = checkSeckillExist(id);
if (seckillVO.getEndTime() == null) {
seckillVO.setEndTime(cn.hutool.core.date.DateUtil.endOfDay(seckillVO.getStartTime()));
}
PromotionTools.checkPromotionTime(seckillVO.getStartTime().getTime(), seckillVO.getEndTime().getTime());
if (PromotionStatusEnum.NEW.name().equals(seckillVO.getPromotionStatus()) || PromotionStatusEnum.CLOSE.name().equals(seckillVO.getPromotionStatus())) {
LambdaUpdateWrapper<Seckill> updateWrapper = new LambdaUpdateWrapper<Seckill>().eq(Seckill::getId, id).set(Seckill::getPromotionStatus, PromotionStatusEnum.START.name());

View File

@ -437,6 +437,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
* @param promotion 活动
*/
private void updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String key, BasePromotion promotion) {
log.info("修改商品活动索引");
log.info("商品索引: {}", goodsIndex);
log.info("关键字: {}", key);
log.info("活动: {}", promotion);
Map<String, Object> promotionMap;
//数据非空处理如果空给一个新的信息
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {