bravo-pool-以防last2000对比值异常,随机newUserPool保底
This commit is contained in:
@@ -78,8 +78,7 @@ public class BravoPoolService {
|
||||
|
||||
BravoPoolTypeEnum poolType = selectPoolType(config, uid);
|
||||
|
||||
List<BravoPool> poolList = bravoPoolMapper.selectList(Wrappers.<BravoPool>lambdaQuery()
|
||||
.eq(BravoPool::getType, poolType.getType()));
|
||||
List<BravoPool> poolList = bravoPoolMapper.selectList(null);
|
||||
if (CollectionUtils.isEmpty(poolList)){
|
||||
throw new ServiceException(BusiStatus.SEIZE_TREASURE_POOL_CONFIG_ERROR);
|
||||
}
|
||||
@@ -163,6 +162,10 @@ public class BravoPoolService {
|
||||
Long uid,
|
||||
BravoPoolTypeEnum poolType, List<BravoPool> poolList) {
|
||||
if (BravoPoolTypeEnum.NEW_USER_POOL.equals(poolType)){
|
||||
poolList = poolList.stream()
|
||||
.filter(pool->pool.getType() == BravoPoolTypeEnum.NEW_USER_POOL.getType())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int randomIndex = RandomUtil.randomByRange(0, poolList.size());
|
||||
BravoPool randomPool = poolList.get(randomIndex);
|
||||
log.info("[bravo] genPool selectPool type {}, pooList {}, randomIndex {}, expect {}",
|
||||
@@ -172,8 +175,15 @@ public class BravoPoolService {
|
||||
|
||||
BigDecimal thisExpect = calExpect(config, partitionConfig, uid);
|
||||
List<BravoPool> expectPoolList = BigDecimal.ZERO.compareTo(thisExpect) < 0 ?
|
||||
poolList.stream().filter(pool->pool.getExpect().compareTo(thisExpect) > 0).collect(Collectors.toList()):
|
||||
poolList.stream().filter(pool->thisExpect.negate().compareTo(pool.getExpect()) >= 0).collect(Collectors.toList());
|
||||
poolList.stream().filter(pool->pool.getType() == BravoPoolTypeEnum.NORMAL_POOL.getType())
|
||||
.filter(pool->pool.getExpect().compareTo(thisExpect) > 0).collect(Collectors.toList()):
|
||||
poolList.stream().filter(pool->pool.getType() == BravoPoolTypeEnum.NORMAL_POOL.getType())
|
||||
.filter(pool->thisExpect.negate().compareTo(pool.getExpect()) >= 0).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(expectPoolList)){
|
||||
expectPoolList = poolList.stream().filter(pool->pool.getType() == BravoPoolTypeEnum.NEW_USER_POOL.getType())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
int randomIndex = RandomUtil.randomByRange(0, expectPoolList.size());
|
||||
BravoPool randomPool = expectPoolList.get(randomIndex);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.business.service.lucky;
|
||||
|
||||
import com.accompany.business.constant.BravoPoolTypeEnum;
|
||||
import com.accompany.business.constant.Lucky24PoolTypeEnum;
|
||||
import com.accompany.business.dto.lucky.Lucky24GiftConfig;
|
||||
import com.accompany.business.dto.lucky.Lucky24Result;
|
||||
@@ -68,8 +69,7 @@ public class Lucky24PoolService {
|
||||
|
||||
Lucky24PoolTypeEnum poolType = selectPoolType(config, uid);
|
||||
|
||||
List<Lucky24Pool> poolList = lucky24PoolMapper.selectList(Wrappers.<Lucky24Pool>lambdaQuery()
|
||||
.eq(Lucky24Pool::getType, poolType.getType()));
|
||||
List<Lucky24Pool> poolList = lucky24PoolMapper.selectList(null);
|
||||
if (CollectionUtils.isEmpty(poolList)){
|
||||
throw new ServiceException(BusiStatus.SEIZE_TREASURE_POOL_CONFIG_ERROR);
|
||||
}
|
||||
@@ -136,12 +136,12 @@ public class Lucky24PoolService {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public Lucky24Pool selectPoolId(int poolId) {
|
||||
return lucky24PoolMapper.selectById(poolId);
|
||||
}
|
||||
|
||||
private Lucky24Pool selectPool(Lucky24GiftConfig config, Lucky24GiftConfig partitionConfig, Long uid, Integer partitionId, Lucky24PoolTypeEnum poolType, List<Lucky24Pool> poolList) {
|
||||
if (Lucky24PoolTypeEnum.NEW_USER_POOL.equals(poolType)){
|
||||
poolList = poolList.stream()
|
||||
.filter(pool->pool.getType() == Lucky24PoolTypeEnum.NEW_USER_POOL.getType())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int randomIndex = RandomUtil.randomByRange(0, poolList.size());
|
||||
Lucky24Pool randomPool = poolList.get(randomIndex);
|
||||
log.info("[lucky24] genPool selectPool type {}, pooList {}, randomIndex {}, expect {}",
|
||||
@@ -153,6 +153,7 @@ public class Lucky24PoolService {
|
||||
if (!CollectionUtils.isEmpty(config.getBlackUidList())
|
||||
&& config.getBlackUidList().contains(uid)){
|
||||
List<Lucky24Pool> balckPoolList = poolList.stream()
|
||||
.filter(pool->pool.getType() == Lucky24PoolTypeEnum.BLACK_POOL.getType())
|
||||
.sorted(Comparator.comparing(Lucky24Pool::getExpect))
|
||||
.limit(1L)
|
||||
.collect(Collectors.toList());
|
||||
@@ -178,6 +179,7 @@ public class Lucky24PoolService {
|
||||
BigDecimal todayProductionRatio = BigDecimal.ZERO.equals(output)? BigDecimal.ZERO: output.divide(input,2, RoundingMode.HALF_UP);
|
||||
if (input.compareTo(BigDecimal.valueOf(300000)) >= 0 && todayProductionRatio.compareTo(partitionConfig.getTodayProductionRatio()) >= 0){
|
||||
List<Lucky24Pool> excludePoolList = poolList.stream()
|
||||
.filter(pool->pool.getType() == Lucky24PoolTypeEnum.NORMAL_POOL.getType())
|
||||
.filter(pool-> pool.getItemList().stream().noneMatch(poolItem->poolItem.getMulti() == 1000 && poolItem.getNum() > 0))
|
||||
.filter(pool-> partitionConfig.getProductionRatio().compareTo(pool.getExpect()) > 0)
|
||||
.collect(Collectors.toList());
|
||||
@@ -194,8 +196,15 @@ public class Lucky24PoolService {
|
||||
|
||||
BigDecimal thisExpect = calExpect(config, partitionConfig, uid);
|
||||
List<Lucky24Pool> expectPoolList = BigDecimal.ZERO.compareTo(thisExpect) < 0 ?
|
||||
poolList.stream().filter(pool->pool.getExpect().compareTo(thisExpect) > 0).collect(Collectors.toList()):
|
||||
poolList.stream().filter(pool->thisExpect.negate().compareTo(pool.getExpect()) >= 0).collect(Collectors.toList());
|
||||
poolList.stream().filter(pool->pool.getType() == Lucky24PoolTypeEnum.NORMAL_POOL.getType())
|
||||
.filter(pool->pool.getExpect().compareTo(thisExpect) > 0).collect(Collectors.toList()):
|
||||
poolList.stream().filter(pool->pool.getType() == Lucky24PoolTypeEnum.NORMAL_POOL.getType())
|
||||
.filter(pool->thisExpect.negate().compareTo(pool.getExpect()) >= 0).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(expectPoolList)){
|
||||
expectPoolList = poolList.stream().filter(pool->pool.getType() == Lucky24PoolTypeEnum.NEW_USER_POOL.getType())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
int randomIndex = RandomUtil.randomByRange(0, expectPoolList.size());
|
||||
Lucky24Pool randomPool = expectPoolList.get(randomIndex);
|
||||
|
Reference in New Issue
Block a user