新增活动礼物类型, 房间火箭统计处理
This commit is contained in:
parent
25cb51e8df
commit
258f6af4d2
@ -32,6 +32,11 @@ public enum GiftTabEnum {
|
|||||||
*/
|
*/
|
||||||
EXCLUSIVE,
|
EXCLUSIVE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动礼物.
|
||||||
|
*/
|
||||||
|
ACTIVITY,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 贵族.
|
* 贵族.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -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.common.gift.GameLuckyGiftCommon;
|
||||||
import com.red.circle.other.app.dto.cmd.RocketEnergyAddCmd;
|
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.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.GiftGiveRunningWater;
|
||||||
import com.red.circle.other.infra.database.mongo.entity.gift.GiftValue;
|
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.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.GiftCurrencyType;
|
||||||
import com.red.circle.other.inner.enums.material.GiftTabEnum;
|
import com.red.circle.other.inner.enums.material.GiftTabEnum;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -33,7 +28,7 @@ import java.util.Objects;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("ROCKET_COUNT_LISTENER")
|
@Service("ROCKET_COUNT_LISTENER")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GiftSendRocketListener implements GiftStrategy {
|
public class GiftRocketListener implements GiftStrategy {
|
||||||
|
|
||||||
private final RocketEnergyAddCmdExe rocketEnergyAddCmdExe;
|
private final RocketEnergyAddCmdExe rocketEnergyAddCmdExe;
|
||||||
private final GiftGiveRunningWaterService giftGiveRunningWaterService;
|
private final GiftGiveRunningWaterService giftGiveRunningWaterService;
|
||||||
@ -82,15 +77,11 @@ public class GiftSendRocketListener implements GiftStrategy {
|
|||||||
// 4. 判断是否为幸运礼物
|
// 4. 判断是否为幸运礼物
|
||||||
boolean isLuckyGift = isLuckyGift(giftValue);
|
boolean isLuckyGift = isLuckyGift(giftValue);
|
||||||
|
|
||||||
// 5. 获取幸运礼物比例
|
// 5. 获取礼物比例
|
||||||
BigDecimal luckyGiftRatio = BigDecimal.ZERO;
|
BigDecimal luckyGiftRatio = calcGiftRatio(runningWater);
|
||||||
if (isLuckyGift) {
|
|
||||||
luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftShareRatio(runningWater.getSysOrigin());
|
|
||||||
log.info("【火箭能量增加】幸运礼物比例:{}", luckyGiftRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. 计算实际金币价值(考虑幸运礼物加成)
|
// 6. 计算实际金币价值(考虑幸运礼物加成)
|
||||||
Long actualGoldValue = getActualAmount(isLuckyGift, giftValue.getActualAmount(), luckyGiftRatio);
|
Long actualGoldValue = getActualAmount(giftValue.getActualAmount(), luckyGiftRatio);
|
||||||
|
|
||||||
Long roomId = Long.parseLong(originId);
|
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) {
|
private boolean isActivityGift(GiftValue giftValue) {
|
||||||
if (isLuckyGift && luckyGiftRatio != null && luckyGiftRatio.compareTo(BigDecimal.ZERO) > 0) {
|
return giftValue.getGiftType() != null &&
|
||||||
// 幸运礼物按比例计算
|
giftValue.getGiftType().contains(GiftTabEnum.ACTIVITY.name());
|
||||||
return amount.multiply(luckyGiftRatio)
|
}
|
||||||
.setScale(0, RoundingMode.DOWN)
|
|
||||||
.longValue();
|
/**
|
||||||
}
|
* 判断是否为CP礼物
|
||||||
return amount.longValue();
|
*/
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user