From ea9cf1913eb785ab3a2c6717bd2c84202769fffb Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 17 Sep 2025 20:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B8=E8=BF=90=E7=A4=BC=E7=89=A9=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/common/gift/GameLuckyGiftCommon.java | 73 ++++++++++++++++--- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java index 12b5871d..c4270d74 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java @@ -62,15 +62,7 @@ import java.io.Serializable; import java.math.BigDecimal; import java.math.RoundingMode; import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Random; -import java.util.TreeMap; +import java.util.*; import java.util.stream.Collectors; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -219,7 +211,28 @@ public class GameLuckyGiftCommon { */ public void run(GameLuckyGiftParamCmd cmd) { - runLuckyGiftGame(cmd); +// runLuckyGiftGame(cmd); + runLuckyGiftGameNew(cmd); + } + + /** + * 抽奖. + */ + private void runLuckyGiftGameNew(GameLuckyGiftParamCmd cmd) { + // 组装幸运礼物参数 + GameLuckyGiftParam param = toBuildGameLuckyGift(cmd); + log.info("runLuckyGiftGame param:{}", JSON.toJSONString(param)); + if (Objects.isNull(param)) { + return; + } + + List orderIds = List.of("LG_" + param.getId().toString()); + ThirdPartyLotteryResult apiResult = callThirdPartyLotteryApi(param, orderIds); + + Integer totalAwardAmount = apiResult.getOrderResults().stream().mapToInt(OrderResult::getRewardNum).sum(); + + // 保存幸运礼物流水 + sendMessageNew(param, Long.valueOf(String.valueOf(totalAwardAmount))); } /** @@ -301,6 +314,45 @@ public class GameLuckyGiftCommon { } + /** + * 处理用户连续赠送幸运礼物奖励逻辑 + */ + private void sendMessageNew(GameLuckyGiftParam param, Long awardAmount) { + + long payAmount = param.getQuantity() * param.getGift().getGiftCandy().longValue(); + int multiple = (int) (awardAmount / payAmount); + + gameLuckyGiftCountService.save(new GameLuckyGiftCount() + .setId(param.getId()) + .setGiftId(param.getGiftId()) + .setRoomId(param.getRoomId()) + .setQuantity(param.getQuantity()) + .setUserId(param.getUserId()) + .setSysOrigin(param.getSysOrigin()) + .setGiftIncCount(param.getGiftsCount()) + .setGiftCombos(param.getComboCount()) + .setGiftCover(param.getGift().getGiftPhoto()) + .setPayAmount(payAmount) + .setMultiple(multiple) + .setChangeInventory(false) + .setSysGiftIncCount(param.getTemplate().getGiftGiveTotal()) + .setAwardAmount(awardAmount) + .setRegionCode(param.getRoomRegionCode()) + .setDateNumber(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()) + ); + + if (awardAmount <= 0) { + return; + } + + // 发送中奖金币 + BigDecimal balance = sendGold(param.getUserId(), param.getSysOrigin(), awardAmount); + + // 发送中奖通知 + sendMsg(param, multiple, balance); + + } + /** * 开启全部模式的情况下抽奖. * @@ -770,6 +822,7 @@ public class GameLuckyGiftCommon { private ThirdPartyLotteryResult createFailedResult() { ThirdPartyLotteryResult result = new ThirdPartyLotteryResult(); result.setSuccess(false); + result.setOrderResults(Collections.emptyList()); return result; }