cp 游戏王奖励定时任务关闭
This commit is contained in:
parent
c77d68bc0f
commit
732221be59
@ -62,8 +62,8 @@ public class DailyTask {
|
||||
* 游戏王日榜金币发放 - 沙特时间每日0点执行.
|
||||
* 取昨日日榜前三名,分别发放 5000/3000/1000 金币。
|
||||
*/
|
||||
@Scheduled(cron = "10 0 0 1/1 * ?", zone = "Asia/Riyadh")
|
||||
@TaskCacheLock(key = "DAILY_PROCESS_TASK", expireSecond = 10000)
|
||||
// @Scheduled(cron = "10 0 0 1/1 * ?", zone = "Asia/Riyadh")
|
||||
// @TaskCacheLock(key = "DAILY_PROCESS_TASK", expireSecond = 10000)
|
||||
public void dailyTask() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("exec king_games_daily_reward start");
|
||||
|
||||
@ -1,102 +0,0 @@
|
||||
package com.red.circle.other.app.scheduler;
|
||||
|
||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
||||
import com.red.circle.common.business.enums.SendPropsOrigin;
|
||||
import com.red.circle.component.redis.annotation.TaskCacheLock;
|
||||
import com.red.circle.other.domain.gateway.props.ActivitySourceGroupGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||
import com.red.circle.other.domain.model.user.ability.RegionConfig;
|
||||
import com.red.circle.other.infra.common.activity.PropsActivitySendCommon;
|
||||
import com.red.circle.other.infra.common.activity.send.SendRewardGroup;
|
||||
import com.red.circle.other.infra.database.cache.service.user.CacheEnumConfigManagerService;
|
||||
import com.red.circle.other.infra.database.mongo.entity.game.ktv.GameKtvUserWeekRankCount;
|
||||
import com.red.circle.other.infra.database.mongo.service.game.GameKtvUserWeekRankCountService;
|
||||
import com.red.circle.other.infra.database.rds.enums.OtherConfigEnum;
|
||||
import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* KTV调器度 - 每周K歌人气榜.
|
||||
*
|
||||
* @author pengshigang on 2023/5/8.
|
||||
*/
|
||||
@Slf4j
|
||||
//@Component
|
||||
@AllArgsConstructor
|
||||
public class GameKtvTask {
|
||||
|
||||
private final PropsActivitySendCommon sendPropsManager;
|
||||
private final UserRegionGateway readUserRegionManager;
|
||||
private final CacheEnumConfigManagerService cacheEnumConfigManagerService;
|
||||
private final ActivitySourceGroupGateway activitySourceGroupRepository;
|
||||
private final GameKtvUserWeekRankCountService gameKtvUserWeekRankCountService;
|
||||
|
||||
/**
|
||||
* 支持系统:tarab. 每周一0点执行.
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 ? * MON", zone = "Asia/Riyadh")
|
||||
@TaskCacheLock(key = "GAME_KTV_WEEK_RANK_TASK", expireSecond = 7200)
|
||||
public void gameKtvWeekRankTask(){
|
||||
gameKtvTarabWeekRankTask();
|
||||
}
|
||||
|
||||
public void gameKtvTarabWeekRankTask(){
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("exec game_ktv_week_rank_task start_2fun");
|
||||
List<RegionConfig> regions = readUserRegionManager
|
||||
.listRegionConfigBySysOrigin(SysOriginPlatformEnum.TARAB.name());
|
||||
if (CollectionUtils.isEmpty(regions)) {
|
||||
log.warn("每周K歌人气榜定时器:tarab系统不存在区域");
|
||||
return;
|
||||
}
|
||||
|
||||
regions.forEach(region -> {
|
||||
|
||||
log.warn("每周K歌人气榜定时器:tarab区域{}", region.getRegionCode());
|
||||
|
||||
List<GameKtvUserWeekRankCount> top10List = gameKtvUserWeekRankCountService
|
||||
.lastWeekTop10(SysOriginPlatformEnum.TARAB.name(), region.getId());
|
||||
if (CollectionUtils.isEmpty(top10List)) {
|
||||
|
||||
log.warn("每周K歌人气榜定时器:tarab区域{}不存在TOP10榜单用户", region.getRegionCode());
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> groupIds = activitySourceGroupRepository
|
||||
.listActivityResourceGroupIds(SysOriginPlatformEnum.TARAB,
|
||||
PropsActivityTypeEnum.GAME_KTV_WEEK_RANK_REWARD);
|
||||
if (CollectionUtils.isEmpty(groupIds) || groupIds.size() != 4) {
|
||||
log.warn("tarab每周K歌人气榜定时器:没有奖品信息或资源配置错误");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cacheEnumConfigManagerService.getValBool(OtherConfigEnum.SUSPEND_CONSUMPTION,
|
||||
SysOriginPlatformEnum.TARAB.name())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int index = 0; index < top10List.size(); index++) {
|
||||
|
||||
sendPropsManager.sendActivityGroup(SendRewardGroup.builder()
|
||||
.resourceGroupId(index >= 3 ? groupIds.get(3) : groupIds.get(index))
|
||||
.trackId(IdWorkerUtils.getId())
|
||||
.acceptUserId(top10List.get(index).getUserId())
|
||||
.origin(SendPropsOrigin.GAME_KTV_WEEK_RANK_REWARD)
|
||||
.sysOrigin(SysOriginPlatformEnum.TARAB)
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
log.info("exec game_ktv_week_rank_task end with_2fun {}",System.currentTimeMillis()-startTime);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,213 +0,0 @@
|
||||
package com.red.circle.other.app.scheduler;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.red.circle.common.business.core.enums.GameStateEnum;
|
||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
||||
import com.red.circle.component.redis.annotation.TaskCacheLock;
|
||||
import com.red.circle.mq.business.model.event.game.GameIndoorTeamPkEvent;
|
||||
import com.red.circle.mq.business.model.event.game.GameRoomPkEvent;
|
||||
import com.red.circle.other.app.manager.activity.refresh.ActivityPkManager;
|
||||
import com.red.circle.other.app.manager.game.GameIndoorTeamPkManager;
|
||||
import com.red.circle.other.app.manager.game.GameRoomPkManager;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.GameIndoorTeamPkRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkWinnerRecord;
|
||||
import com.red.circle.other.infra.database.rds.service.game.GameIndoorTeamPkRecordService;
|
||||
import com.red.circle.other.infra.database.rds.service.game.GameRoomPkRecordService;
|
||||
import com.red.circle.other.infra.database.rds.service.game.GameRoomPkWinnerRecordService;
|
||||
import com.red.circle.other.inner.enums.game.GamePkTypeEnum;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.LocalDateTimeUtils;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 游戏-房间Pk.
|
||||
*
|
||||
* @author pengshigang on 2021/9/27
|
||||
*/
|
||||
@Slf4j
|
||||
//@Component
|
||||
@AllArgsConstructor
|
||||
public class GameRoomPkTask {
|
||||
|
||||
private final ActivityPkManager activityPkManager;
|
||||
private final GameRoomPkManager gameRoomPkManager;
|
||||
private final GameIndoorTeamPkManager gameIndoorTeamPkManager;
|
||||
private final GameRoomPkRecordService gameRoomPkRecordService;
|
||||
private final GameRoomPkWinnerRecordService gameRoomPkWinnerRecordService;
|
||||
private final GameIndoorTeamPkRecordService gameIndoorTeamPkRecordService;
|
||||
|
||||
/**
|
||||
* 每10分钟检查一次是否有超时未关闭的pk记录,有则将其主动结束掉
|
||||
*/
|
||||
@Scheduled(cron = "0 0/10 * * * ?")
|
||||
@TaskCacheLock(key = "PK_RECORD_TIME_OUT_CLOSE_TASK", expireSecond = 540)
|
||||
// @XxlJob("pk_record_time_out_close_task")
|
||||
public void pkRecordTimeOutCloseTask() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("exec pk_record_time_out_close_task start");
|
||||
//Pk游戏 - 处理结束消息发送与数据处理
|
||||
listExpiredPkRecords().forEach(
|
||||
item -> gameRoomPkManager.processRoomPk(new GameRoomPkEvent().setGameId(item.getId())
|
||||
.setState(GameStateEnum.valueOf(item.getGameStatus())))
|
||||
);
|
||||
|
||||
//房间内团队PK游戏 - 处理结束消息发送与数据处理
|
||||
listExpiredIndoorTeamPkRecords().forEach(item -> gameIndoorTeamPkManager
|
||||
.processRoomPk(new GameIndoorTeamPkEvent().setGameId(item.getId())
|
||||
.setState(GameStateEnum.valueOf(item.getGameStatus())))
|
||||
);
|
||||
log.info("exec pk_record_time_out_close_task end with {}",System.currentTimeMillis()-startTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每天0点执行,给昨天的top用户加额外积分.
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 1/1 * ?", zone = "Asia/Riyadh")
|
||||
@TaskCacheLock(key = "GAME_ROOM_PK_TASK_DAY", expireSecond = 1800)
|
||||
public void gameRoomPkTaskDay() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("exec game_room_pk_task_day start");
|
||||
log.warn("[execute] ResetUserWeekConsumeManager.everyDay start:{}",
|
||||
LocalDateTimeUtils.nowFormat("yyyy-MM-dd"));
|
||||
|
||||
//给昨天的top3奖励额外积分
|
||||
addedDailyTop3Bonus();
|
||||
//刷新上周PK数据(暂时这么处理)
|
||||
activityPkManager.weekly();
|
||||
|
||||
log.warn("[execute] ResetUserWeekConsumeManager.everyDay end:{}",
|
||||
LocalDateTimeUtils.nowFormat("yyyy-MM-dd"));
|
||||
log.info("exec game_room_pk_task_day end with {}",System.currentTimeMillis()-startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给昨天的top3奖励额外积分
|
||||
*/
|
||||
private void addedDailyTop3Bonus() {
|
||||
|
||||
List<GameRoomPkWinnerRecord> saveAll = Lists.newArrayList();
|
||||
|
||||
SysOriginPlatformEnum.getVoiceSystems().forEach(origin -> {
|
||||
|
||||
List<GameRoomPkWinnerRecord> tops = listDayWinnerTop(origin);
|
||||
|
||||
for (int i = 0; i < tops.size(); i++) {
|
||||
|
||||
GameRoomPkWinnerRecord save =new GameRoomPkWinnerRecord()
|
||||
.setId(IdWorkerUtils.getId())
|
||||
.setSysOrigin(origin.name())
|
||||
.setTotalIntegral(getTotalIntegral(tops.get(i).getTotalIntegral(), i))
|
||||
.setUserId(tops.get(i).getUserId())
|
||||
.setIntegral(0L)
|
||||
.setPkType(GamePkTypeEnum.ONE_VS_ONE.name())
|
||||
.setType(Boolean.TRUE);
|
||||
save.setCreateTime(TimestampUtils.nowMinusMinutes(10));
|
||||
save.setCreateUser(tops.get(i).getUserId());
|
||||
save.setUpdateTime(TimestampUtils.now());
|
||||
save.setUpdateUser(tops.get(i).getUserId());
|
||||
saveAll.add(save);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (CollectionUtils.isNotEmpty(saveAll) && saveAll.size() > 0) {
|
||||
gameRoomPkWinnerRecordService.saveBatch(saveAll);
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameRoomPkWinnerRecord> listDayWinnerTop(SysOriginPlatformEnum origin) {
|
||||
|
||||
return Optional.ofNullable(gameRoomPkWinnerRecordService.dayTop(origin, Boolean.TRUE))
|
||||
.orElse(Lists.newArrayList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据总积分与排行榜名次计算额外奖励积分
|
||||
*/
|
||||
private long getTotalIntegral(Long totalIntegral, int topIndex) {
|
||||
|
||||
if (Objects.isNull(totalIntegral) || totalIntegral.intValue() <= 0) {
|
||||
return 0L;
|
||||
}
|
||||
if (topIndex == 0) {
|
||||
return Double.valueOf(totalIntegral * 0.03).longValue();
|
||||
}
|
||||
if (topIndex == 1) {
|
||||
return Double.valueOf(totalIntegral * 0.02).longValue();
|
||||
}
|
||||
if (topIndex == 2) {
|
||||
return Double.valueOf(totalIntegral * 0.01).longValue();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得超时未结束记录 - PK
|
||||
*/
|
||||
private List<GameRoomPkRecord> listExpiredPkRecords() {
|
||||
|
||||
List<GameRoomPkRecord> startList = getListExpiredStartedRecordByNow();
|
||||
List<GameRoomPkRecord> waitingList = getListExpiredWaitingRecordByNow();
|
||||
List<GameRoomPkRecord> items = Lists.newArrayList();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(startList)) {
|
||||
items.addAll(startList);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(waitingList)) {
|
||||
items.addAll(waitingList);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得超时未结束记录 - 房间内团队PK
|
||||
*/
|
||||
private List<GameIndoorTeamPkRecord> listExpiredIndoorTeamPkRecords() {
|
||||
|
||||
List<GameIndoorTeamPkRecord> startList = getListExpiredStartedIndoorTeamPkRecordByNow();
|
||||
List<GameIndoorTeamPkRecord> waitingList = getListExpiredWaitingIndoorTeamPkRecordByNow();
|
||||
List<GameIndoorTeamPkRecord> items = Lists.newArrayList();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(startList)) {
|
||||
items.addAll(startList);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(waitingList)) {
|
||||
items.addAll(waitingList);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<GameIndoorTeamPkRecord> getListExpiredStartedIndoorTeamPkRecordByNow() {
|
||||
return gameIndoorTeamPkRecordService
|
||||
.listExpiredStartedRecordByNow(TimestampUtils.now());
|
||||
}
|
||||
|
||||
private List<GameIndoorTeamPkRecord> getListExpiredWaitingIndoorTeamPkRecordByNow() {
|
||||
return gameIndoorTeamPkRecordService
|
||||
.listExpiredWaitingRecordByNow(TimestampUtils.now());
|
||||
}
|
||||
|
||||
private List<GameRoomPkRecord> getListExpiredStartedRecordByNow() {
|
||||
return gameRoomPkRecordService
|
||||
.listExpiredStartedRecordByNow(TimestampUtils.now());
|
||||
}
|
||||
|
||||
private List<GameRoomPkRecord> getListExpiredWaitingRecordByNow() {
|
||||
return gameRoomPkRecordService
|
||||
.listExpiredWaitingRecordByNow(TimestampUtils.now());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,194 +0,0 @@
|
||||
package com.red.circle.other.app.scheduler;
|
||||
|
||||
|
||||
import com.red.circle.component.redis.service.RedisService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
//@Component
|
||||
@RequiredArgsConstructor
|
||||
public class HotGameTask {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final RedisService redisService;
|
||||
|
||||
/**
|
||||
* Redis key 常量定义
|
||||
*/
|
||||
private static final String REDIS_KEY_PREFIX = "HOTGAME:";
|
||||
private static final String REDIS_KEY_RATIO = REDIS_KEY_PREFIX + "RATIO";
|
||||
private static final String REDIS_KEY_VIP = REDIS_KEY_PREFIX + "VIP";
|
||||
|
||||
/**
|
||||
* 大盘数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void calculateHotGameRatio() {
|
||||
System.out.println("开始执行热游大盘返奖比计算任务...");
|
||||
// 获取当前月份
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String tableSuffix = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
||||
|
||||
String sql = """
|
||||
SELECT
|
||||
SUM(IF(event_type LIKE 'HOT_GAME%' AND type = 1, penny_amount, 0)) AS hot_game_water,
|
||||
SUM(IF(event_type LIKE 'HOT_GAME%' AND type = 0, penny_amount, 0)) AS hot_game_reward
|
||||
FROM lotfun_wallet.wallet_gold_asset_record_{table}
|
||||
""".replace("{table}", tableSuffix);
|
||||
|
||||
Map<String, Object> result = jdbcTemplate.queryForMap(sql);
|
||||
|
||||
String waterStr = String.valueOf(result.get("hot_game_water"));
|
||||
String rewardStr = String.valueOf(result.get("hot_game_reward"));
|
||||
|
||||
BigDecimal water = new BigDecimal(waterStr);
|
||||
BigDecimal reward = new BigDecimal(rewardStr);
|
||||
|
||||
BigDecimal ratio = BigDecimal.ZERO;
|
||||
if (water.compareTo(BigDecimal.ZERO) != 0) {
|
||||
ratio = reward.multiply(new BigDecimal("100"))
|
||||
.divide(water, 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
redisService.redisTemplate().opsForValue().set(REDIS_KEY_RATIO, ratio.intValue());
|
||||
//结束输出日志
|
||||
System.out.println("Hot Game Ratio: " + ratio);
|
||||
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void calculateHotGameVIP() {
|
||||
System.out.println("开始执行热游VIP计算任务...");
|
||||
// 获取当前月份
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String tableSuffix = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
||||
|
||||
long sevenDaysAgo = System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000;
|
||||
|
||||
String sql = """
|
||||
SELECT user_id,
|
||||
SUM(IF(type = 1, penny_amount, 0)) as total_water
|
||||
FROM lotfun_wallet.wallet_gold_asset_record_{table}
|
||||
WHERE event_type LIKE 'HOT_GAME%'
|
||||
AND create_time >= ?
|
||||
GROUP BY user_id
|
||||
ORDER BY total_water DESC
|
||||
""".replace("{table}", tableSuffix);
|
||||
|
||||
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, sevenDaysAgo);
|
||||
|
||||
int totalUsers = results.size();
|
||||
int vip1Start = (int) (totalUsers * 0.02);
|
||||
int vip1End = (int) (totalUsers * 0.03);
|
||||
int vip2Start = (int) (totalUsers * 0.01);
|
||||
int vip2End = (int) (totalUsers * 0.02);
|
||||
int vip3End = (int) (totalUsers * 0.01);
|
||||
|
||||
Set<String> vip1Users = new HashSet<>();
|
||||
Set<String> vip2Users = new HashSet<>();
|
||||
Set<String> vip3Users = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
String userId = String.valueOf(results.get(i).get("user_id"));
|
||||
|
||||
if (i < vip3End) {
|
||||
vip3Users.add(userId);
|
||||
} else if (i >= vip2Start && i < vip2End) {
|
||||
vip2Users.add(userId);
|
||||
} else if (i >= vip1Start && i < vip1End) {
|
||||
vip1Users.add(userId);
|
||||
}
|
||||
}
|
||||
|
||||
// 充值VIP
|
||||
String rechargeSql = """
|
||||
SELECT
|
||||
user_id,
|
||||
SUM(penny_amount) as total_recharge,
|
||||
MAX(create_time) as last_recharge_time
|
||||
FROM lotfun_wallet.wallet_gold_asset_record_{table}
|
||||
WHERE (event_type = 'BUY_GOLD' OR event_type = 'SHIPPING_AGENT')
|
||||
AND create_time >= ?
|
||||
GROUP BY user_id
|
||||
HAVING total_recharge >= 1500000
|
||||
""".replace("{table}", tableSuffix);
|
||||
|
||||
List<Map<String, Object>> rechargeResults = jdbcTemplate.queryForList(rechargeSql, sevenDaysAgo);
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long twoDaysAgo = currentTime - 2 * 24 * 60 * 60 * 1000;
|
||||
long fourDaysAgo = currentTime - 4 * 24 * 60 * 60 * 1000;
|
||||
|
||||
for (Map<String, Object> result : rechargeResults) {
|
||||
String userId = String.valueOf(result.get("user_id"));
|
||||
long lastRechargeTime = Long.parseLong(String.valueOf(result.get("last_recharge_time")));
|
||||
|
||||
if (lastRechargeTime >= twoDaysAgo) {
|
||||
vip3Users.add(userId);
|
||||
} else if (lastRechargeTime >= fourDaysAgo) {
|
||||
vip2Users.add(userId);
|
||||
} else {
|
||||
vip1Users.add(userId);
|
||||
}
|
||||
}
|
||||
|
||||
redisService.redisTemplate().opsForHash().put(REDIS_KEY_VIP, "VIP1", vip1Users);
|
||||
redisService.redisTemplate().opsForHash().put(REDIS_KEY_VIP, "VIP2", vip2Users);
|
||||
redisService.redisTemplate().opsForHash().put(REDIS_KEY_VIP, "VIP3", vip3Users);
|
||||
// 添加日志打印
|
||||
System.out.println("VIP1用户数量: " + vip1Users.size() + ", 用户列表: " + vip1Users);
|
||||
System.out.println("VIP2用户数量: " + vip2Users.size() + ", 用户列表: " + vip2Users);
|
||||
System.out.println("VIP3用户数量: " + vip3Users.size() + ", 用户列表: " + vip3Users);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void calculateLossVIP() {
|
||||
System.out.println("开始执行热游亏损VIP计算任务...");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String tableSuffix = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
||||
long oneDayAgo = System.currentTimeMillis() - 24 * 60 * 60 * 1000;
|
||||
|
||||
String sql = """
|
||||
SELECT
|
||||
user_id,
|
||||
SUM(IF(event_type LIKE 'HOT_GAME%' AND type = 0, penny_amount, 0)) AS game_income,
|
||||
SUM(IF(event_type LIKE 'HOT_GAME%' AND type = 1, penny_amount, 0)) AS game_cost
|
||||
FROM lotfun_wallet.wallet_gold_asset_record_{table}
|
||||
WHERE create_time >= ?
|
||||
AND event_type LIKE 'HOT_GAME%'
|
||||
GROUP BY user_id
|
||||
HAVING (game_cost - game_income) >= 500000
|
||||
""".replace("{table}", tableSuffix);
|
||||
|
||||
List<Map<String, Object>> lossResults = jdbcTemplate.queryForList(sql, oneDayAgo);
|
||||
|
||||
// 获取现有的VIP2用户集合
|
||||
Object vip2Obj = redisService.redisTemplate().opsForHash().get(REDIS_KEY_VIP, "VIP2");
|
||||
Set<String> existingVip2Users = null;
|
||||
if (vip2Obj instanceof Set<?>) {
|
||||
// 确认对象是Set类型后进行强制类型转换
|
||||
existingVip2Users = (Set<String>) vip2Obj;
|
||||
}
|
||||
|
||||
// 如果 existingVip2Users 为 null,创建一个新的 HashSet
|
||||
Set<String> vip2Users = existingVip2Users != null ? new HashSet<>(existingVip2Users) : new HashSet<>();
|
||||
|
||||
// 添加亏损用户
|
||||
for (Map<String, Object> result : lossResults) {
|
||||
vip2Users.add(String.valueOf(result.get("user_id")));
|
||||
}
|
||||
|
||||
// 更新Redis
|
||||
redisService.redisTemplate().opsForHash().put(REDIS_KEY_VIP, "VIP2", vip2Users);
|
||||
|
||||
// 打印日志
|
||||
System.out.println("更新后的VIP2用户数量: " + vip2Users.size() + ", 用户列表: " + vip2Users);
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.red.circle.other.app.scheduler;
|
||||
|
||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
||||
import com.red.circle.component.redis.annotation.TaskCacheLock;
|
||||
import com.red.circle.other.app.manager.activity.award.WeeklyRewardsSentManager;
|
||||
import com.red.circle.other.infra.database.cache.service.user.CacheEnumConfigManagerService;
|
||||
import com.red.circle.other.infra.database.rds.enums.OtherConfigEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 每月固定活动榜单奖励发送.
|
||||
*
|
||||
* @author pengshigang on 2021/10/27
|
||||
*/
|
||||
@Slf4j
|
||||
//@Component
|
||||
@AllArgsConstructor
|
||||
public class MonthFixedActivityTask {
|
||||
|
||||
private final WeeklyRewardsSentManager weeklyRewardsSentManager;
|
||||
private final CacheEnumConfigManagerService cacheEnumConfigManagerService;
|
||||
|
||||
/**
|
||||
* 每月一号 0点5分执行.
|
||||
*/
|
||||
@Scheduled(cron = "5 0 0 1 * ?", zone = "Asia/Riyadh")
|
||||
@TaskCacheLock(key = "MONTH_ACTIVITY_TASK", expireSecond = 86400)
|
||||
// @XxlJob("month_activity_task")
|
||||
public void startMonthActivityTask() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("exec month_activity_task start");
|
||||
if (cacheEnumConfigManagerService.getValBool(OtherConfigEnum.SUSPEND_CONSUMPTION,
|
||||
SysOriginPlatformEnum.ASWAT.name())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 代理活动 - 月
|
||||
weeklyRewardsSentManager.processSendRewardAgentActivity(SysOriginPlatformEnum.ASWAT, "MONTH",
|
||||
null);
|
||||
log.info("exec month_activity_task end with {}",System.currentTimeMillis()-startTime);
|
||||
}
|
||||
|
||||
}
|
||||
@ -43,8 +43,8 @@ public class GameKingRewardTask {
|
||||
/**
|
||||
* 每5分钟执行一次,兜底发送游戏王排名奖励.
|
||||
*/
|
||||
@Scheduled(cron = "0 */5 * * * ?")
|
||||
@TaskCacheLock(key = "GAME_KING_REWARDTASK", expireSecond = 240)
|
||||
// @Scheduled(cron = "0 */5 * * * ?")
|
||||
// @TaskCacheLock(key = "GAME_KING_REWARDTASK", expireSecond = 240)
|
||||
public void executeGameKingReward() {
|
||||
try {
|
||||
log.info("开始执行游戏王排名奖励兜底任务");
|
||||
|
||||
@ -42,8 +42,8 @@ public class RamadanRankingBadgeTask {
|
||||
/**
|
||||
* 每分钟发放和收回排名徽章
|
||||
*/
|
||||
@Scheduled(cron = "0 0/1 * * * *", zone = "Asia/Riyadh")
|
||||
@TaskCacheLock(key = "RAMADAN_RANKING_BADGE_TASK", expireSecond = 20)
|
||||
// @Scheduled(cron = "0 0/1 * * * *", zone = "Asia/Riyadh")
|
||||
// @TaskCacheLock(key = "RAMADAN_RANKING_BADGE_TASK", expireSecond = 20)
|
||||
public void sendWeekRankingReward() {
|
||||
try {
|
||||
// 获取前十名
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(name = "scheduler.cp-ranking-badge", havingValue = "true", matchIfMissing = true)
|
||||
public class CpRankingBadgeTask {
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* CP排行榜奖励发放定时任务.
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CpRankingRewardTask {
|
||||
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
package com.red.circle;
|
||||
|
||||
import com.red.circle.component.redis.RedisAutoConfiguration;
|
||||
import com.red.circle.other.app.scheduler.HotGameTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
/**
|
||||
* Spring Boot Starter.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user