|
@@ -225,12 +225,12 @@ public class MarketingServiceImpl extends ServiceImpl<MarketingMapper, Marketing
|
|
|
boolean isInside = false;
|
|
|
|
|
|
// 参与人数不足,全部采用内定人员开奖
|
|
|
- if (prizeQuantity >= realNum) {
|
|
|
- insideNum = prizeQuantity;
|
|
|
- isInside = true;
|
|
|
- } else {
|
|
|
+// if (prizeQuantity >= realNum) {
|
|
|
+// insideNum = prizeQuantity;
|
|
|
+// isInside = true;
|
|
|
+// } else {
|
|
|
insideNum = marketingAwardsList.stream().mapToInt(MarketingAwards::getInsideNum).sum();
|
|
|
- }
|
|
|
+// }
|
|
|
|
|
|
// 获取一定数量的内定人员设置抽奖码加入抽奖关系表和抽奖池
|
|
|
List<SysUser> insideUserList = sysUserService.selectUserListByRand(UserTypeEnum.INSIDE.getValue(), insideNum);
|
|
@@ -336,6 +336,9 @@ public class MarketingServiceImpl extends ServiceImpl<MarketingMapper, Marketing
|
|
|
if (CollectionUtils.isEmpty(hitCodeList)) {
|
|
|
hitCodeList = redisCache.popCacheSet(userLowLotteryPool, 1);
|
|
|
}
|
|
|
+ if (CollectionUtils.isEmpty(hitCodeList)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
MarketingUserCode marketingUserCode = marketingUserCodeService.getOne(new LambdaQueryWrapper<MarketingUserCode>()
|
|
|
.eq(MarketingUserCode::getMarketingId, marketing.getId())
|
|
|
.eq(MarketingUserCode::getCode, hitCodeList.get(0)));
|
|
@@ -605,14 +608,12 @@ public class MarketingServiceImpl extends ServiceImpl<MarketingMapper, Marketing
|
|
|
* @param marketing
|
|
|
*/
|
|
|
private void createAwardsAndPrize(List<MarketingAwardsParam> awardsList, Marketing marketing) {
|
|
|
- int sum = awardsList.stream().mapToInt(MarketingAwardsParam::getQuantity).sum();
|
|
|
- if (sum > 100) {
|
|
|
- throw new ServiceException("中奖名额不能超过100");
|
|
|
- }
|
|
|
|
|
|
+ int insideNum = 0;
|
|
|
// 创建奖级
|
|
|
List<MarketingAwardsPrize> marketingAwardsPrizeList = new ArrayList<>();
|
|
|
for (MarketingAwardsParam awardsParam : awardsList) {
|
|
|
+ insideNum += awardsParam.getInsideNum();
|
|
|
if (awardsParam.getInsideNum() > awardsParam.getQuantity()) {
|
|
|
throw new ServiceException("内定数量不能大于奖品数量");
|
|
|
}
|
|
@@ -656,6 +657,9 @@ public class MarketingServiceImpl extends ServiceImpl<MarketingMapper, Marketing
|
|
|
marketingAwardsPrizeList.add(awardsPrize);
|
|
|
}
|
|
|
}
|
|
|
+ if (insideNum >= 100) {
|
|
|
+ throw new ServiceException("内定人数不能超过100");
|
|
|
+ }
|
|
|
marketingAwardsPrizeService.saveBatch(marketingAwardsPrizeList);
|
|
|
}
|
|
|
|