幸运25-兼容旧数组
This commit is contained in:
@@ -86,18 +86,21 @@ public class Lucky25DrawService {
|
||||
}
|
||||
}
|
||||
|
||||
// todo 比较
|
||||
if (null != config.getJudgeInputThreshold() && beforeTotalInput > config.getJudgeInputThreshold()){
|
||||
int curPoolType = userMetaMap.getOrDefault(Lucky25UserMetaService.POOL_TYPE, Lucky25PoolTypeEnum.NEW_USER_POOL.getType()).intValue();
|
||||
poolJudgeService.judge(config, senderUid, partitionId, curPoolType);
|
||||
}
|
||||
|
||||
List<Lucky25Result> remainResultList = poolService.drawMultipleFromPool(config, senderUid, partitionId, receiverList.size());
|
||||
for (int i = 0; i < receiverList.size(); i++) {
|
||||
Long receiverUid = receiverList.get(i);
|
||||
Lucky25Result result = remainResultList.get(i);
|
||||
result.setReceiverUid(receiverUid);
|
||||
}
|
||||
resultList.addAll(remainResultList);
|
||||
|
||||
// todo 原数组
|
||||
|
||||
|
||||
return receiverList.parallelStream()
|
||||
.map(receiverUid-> drawMultiple(config, senderUid, partitionId, gift, everyGiftNum, receiverUid, everyoneGoldNum, room, sendGiftTime))
|
||||
return resultList.parallelStream().map(drawResult->
|
||||
updateMeta(config, senderUid, partitionId, gift, everyGiftNum, everyoneGoldNum, room, sendGiftTime, drawResult))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -119,13 +122,6 @@ public class Lucky25DrawService {
|
||||
return highRechargePoolService.drawMultipleFromPool(config, uid, partitionId);
|
||||
}
|
||||
|
||||
public Lucky25Record drawMultiple(Lucky25GiftConfig config, long senderUid, int partitionId,
|
||||
Gift gift, int giftNum, long receiverUid, long everyoneGoldNum, Room room, Date sendGiftTime) {
|
||||
Lucky25Result drawResult = poolService.drawMultipleFromPool(config, senderUid, partitionId);
|
||||
drawResult.setReceiverUid(receiverUid);
|
||||
return updateMeta(config, senderUid, partitionId, gift, giftNum, everyoneGoldNum, room, sendGiftTime, drawResult);
|
||||
}
|
||||
|
||||
private Lucky25Record updateMeta(Lucky25GiftConfig config, long senderUid, int partitionId,
|
||||
Gift gift, int giftNum, long everyoneGoldNum, Room room, Date sendGiftTime,
|
||||
Lucky25Result drawResult){
|
||||
|
||||
@@ -37,16 +37,22 @@ public class Lucky25PoolService {
|
||||
@Autowired
|
||||
private Lucky25PoolMapper poolMapper;
|
||||
|
||||
public Lucky25Result drawMultipleFromPool(Lucky25GiftConfig config, Long uid, int partitionId){
|
||||
public List<Lucky25Result> drawMultipleFromPool(Lucky25GiftConfig config, Long uid, int partitionId, int num){
|
||||
List<Lucky25Result> resultList = new ArrayList<>();
|
||||
RQueue<Lucky25Result> userPool = getUserPool(uid);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Lucky25Result result = userPool.poll();
|
||||
if (null != result) {
|
||||
int n = num - resultList.size();
|
||||
resultList.addAll(userPool.poll(n));
|
||||
if (resultList.size() >= num) {
|
||||
userPool.expireAsync(Duration.of(14, ChronoUnit.DAYS));
|
||||
return result;
|
||||
return resultList;
|
||||
}
|
||||
genPool(config, uid, partitionId, userPool);
|
||||
}
|
||||
//放回
|
||||
if (!CollectionUtils.isEmpty(resultList)){
|
||||
userPool.addAll(resultList);
|
||||
}
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
@@ -286,7 +292,6 @@ public class Lucky25PoolService {
|
||||
return thisExpect.negate();
|
||||
}
|
||||
|
||||
//todo deviceId
|
||||
private Lucky25PoolTypeEnum selectPoolType(Lucky25GiftConfig config, long senderUid) {
|
||||
if (!CollectionUtils.isEmpty(config.getBlackUidList()) && config.getBlackUidList().contains(senderUid)){
|
||||
log.info("[lucky25] genPool selectPoolType uid {}, 黑名单", senderUid);
|
||||
@@ -297,9 +302,20 @@ public class Lucky25PoolService {
|
||||
return Lucky25PoolTypeEnum.NORMAL_POOL;
|
||||
}
|
||||
long userTimes = userMetaService.getTimes(senderUid);
|
||||
Lucky25PoolTypeEnum typeEnum = userTimes < (long) config.getPoolSize() * config.getNewUserPoolCount()?
|
||||
Lucky25PoolTypeEnum.NEW_USER_POOL:
|
||||
Lucky25PoolTypeEnum.NORMAL_POOL;
|
||||
if (userTimes < (long) config.getPoolSize() * config.getNewUserPoolCount()){
|
||||
log.info("[lucky25] genPool selectPoolType newUserPool uid {}, userTimes {}", senderUid, userTimes);
|
||||
return Lucky25PoolTypeEnum.NEW_USER_POOL;
|
||||
}
|
||||
|
||||
//默认普通奖池,如果curType是新人奖池,但又超过上面的userTimes判断,则是退出high或者low并完成追加的4次新手,则设置为普通奖池
|
||||
RMap<String, Number> userMetaMap = userMetaService.getUserMeta(senderUid);
|
||||
int curType = userMetaMap.getOrDefault(Lucky25UserMetaService.POOL_TYPE, Lucky25PoolTypeEnum.NORMAL_POOL.getType()).intValue();
|
||||
if (curType == Lucky25PoolTypeEnum.NEW_USER_POOL.getType()){
|
||||
userMetaMap.put(Lucky25UserMetaService.POOL_TYPE, Lucky25PoolTypeEnum.NORMAL_POOL.getType());
|
||||
curType = Lucky25PoolTypeEnum.NORMAL_POOL.getType();
|
||||
}
|
||||
|
||||
Lucky25PoolTypeEnum typeEnum = Lucky25PoolTypeEnum.get(curType);
|
||||
log.info("[lucky25] genPool selectPoolType uid {}, userTimes {}, type {}",
|
||||
senderUid, userTimes, typeEnum);
|
||||
return typeEnum;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.accompany.business.service.lucky;
|
||||
|
||||
import com.accompany.business.constant.Lucky25PoolTypeEnum;
|
||||
import com.accompany.business.dto.lucky.Lucky25Result;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
|
||||
Reference in New Issue
Block a user