|
|
@@ -394,28 +394,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
throw new BizException("订单金额异常");
|
|
|
}
|
|
|
if (chargeInfo.getMaxNum() != null) {
|
|
|
- //重试避免人数过多频繁冲突
|
|
|
- boolean flag = false;
|
|
|
- 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(500);
|
|
|
- }
|
|
|
- chargeInfo = sporadicChargeInfoDao.get(sporadicPayDto.getSporadicId());
|
|
|
- if (chargeInfo.getMaxNum() != null && chargeInfo.getMaxNum() <= chargeInfo.getPaidNum()) {
|
|
|
- throw new BizException("活动人数暂时已满,请稍后再试");
|
|
|
- }
|
|
|
- chargeInfo.setPaidNum(chargeInfo.getPaidNum() + 1);
|
|
|
- chargeInfo.setUpdateTime(new Date());
|
|
|
- int update = sporadicChargeInfoDao.update(chargeInfo);
|
|
|
- if (update > 0) {
|
|
|
- flag = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!flag) {
|
|
|
- throw new BizException("活动火爆,请稍后再试"+ran2);
|
|
|
+ chargeInfo.setPaidNum(chargeInfo.getPaidNum() + 1);
|
|
|
+ chargeInfo.setUpdateTime(new Date());
|
|
|
+ int update = sporadicChargeInfoDao.update(chargeInfo);
|
|
|
+ if (update <= 0) {
|
|
|
+ throw new BizException("活动火爆,请稍后再试");
|
|
|
}
|
|
|
}
|
|
|
|