| | |
| | | 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(); |
| | |
| | | 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 : |