游戏获奖新增打榜排名

This commit is contained in:
tianfeng 2025-11-28 17:33:39 +08:00
parent c6237e8db4
commit a1b3cf93f1
6 changed files with 63 additions and 4 deletions

View File

@ -49,7 +49,9 @@ public class RankingActivityRestController extends BaseController {
*/
@PostMapping("/list")
public RankingListCO getRankingList(@RequestBody @Validated RankingListQueryCmd cmd) {
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
if (cmd.getCycleType() == null) {
cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
}
return rankingActivityService.getRankingList(cmd);
}

View File

@ -45,7 +45,7 @@ public class RankingListQryExe {
public RankingListCO execute(RankingListQueryCmd cmd) {
// 获取枚举
RankingActivityType activityType = RankingActivityType.getByCode(cmd.getActivityType());
RankingCycleType cycleType = RankingCycleType.WEEKLY;
RankingCycleType cycleType = cmd.getCycleType() != null ? RankingCycleType.getByCode(cmd.getCycleType()) : RankingCycleType.WEEKLY;
// 查询排行榜列表
List<RankingActivityRecord> records = rankingActivityGateway.getRankingList(

View File

@ -18,13 +18,19 @@ import com.red.circle.external.inner.endpoint.message.ImGroupClient;
import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd;
import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.dto.ReqSysOrigin;
import com.red.circle.framework.core.exception.ResponseException;
import com.red.circle.framework.core.security.UserCredential;
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
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.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
@ -45,6 +51,7 @@ import java.util.Objects;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
@ -67,6 +74,9 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final EnumConfigCacheService enumConfigCacheService;
private final GameListConfigService gameListConfigService;
private final ImGroupClient imGroupClient;
private final RankingActivityService rankingActivityService;
@Value("${red-circle.game-rank.gameid}")
private String gameId;
@Override
public BaishunResponse<BaishunTokenResponse> getToken(BaishunTokenRequest request) {
@ -199,6 +209,13 @@ 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());
}
log.warn("{} 发送游戏获奖通知--金币数量{}", GoldOrigin.BAISHUN_GAME.name(), request.getCurrencyDiff());
return BaishunResponse.success(new BaishunChangeCurrencyResponse()
.setCurrencyBalance(receiptRes.getBalance().getDollarAmount().stripTrailingZeros()),
@ -217,7 +234,21 @@ public class GameBaishunServiceImpl implements GameBaishunService {
return BaishunResponse.fail(BaishunErrorCode.SERVER_ERROR);
}
private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) {
private void incGameRankingActivity(Long userId, Integer userSex, Long amount, String gameRoundId) {
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
receiverCmd.setUserId(userId);
receiverCmd.setUserSex(userSex);
receiverCmd.setActivityType(RankingActivityType.GREEDY_GAME.getCode());
receiverCmd.setCycleType(RankingCycleType.MONTHLY.getCode());
receiverCmd.setCycleKey("202511");
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
receiverCmd.setIncrementQuantity(amount);
receiverCmd.setBizNo(gameRoundId);
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
rankingActivityService.accumulateRankingData(receiverCmd);
}
private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) {
UserCredential userCredential = UserCredential.parseToken(param.getToken());
return createGoldReceiptCmdBuilder(param.getCurrencyDiff())
.userId(DataTypeUtils.toLong(param.getUserId()))

View File

@ -34,8 +34,9 @@ public enum RankingActivityType {
LIBANEN_DAY(5, "黎巴嫩独立日", "统计送礼物消费排行"),
YEMEN_DAY(6, "也门独立日", "统计送礼物消费排行")
YEMEN_DAY(6, "也门独立日", "统计送礼物消费排行"),
GREEDY_GAME(1068, "GreedyLion", "游戏中奖排行"),
;
/**

View File

@ -19,6 +19,8 @@ public enum RankingDimension {
*/
CONSUME_AMOUNT(1, "消费金额", "金币"),
GAME_WIN(2, "游戏中奖", "金币"),
;
/**
* 维度编码

View File

@ -7,13 +7,19 @@ import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd;
import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum;
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
import com.red.circle.framework.core.dto.ReqSysOrigin;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.user.user.AppUserDataViolationService;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.gateway.PropCouponGateway;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.InviteUserGateway;
import com.red.circle.other.domain.propcoupon.PropCoupon;
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.rds.entity.sys.GameListConfig;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
@ -53,6 +59,23 @@ public class SpringTest {
private PropCouponGateway propCouponGateway;
@Autowired
private AppUserDataViolationService userDataViolationService;
@Autowired
private RankingActivityService rankingActivityService;
@Test
public void testGame() {
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
receiverCmd.setUserId(1957345312961527809L);
receiverCmd.setUserSex(1);
receiverCmd.setActivityType(RankingActivityType.GREEDY_GAME.getCode());
receiverCmd.setCycleType(RankingCycleType.MONTHLY.getCode());
receiverCmd.setCycleKey("202511");
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
receiverCmd.setIncrementQuantity(111L);
receiverCmd.setBizNo("3243k1od");
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
rankingActivityService.accumulateRankingData(receiverCmd);
}
@Test
public void test() {