Commit 6b06bf8a3da6afca15e22755ab8e39116f986b8f

Authored by YunaiV
1 parent da6e01f6

bugfix MALL:已过期的优惠劵,还显示可以使用

yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
@@ -194,9 +194,12 @@ public class CouponServiceImpl implements CouponService { @@ -194,9 +194,12 @@ public class CouponServiceImpl implements CouponService {
194 194
195 @Override 195 @Override
196 public List<CouponDO> getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) { 196 public List<CouponDO> getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) {
197 - return couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId, 197 + List<CouponDO> list = couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId,
198 CouponStatusEnum.UNUSED.getStatus(), 198 CouponStatusEnum.UNUSED.getStatus(),
199 matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds()); 199 matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds());
  200 + // 兜底逻辑:如果 CouponExpireJob 未执行,status 未变成 EXPIRE ,但是 validEndTime 已经过期了,需要进行过滤
  201 + list.removeIf(coupon -> !LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime()));
  202 + return list;
200 } 203 }
201 204
202 @Override 205 @Override