소스 검색

优惠券计算错误问题修改

zc 2 달 전
부모
커밋
b6bb748d11
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java

+ 2 - 2
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java

@@ -345,9 +345,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     @Override
     public List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo) {
         List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
+        LocalDate now = LocalDate.now();
         //根据店铺id查询该店铺的优惠券,状态是开启领取的券
         List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(new LambdaQueryWrapper<LifeDiscountCoupon>().eq(LifeDiscountCoupon::getStoreId, storeId).eq(LifeDiscountCoupon::getGetStatus, "1").gt(LifeDiscountCoupon::getSingleQty, 0) //还有库存
-                .gt(LifeDiscountCoupon::getEndGetDate, new Date()).orderByDesc(LifeDiscountCoupon::getCreatedTime));
+                .ge(LifeDiscountCoupon::getEndGetDate, now).orderByDesc(LifeDiscountCoupon::getCreatedTime));
         //根据优惠券列表查询该优惠券是否领取过
         for (LifeDiscountCoupon lifeDiscountCoupon : lifeDiscountCoupons) {
             LifeDiscountCouponVo lifeDiscountCouponVo = new LifeDiscountCouponVo();
@@ -389,7 +390,6 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
                     LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
 
                     String unavailableRuleValue = lifeDiscountCouponUnavailableRules.getUnavailableRuleValue();
-                    LocalDateTime now = LocalDateTime.now();
                     long confineTo = 0L;
                     if (DiscountCouponEnum.DAY.getValue().equals(unavailableRuleValue)) {//如果规则限制一天一张
                         confineTo = ChronoUnit.DAYS.between(localDateTime, now);