From 7a9e05846c5e37f7278f242857056d0623532379 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期五, 16 六月 2023 20:17:32 +0800 Subject: [PATCH] 修改bug和功能优化 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java index 9e29d77..7772e09 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java @@ -39,6 +39,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.math.BigInteger; import java.net.InetAddress; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -190,7 +191,19 @@ appUser.setInviterType(signInToRegister.getInviterType()); this.insert(appUser); //发送优惠券 - boolean lock = redisUtil.lock(); + boolean lock = redisUtil.lock(5); + if(!lock){ + int num1 = 1; + while (num1 <= 10){ + Thread.sleep(3000);//等待3秒 + lock = redisUtil.lock(5); + if(lock){ + break; + }else{ + num1++; + } + } + } if(lock){ List<CouponWarpper> list = pushCoupon(appUser.getId()); redisUtil.unlock(); @@ -248,6 +261,8 @@ + + /** * 发送优惠券 * @param userId @@ -265,7 +280,7 @@ userToCoupon.setCouponTotal(coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? coupon.getRemainingQuantity() : coupon.getCouponSendQuantity()); userToCoupon.setValidCount(userToCoupon.getCouponTotal()); - userToCoupon.setExpireTime(new Date(System.currentTimeMillis() + (coupon.getCouponValidity() * 24 * 60 * 60 * 1000))); + userToCoupon.setExpireTime(new Date(System.currentTimeMillis() + (coupon.getCouponValidity().longValue() * 24L * 60L * 60L * 1000L))); userToCouponService.insert(userToCoupon); coupon.setRemainingQuantity(coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? 0 : -- Gitblit v1.7.1