From 078e53e937604b719ae1df1d398e7210f08b712f Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 22 Jan 2026 16:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E7=89=A9=E6=B6=88=E6=81=AF=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E9=80=BB=E8=BE=91=EF=BC=8C=E6=96=B0=E5=A2=9EMAGIC=20?= =?UTF-8?q?=E9=AD=94=E6=B3=95=E7=A4=BC=E7=89=A9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inner/enums/material/GiftTabEnum.java | 5 ++ .../gift/strategy/GiftCountStrategy.java | 12 +++ .../strategy/GiftPrizeAcceptStrategy.java | 8 +- .../gift/strategy/GiftRocketListener.java | 12 +++ .../gift/strategy/RankCountStrategy.java | 83 +++++++++++-------- 5 files changed, 84 insertions(+), 36 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/material/GiftTabEnum.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/material/GiftTabEnum.java index 6a447622..6ca6d6f3 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/material/GiftTabEnum.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/material/GiftTabEnum.java @@ -46,4 +46,9 @@ public enum GiftTabEnum { * 幸运礼物. */ LUCKY_GIFT, + + /** + * 魔法礼物(新爆率的幸运礼物) + */ + MAGIC, } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java index 7c8be3a4..265c894e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java @@ -616,6 +616,13 @@ public class GiftCountStrategy implements GiftStrategy { return giftValue.getGiftType().contains(GiftTabEnum.LUCKY_GIFT.name()); } + /** + * 是否魔法礼物 + */ + private boolean isMagicGift(GiftValue giftValue) { + return giftValue.getGiftType().contains(GiftTabEnum.MAGIC.name()); + } + /** * 判断是否为活动礼物 */ @@ -643,6 +650,11 @@ public class GiftCountStrategy implements GiftStrategy { return acceptAmount.multiply(ratio).setScale(0, RoundingMode.DOWN).longValue(); } + if (isMagicGift(giftValue)) { + BigDecimal ratio = new BigDecimal("0.1"); + return acceptAmount.multiply(ratio).setScale(0, RoundingMode.DOWN).longValue(); + } + if (isActivityGift(giftValue) || isCpGift(giftValue)) { BigDecimal ratio = new BigDecimal("0.7"); return acceptAmount.multiply(ratio).setScale(0, RoundingMode.DOWN).longValue(); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftPrizeAcceptStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftPrizeAcceptStrategy.java index b30cc099..5c534681 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftPrizeAcceptStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftPrizeAcceptStrategy.java @@ -87,10 +87,12 @@ public class GiftPrizeAcceptStrategy implements GiftStrategy { // 当前礼物是否为幸运礼物 boolean isLuckyGift = runningWater.getGiftValue().getGiftType() .contains(GiftTabEnum.LUCKY_GIFT.name()); - boolean isCpGift = runningWater.getGiftValue().getGiftType() - .contains(GiftTabEnum.LUCKY_GIFT.name()); + boolean isMagicGift = runningWater.getGiftValue().getGiftType() + .contains(GiftTabEnum.MAGIC.name()); // 发送金币 - if (GiftCurrencyType.GOLD.eq(runningWater.getGiftValue().getCurrencyType()) && !isLuckyGift) { + if (GiftCurrencyType.GOLD.eq(runningWater.getGiftValue().getCurrencyType()) + && !isLuckyGift + && !isMagicGift) { Long consumeId = walletGoldClient.changeBalance(GoldReceiptCmd.builder() .appIncome() diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java index c37bfd6d..d6d9a1ff 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java @@ -113,6 +113,10 @@ public class GiftRocketListener implements GiftStrategy { return gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin()); } + if (isMagicGift(giftValue)) { + return new BigDecimal("0.1"); + } + if (isActivityGift(giftValue) || isCpGift(giftValue)) { return new BigDecimal("0.7"); } @@ -144,6 +148,14 @@ public class GiftRocketListener implements GiftStrategy { giftValue.getGiftType().contains(GiftTabEnum.CP.name()); } + /** + * 判断是否为魔法礼物 + */ + private boolean isMagicGift(GiftValue giftValue) { + return giftValue.getGiftType() != null && + giftValue.getGiftType().contains(GiftTabEnum.MAGIC.name()); + } + /** * 计算实际金额 */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java index d8df8c5a..0684c4e9 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/RankCountStrategy.java @@ -43,12 +43,9 @@ import com.red.circle.other.inner.model.dto.sys.SysActivityCountType; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; -import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.regex.RegexConstant; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -106,9 +103,7 @@ public class RankCountStrategy implements GiftStrategy { GiftValue giftValue = runningWater.getGiftValue(); // 幸运礼物比例 - boolean isLuckyGift = isLuckyGift(giftValue); - BigDecimal luckyGiftRatio = getLuckyGiftShareRatio(runningWater); - log.info("RankCountStrategy.processor---幸运礼物比例:{}", luckyGiftRatio); + BigDecimal giftRatio = getGiftRatio(runningWater); // 周星礼物排行榜计算 boolean isWeekStar = isWeekStar(giftValue); @@ -125,20 +120,22 @@ public class RankCountStrategy implements GiftStrategy { if (isWeekKingQueen) { // king & queen + // ActualAmount: * userSize 发送给所有用户礼物的总价值 + // GiftValue: * quantity 单个礼物的总价值 weekKingQueenCountService.incrThisWeekQuantity(runningWater.getSysOrigin(), runningWater.getUserId(), KingQueenType.WEALTH, - getActualAmount(isLuckyGift, giftValue.getActualAmount(), luckyGiftRatio)); + getActualAmount(giftValue.getActualAmount(), giftRatio)); // queen runningWater.getAcceptUsers().forEach(accept -> weekKingQueenCountService.incrThisWeekQuantity(runningWater.getSysOrigin(), accept.getAcceptUserId(), KingQueenType.CHARM, - getActualAmount(isLuckyGift, giftValue.getGiftValue(), luckyGiftRatio))); + getActualAmount(giftValue.getGiftValue(), giftRatio))); } // 新排行榜累计数据 - accumulateNewRankingData(runningWater, isLuckyGift, luckyGiftRatio); + accumulateNewRankingData(runningWater, giftRatio); // cp if (isCpGift(giftValue)) { @@ -146,31 +143,39 @@ public class RankCountStrategy implements GiftStrategy { } // 首页排行榜 - homeRank(runningWater, luckyGiftRatio); + homeRank(runningWater, giftRatio); giftGiveRunningWaterService.addLog(runningWater.getId(), "结束:排行榜相关统计"); } - private BigDecimal getLuckyGiftShareRatio(GiftGiveRunningWater runningWater) { - return gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin()); + private BigDecimal getGiftRatio(GiftGiveRunningWater runningWater) { + GiftValue giftValue = runningWater.getGiftValue(); + if (isLuckyGift(giftValue)) { + gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin()); + } + + if (isMagicGift(giftValue)) { + return new BigDecimal("0.1"); + } + + if (isActivityGift(giftValue) || isCpGift(giftValue)) { + return new BigDecimal("0.7"); + } + + return BigDecimal.ONE; } /** * 获得礼物额度. */ - private Long getActualAmount(boolean checkLuckyGift, BigDecimal amount, - BigDecimal luckyGiftRatio) { - - if (checkLuckyGift) { - return amount.multiply(luckyGiftRatio).setScale(0, RoundingMode.DOWN).longValue(); - } - return amount.longValue(); + private Long getActualAmount(BigDecimal amount, BigDecimal giftRatio) { + return amount.multiply(giftRatio).setScale(0, RoundingMode.DOWN).longValue(); } /** * KTV游戏统计. */ - private void gameKtv(GiftGiveRunningWater runningWater, BigDecimal luckyGiftRatio) { + private void gameKtv(GiftGiveRunningWater runningWater, BigDecimal giftRatio) { // 演唱者一定是一号麦且必须要有已点歌曲i标识id List users = runningWater.getAcceptUsers().stream().filter(acceptUsers -> @@ -179,9 +184,8 @@ public class RankCountStrategy implements GiftStrategy { if (Objects.nonNull(runningWater.getSongId()) && CollectionUtils.isNotEmpty(users)) { gameKtvCommon.incIntegral(users.get(0).getAcceptUserId(), runningWater.getSongId(), - getActualAmount(isLuckyGift(runningWater.getGiftValue()), - runningWater.getGiftValue().getGiftValue(), - luckyGiftRatio) + getActualAmount( runningWater.getGiftValue().getGiftValue(), + giftRatio) ); } } @@ -262,9 +266,7 @@ public class RankCountStrategy implements GiftStrategy { /** * 首页排行榜. */ - private void homeRank(GiftGiveRunningWater runningWater, BigDecimal luckyGiftRatio) { - - boolean isLuckyGift = isLuckyGift(runningWater.getGiftValue()); + private void homeRank(GiftGiveRunningWater runningWater, BigDecimal giftRatio) { // 房间榜 if (runningWater.getOriginId().matches(RegexConstant.NUMBER)) { @@ -273,23 +275,21 @@ public class RankCountStrategy implements GiftStrategy { if (Objects.nonNull(roomProfile)) { appRankCountService.incrRoomWealthQuantity(runningWater.getSysOrigin() , roomProfile.getId() - , getActualAmount(isLuckyGift, runningWater.getGiftValue().getActualAmount(), - luckyGiftRatio) + , getActualAmount(runningWater.getGiftValue().getActualAmount(), giftRatio) ); } } // 财富榜 appRankCountService.incrWealthQuantity(runningWater.getSysOrigin(), runningWater.getUserId(), - getActualAmount(isLuckyGift, runningWater.getGiftValue().getActualAmount(), luckyGiftRatio) + getActualAmount(runningWater.getGiftValue().getActualAmount(), giftRatio) ); // 魅力榜 runningWater.getAcceptUsers() .forEach(accept -> appRankCountService.incrCharmQuantity(runningWater.getSysOrigin(), accept.getAcceptUserId(), - getActualAmount(isLuckyGift, runningWater.getGiftValue().getGiftValue(), - luckyGiftRatio))); + getActualAmount(runningWater.getGiftValue().getGiftValue(), giftRatio))); } @@ -398,10 +398,27 @@ public class RankCountStrategy implements GiftStrategy { return giftValue.getGiftType().contains(GiftTabEnum.CP.name()); } + /** + * 判断是否为活动礼物 + */ + private boolean isActivityGift(GiftValue giftValue) { + return giftValue.getGiftType() != null && + giftValue.getGiftType().contains(GiftTabEnum.ACTIVITY.name()); + } + + /** + * 判断是否为魔法礼物 + */ + private boolean isMagicGift(GiftValue giftValue) { + return giftValue.getGiftType() != null && + giftValue.getGiftType().contains(GiftTabEnum.MAGIC.name()); + } + + /** * 累计新排行榜数据 */ - private void accumulateNewRankingData(GiftGiveRunningWater runningWater, boolean isLuckyGift, BigDecimal luckyGiftRatio) { + private void accumulateNewRankingData(GiftGiveRunningWater runningWater, BigDecimal giftRatio) { try { // 先查询上架且进行中的活动 @@ -412,7 +429,7 @@ public class RankCountStrategy implements GiftStrategy { } // 计算实际金额 - Long actualAmount = getActualAmount(isLuckyGift, runningWater.getGiftValue().getActualAmount(), luckyGiftRatio); + Long actualAmount = getActualAmount(runningWater.getGiftValue().getActualAmount(), giftRatio); // 遍历活动,找到对应的type再累计对应活动类型的数据 for (ActivityConfig activity : ongoingActivities) {