幸运25-大R-支持一批多次
This commit is contained in:
@@ -52,16 +52,18 @@ public class Lucky25DrawService {
|
||||
long afterTotalInput = userMetaMap.addAndGet(Lucky25UserMetaService.INPUT_KEY, totalGoldNum).longValue();
|
||||
long beforeTotalInput = afterTotalInput - totalGoldNum;
|
||||
|
||||
Lucky25Result highRechargeResult = drawHighRechargeUserPool(config, senderUid, partitionId,
|
||||
beforeTotalInput, afterTotalInput);
|
||||
if (null != highRechargeResult){
|
||||
Long receiver = receiverList.remove(0);
|
||||
highRechargeResult.setReceiverUid(receiver);
|
||||
List<Lucky25Result> highRechargeResults = drawHighRechargeUserPool(config, senderUid, partitionId,
|
||||
beforeTotalInput, afterTotalInput, receiverList.size());
|
||||
if (!CollectionUtils.isEmpty(highRechargeResults)){
|
||||
for (Lucky25Result highRechargeResult : highRechargeResults){
|
||||
Long receiver = receiverList.remove(0);
|
||||
highRechargeResult.setReceiverUid(receiver);
|
||||
|
||||
log.info("[lucky25] highRechargeResult uid {} beforeTotalInput {} afterTotalInput {} highRechargeResult {} receiverUid {}",
|
||||
senderUid, beforeTotalInput, afterTotalInput, JSON.toJSONString(highRechargeResult), receiver);
|
||||
log.info("[lucky25] highRechargeResult uid {} beforeTotalInput {} afterTotalInput {} highRechargeResult {} receiverUid {}",
|
||||
senderUid, beforeTotalInput, afterTotalInput, JSON.toJSONString(highRechargeResult), receiver);
|
||||
|
||||
resultList.add(highRechargeResult);
|
||||
resultList.add(highRechargeResult);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(receiverList)){
|
||||
return resultList.stream().map(drawResult->
|
||||
@@ -110,7 +112,7 @@ public class Lucky25DrawService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Lucky25Result drawHighRechargeUserPool(Lucky25GiftConfig config, long uid, int partitionId, long beforeInput, long afterInput) {
|
||||
private List<Lucky25Result> drawHighRechargeUserPool(Lucky25GiftConfig config, long uid, int partitionId, long beforeInput, long afterInput, int receiverUidSize) {
|
||||
Lucky25GiftConfig partitionConfig = config.getRatioByPartitionId(partitionId);
|
||||
if (null == partitionConfig || null == partitionConfig.getHighRechargeThreshold_M()){
|
||||
return null;
|
||||
@@ -125,7 +127,13 @@ public class Lucky25DrawService {
|
||||
return null;
|
||||
}
|
||||
|
||||
return highRechargePoolService.drawMultipleFromPool(config, uid, partitionId);
|
||||
int thresholdNum = Math.toIntExact(afterThreshold - beforeThreshold);
|
||||
int num = Math.min(receiverUidSize, thresholdNum);
|
||||
|
||||
log.info("[lucky25] drawHighRechargeUserPool uid {} beforeThreshold {} afterThreshold {} thresholdNum {} receiverUidSize {} num {}",
|
||||
uid, beforeThreshold, afterThreshold, thresholdNum, receiverUidSize, num);
|
||||
|
||||
return highRechargePoolService.drawMultipleFromPool(config, uid, partitionId, num);
|
||||
}
|
||||
|
||||
private Lucky25Record updateMeta(Lucky25GiftConfig config, long senderUid, int partitionId,
|
||||
|
@@ -47,8 +47,9 @@ public class Lucky25GiftSendService {
|
||||
log.info("[lucky25] uid {}, partitionId {}, addStockGoldNum {}, afterStock {}",
|
||||
senderUid, partitionId, incomeAllot.getRemainValue(), afterStock);
|
||||
|
||||
List<Long> receiverUidList = new ArrayList<>(receiverList);
|
||||
List<Lucky25Record> recordList = drawService.draw(config, senderUid, partitionId,
|
||||
gift, everyGiftNum, everyoneGoldNum, receiverList, room, sendGiftTime);
|
||||
gift, everyGiftNum, everyoneGoldNum, receiverUidList, room, sendGiftTime);
|
||||
log.info("[lucky25] uid {}, totalWinGoldNum {}", senderUid, JSON.toJSONString(recordList));
|
||||
|
||||
mqService.sendMq(recordList);
|
||||
|
@@ -38,20 +38,25 @@ public class Lucky25HighRechargePoolService {
|
||||
@Autowired
|
||||
private Lucky25PoolMapper poolMapper;
|
||||
|
||||
public Lucky25Result drawMultipleFromPool(Lucky25GiftConfig config, Long uid, Integer partitionId){
|
||||
public List<Lucky25Result> drawMultipleFromPool(Lucky25GiftConfig config, Long uid, Integer partitionId, int num){
|
||||
if (!highRechargeUserService.isHighRechargeUser(uid)){
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Lucky25Result> resultList = new ArrayList<>();
|
||||
RQueue<Lucky25Result> partitionPool = getHighRechargePool(partitionId);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Lucky25Result result = partitionPool.poll();
|
||||
if (null != result) {
|
||||
int n = num - resultList.size();
|
||||
resultList.addAll(partitionPool.poll(n));
|
||||
if (resultList.size() >= num) {
|
||||
partitionPool.expireAsync(Duration.of(14, ChronoUnit.DAYS));
|
||||
return result;
|
||||
return resultList;
|
||||
}
|
||||
genPool(config, partitionId, partitionPool);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(resultList)){
|
||||
partitionPool.addAll(resultList);
|
||||
}
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
|
@@ -129,9 +129,6 @@ public class Lucky25UserMetaService {
|
||||
//log.info("[lucky25] updateUserMeta uid {} times {} totalInput {} totalOutput {}",
|
||||
// senderUid, times, totalInput, totalOutput);
|
||||
|
||||
log.info("[lucky25] updateUserMeta uid {} times {} totalOutput {}",
|
||||
senderUid, times, totalOutput);
|
||||
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
long todayStartTimeLong = DateTimeUtil.getZonedTodayTime(partitionEnum.getZoneId());
|
||||
|
||||
@@ -151,8 +148,8 @@ public class Lucky25UserMetaService {
|
||||
String todayOutputKey = String.join("_", today, OUTPUT_KEY);
|
||||
long todayOutput = userMetaMap.addAndGet(todayOutputKey, output).longValue();
|
||||
|
||||
log.info("[lucky25] updateUserMeta uid {} times {} today {} todayInput {} todayOutput {}",
|
||||
senderUid, times, todayStartTimeLong, todayInput, todayOutput);
|
||||
log.info("[lucky25] updateUserMeta uid {} times {} totalOutput {} today {} todayInput {} todayOutput {}",
|
||||
senderUid, totalOutput, times, todayStartTimeLong, todayInput, todayOutput);
|
||||
}
|
||||
|
||||
public int subAdminTicketNum(long uid, int superTicketNum) {
|
||||
|
Reference in New Issue
Block a user