Преглед изворни кода

领取优惠券列表修改

zhangchen пре 4 месеци
родитељ
комит
c312cd1df9

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

@@ -354,7 +354,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
                         .eq(LifeDiscountCoupon::getStoreId, storeId)
                         .eq(LifeDiscountCoupon::getGetStatus, "1")
                         .gt(LifeDiscountCoupon::getSingleQty, 0) //还有库存
-                        .ge(LifeDiscountCoupon::getEndDate, new Date())
+                        .ge(LifeDiscountCoupon::getEndGetDate, new Date())
                         .orderByDesc(LifeDiscountCoupon::getCreatedTime));
         //根据优惠券列表查询该优惠券是否领取过
         for (LifeDiscountCoupon lifeDiscountCoupon : lifeDiscountCoupons) {
@@ -403,11 +403,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
                         confineTo = ChronoUnit.YEARS.between(localDateTime, now);
                     }
                     //如果在规则范围内,则不允许领取,范围外,则可以领取
-                    if (confineTo < 1) {
-                        lifeDiscountCouponVo.setCanReceived(false);
-                    } else {
-                        lifeDiscountCouponVo.setCanReceived(true);
-                    }
+                    lifeDiscountCouponVo.setCanReceived(confineTo >= 1);
                 }
             }
             lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUsers.size());

+ 7 - 3
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponUserServiceImpl.java

@@ -45,17 +45,22 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
             Instant instant = now.toInstant();
             ZoneId zoneId = ZoneId.systemDefault();
             LocalDate localNow = instant.atZone(zoneId).toLocalDate();
-            int startResult = localNow.compareTo(lifeDiscountCoupon.getStartDate());
+            int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
             if (startResult < 0) {
                 return R.fail("该优惠劵活动时间未开始");
             }
+            int getStatus = lifeDiscountCoupon.getGetStatus();
+            if (getStatus == 0) {
+                return R.fail("该优惠劵已经关闭领取");
+            }
+
             //判断领取数量
             for (int i = 0; i < receiveQuantity; i++) {
                 LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
                 BeanUtils.copyProperties(lifeDiscountCouponUserDto, lifeDiscountCouponUser);
                 lifeDiscountCouponUser.setReceiveTime(new Date());
                 //存入过期时间
-                lifeDiscountCouponUser.setExpirationTime(lifeDiscountCoupon.getEndDate());
+                lifeDiscountCouponUser.setExpirationTime(lifeDiscountCoupon.getValidDate());
                 //存入状态  待使用:0
                 lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
                 lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
@@ -64,7 +69,6 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
             lifeDiscountCoupon.setSingleQty(lifeDiscountCoupon.getSingleQty() - receiveQuantity);
             lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
         } catch (BeansException e) {
-            e.printStackTrace();
             log.error("LifeDiscountCouponController.receiveCoupon ERROR Msg=" + e.getMessage());
             return R.fail("领取失败");
         }