From 831e3312572cf29dd91cbd882ef3dce809ac852d Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 14 六月 2023 20:58:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.1' into 1.1

---
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 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..a34febb 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,12 +191,22 @@
                 appUser.setInviterType(signInToRegister.getInviterType());
                 this.insert(appUser);
                 //发送优惠券
-                boolean lock = redisUtil.lock();
-                if(lock){
-                    List<CouponWarpper> list = pushCoupon(appUser.getId());
-                    redisUtil.unlock();
-                    warpper.setCoupons(list);
+                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++;
+                        }
+                    }
                 }
+                List<CouponWarpper> list = pushCoupon(appUser.getId());
+                redisUtil.unlock();
+                warpper.setCoupons(list);
             }
             if(appUser.getStatus() == 2){
                 return ResultUtil.error("账号被冻结");
@@ -248,6 +259,8 @@
 
 
 
+
+
     /**
      * 发送优惠券
      * @param userId
@@ -265,7 +278,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