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 97f95c73..6a447622 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 @@ -32,6 +32,11 @@ public enum GiftTabEnum { */ EXCLUSIVE, + /** + * 活动礼物. + */ + ACTIVITY, + /** * 贵族. */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java similarity index 75% rename from rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java rename to rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java index ff91be53..c37bfd6d 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftSendRocketListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftRocketListener.java @@ -6,16 +6,11 @@ import com.red.circle.other.app.command.rocket.RocketEnergyAddCmdExe; import com.red.circle.other.app.common.gift.GameLuckyGiftCommon; import com.red.circle.other.app.dto.cmd.RocketEnergyAddCmd; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; -import com.red.circle.other.infra.database.cache.service.other.RoomManagerCacheService; -import com.red.circle.other.infra.database.mongo.entity.gift.GiftAcceptUser; import com.red.circle.other.infra.database.mongo.entity.gift.GiftGiveRunningWater; import com.red.circle.other.infra.database.mongo.entity.gift.GiftValue; import com.red.circle.other.infra.database.mongo.service.gift.GiftGiveRunningWaterService; -import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; -import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.enums.material.GiftCurrencyType; import com.red.circle.other.inner.enums.material.GiftTabEnum; -import com.red.circle.tool.core.text.StringUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -33,7 +28,7 @@ import java.util.Objects; @Slf4j @Service("ROCKET_COUNT_LISTENER") @RequiredArgsConstructor -public class GiftSendRocketListener implements GiftStrategy { +public class GiftRocketListener implements GiftStrategy { private final RocketEnergyAddCmdExe rocketEnergyAddCmdExe; private final GiftGiveRunningWaterService giftGiveRunningWaterService; @@ -82,15 +77,11 @@ public class GiftSendRocketListener implements GiftStrategy { // 4. 判断是否为幸运礼物 boolean isLuckyGift = isLuckyGift(giftValue); - // 5. 获取幸运礼物比例 - BigDecimal luckyGiftRatio = BigDecimal.ZERO; - if (isLuckyGift) { - luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin()); - log.info("【火箭能量增加】幸运礼物比例:{}", luckyGiftRatio); - } + // 5. 获取礼物比例 + BigDecimal luckyGiftRatio = calcGiftRatio(runningWater); // 6. 计算实际金币价值(考虑幸运礼物加成) - Long actualGoldValue = getActualAmount(isLuckyGift, giftValue.getActualAmount(), luckyGiftRatio); + Long actualGoldValue = getActualAmount(giftValue.getActualAmount(), luckyGiftRatio); Long roomId = Long.parseLong(originId); @@ -116,6 +107,19 @@ public class GiftSendRocketListener implements GiftStrategy { } } + private BigDecimal calcGiftRatio(GiftGiveRunningWater runningWater) { + GiftValue giftValue = runningWater.getGiftValue(); + if (isLuckyGift(giftValue)) { + return gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin()); + } + + if (isActivityGift(giftValue) || isCpGift(giftValue)) { + return new BigDecimal("0.7"); + } + + return BigDecimal.ONE; + } + /** * 判断是否为幸运礼物 */ @@ -125,15 +129,28 @@ public class GiftSendRocketListener implements GiftStrategy { } /** - * 计算实际金额(考虑幸运礼物加成) + * 判断是否为活动礼物 */ - private Long getActualAmount(boolean isLuckyGift, BigDecimal amount, BigDecimal luckyGiftRatio) { - if (isLuckyGift && luckyGiftRatio != null && luckyGiftRatio.compareTo(BigDecimal.ZERO) > 0) { - // 幸运礼物按比例计算 - return amount.multiply(luckyGiftRatio) - .setScale(0, RoundingMode.DOWN) - .longValue(); - } - return amount.longValue(); + private boolean isActivityGift(GiftValue giftValue) { + return giftValue.getGiftType() != null && + giftValue.getGiftType().contains(GiftTabEnum.ACTIVITY.name()); + } + + /** + * 判断是否为CP礼物 + */ + private boolean isCpGift(GiftValue giftValue) { + return giftValue.getGiftType() != null && + giftValue.getGiftType().contains(GiftTabEnum.CP.name()); + } + + /** + * 计算实际金额 + */ + private Long getActualAmount(BigDecimal amount, BigDecimal luckyGiftRatio) { + // 礼物按比例计算 + return amount.multiply(luckyGiftRatio) + .setScale(0, RoundingMode.DOWN) + .longValue(); } }