diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java index eb3a4ffd..ed293586 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/GiveGiftsListener.java @@ -783,25 +783,21 @@ public class GiveGiftsListener implements MessageListener { //先获取房间redis值 List liveHeartbeatCaches = liveHeartbeatCacheService.listLiveHeartbeat( event.getRoomId()); - //组装一下心动值数据 key 用户id + //组装一下魅力值数据 key 用户id Map liveHeartbeatCacheMap = getLiveHeartbeatCacheMap(liveHeartbeatCaches); Map cacheMap = acceptsUserIds.stream().map(userId -> { - // 礼物比例 - BigDecimal giftRatio = BigDecimal.valueOf(1L); - if (event.checkLuckyGift()) { - // 幸运礼物比例 - giftRatio = gameLuckyGiftCommon.getLuckyGiftTargetRatio(event.getSysOrigin().name()); - } - //总的心动值 - BigDecimal amountTotal = event.countSingleGiftGolds().multiply(giftRatio); + // 礼物比例 + BigDecimal giftRatio = calcGiftRatio(event); + //总的魅力值 + BigDecimal amountTotal = event.countSingleGiftGolds().multiply(giftRatio); - LiveHeartbeatCache liveHeartbeatCache = new LiveHeartbeatCache(); - liveHeartbeatCache.setId(userId); - liveHeartbeatCache.setHeartbeatVal(getHeartbeatTotal(amountTotal, - Objects.nonNull(liveHeartbeatCacheMap.get(userId)) ? liveHeartbeatCacheMap.get(userId) - .getHeartbeatVal() : null)); + LiveHeartbeatCache liveHeartbeatCache = new LiveHeartbeatCache(); + liveHeartbeatCache.setId(userId); + liveHeartbeatCache.setHeartbeatVal(getHeartbeatTotal(amountTotal, + Objects.nonNull(liveHeartbeatCacheMap.get(userId)) ? + liveHeartbeatCacheMap.get(userId).getHeartbeatVal() : null)); return liveHeartbeatCache; }).collect(Collectors.toMap(LiveHeartbeatCache::getId, v -> v)); liveHeartbeatCacheMap.putAll(cacheMap); @@ -810,6 +806,18 @@ public class GiveGiftsListener implements MessageListener { } } + private BigDecimal calcGiftRatio(GiveAwayGiftBatchEvent event) { + if (event.checkLuckyGift()) { + // 幸运礼物比例 + return gameLuckyGiftCommon.getLuckyGiftTargetRatio(event.getSysOrigin().name()); + } + if (event.checkCpGift()) { + return getAssistCpGiftGoldRatio("").multiply(new BigDecimal("10").max(new BigDecimal("0.7"))); + } + + return BigDecimal.valueOf(1L); + } + private Map getLiveHeartbeatCacheMap(List list) { return Optional.ofNullable(