礼物消息消费逻辑,新增MAGIC 魔法礼物类型
This commit is contained in:
parent
acf72c9b0f
commit
078e53e937
@ -46,4 +46,9 @@ public enum GiftTabEnum {
|
||||
* 幸运礼物.
|
||||
*/
|
||||
LUCKY_GIFT,
|
||||
|
||||
/**
|
||||
* 魔法礼物(新爆率的幸运礼物)
|
||||
*/
|
||||
MAGIC,
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算实际金额
|
||||
*/
|
||||
|
||||
@ -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<GiftAcceptUser> 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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user