Explorar o código

Merge branch 'doubleEleven2020' of http://git.dayaedu.com/yonge/mec into doubleEleven2020

yonge %!s(int64=4) %!d(string=hai) anos
pai
achega
55afe1ac55

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/SporadicChargeInfoService.java

@@ -17,7 +17,7 @@ public interface SporadicChargeInfoService extends BaseService<Integer, Sporadic
      *
      * @param order
      */
-    Boolean renewForCallback(StudentPaymentOrder order);
+    Boolean renewForCallback(StudentPaymentOrder order) throws Exception;
 
     /**
      * 分页查询

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -302,7 +302,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if(chargeInfo.getMaxNum() != null) {
             //重试避免人数过多频繁冲突
             boolean flag = false;
-            for (int i = 1; i <= 10; i++) {
+            int max = 100, min = 1;
+            int ran2 = (int) (Math.random() * (max - min) + min);
+            for (int i = 1; i <= 100; i++) {
+                if (i == ran2) {
+                    Thread.sleep(ran2);
+                }
                 chargeInfo = sporadicChargeInfoDao.get(sporadicPayDto.getSporadicId());
                 if (chargeInfo.getMaxNum() <= chargeInfo.getPaidNum()) {
                     throw new BizException("活动人数暂时已满,请稍后再试");

+ 7 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -63,7 +63,7 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public Boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) {
+    public Boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) throws Exception {
         int updateCount = studentPaymentOrderDao.update(studentPaymentOrder);
         if (updateCount <= 0) {
             throw new BizException("订单更新失败");
@@ -142,7 +142,12 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             if (info.getMaxNum() != null && info.getPaidNum() > 0) {
                 //重试避免人数过多频繁冲突
                 boolean flag = false;
-                for (int i = 1; i <= 10; i++) {
+                int max = 100, min = 1;
+                int ran2 = (int) (Math.random() * (max - min) + min);
+                for (int i = 1; i <= 100; i++) {
+                    if (i == ran2) {
+                        Thread.sleep(ran2);
+                    }
                     info = sporadicChargeInfoDao.get(info.getId());
                     info.setPaidNum(info.getPaidNum() - 1);
                     info.setUpdateTime(new Date());