boomRate_配置
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package com.accompany.business.constant;
|
||||
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.BaseRedisKey;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public interface RoomBoomConstant {
|
||||
|
||||
@@ -103,4 +108,43 @@ public interface RoomBoomConstant {
|
||||
|
||||
String DENY_JOB_SIGN = "room_boom_award_deny_job";//boom升级奖励派发标识
|
||||
Integer DENY_JOB_SECONDS = 15;//boom升级奖励延时发放
|
||||
|
||||
|
||||
/**
|
||||
* 阿拉伯:普通100%+lucky5%+Bravo2%
|
||||
* 土耳其:普通100%+lucky5%+Bravo2%
|
||||
* 英语区:普通100%+lucky2%+Bravo2%
|
||||
* 英语2区:普通100%+lucky5%+Bravo2%
|
||||
* @return
|
||||
*/
|
||||
BigDecimal NORMAL_GIFT_BOOM_RATE = BigDecimal.valueOf(1.0D);
|
||||
BigDecimal SUPER_GIFT_BOOM_RATE_AR = BigDecimal.valueOf(0.05D);
|
||||
BigDecimal SUPER_GIFT_BOOM_RATE_EN = BigDecimal.valueOf(0.02D);
|
||||
BigDecimal BRAVO_GIFT_BOOM_RATE_EN = BigDecimal.valueOf(0.02D);
|
||||
|
||||
enum BoomRateStrategy {
|
||||
DEFAULT((type, partition) -> NORMAL_GIFT_BOOM_RATE),
|
||||
LUCKY((type, partition) -> {
|
||||
if (PartitionEnum.ENGLISH.getId() == partition || PartitionEnum.CHINESE.getId() == partition) {
|
||||
return SUPER_GIFT_BOOM_RATE_EN;
|
||||
}
|
||||
return SUPER_GIFT_BOOM_RATE_AR;
|
||||
}),
|
||||
BRAVO((type, partition) -> BRAVO_GIFT_BOOM_RATE_EN);
|
||||
|
||||
private final BiFunction<Integer, Integer, BigDecimal> strategy;
|
||||
|
||||
BoomRateStrategy(BiFunction<Integer, Integer, BigDecimal> strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
public static BigDecimal apply(int giftType, int partitionId) {
|
||||
if (Constant.GiftType.LUCKY_24 == giftType || Constant.GiftType.SUPER_LUCKY == giftType) {
|
||||
return LUCKY.strategy.apply(giftType, partitionId);
|
||||
} else if (Constant.GiftType.BRAVO_GIFT == giftType) {
|
||||
return BRAVO.strategy.apply(giftType, partitionId);
|
||||
} else {
|
||||
return DEFAULT.strategy.apply(giftType, partitionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -88,10 +89,6 @@ public class RoomBoomBizService {
|
||||
// 房间
|
||||
private final static Integer EXPIRE_DAY = 2;
|
||||
|
||||
public static final BigDecimal NORMAL_GIFT_BOOM_RATE = BigDecimal.valueOf(1.0D);
|
||||
public static final BigDecimal SUPER_GIFT_BOOM_RATE_AR = BigDecimal.valueOf(0.05D);
|
||||
public static final BigDecimal SUPER_GIFT_BOOM_RATE_EN = BigDecimal.valueOf(0.02D);
|
||||
|
||||
/**
|
||||
* 普通礼物跟幸运礼物的钻石流水逻辑不一样,
|
||||
* 英语2区boom计算用钻石流水的特殊性特殊处理
|
||||
@@ -156,26 +153,12 @@ public class RoomBoomBizService {
|
||||
boomData.goldNum = giftMessage.getRealGoldNum();
|
||||
}
|
||||
|
||||
BigDecimal boomRate = boomRateStat(giftMessage.getPartitionId(), giftMessage.getGiftType());
|
||||
BigDecimal boomRate = RoomBoomConstant.BoomRateStrategy.apply(giftMessage.getGiftType(), giftMessage.getPartitionId());
|
||||
boomData.addBoomValue = BigDecimal.valueOf(boomData.goldNum).multiply(boomRate).doubleValue();
|
||||
|
||||
return Optional.of(boomData);
|
||||
}
|
||||
|
||||
private BigDecimal boomRateStat(Integer partitionId, Byte giftType) {
|
||||
BigDecimal boomRate = NORMAL_GIFT_BOOM_RATE;
|
||||
if (Constant.GiftType.LUCKY_24 == giftType
|
||||
|| Constant.GiftType.SUPER_LUCKY == giftType
|
||||
|| Constant.GiftType.BRAVO_GIFT == giftType) {
|
||||
if (PartitionEnum.ARAB.getId() == partitionId) {
|
||||
boomRate = SUPER_GIFT_BOOM_RATE_AR;
|
||||
} else if (PartitionEnum.ENGLISH.getId() == partitionId || PartitionEnum.CHINESE.getId() == partitionId) {
|
||||
boomRate = SUPER_GIFT_BOOM_RATE_EN;
|
||||
}
|
||||
}
|
||||
return boomRate;
|
||||
}
|
||||
|
||||
private void addRoomHotList(Long roomUid, RoomBoomLevelInfoVo roomBoomSpeedAndLevel, String cycleDate) {
|
||||
RMap<Long, RoomBoomLevelInfoVo> roomHotMap = getRoomHotMap(cycleDate);
|
||||
roomHotMap.put(roomUid, roomBoomSpeedAndLevel);
|
||||
|
Reference in New Issue
Block a user