baishun 和 灵仙游戏处理
This commit is contained in:
parent
ffbb9320dc
commit
c10b7dc378
@ -1,7 +1,6 @@
|
|||||||
package com.red.circle.other.adapter.app.game.party3rd;
|
package com.red.circle.other.adapter.app.game.party3rd;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
|
||||||
import com.red.circle.component.game.hkys.GameHkysService;
|
import com.red.circle.component.game.hkys.GameHkysService;
|
||||||
import com.red.circle.component.game.hkys.props.GameHkysProperties;
|
import com.red.circle.component.game.hkys.props.GameHkysProperties;
|
||||||
import com.red.circle.component.game.hkys.request.HkysUserCoinUpdate;
|
import com.red.circle.component.game.hkys.request.HkysUserCoinUpdate;
|
||||||
@ -11,47 +10,21 @@ import com.red.circle.component.game.hkys.response.HkysUserProfileResponse;
|
|||||||
import com.red.circle.component.game.hkys.response.HyksErrorEnum;
|
import com.red.circle.component.game.hkys.response.HyksErrorEnum;
|
||||||
import com.red.circle.component.game.hkys.response.UpdateUserCoinResponse;
|
import com.red.circle.component.game.hkys.response.UpdateUserCoinResponse;
|
||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
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.dto.ReqSysOrigin;
|
|
||||||
import com.red.circle.framework.core.security.UserCredential;
|
import com.red.circle.framework.core.security.UserCredential;
|
||||||
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
||||||
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.dto.cmd.game.GameLxwlUpdateBalanceCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
|
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
|
||||||
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.activity.ActivityRechargeTicketService;
|
|
||||||
import com.red.circle.other.app.service.activity.RankingActivityService;
|
|
||||||
import com.red.circle.other.app.service.game.GameActivityService;
|
import com.red.circle.other.app.service.game.GameActivityService;
|
||||||
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
|
import com.red.circle.other.app.service.game.common.GameEventService;
|
||||||
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
|
||||||
import com.red.circle.other.app.util.OfficialNoticeUtils;
|
|
||||||
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
|
|
||||||
import com.red.circle.other.domain.gateway.game.GameRankingGateway;
|
|
||||||
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.cache.service.other.GameListCacheService;
|
import com.red.circle.other.infra.database.cache.service.other.GameListCacheService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
|
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.infra.database.rds.service.sys.GameListConfigService;
|
||||||
import com.red.circle.other.inner.enums.config.EnumConfigKey;
|
|
||||||
import com.red.circle.other.inner.enums.task.RoomDailyTaskCode;
|
|
||||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
|
||||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
|
||||||
import com.red.circle.tool.core.parse.DataTypeUtils;
|
import com.red.circle.tool.core.parse.DataTypeUtils;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
import com.red.circle.tool.crypto.SecurityUtils;
|
import com.red.circle.tool.crypto.SecurityUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -75,19 +48,11 @@ public class GameHkysRestController {
|
|||||||
|
|
||||||
private final GameHkysService gameHkysService;
|
private final GameHkysService gameHkysService;
|
||||||
private final GameHkysProperties gameHkysProperties;
|
private final GameHkysProperties gameHkysProperties;
|
||||||
private final TaskMqMessage taskMqMessage;
|
|
||||||
private final EnumConfigCacheService enumConfigCacheService;
|
|
||||||
private final UserProfileGateway userProfileGateway;
|
|
||||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
|
||||||
private final GameListConfigService gameListConfigService;
|
private final GameListConfigService gameListConfigService;
|
||||||
private final ImGroupClient imGroupClient;
|
|
||||||
private final GameRankingGateway gameRankingGateway;
|
|
||||||
private final GameListCacheService gameListCacheService;
|
private final GameListCacheService gameListCacheService;
|
||||||
private final RankingActivityService rankingActivityService;
|
|
||||||
private final GameActivityService gameActivityService;
|
private final GameActivityService gameActivityService;
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final GameEventService gameEventService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
|
||||||
|
|
||||||
@IgnoreResultResponse
|
@IgnoreResultResponse
|
||||||
@PostMapping("/getUserInfo")
|
@PostMapping("/getUserInfo")
|
||||||
@ -148,53 +113,19 @@ public class GameHkysRestController {
|
|||||||
|
|
||||||
String sysOrigin = UserCredential.parseToken(cmd.getToken()).getSysOrigin();
|
String sysOrigin = UserCredential.parseToken(cmd.getToken()).getSysOrigin();
|
||||||
|
|
||||||
BigDecimal cost = enumConfigCacheService
|
|
||||||
.getValueBigDecimal(EnumConfigKey.GAME_BROADCAST_AMOUNT, sysOrigin) ;
|
|
||||||
if (cost == null || cost.compareTo(BigDecimal.ZERO) <= 0) {
|
|
||||||
cost = BigDecimal.valueOf(5000L);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache(
|
GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache(
|
||||||
cmd.getGameId(),
|
cmd.getGameId(),
|
||||||
GameOriginEnum.LINGXIAN.name(),
|
GameOriginEnum.LINGXIAN.name(),
|
||||||
sysOrigin,
|
sysOrigin,
|
||||||
() -> gameListConfigService.getByGameId(cmd.getGameId(), GameOriginEnum.LINGXIAN.name(), sysOrigin)
|
() -> gameListConfigService.getByGameId(cmd.getGameId(), GameOriginEnum.LINGXIAN.name(), sysOrigin)
|
||||||
);
|
);
|
||||||
if (cmd.getType() != null && cmd.getType() == 2 && cmd.getCoin() >= cost.longValue()) {
|
|
||||||
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
|
||||||
userProfileGateway.getByUserId(userId));
|
|
||||||
if (Objects.nonNull(gameListConfig)) {
|
|
||||||
Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile);
|
|
||||||
build.put("gameUrl", gameListConfig.getCover());
|
|
||||||
build.put("currencyDiff", cmd.getCoin());
|
|
||||||
|
|
||||||
imGroupClient.sendMessageBroadcast(
|
|
||||||
BroadcastGroupMsgBodyCmd.builder()
|
|
||||||
.toPlatform(SysOriginPlatformEnum.ATYOU)
|
|
||||||
.type(GroupMessageTypeEnum.GAME_BAISHUN_WIN)
|
|
||||||
.data(build)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// type = 1 是支出 type = 2 是收入
|
// type = 1 是支出 type = 2 是收入
|
||||||
|
if (cmd.getType() != null && cmd.getType() == 2) {
|
||||||
//游戏参与打榜活动
|
gameEventService.onWinEvent(userId, cmd.getCoin(), GameOriginEnum.LINGXIAN.name(), gameListConfig);
|
||||||
incGameRankingActivity(cmd);
|
|
||||||
|
|
||||||
//累计游戏排行榜
|
|
||||||
incGameRankingRecord(cmd, gameListConfig);
|
|
||||||
|
|
||||||
//处理游戏获得任务
|
|
||||||
if (cmd.getType() == 2) {
|
|
||||||
gameActivityService.handleGameSpendTask(userId, cmd.getCoin());
|
gameActivityService.handleGameSpendTask(userId, cmd.getCoin());
|
||||||
|
gameActivityService.incKingGameDaily(userId, cmd.getCoin(), cmd.getGameId());
|
||||||
// 累加用户获得的金币并发送抽奖券
|
|
||||||
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, Math.abs(cmd.getCoin()), MonthlyRechargeType.UNDEFINED);
|
|
||||||
} else {
|
} else {
|
||||||
|
gameEventService.onBetEvent(userId, cmd.getCoin());
|
||||||
updateRoomDailyTask(cmd.getCoin(), userId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,56 +134,6 @@ public class GameHkysRestController {
|
|||||||
.setData(jsonObject);
|
.setData(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRoomDailyTask(Long coins, Long userId) {
|
|
||||||
RoomDailyTaskCode taskType = RoomDailyTaskCode.PERSONAL_GAME_CONSUME;
|
|
||||||
String redisKey = "room:daily:task:progress:" + taskType.name() + ":" + userId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
|
||||||
Long total = redisService.increment(redisKey, Math.abs(coins.intValue()));
|
|
||||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
|
||||||
roomDailyTaskProgressService.updateTaskProgress(
|
|
||||||
new RoomDailyTaskProgressUpdateCmd()
|
|
||||||
.setUserId(userId)
|
|
||||||
.setTaskCode(taskType.name())
|
|
||||||
.setProgressValue(total.intValue())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incGameRankingRecord(GameLxwlUpdateBalanceCmd request, GameListConfig gameListConfig) {
|
|
||||||
if (request.getType() != 2 || gameListConfig == null || request.getCoin() <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameRankingIncrementCmd build = GameRankingIncrementCmd.builder()
|
|
||||||
.gameOrigin(GameOriginEnum.LINGXIAN.name())
|
|
||||||
.gameId(gameListConfig.getGameId())
|
|
||||||
.gameName(gameListConfig.getName())
|
|
||||||
.gameCover(gameListConfig.getCover())
|
|
||||||
.gameUrl(gameListConfig.getGameCode())
|
|
||||||
.sysOrigin(gameListConfig.getSysOrigin())
|
|
||||||
.amount(request.getCoin())
|
|
||||||
.periodType("ALL")
|
|
||||||
.build();
|
|
||||||
gameRankingGateway.incrementPrizeAmount(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incGameRankingActivity(GameLxwlUpdateBalanceCmd request) {
|
|
||||||
if (request.getType() != null && request.getType() == 2 && request.getCoin() > 0) {
|
|
||||||
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
|
|
||||||
receiverCmd.setUserId(DataTypeUtils.toLong(request.getUid()));
|
|
||||||
receiverCmd.setUserSex(1);
|
|
||||||
receiverCmd.setActivityType(RankingActivityType.KING_GAMES.getCode());
|
|
||||||
receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode());
|
|
||||||
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
|
|
||||||
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
|
|
||||||
receiverCmd.setIncrementQuantity(request.getCoin());
|
|
||||||
receiverCmd.setBizNo(request.getGameId());
|
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of(SysOriginPlatformEnum.ATYOU.name()));
|
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
|
||||||
|
|
||||||
//游戏王日榜
|
|
||||||
gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUid()), request.getCoin(), request.getGameId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@IgnoreResultResponse
|
@IgnoreResultResponse
|
||||||
@PostMapping("/orderCompensation")
|
@PostMapping("/orderCompensation")
|
||||||
public HkysResponse<JSONObject> orderCompensation(@RequestBody JSONObject object) {
|
public HkysResponse<JSONObject> orderCompensation(@RequestBody JSONObject object) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.red.circle.other.app.service.game;
|
package com.red.circle.other.app.service.game;
|
||||||
|
|
||||||
import com.red.circle.auth.inner.endpoint.AuthClient;
|
import com.red.circle.auth.inner.endpoint.AuthClient;
|
||||||
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
|
|
||||||
import com.red.circle.component.game.baishun.GameBaishunService;
|
import com.red.circle.component.game.baishun.GameBaishunService;
|
||||||
import com.red.circle.component.game.baishun.error.BaishunErrorCode;
|
import com.red.circle.component.game.baishun.error.BaishunErrorCode;
|
||||||
import com.red.circle.component.game.baishun.props.GameBaishunProperties;
|
import com.red.circle.component.game.baishun.props.GameBaishunProperties;
|
||||||
@ -14,41 +13,23 @@ import com.red.circle.component.game.baishun.response.BaishunResponse;
|
|||||||
import com.red.circle.component.game.baishun.response.BaishunTokenResponse;
|
import com.red.circle.component.game.baishun.response.BaishunTokenResponse;
|
||||||
import com.red.circle.component.game.baishun.response.BaishunUserProfileResponse;
|
import com.red.circle.component.game.baishun.response.BaishunUserProfileResponse;
|
||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
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.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.dto.ReqSysOrigin;
|
|
||||||
import com.red.circle.framework.core.exception.ResponseException;
|
import com.red.circle.framework.core.exception.ResponseException;
|
||||||
import com.red.circle.framework.core.security.UserCredential;
|
import com.red.circle.framework.core.security.UserCredential;
|
||||||
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
|
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
|
||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
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.dto.cmd.activity.RankingDataUpdateCmd;
|
|
||||||
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
|
|
||||||
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.activity.ActivityRechargeTicketService;
|
import com.red.circle.other.app.service.game.common.GameEventService;
|
||||||
import com.red.circle.other.app.service.activity.RankingActivityService;
|
|
||||||
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
|
|
||||||
import com.red.circle.other.app.service.task.TaskService;
|
import com.red.circle.other.app.service.task.TaskService;
|
||||||
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
|
|
||||||
import com.red.circle.other.app.util.OfficialNoticeUtils;
|
|
||||||
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
|
|
||||||
import com.red.circle.other.domain.gateway.game.GameRankingGateway;
|
|
||||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
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.cache.service.other.EnumConfigCacheService;
|
||||||
import com.red.circle.other.infra.database.cache.service.other.GameListCacheService;
|
import com.red.circle.other.infra.database.cache.service.other.GameListCacheService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
|
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.infra.database.rds.service.sys.GameListConfigService;
|
||||||
import com.red.circle.other.inner.enums.config.EnumConfigKey;
|
|
||||||
import com.red.circle.other.inner.enums.task.RoomDailyTaskCode;
|
|
||||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||||
import com.red.circle.tool.core.date.DateUtils;
|
import com.red.circle.tool.core.date.DateUtils;
|
||||||
import com.red.circle.tool.core.date.LocalDateTimeUtils;
|
import com.red.circle.tool.core.date.LocalDateTimeUtils;
|
||||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
|
||||||
import com.red.circle.tool.core.json.JacksonUtils;
|
import com.red.circle.tool.core.json.JacksonUtils;
|
||||||
import com.red.circle.tool.core.parse.DataTypeUtils;
|
import com.red.circle.tool.core.parse.DataTypeUtils;
|
||||||
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
|
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
|
||||||
@ -57,7 +38,6 @@ import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd.GoldReceiptCmdBuilde
|
|||||||
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
|
||||||
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -84,14 +64,10 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||||
private final EnumConfigCacheService enumConfigCacheService;
|
private final EnumConfigCacheService enumConfigCacheService;
|
||||||
private final GameListConfigService gameListConfigService;
|
private final GameListConfigService gameListConfigService;
|
||||||
private final ImGroupClient imGroupClient;
|
|
||||||
private final RankingActivityService rankingActivityService;
|
|
||||||
private final GameRankingGateway gameRankingGateway;
|
|
||||||
private final GameListCacheService gameListCacheService;
|
private final GameListCacheService gameListCacheService;
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
private final GameActivityService gameActivityService;
|
private final GameActivityService gameActivityService;
|
||||||
private final ActivityRechargeTicketService activityRechargeTicketService;
|
private final GameEventService gameEventService;
|
||||||
private final RoomDailyTaskProgressService roomDailyTaskProgressService;
|
|
||||||
@Value("${red-circle.game-rank.gameid}")
|
@Value("${red-circle.game-rank.gameid}")
|
||||||
private String gameId;
|
private String gameId;
|
||||||
|
|
||||||
@ -213,22 +189,12 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
|
|
||||||
// request.getCurrencyDiff() > 0 是收入 request.getCurrencyDiff() < 0 是支出
|
// request.getCurrencyDiff() > 0 是收入 request.getCurrencyDiff() < 0 是支出
|
||||||
if (Objects.nonNull(gameListConfig)) {
|
if (Objects.nonNull(gameListConfig)) {
|
||||||
sendBroadcast(request, gameListConfig);
|
|
||||||
|
|
||||||
//游戏参与打榜活动
|
|
||||||
incGameRankingActivity(request);
|
|
||||||
|
|
||||||
//累计游戏排行榜
|
|
||||||
incGameRankingRecord(request, gameListConfig);
|
|
||||||
|
|
||||||
//处理游戏获得任务
|
|
||||||
if (request.getCurrencyDiff() > 0) {
|
if (request.getCurrencyDiff() > 0) {
|
||||||
|
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());
|
||||||
// 累加用户获得的金币并发送抽奖券
|
|
||||||
// activityRechargeTicketService.accumulatedRechargeAndAddTicket(userId, request.getCurrencyDiff(), MonthlyRechargeType.UNDEFINED);
|
|
||||||
} else {
|
} else {
|
||||||
updateRoomDailyTask(request.getCurrencyDiff(), userId);
|
gameEventService.onBetEvent(userId, request.getCurrencyDiff());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,85 +216,6 @@ public class GameBaishunServiceImpl implements GameBaishunService {
|
|||||||
return BaishunResponse.fail(BaishunErrorCode.SERVER_ERROR);
|
return BaishunResponse.fail(BaishunErrorCode.SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRoomDailyTask(Long coins, Long userId) {
|
|
||||||
RoomDailyTaskCode taskType = RoomDailyTaskCode.PERSONAL_GAME_CONSUME;
|
|
||||||
String redisKey = "room:daily:task:progress:" + taskType.name() + ":" + userId + ":" + ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
|
||||||
Long total = redisService.increment(redisKey, Math.abs(coins.intValue()));
|
|
||||||
redisService.expire(redisKey, DateTimeAsiaRiyadhUtils.getSecondsUntilMidnight(), TimeUnit.SECONDS);
|
|
||||||
roomDailyTaskProgressService.updateTaskProgress(
|
|
||||||
new RoomDailyTaskProgressUpdateCmd()
|
|
||||||
.setUserId(userId)
|
|
||||||
.setTaskCode(taskType.name())
|
|
||||||
.setProgressValue(total.intValue())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendBroadcast(BaishunChangeCurrencyRequest request, GameListConfig gameListConfig) {
|
|
||||||
if (gameListConfig == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal cost = enumConfigCacheService
|
|
||||||
.getValueBigDecimal(EnumConfigKey.GAME_BROADCAST_AMOUNT, gameListConfig.getSysOrigin()) ;
|
|
||||||
if (cost == null || cost.compareTo(BigDecimal.ZERO) <= 0) {
|
|
||||||
cost = BigDecimal.valueOf(5000L);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getCurrencyDiff() >= cost.longValue()) {
|
|
||||||
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
|
|
||||||
userProfileGateway.getByUserId(DataTypeUtils.toLong(request.getUserId())));
|
|
||||||
|
|
||||||
Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile);
|
|
||||||
build.put("gameUrl", gameListConfig.getCover());
|
|
||||||
build.put("currencyDiff", request.getCurrencyDiff());
|
|
||||||
|
|
||||||
imGroupClient.sendMessageBroadcast(
|
|
||||||
BroadcastGroupMsgBodyCmd.builder()
|
|
||||||
.toPlatform(SysOriginPlatformEnum.ATYOU)
|
|
||||||
.type(GroupMessageTypeEnum.GAME_BAISHUN_WIN)
|
|
||||||
.data(build)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incGameRankingRecord(BaishunChangeCurrencyRequest request, GameListConfig gameListConfig) {
|
|
||||||
if (gameListConfig == null || request.getCurrencyDiff() <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameRankingIncrementCmd build = GameRankingIncrementCmd.builder()
|
|
||||||
.gameOrigin(GameOriginEnum.BAISHUN.name())
|
|
||||||
.gameId(gameListConfig.getGameId())
|
|
||||||
.gameName(gameListConfig.getName())
|
|
||||||
.gameCover(gameListConfig.getCover())
|
|
||||||
.gameUrl(gameListConfig.getGameCode())
|
|
||||||
.sysOrigin(gameListConfig.getSysOrigin())
|
|
||||||
.amount(request.getCurrencyDiff())
|
|
||||||
.periodType("ALL")
|
|
||||||
.build();
|
|
||||||
gameRankingGateway.incrementPrizeAmount(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incGameRankingActivity(BaishunChangeCurrencyRequest request) {
|
|
||||||
if (request.getCurrencyDiff() > 0) {
|
|
||||||
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
|
|
||||||
receiverCmd.setUserId(DataTypeUtils.toLong(request.getUserId()));
|
|
||||||
receiverCmd.setUserSex(1);
|
|
||||||
receiverCmd.setActivityType(RankingActivityType.KING_GAMES.getCode());
|
|
||||||
receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode());
|
|
||||||
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
|
|
||||||
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
|
|
||||||
receiverCmd.setIncrementQuantity(request.getCurrencyDiff());
|
|
||||||
receiverCmd.setBizNo(request.getGameRoundId());
|
|
||||||
receiverCmd.setReqSysOrigin(ReqSysOrigin.of(SysOriginPlatformEnum.ATYOU.name()));
|
|
||||||
rankingActivityService.accumulateRankingData(receiverCmd);
|
|
||||||
|
|
||||||
//游戏王日榜
|
|
||||||
gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUserId()), request.getCurrencyDiff(), request.getGameId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) {
|
private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) {
|
||||||
UserCredential userCredential = UserCredential.parseToken(param.getToken());
|
UserCredential userCredential = UserCredential.parseToken(param.getToken());
|
||||||
return createGoldReceiptCmdBuilder(param.getCurrencyDiff())
|
return createGoldReceiptCmdBuilder(param.getCurrencyDiff())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user