游戏活动逻辑重写
(cherry picked from commit fd8d0dec8752893ee01ecd333119136e21ea0b65)
This commit is contained in:
parent
898bc5aed4
commit
d1a7543816
@ -8,10 +8,16 @@ import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
|
|||||||
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
|
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
|
||||||
import com.red.circle.other.app.service.activity.RankingActivityService;
|
import com.red.circle.other.app.service.activity.RankingActivityService;
|
||||||
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
||||||
|
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||||
import com.red.circle.other.domain.ranking.RankingActivityType;
|
import com.red.circle.other.domain.ranking.RankingActivityType;
|
||||||
import com.red.circle.other.domain.ranking.RankingCycleType;
|
import com.red.circle.other.domain.ranking.RankingCycleType;
|
||||||
import com.red.circle.other.domain.ranking.RankingDimension;
|
import com.red.circle.other.domain.ranking.RankingDimension;
|
||||||
|
import com.red.circle.other.infra.config.GameRankingActivityConfig;
|
||||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||||
|
import com.red.circle.tool.core.date.ZonedId;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
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;
|
||||||
@ -32,6 +38,8 @@ public class GameActivityService {
|
|||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
private final SpinsUserTaskProgressService spinsUserTaskProgressService;
|
private final SpinsUserTaskProgressService spinsUserTaskProgressService;
|
||||||
private final RankingActivityService rankingActivityService;
|
private final RankingActivityService rankingActivityService;
|
||||||
|
private final UserRegionGateway userRegionGateway;
|
||||||
|
private final GameRankingActivityConfig gameRankingActivityConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理游戏消费/获得任务
|
* 处理游戏消费/获得任务
|
||||||
@ -86,6 +94,43 @@ public class GameActivityService {
|
|||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
rankingActivityService.accumulateRankingData(receiverCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void incConfiguredRankingActivity(Long userId, Long rewardAmount, String gameId, RankingActivityType activityType) {
|
||||||
|
try {
|
||||||
|
GameRankingActivityConfig.ActivityItem item = gameRankingActivityConfig.getItems().stream()
|
||||||
|
.filter(i -> activityType.equals(i.resolveActivityType()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (item == null || item.getGameId() == null || item.getFinishTime() == null || item.getCycleKey() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!item.getGameId().equals(gameId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ZonedDateTime finish = ZonedDateTime.of(
|
||||||
|
LocalDateTime.parse(item.getFinishTime()),
|
||||||
|
ZonedId.ASIA_RIYADH.getZonedId()
|
||||||
|
);
|
||||||
|
if (ZonedDateTimeAsiaRiyadhUtils.now().isAfter(finish)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String regionId = userRegionGateway.getRegionId(userId);
|
||||||
|
RankingDataUpdateCmd cmd = new RankingDataUpdateCmd();
|
||||||
|
cmd.setUserId(userId);
|
||||||
|
cmd.setUserSex(1);
|
||||||
|
cmd.setActivityType(activityType.getCode());
|
||||||
|
cmd.setCycleType(RankingCycleType.WEEKLY.getCode());
|
||||||
|
cmd.setCycleKey(item.getCycleKey());
|
||||||
|
cmd.setDimension(RankingDimension.GAME_WIN.getCode());
|
||||||
|
cmd.setIncrementQuantity(rewardAmount);
|
||||||
|
cmd.setBizNo(gameId);
|
||||||
|
cmd.setRegionId(regionId);
|
||||||
|
cmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
|
||||||
|
rankingActivityService.accumulateRankingData(cmd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("incConfiguredRankingActivity error: userId={}, activityType={}", userId, activityType, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新游戏进度
|
* 更新游戏进度
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
|||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.enums.violation.GameOriginEnum;
|
import com.red.circle.other.app.enums.violation.GameOriginEnum;
|
||||||
import com.red.circle.other.app.service.game.common.GameEventService;
|
import com.red.circle.other.app.service.game.common.GameEventService;
|
||||||
|
import com.red.circle.other.domain.ranking.RankingActivityType;
|
||||||
import com.red.circle.other.app.service.task.TaskService;
|
import com.red.circle.other.app.service.task.TaskService;
|
||||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||||
@ -181,15 +182,16 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache(
|
GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache(
|
||||||
request.getGameId(),
|
request.getGameId(),
|
||||||
GameOriginEnum.BAISHUN.name(),
|
GameOriginEnum.BAISHUN.name(),
|
||||||
sysOrigin,
|
sysOrigin,
|
||||||
() -> gameListConfigService.getByGameId(request.getGameId(), GameOriginEnum.BAISHUN.name(), sysOrigin)
|
() -> gameListConfigService.getByGameId(request.getGameId(), GameOriginEnum.BAISHUN.name(), sysOrigin)
|
||||||
);
|
);
|
||||||
|
|
||||||
// request.getCurrencyDiff() > 0 是收入 request.getCurrencyDiff() < 0 是支出
|
// request.getCurrencyDiff() > 0 是收入 request.getCurrencyDiff() < 0 是支出
|
||||||
if (Objects.nonNull(gameListConfig)) {
|
if (Objects.nonNull(gameListConfig)) {
|
||||||
if (request.getCurrencyDiff() > 0) {
|
if (request.getCurrencyDiff() > 0) {
|
||||||
|
gameActivityService.incConfiguredRankingActivity(userId, request.getCurrencyDiff(), request.getGameId(), RankingActivityType.FOOT_BALL);
|
||||||
gameEventService.onWinEvent(userId, request.getCurrencyDiff(), GameOriginEnum.BAISHUN.name(), gameListConfig);
|
gameEventService.onWinEvent(userId, request.getCurrencyDiff(), GameOriginEnum.BAISHUN.name(), gameListConfig);
|
||||||
gameActivityService.handleGameSpendTask(userId, Math.abs(request.getCurrencyDiff()));
|
gameActivityService.handleGameSpendTask(userId, Math.abs(request.getCurrencyDiff()));
|
||||||
gameActivityService.incKingGameDaily(userId, request.getCurrencyDiff(), request.getGameId());
|
gameActivityService.incKingGameDaily(userId, request.getCurrencyDiff(), request.getGameId());
|
||||||
|
|||||||
@ -77,4 +77,9 @@ public class RankingDataUpdateCmd extends AppExtCommand {
|
|||||||
* 扩展数据(JSON 格式)
|
* 扩展数据(JSON 格式)
|
||||||
*/
|
*/
|
||||||
private String extData;
|
private String extData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域ID
|
||||||
|
*/
|
||||||
|
private String regionId;
|
||||||
}
|
}
|
||||||
@ -59,6 +59,14 @@ public enum RankingActivityType {
|
|||||||
KING_GAMES_DAILY(15, "游戏王日榜活动", "统计游戏数据排行"),
|
KING_GAMES_DAILY(15, "游戏王日榜活动", "统计游戏数据排行"),
|
||||||
|
|
||||||
OPEN_RAMADAN(16, "开斋节活动", "统计送礼物消费排行"),
|
OPEN_RAMADAN(16, "开斋节活动", "统计送礼物消费排行"),
|
||||||
|
|
||||||
|
POKER_ACE(17, "PokerAce游戏活动", "玩游戏获胜排行"),
|
||||||
|
|
||||||
|
MAGIC_GIFT_DAILY(18, "每日魔法礼物", "统计送魔法礼物排行"),
|
||||||
|
|
||||||
|
EID_AL_ADHA(19, "古尔邦节活动", "统计送魔法礼物排行"),
|
||||||
|
|
||||||
|
FOOT_BALL(20, "FootBall", "玩游戏获胜排行"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,43 @@
|
|||||||
|
package com.red.circle.other.infra.config;
|
||||||
|
|
||||||
|
import com.red.circle.other.domain.ranking.RankingActivityType;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 游戏排行榜活动配置
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "game.ranking-activity")
|
||||||
|
public class GameRankingActivityConfig {
|
||||||
|
|
||||||
|
private List<ActivityItem> items = Collections.emptyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个活动配置项
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class ActivityItem {
|
||||||
|
|
||||||
|
/** 活动类型,对应 RankingActivityType 枚举常量名 */
|
||||||
|
private String activityType;
|
||||||
|
|
||||||
|
/** 参与排行的游戏 ID */
|
||||||
|
private String gameId;
|
||||||
|
|
||||||
|
/** 活动结束时间,格式 yyyy-MM-dd'T'HH:mm:ss(Riyadh 时区) */
|
||||||
|
private String finishTime;
|
||||||
|
|
||||||
|
/** 周期 key,格式 yyyyMMdd */
|
||||||
|
private String cycleKey;
|
||||||
|
|
||||||
|
public RankingActivityType resolveActivityType() {
|
||||||
|
return RankingActivityType.getByConstantName(activityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user