游戏打榜活动根据活动时间处理

This commit is contained in:
tianfeng 2025-11-28 19:08:36 +08:00
parent d6c214422f
commit 5124df5438
4 changed files with 38 additions and 2 deletions

View File

@ -32,6 +32,8 @@ import com.red.circle.other.domain.ranking.RankingActivityType;
import com.red.circle.other.domain.ranking.RankingCycleType;
import com.red.circle.other.domain.ranking.RankingDimension;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.mongo.entity.sys.ActivityConfig;
import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
@ -75,8 +77,11 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final GameListConfigService gameListConfigService;
private final ImGroupClient imGroupClient;
private final RankingActivityService rankingActivityService;
private final ActivityConfigService activityConfigService;
@Value("${red-circle.game-rank.gameid}")
private String gameId;
@Value("${red-circle.game-rank.templateId}")
private Long templateId;
@Override
public BaishunResponse<BaishunTokenResponse> getToken(BaishunTokenRequest request) {
@ -211,8 +216,11 @@ public class GameBaishunServiceImpl implements GameBaishunService {
//游戏是否参与打榜活动
if (gameId != null && gameId.equals(request.getGameId()) && request.getCurrencyDiff() > 0) {
incGameRankingActivity(DataTypeUtils.toLong(request.getUserId()), 1, request.getCurrencyDiff(),
request.getGameRoundId());
ActivityConfig config = activityConfigService.getOngoingActivityConf(templateId, RankingActivityType.GREEDY_GAME.name());
if (config != null) {
incGameRankingActivity(DataTypeUtils.toLong(request.getUserId()), 1, request.getCurrencyDiff(),
request.getGameRoundId());
}
}

View File

@ -71,6 +71,8 @@ public interface ActivityConfigService {
ActivityConfig getShowcaseActivityConf(Long templateId, String activityType);
ActivityConfig getOngoingActivityConf(Long templateId, String activityType);
List<ActivityConfig> listRecentlyEndedActivities(String sysOrigin, Integer limit);
/**

View File

@ -250,6 +250,20 @@ public class ActivityConfigServiceImpl implements ActivityConfigService {
, ActivityConfig.class);
}
public ActivityConfig getOngoingActivityConf(Long templateId, String activityType) {
Date now = TimestampUtils.now();
Criteria criteria = Criteria.where("showcase").is(true);
criteria.and("templateId").is(templateId);
criteria.and("activityType").is(activityType);
criteria.and("startTime").lte(now);
criteria.and("endTime").gte(now);
return mongoTemplate.findOne(Query.query(criteria)
.with(Sort.by(Sort.Order.desc("id")))
.limit(1)
, ActivityConfig.class);
}
@Override
public List<ActivityConfig> listRecentlyEndedActivities(String sysOrigin, Integer limit) {
Date now = TimestampUtils.now();

View File

@ -21,6 +21,8 @@ import com.red.circle.other.domain.ranking.RankingActivityType;
import com.red.circle.other.domain.ranking.RankingCycleType;
import com.red.circle.other.domain.ranking.RankingDimension;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.mongo.entity.sys.ActivityConfig;
import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
import com.red.circle.other.inner.model.cmd.user.ApprovalAccountCmd;
@ -61,6 +63,16 @@ public class SpringTest {
private AppUserDataViolationService userDataViolationService;
@Autowired
private RankingActivityService rankingActivityService;
@Autowired
private ActivityConfigService activityConfigService;
@Test
public void testQuery() {
ActivityConfig ongoingActivityConf = activityConfigService.getOngoingActivityConf(1994334094730010626L, RankingActivityType.GREEDY_GAME.name());
System.out.println();
}
@Test
public void testGame() {