refactor(ff-game): 重构游戏 API 控制器

- 移除了对 GameSecretKeyCurrencyDTO 和 GameSecretKeyLangDTO 的依赖- 引入了 Platform 和 KeyInfo 类
- 优化了货币和语言的处理逻辑
-简化了游戏平台的配置和访问
- 调整了线程池的使用方式
main-meitian
liaoyong 2025-04-03 14:34:49 +08:00
parent e2375788b4
commit 22b613ece0
10 changed files with 502 additions and 235 deletions

View File

@ -9,12 +9,14 @@ import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController; import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult; import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.page.TableDataInfo; import com.ff.base.core.page.TableDataInfo;
import com.ff.base.enums.*; import com.ff.base.enums.ErrorCode;
import com.ff.base.enums.GamePlatforms;
import com.ff.base.enums.TransferType;
import com.ff.base.exception.base.ApiException; import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException; import com.ff.base.exception.base.BaseException;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.utils.StringUtils; import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils; import com.ff.base.utils.bean.BeanUtils;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.dto.GameBalanceExchange; import com.ff.common.dto.GameBalanceExchange;
import com.ff.common.service.ITenantGameQuotaFlowService; import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.common.service.ITenantGameQuotaService; import com.ff.common.service.ITenantGameQuotaService;
@ -23,18 +25,16 @@ import com.ff.game.api.IGamesService;
import com.ff.game.api.request.*; import com.ff.game.api.request.*;
import com.ff.game.domain.*; import com.ff.game.domain.*;
import com.ff.game.dto.GameBettingDetailsDTO; import com.ff.game.dto.GameBettingDetailsDTO;
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
import com.ff.game.dto.GameSecretKeyLangDTO;
import com.ff.game.service.*; import com.ff.game.service.*;
import com.ff.member.domain.Member; import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService; import com.ff.member.service.IMemberService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -45,10 +45,12 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Collectors;
/** /**
* api * api
@ -74,16 +76,9 @@ public class ApiGameController extends BaseController {
@Resource @Resource
private KeyConfig keyConfig; private KeyConfig keyConfig;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource @Resource
private IMemberService memberService; private IMemberService memberService;
@Resource
private IGamePlatformService gamePlatformService;
@Resource @Resource
private ITenantGameQuotaService tenantGameQuotaService; private ITenantGameQuotaService tenantGameQuotaService;
@ -98,17 +93,12 @@ public class ApiGameController extends BaseController {
@Resource @Resource
private IGameExchangeMoneyService gameExchangeMoneyService; private IGameExchangeMoneyService gameExchangeMoneyService;
@Resource
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
@Resource
private IGameSecretKeyLangService gameSecretKeyLangService;
@Autowired @Autowired
@Qualifier("threadPoolTaskExecutor") @Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Resource
private IPlatformService platformService;
/** /**
* *
@ -118,11 +108,20 @@ public class ApiGameController extends BaseController {
@PostMapping("/list") @PostMapping("/list")
public AjaxResult list() { public AjaxResult list() {
List<GameResponse> gameResponses = gameService.selectGameResponseList(); List<GameResponse> gameResponses = gameService.selectGameResponseList();
for (GameResponse gameRespons : gameResponses) { for (GameResponse gameResponse : gameResponses) {
Platform platform = platformService.get(gameResponse.getPlatformCode());
if (null == platform) {
continue;
}
// List<GameSecretKeyCurrencyDTO> gameSecretKeyCurrencies =
// gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(
// GameSecretKeyCurrencyDTO.builder().platformCode(gameResponse.getPlatformCode())
// .build()
// );
// List<String> currencyCode = gameSecretKeyCurrencies.stream().map(GameSecretKeyCurrencyDTO::getSystemCurrency).collect(Collectors.toList());
List<GameSecretKeyCurrencyDTO> gameSecretKeyCurrencies = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder().platformCode(gameRespons.getPlatformCode()).build()); List<String> currencyCode = new ArrayList<>(platform.getCurrencyInfo().keySet());
List<String> currencyCode = gameSecretKeyCurrencies.stream().map(GameSecretKeyCurrencyDTO::getSystemCurrency).collect(Collectors.toList()); gameResponse.setCurrencyCode(currencyCode);
gameRespons.setCurrencyCode(currencyCode);
} }
return AjaxResult.success(gameResponses); return AjaxResult.success(gameResponses);
} }
@ -131,50 +130,67 @@ public class ApiGameController extends BaseController {
/** /**
* *
* *
* @param memberCreateApiRequest api * @param loginRequest
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/login") @PostMapping("/login")
public AjaxResult login(@Validated @RequestBody GameLoginRequest memberCreateApiRequest) { public AjaxResult login(@Validated @RequestBody GameLoginRequest loginRequest) {
Game game = gameService.selectGameById(memberCreateApiRequest.getGameId()); Game game = gameService.selectGameById(loginRequest.getGameId());
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode()); ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId()); Platform platform = platformService.get(game.getPlatformCode());
ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(platform.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(loginRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(loginRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(loginRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String targetLang = platform.getLangInfo().get(loginRequest.getLangCode());
ApiException.notNull(targetLang, ErrorCode.LANG_NOT_EXIST.getCode());
// TenantSecretKey tenantSecretKey = keyConfig.get();
// GameSecretKeyCurrencyDTO secretKeyCurrencyDTO = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gamePlatform.getPlatformCode())
// .systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
// ApiException.notNull(secretKeyCurrencyDTO, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// GameSecretKeyLangDTO gameSecretKeyLangDTO = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
// .platformCode(gamePlatform.getPlatformCode())
// .systemLangCode(memberCreateApiRequest.getLangCode())
// .build());
// ApiException.notNull(gameSecretKeyLangDTO, ErrorCode.LANG_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gamePlatform.getPlatformCode() + Constants.SERVICE); Member member = memberService.selectMemberByAccount(loginRequest.getAccount(), loginRequest.getCurrencyCode(), platform.getPlatformCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO secretKeyCurrencyDTO = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gamePlatform.getPlatformCode())
.systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
ApiException.notNull(secretKeyCurrencyDTO, ErrorCode.CURRENCY_NOT_EXIST.getCode());
GameSecretKeyLangDTO gameSecretKeyLangDTO = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
.platformCode(gamePlatform.getPlatformCode())
.systemLangCode(memberCreateApiRequest.getLangCode())
.build());
ApiException.notNull(gameSecretKeyLangDTO, ErrorCode.LANG_NOT_EXIST.getCode());
Member member = memberService.selectMemberByAccount(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode(), gamePlatform.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode()); ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
GamesLogin gamesLogin = GamesLogin.builder() GamesLogin gamesLogin = GamesLogin.builder()
.agentId(secretKeyCurrencyDTO.getCode()) .agentId(keyInfo.getCode())
.agentKey(secretKeyCurrencyDTO.getKey()) .agentKey(keyInfo.getKey())
.account(member.getGameAccount()) .account(member.getGameAccount())
.gameType(game.getGameSourceType()) .gameType(game.getGameSourceType())
.currency(secretKeyCurrencyDTO.getCurrency()) .currency(/*secretKeyCurrencyDTO.getCurrency()*/targetCurrency)
.gameId(game.getGameCode()) .gameId(game.getGameCode())
.homeUrl(memberCreateApiRequest.getHomeUrl()) .homeUrl(loginRequest.getHomeUrl())
.betLimit(memberCreateApiRequest.getBetLimit()) .betLimit(loginRequest.getBetLimit())
.platform(memberCreateApiRequest.getPlatform()) .platform(loginRequest.getPlatform())
.disableFullScreen(memberCreateApiRequest.getDisableFullScreen()) .disableFullScreen(loginRequest.getDisableFullScreen())
.lang(gameSecretKeyLangDTO.getLang()) .lang(/*gameSecretKeyLangDTO.getLang()*/ targetLang)
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
String login = iGamesService.loginWithoutRedirect(gamesLogin); String login = iGamesService.loginWithoutRedirect(gamesLogin);
@ -193,17 +209,33 @@ public class ApiGameController extends BaseController {
@Transactional @Transactional
public AjaxResult exchangeBalance(@Validated @RequestBody GameExchangeBalanceRequest gameExchangeBalanceRequest) { public AjaxResult exchangeBalance(@Validated @RequestBody GameExchangeBalanceRequest gameExchangeBalanceRequest) {
IGamesService iGamesService = gamesService.get(gameExchangeBalanceRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(gameExchangeBalanceRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get(); TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameExchangeBalanceRequest.getPlatformCode()) // .platformCode(gameExchangeBalanceRequest.getPlatformCode())
.systemCurrency(gameExchangeBalanceRequest.getCurrencyCode()).build()); // .systemCurrency(gameExchangeBalanceRequest.getCurrencyCode()).build());
//
// ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); Platform platform = platformService.get(gameExchangeBalanceRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(gameExchangeBalanceRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(gameExchangeBalanceRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(gameExchangeBalanceRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
BigDecimal quota = tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder() BigDecimal quota = tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder()
.platformCode(gameExchangeBalanceRequest.getPlatformCode()) .platformCode(gameExchangeBalanceRequest.getPlatformCode())
@ -222,15 +254,17 @@ public class ApiGameController extends BaseController {
//操作第三方额度接口 //操作第三方额度接口
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder() ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.orderId(gameExchangeBalanceRequest.getOrderId()) .orderId(gameExchangeBalanceRequest.getOrderId())
.account(member.getGameAccount()) .account(member.getGameAccount())
.currency(gameSecretKey.getCurrency()) .currency(/*gameSecretKey.getCurrency()*/targetCurrency)
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(tenantSecretKey.getTenantKey())
.quota(quota) .quota(quota)
.amount(gameExchangeBalanceRequest.getAmount()) .amount(gameExchangeBalanceRequest.getAmount())
.transferType(gameExchangeBalanceRequest.getTransferType()) .transferType(gameExchangeBalanceRequest.getTransferType())
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO); Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId); GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId);
@ -276,12 +310,27 @@ public class ApiGameController extends BaseController {
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get(); // TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameCreateFreeSpinRequest.getPlatformCode()) // .platformCode(gameCreateFreeSpinRequest.getPlatformCode())
.systemCurrency(gameCreateFreeSpinRequest.getCurrencyCode()).build()); // .systemCurrency(gameCreateFreeSpinRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); // ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Platform platform = platformService.get(gameCreateFreeSpinRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(gameCreateFreeSpinRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(gameCreateFreeSpinRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(gameCreateFreeSpinRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Member member = memberService.selectMemberByAccount(gameCreateFreeSpinRequest.getAccount(), gameCreateFreeSpinRequest.getCurrencyCode(), gameCreateFreeSpinRequest.getPlatformCode()); Member member = memberService.selectMemberByAccount(gameCreateFreeSpinRequest.getAccount(), gameCreateFreeSpinRequest.getCurrencyCode(), gameCreateFreeSpinRequest.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode()); ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
@ -289,15 +338,17 @@ public class ApiGameController extends BaseController {
CreateFreeSpinRequestDTO createFreeSpinRequestDTO = CreateFreeSpinRequestDTO.builder() CreateFreeSpinRequestDTO createFreeSpinRequestDTO = CreateFreeSpinRequestDTO.builder()
.account(member.getGameAccount()) .account(member.getGameAccount())
.currency(gameCreateFreeSpinRequest.getCurrencyCode()) .currency(/*gameCreateFreeSpinRequest.getCurrencyCode()*/targetCurrency)
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.referenceId(gameCreateFreeSpinRequest.getReferenceId()) .referenceId(gameCreateFreeSpinRequest.getReferenceId())
.freeSpinValidity(gameCreateFreeSpinRequest.getFreeSpinValidity()) .freeSpinValidity(gameCreateFreeSpinRequest.getFreeSpinValidity())
.numberOfRounds(gameCreateFreeSpinRequest.getNumberOfRounds()) .numberOfRounds(gameCreateFreeSpinRequest.getNumberOfRounds())
.gameIds(gameCreateFreeSpinRequest.getGameIds()) .gameIds(gameCreateFreeSpinRequest.getGameIds())
.betValue(gameCreateFreeSpinRequest.getBetValue()) .betValue(gameCreateFreeSpinRequest.getBetValue())
.startTime(gameCreateFreeSpinRequest.getStartTime()) .startTime(gameCreateFreeSpinRequest.getStartTime())
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
@ -350,32 +401,52 @@ public class ApiGameController extends BaseController {
*/ */
@PostMapping("/get/detail") @PostMapping("/get/detail")
public AjaxResult getDetail(@Validated @RequestBody GameGetDetailRequest gameGetDetailRequest) { public AjaxResult getDetail(@Validated @RequestBody GameGetDetailRequest gameGetDetailRequest) {
Platform platform = platformService.get(gameGetDetailRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(gameGetDetailRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(gameGetDetailRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(gameGetDetailRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String targetLang = platform.getLangInfo().get(gameGetDetailRequest.getLangCode());
ApiException.notNull(targetLang, ErrorCode.LANG_NOT_EXIST.getCode());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameGetDetailRequest.getPlatformCode())
// .systemCurrency(gameGetDetailRequest.getCurrencyCode()).build());
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
.platformCode(gameGetDetailRequest.getPlatformCode())
.systemCurrency(gameGetDetailRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameGetDetailRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(gameGetDetailRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
GameSecretKeyLangDTO gameSecretKeyLang = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder() // GameSecretKeyLangDTO gameSecretKeyLang = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
.platformCode(gameGetDetailRequest.getPlatformCode()) // .platformCode(gameGetDetailRequest.getPlatformCode())
.systemLangCode(gameGetDetailRequest.getLangCode()) // .systemLangCode(gameGetDetailRequest.getLangCode())
.build()); // .build());
ApiException.notNull(gameSecretKeyLang, ErrorCode.LANG_NOT_EXIST.getCode()); // ApiException.notNull(gameSecretKeyLang, ErrorCode.LANG_NOT_EXIST.getCode());
GetGameDetailResponseDTO gameDetail = iGamesService.getGameDetail(GetGameDetailRequestDTO.builder() GetGameDetailResponseDTO gameDetail = iGamesService.getGameDetail(GetGameDetailRequestDTO.builder()
.wagersId(gameGetDetailRequest.getWagersId()) .wagersId(gameGetDetailRequest.getWagersId())
.lang(gameSecretKeyLang.getLang()) .lang(/*gameSecretKeyLang.getLang()*/targetLang)
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build()); .build());
return AjaxResult.success(gameDetail); return AjaxResult.success(gameDetail);
} }
@ -388,44 +459,80 @@ public class ApiGameController extends BaseController {
*/ */
@PostMapping("/kick/member") @PostMapping("/kick/member")
public AjaxResult kickMember(@Validated @RequestBody GameKickMemeberRequest gameKickMemeberRequest) { public AjaxResult kickMember(@Validated @RequestBody GameKickMemeberRequest gameKickMemeberRequest) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameKickMemeberRequest.getPlatformCode()) // .platformCode(gameKickMemeberRequest.getPlatformCode())
.systemCurrency(gameKickMemeberRequest.getCurrencyCode()).build()); // .systemCurrency(gameKickMemeberRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); // ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Platform platform = platformService.get(gameKickMemeberRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
Member member = memberService.selectMemberByAccount(gameKickMemeberRequest.getAccount(), gameKickMemeberRequest.getCurrencyCode(), gameKickMemeberRequest.getPlatformCode()); String targetCurrency = platform.getCurrencyInfo().get(gameKickMemeberRequest.getCurrencyCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode()); ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(gameKickMemeberRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(gameKickMemeberRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameKickMemeberRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(gameKickMemeberRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
Member member = memberService.selectMemberByAccount(gameKickMemeberRequest.getAccount(), gameKickMemeberRequest.getCurrencyCode(), gameKickMemeberRequest.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
return AjaxResult.success(iGamesService.kickMember(KickMemberRequestDTO.builder() return AjaxResult.success(iGamesService.kickMember(KickMemberRequestDTO.builder()
.account(member.getGameAccount()) .account(member.getGameAccount())
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.currency(gameSecretKey.getCurrency()) .currency(targetCurrency)
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build())); .build()));
} }
@PostMapping("/kick/member/all") @PostMapping("/kick/member/all")
public AjaxResult kickMemberAll(@Validated @RequestBody GameKickMemeberAllRequest gameKickMemeberAllRequest) { public AjaxResult kickMemberAll(@Validated @RequestBody GameKickMemeberAllRequest gameKickMemeberAllRequest) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameKickMemeberAllRequest.getPlatformCode()) // .platformCode(gameKickMemeberAllRequest.getPlatformCode())
.systemCurrency(gameKickMemeberAllRequest.getCurrencyCode()).build()); // .systemCurrency(gameKickMemeberAllRequest.getCurrencyCode()).build());
//
// ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Platform platform = platformService.get(gameKickMemeberAllRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); String targetCurrency = platform.getCurrencyInfo().get(gameKickMemeberAllRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(gameKickMemeberAllRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(gameKickMemeberAllRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameKickMemeberAllRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(gameKickMemeberAllRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
KickMemberAllDTO kickMemberAllDTO = KickMemberAllDTO.builder() KickMemberAllDTO kickMemberAllDTO = KickMemberAllDTO.builder()
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.currency(gameSecretKey.getCurrency()) .currency(/*gameSecretKey.getCurrency()*/targetCurrency)
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
if (!ObjectUtils.isEmpty(gameKickMemeberAllRequest.getGameId())) { if (!ObjectUtils.isEmpty(gameKickMemeberAllRequest.getGameId())) {
Game game = gameService.selectGameById(gameKickMemeberAllRequest.getGameId()); Game game = gameService.selectGameById(gameKickMemeberAllRequest.getGameId());
@ -474,23 +581,42 @@ public class ApiGameController extends BaseController {
/** /**
* *
* *
* @param gameGetFreeSpinDashflowRequest dashflow * @param request dashflow
* @return {@link TableDataInfo } * @return {@link TableDataInfo }
*/ */
@PostMapping("/cancel/free/spin") @PostMapping("/cancel/free/spin")
public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest gameGetFreeSpinDashflowRequest) { public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest request) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode()) // .platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode())
.systemCurrency(gameGetFreeSpinDashflowRequest.getCurrencyCode()).build()); // .systemCurrency(gameGetFreeSpinDashflowRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); // ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameGetFreeSpinDashflowRequest.getPlatformCode() + Constants.SERVICE); Platform platform = platformService.get(request.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(request.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(request.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(request.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(request.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
Boolean cancelFreeSpin = iGamesService.cancelFreeSpin(CancelFreeSpinRequestDTO.builder() Boolean cancelFreeSpin = iGamesService.cancelFreeSpin(CancelFreeSpinRequestDTO.builder()
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.referenceId(gameGetFreeSpinDashflowRequest.getReferenceId()) .referenceId(request.getReferenceId())
.vendor(platform)
.keyInfo(keyInfo)
.build()); .build());
return AjaxResult.success(cancelFreeSpin); return AjaxResult.success(cancelFreeSpin);
} }
@ -498,45 +624,79 @@ public class ApiGameController extends BaseController {
/** /**
* *
* *
* @param gameExchangeBalanceAllRequest api * @param request api
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/exchange/balance/all") @PostMapping("/exchange/balance/all")
public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest gameExchangeBalanceAllRequest) { public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest request) {
TenantSecretKey tenantSecretKey = keyConfig.get(); TenantSecretKey tenantSecretKey = keyConfig.get();
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder() // List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
.systemCurrency(gameExchangeBalanceAllRequest.getCurrencyCode()).build()); // .systemCurrency(gameExchangeBalanceAllRequest.getCurrencyCode()).build());
List<Key> keys = new ArrayList<>();
for (GamePlatforms platformEnum : GamePlatforms.values()) {
Platform platform = platformService.get(platformEnum.getCode());
String targetCurrency = platform.getCurrencyInfo().get(request.getCurrencyCode());
if (StringUtils.isEmpty(targetCurrency)) {
continue;
}
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(request.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(request.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
if (null == keyInfo) {
continue;
}
Key key = new Key();
key.setPlatformCode(platform.getPlatformCode());
key.setCode(keyInfo.getCode());
key.setKey(keyInfo.getKey());
key.setCurrency(targetCurrency);
key.setPlatform(platform);
key.setKeyInfo(keyInfo);
keys.add(key);
}
// 创建线程池 // 创建线程池
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>(); Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size()); CountDownLatch latch = new CountDownLatch(keys.size());
// 使用List存储Future对象用于获取异步执行的结果 // 使用List存储Future对象用于获取异步执行的结果
List<Future<Long>> futures = new ArrayList<>(); List<Future<Long>> futures = new ArrayList<>();
// 提交异步任务到线程池 // 提交异步任务到线程池
for (GameSecretKeyCurrencyDTO gameSecretKeyCurrencyDTO : gameSecretKeys) { // for (GameSecretKeyCurrencyDTO gameSecretKeyCurrencyDTO : gameSecretKeys) {
for (Key key : keys) {
futures.add(threadPoolTaskExecutor.submit(() -> { futures.add(threadPoolTaskExecutor.submit(() -> {
try { try {
IGamesService iGamesService = gamesService.get(gameSecretKeyCurrencyDTO.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(key.getPlatformCode() + Constants.SERVICE);
Member member = memberService.selectMemberByAccount(gameExchangeBalanceAllRequest.getAccount(), gameExchangeBalanceAllRequest.getCurrencyCode(), gameSecretKeyCurrencyDTO.getPlatformCode()); Member member = memberService.selectMemberByAccount(request.getAccount(), request.getCurrencyCode(), key.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode()); ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
//操作第三方钱包 //操作第三方钱包
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder() ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
.agentId(gameSecretKeyCurrencyDTO.getCode()) .agentId(key.getCode())
.agentKey(gameSecretKeyCurrencyDTO.getKey()) .agentKey(key.getKey())
.orderId(gameExchangeBalanceAllRequest.getOrderId()) .orderId(request.getOrderId())
.amount(BigDecimal.ONE) .amount(BigDecimal.ONE)
.currency(gameSecretKeyCurrencyDTO.getCurrency()) .currency(/*gameSecretKeyCurrencyDTO.getCurrency()*/key.currency)
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(tenantSecretKey.getTenantKey())
.account(member.getGameAccount()) .account(member.getGameAccount())
.vendor(key.getPlatform())
.keyInfo(key.getKeyInfo())
.transferType(TransferType.ALL.getCode()) .transferType(TransferType.ALL.getCode())
.build(); .build();
return iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO); return iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
@ -571,7 +731,7 @@ public class ApiGameController extends BaseController {
tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder() tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder()
.platformCode(gameExchangeMoney.getPlatformCode()) .platformCode(gameExchangeMoney.getPlatformCode())
.currencyCode(gameExchangeMoney.getCurrencyCode()) .currencyCode(gameExchangeMoney.getCurrencyCode())
.sourceId(gameExchangeBalanceAllRequest.getOrderId()) .sourceId(request.getOrderId())
.transferType(TransferType.ALL.getCode()) .transferType(TransferType.ALL.getCode())
.amount(gameExchangeMoney.getBalance()) .amount(gameExchangeMoney.getBalance())
.account(member.getMemberAccount()) .account(member.getMemberAccount())
@ -593,33 +753,54 @@ public class ApiGameController extends BaseController {
/** /**
* *
* *
* @param gameDemoLoginRequest * @param request
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/demo/login") @PostMapping("/demo/login")
public AjaxResult demoLogin(@Validated @RequestBody GameDemoLoginRequest gameDemoLoginRequest) { public AjaxResult demoLogin(@Validated @RequestBody GameDemoLoginRequest request) {
Game game = gameService.selectGameById(gameDemoLoginRequest.getGameId()); Game game = gameService.selectGameById(request.getGameId());
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode()); ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId()); //GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode()); //ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
Platform platform = platformService.get(game.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gamePlatform.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(platform.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(request.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
GameSecretKeyLangDTO gameSecretKeyLangDTO = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder() KeyInfo keyInfo = null;
.platformCode(gamePlatform.getPlatformCode()) for (KeyInfo keyData : platform.getKeyInfo()) {
.systemLangCode(gameDemoLoginRequest.getLangCode()) if (StringUtils.isNotEmpty(request.getCurrencyCode())) {
.build()); if (keyData.getCurrency().equalsIgnoreCase(request.getCurrencyCode())) {
ApiException.notNull(gameSecretKeyLangDTO, ErrorCode.LANG_NOT_EXIST.getCode()); keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String targetLang = platform.getLangInfo().get(request.getLangCode());
ApiException.notNull(targetLang, ErrorCode.LANG_NOT_EXIST.getCode());
// GameSecretKeyLangDTO gameSecretKeyLangDTO = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
// .platformCode(gamePlatform.getPlatformCode())
// .systemLangCode(gameDemoLoginRequest.getLangCode())
// .build());
// ApiException.notNull(gameSecretKeyLangDTO, ErrorCode.LANG_NOT_EXIST.getCode());
GameDemoLoginRequestDTO gamesLogin = GameDemoLoginRequestDTO.builder() GameDemoLoginRequestDTO gamesLogin = GameDemoLoginRequestDTO.builder()
.gameId(game.getGameCode()) .gameId(game.getGameCode())
.gameType(game.getGameSourceType()) .gameType(game.getGameSourceType())
.lang(gameSecretKeyLangDTO.getLang()) .lang(/*gameSecretKeyLangDTO.getLang()*/targetLang)
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
GameDemoLoginResponseDTO gameDemoLoginResponseDTO = iGamesService.gameDemoLogin(gamesLogin); GameDemoLoginResponseDTO gameDemoLoginResponseDTO = iGamesService.gameDemoLogin(gamesLogin);
@ -627,4 +808,14 @@ public class ApiGameController extends BaseController {
BeanUtils.copyProperties(gameDemoLoginResponseDTO, gameDemoLoginResponse); BeanUtils.copyProperties(gameDemoLoginResponseDTO, gameDemoLoginResponse);
return AjaxResult.success(gameDemoLoginResponse); return AjaxResult.success(gameDemoLoginResponse);
} }
@Data
class Key {
private String platformCode;
private String code;
private String currency;
private String key;
private Platform platform;
private KeyInfo keyInfo;
}
} }

View File

@ -11,20 +11,22 @@ import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController; import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult; import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.ErrorCode; import com.ff.base.enums.ErrorCode;
import com.ff.base.enums.GamePlatforms;
import com.ff.base.exception.base.ApiException; import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException; import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.StringUtils;
import com.ff.base.system.domain.TenantSecretKey; import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.utils.StringUtils;
import com.ff.config.KeyConfig; import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService; import com.ff.game.api.IGamesService;
import com.ff.game.api.request.*; import com.ff.game.api.request.CreateMemberRequestDTO;
import com.ff.game.domain.GameSecretKey; import com.ff.game.api.request.MemberInfoRequestDTO;
import com.ff.game.dto.GameSecretKeyCurrencyDTO; import com.ff.game.api.request.MemberInfoResponseDTO;
import com.ff.game.service.IGameSecretKeyCurrencyService; import com.ff.game.domain.KeyInfo;
import com.ff.game.service.IGameSecretKeyService; import com.ff.game.domain.Platform;
import com.ff.game.service.IGameService; import com.ff.game.service.IPlatformService;
import com.ff.member.domain.Member; import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService; import com.ff.member.service.IMemberService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -32,10 +34,12 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -58,31 +62,21 @@ import java.util.concurrent.Future;
@Slf4j @Slf4j
public class ApiMemberController extends BaseController { public class ApiMemberController extends BaseController {
@Autowired @Autowired
private Map<String, IGamesService> gamesService; private Map<String, IGamesService> gamesService;
@Resource
private IGameService gameService;
@Resource @Resource
private KeyConfig keyConfig; private KeyConfig keyConfig;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource @Resource
private IMemberService memberService; private IMemberService memberService;
@Autowired @Autowired
@Qualifier("threadPoolTaskExecutor") @Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Resource @Resource
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService; private IPlatformService platformService;
/** /**
* *
@ -98,24 +92,38 @@ public class ApiMemberController extends BaseController {
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get(); TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(memberCreateApiRequest.getPlatformCode())
.systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); Platform platform = platformService.get(memberCreateApiRequest.getPlatformCode());
ApiException.notNull(platform, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(memberCreateApiRequest.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(memberCreateApiRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(memberCreateApiRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(memberCreateApiRequest.getPlatformCode())
// .systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
// ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String gameAccount = StringUtils.addSuffix(memberService.getMemberGameAccount(memberCreateApiRequest.getPlatformCode()), tenantSecretKey.getTenantSn()); String gameAccount = StringUtils.addSuffix(memberService.getMemberGameAccount(memberCreateApiRequest.getPlatformCode()), tenantSecretKey.getTenantSn());
// 获取用户信息 // 获取用户信息
Member gameMember = memberService.selectMemberByAccount(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode(), memberCreateApiRequest.getPlatformCode()); Member gameMember = memberService.selectMemberByAccount(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode(), memberCreateApiRequest.getPlatformCode());
if (!ObjectUtils.isEmpty(gameMember)){ if (!ObjectUtils.isEmpty(gameMember)) {
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode()); throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
} }
//注册本地账号 //注册本地账号
Member member = Member.builder() Member member = Member.builder()
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(tenantSecretKey.getTenantKey())
@ -130,11 +138,13 @@ public class ApiMemberController extends BaseController {
//向第三方注册账号 //向第三方注册账号
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder() CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
.account(gameAccount) .account(gameAccount)
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.betLimit(memberCreateApiRequest.getBetLimit()) .betLimit(memberCreateApiRequest.getBetLimit())
.platformType(memberCreateApiRequest.getPlatformType()) .platformType(memberCreateApiRequest.getPlatformType())
.currency(gameSecretKey.getCurrency()) .currency(targetCurrency)
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
Boolean result = iGamesService.createMember(gamesBaseRequestDTO); Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
Assert.isTrue(result, "建立游戏账号失败"); Assert.isTrue(result, "建立游戏账号失败");
@ -146,35 +156,51 @@ public class ApiMemberController extends BaseController {
/** /**
* *
* *
* @param memberInfoApiRequest api * @param request api
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/info") @PostMapping("/info")
public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest memberInfoApiRequest) { public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest request) {
IGamesService iGamesService = gamesService.get(memberInfoApiRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(request.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode()); ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get(); TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() // GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(memberInfoApiRequest.getPlatformCode()) // .platformCode(memberInfoApiRequest.getPlatformCode())
.systemCurrency(memberInfoApiRequest.getCurrencyCode()).build()); // .systemCurrency(memberInfoApiRequest.getCurrencyCode()).build());
//
// ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Platform platform = platformService.get(request.getPlatformCode());
ApiException.notNull(platform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode()); String targetCurrency = platform.getCurrencyInfo().get(request.getCurrencyCode());
ApiException.notNull(targetCurrency, ErrorCode.CURRENCY_NOT_EXIST.getCode());
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(request.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(request.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
ApiException.notNull(keyInfo, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// 获取用户信息 // 获取用户信息
Member member = memberService.selectMemberByAccount(memberInfoApiRequest.getAccount(), memberInfoApiRequest.getCurrencyCode(), memberInfoApiRequest.getPlatformCode()); Member member = memberService.selectMemberByAccount(request.getAccount(), request.getCurrencyCode(), request.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode()); ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
//向第三方查询账号 //向第三方查询账号
MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder() MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder()
.accounts(member.getGameAccount()) .accounts(member.getGameAccount())
.agentId(gameSecretKey.getCode()) .agentId(keyInfo.getCode())
.currency(gameSecretKey.getCurrency()) .currency(targetCurrency)
.agentKey(gameSecretKey.getKey()) .agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build(); .build();
MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO); MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO);
MemberInfoResponse memberInfoResponse = new MemberInfoResponse(); MemberInfoResponse memberInfoResponse = new MemberInfoResponse();
@ -193,22 +219,49 @@ public class ApiMemberController extends BaseController {
public AjaxResult infoAll(@Validated @RequestBody MemberInfoAllApiRequest memberInfoAllApiRequest) { public AjaxResult infoAll(@Validated @RequestBody MemberInfoAllApiRequest memberInfoAllApiRequest) {
// List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(
// GameSecretKeyCurrencyDTO.builder()
// .systemCurrency(memberInfoAllApiRequest.getCurrencyCode()).build());
List<Key> keys = new ArrayList<>();
for (GamePlatforms platformEnum : GamePlatforms.values()) {
Platform platform = platformService.get(platformEnum.getCode());
String targetCurrency = platform.getCurrencyInfo().get(memberInfoAllApiRequest.getCurrencyCode());
if (StringUtils.isEmpty(targetCurrency)) {
continue;
}
KeyInfo keyInfo = null;
for (KeyInfo keyData : platform.getKeyInfo()) {
if (StringUtils.isNotEmpty(memberInfoAllApiRequest.getCurrencyCode())) {
if (keyData.getCurrency().equalsIgnoreCase(memberInfoAllApiRequest.getCurrencyCode())) {
keyInfo = keyData;
break;
}
}
}
if (null == keyInfo) {
continue;
}
Key key = new Key();
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder() key.setPlatformCode(platform.getPlatformCode());
.systemCurrency(memberInfoAllApiRequest.getCurrencyCode()).build()); key.setCode(keyInfo.getCode());
key.setKey(keyInfo.getKey());
key.setCurrency(targetCurrency);
keys.add(key);
}
// 创建线程池 // 创建线程池
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>(); Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size()); CountDownLatch latch = new CountDownLatch(keys.size());
// 使用List存储Future对象用于获取异步执行的结果 // 使用List存储Future对象用于获取异步执行的结果
List<Future<MemberInfoAllResponse>> futures = new ArrayList<>(); List<Future<MemberInfoAllResponse>> futures = new ArrayList<>();
// 提交异步任务到线程池 // 提交异步任务到线程池
for (GameSecretKeyCurrencyDTO gameSecretKey : gameSecretKeys) { for (Key gameSecretKey : keys) {
futures.add(threadPoolTaskExecutor.submit(() -> { futures.add(threadPoolTaskExecutor.submit(() -> {
try { try {
IGamesService iGamesService = gamesService.get(gameSecretKey.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(gameSecretKey.getPlatformCode() + Constants.SERVICE);
@ -256,5 +309,12 @@ public class ApiMemberController extends BaseController {
return AjaxResult.success(balanceMap); return AjaxResult.success(balanceMap);
} }
@Data
class Key {
private String platformCode;
private String code;
private String currency;
private String key;
}
} }

View File

@ -49,5 +49,11 @@ public class GameDemoLoginRequest implements Serializable {
*/ */
private Integer disableFullScreen; private Integer disableFullScreen;
/**
*
*/
@NotBlank(message = "currencyCode不能为空")
@Length(max = 32, message = "currencyCode长度不能超过32个字符")
private String currencyCode;
} }

View File

@ -76,10 +76,6 @@ public class MeiTianGameServiceImpl implements IGamesService {
@Resource @Resource
private IMemberService memberService; private IMemberService memberService;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource @Resource
private MeiTianClient meiTianClient; private MeiTianClient meiTianClient;
@ -112,11 +108,10 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/ */
@Override @Override
public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) { public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(createMemberRequestDTO.getAgentId());
String playerName = createMemberRequestDTO.getAccount(); String playerName = createMemberRequestDTO.getAccount();
String merchantId = createMemberRequestDTO.getAgentId(); String merchantId = createMemberRequestDTO.getAgentId();
String md5Password = Md5Utils.md5New(gameSecretKey.getPassword()); String md5Password = Md5Utils.md5New(createMemberRequestDTO.getKeyInfo().getPassword());
Map<String, String> rawMap = new LinkedHashMap<>(); Map<String, String> rawMap = new LinkedHashMap<>();
rawMap.put("nickname", createMemberRequestDTO.getAccount()); rawMap.put("nickname", createMemberRequestDTO.getAccount());
rawMap.put("playerLevel", "0"); rawMap.put("playerLevel", "0");
@ -128,7 +123,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
log.error("[MeiTian] encode rawData failure", e); log.error("[MeiTian] encode rawData failure", e);
throw new ApiException(ErrorCode.ERROR.getCode()); throw new ApiException(ErrorCode.ERROR.getCode());
} }
String md5Code = Md5Utils.md5New(gameSecretKey.getKey() + rawData);//MD5(key+rawData); String md5Code = Md5Utils.md5New(createMemberRequestDTO.getKeyInfo().getKey() + rawData);//MD5(key+rawData);
MeiTianCreateMemberResponseDTO createMemberResponseDTO = MeiTianCreateMemberResponseDTO createMemberResponseDTO =
meiTianClient.createMember( meiTianClient.createMember(
playerName, playerName,
@ -181,11 +176,10 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/ */
@Override @Override
public String loginWithoutRedirect(GamesLogin gamesLogin) { public String loginWithoutRedirect(GamesLogin gamesLogin) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(gamesLogin.getAgentId());
String merchantId = gamesLogin.getAgentId(); String merchantId = gamesLogin.getAgentId();
String playerName = gamesLogin.getAccount(); String playerName = gamesLogin.getAccount();
String md5Password = Md5Utils.md5New(gameSecretKey.getPassword()); String md5Password = Md5Utils.md5New(gamesLogin.getKeyInfo().getPassword());
Map<String, String> rawMap = new LinkedHashMap<>(); Map<String, String> rawMap = new LinkedHashMap<>();
/*rawMap.put("gameHall ", gamesLogin.getGameType());*/ /*rawMap.put("gameHall ", gamesLogin.getGameType());*/
rawMap.put("gameCode", gamesLogin.getGameId()); rawMap.put("gameCode", gamesLogin.getGameId());
@ -200,7 +194,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
log.error("[MeiTian] encode rawData failure", e); log.error("[MeiTian] encode rawData failure", e);
throw new ApiException(ErrorCode.ERROR.getCode()); throw new ApiException(ErrorCode.ERROR.getCode());
} }
String code = Md5Utils.md5New(gameSecretKey.getKey() + rawData); String code = Md5Utils.md5New(gamesLogin.getKeyInfo().getKey() + rawData);
MeiTianLoginResultDTO loginWithoutRedirectResponseDTO = MeiTianLoginResultDTO loginWithoutRedirectResponseDTO =
meiTianClient.loginWithoutRedirect( meiTianClient.loginWithoutRedirect(
merchantId, merchantId,
@ -238,12 +232,12 @@ public class MeiTianGameServiceImpl implements IGamesService {
for (MeiTianGameDataDTO gamesDataDTO : gameList.getData()) { for (MeiTianGameDataDTO gamesDataDTO : gameList.getData()) {
GamePlatform gamePlatform = GamePlatform.builder() GamePlatform gamePlatform = GamePlatform.builder()
.platformType(MeiTianGameType.findSystemByCode(gamesDataDTO.getGameCategoryId())) .platformType(MeiTianGameType.findSystemByCode(gamesDataDTO.getGameCategoryId()))
.platformCode(GamePlatforms.MeiTian.getCode()) .platformCode(GamePlatforms.MT.getCode())
.build(); .build();
List<GamePlatform> gamePlatforms = gamePlatformService.selectGamePlatformList(gamePlatform); List<GamePlatform> gamePlatforms = gamePlatformService.selectGamePlatformList(gamePlatform);
//没有此平台就新增一个平台 //没有此平台就新增一个平台
if (CollectionUtils.isEmpty(gamePlatforms)) { if (CollectionUtils.isEmpty(gamePlatforms)) {
gamePlatform.setPlatformName(GamePlatforms.MeiTian.getInfo() + MeiTianGameType.findInfoByCode(gamesDataDTO.getGameCategoryId())); gamePlatform.setPlatformName(GamePlatforms.MT.getInfo() + MeiTianGameType.findInfoByCode(gamesDataDTO.getGameCategoryId()));
gamePlatform.setSortNo(gamePlatformService.selectMaxSortNo() + 1); gamePlatform.setSortNo(gamePlatformService.selectMaxSortNo() + 1);
gamePlatform.setCreateBy(Constants.SYSTEM); gamePlatform.setCreateBy(Constants.SYSTEM);
gamePlatformService.insertGamePlatform(gamePlatform); gamePlatformService.insertGamePlatform(gamePlatform);
@ -309,7 +303,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.currency(exchangeTransferMoneyRequestDTO.getCurrency()).build()); .currency(exchangeTransferMoneyRequestDTO.getCurrency()).build());
Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount()); Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount());
String transactionId = GamePlatforms.MeiTian.getCode() + IdUtils.simpleUUID(); String transactionId = GamePlatforms.MT.getCode() + IdUtils.simpleUUID();
List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList( List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList(
GameExchangeMoney.builder() GameExchangeMoney.builder()
@ -331,7 +325,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.currencyCode(gameSecretKey.getSystemCurrency()) .currencyCode(gameSecretKey.getSystemCurrency())
.memberId(member.getId()) .memberId(member.getId())
.transactionId(transactionId) .transactionId(transactionId)
.platformCode(GamePlatforms.MeiTian.getCode()) .platformCode(GamePlatforms.MT.getCode())
.build(); .build();
exchangeMoney.setCreateBy(Constants.SYSTEM); exchangeMoney.setCreateBy(Constants.SYSTEM);
//接口限制限制50字符 //接口限制限制50字符
@ -439,7 +433,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
} }
boolean doSyncRecordByRecordID(BetRecordByTimeDTO betRecordByTimeDTO) { boolean doSyncRecordByRecordID(BetRecordByTimeDTO betRecordByTimeDTO) {
String configKey = GamePlatforms.MeiTian.getCode() + ":lastRecordID"; String configKey = GamePlatforms.MT.getCode() + ":lastRecordID";
String lastRecordID = sysConfigServiceImpl.selectConfigByKey(configKey); String lastRecordID = sysConfigServiceImpl.selectConfigByKey(configKey);
long recordID = 0; long recordID = 0;
if (lastRecordID == null || lastRecordID.isEmpty()) { if (lastRecordID == null || lastRecordID.isEmpty()) {
@ -496,7 +490,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO, int daysToSubtract) { boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO, int daysToSubtract) {
String date = getDateStr(daysToSubtract); String date = getDateStr(daysToSubtract);
String configKey = GamePlatforms.MeiTian.getCode() + ":lastSyncDate"; String configKey = GamePlatforms.MT.getCode() + ":lastSyncDate";
String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey); String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey);
Map<String, Long> syncDateMap = new HashMap<>(); Map<String, Long> syncDateMap = new HashMap<>();
long recordID = 0; long recordID = 0;
@ -597,9 +591,8 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/ */
@Override @Override
public GetGameDetailResponseDTO getGameDetail(GetGameDetailRequestDTO getGameDetailRequestDTO) { public GetGameDetailResponseDTO getGameDetail(GetGameDetailRequestDTO getGameDetailRequestDTO) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(getGameDetailRequestDTO.getAgentId());
String key = gameSecretKey.getKey(); String key = getGameDetailRequestDTO.getKeyInfo().getKey();
String merchantId = getGameDetailRequestDTO.getAgentId(); String merchantId = getGameDetailRequestDTO.getAgentId();
Map<String, String> rawMap = new LinkedHashMap<>(); Map<String, String> rawMap = new LinkedHashMap<>();
rawMap.put("rowID", getGameDetailRequestDTO.getWagersId()); rawMap.put("rowID", getGameDetailRequestDTO.getWagersId());
@ -721,7 +714,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
} }
if (!CollectionUtils.isEmpty(gameBettingDetails)) { if (!CollectionUtils.isEmpty(gameBettingDetails)) {
//查询重复数据id //查询重复数据id
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds, GamePlatforms.MeiTian.getCode()); List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds, GamePlatforms.MT.getCode());
//用steam流清除list中与wagersIds集合相同的数据 //用steam流清除list中与wagersIds集合相同的数据
gameBettingDetails = gameBettingDetails.stream() gameBettingDetails = gameBettingDetails.stream()
.filter(detail -> !removeWagersIds.contains(detail.getWagersId())) .filter(detail -> !removeWagersIds.contains(detail.getWagersId()))
@ -747,7 +740,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
GameSecretKeyCurrencyDTO gameSecretKey = GameSecretKeyCurrencyDTO gameSecretKey =
gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder() gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.currency(dataBean.getCurrency()) .currency(dataBean.getCurrency())
.platformCode(GamePlatforms.MeiTian.getCode()).build()); .platformCode(GamePlatforms.MT.getCode()).build());
Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName()); Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName());
@ -769,7 +762,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.memberId(member.getId()) .memberId(member.getId())
.gameCode(dataBean.getGameCode()) .gameCode(dataBean.getGameCode())
.gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameType()))) .gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameType())))
.platformCode(GamePlatforms.MeiTian.getCode()) .platformCode(GamePlatforms.MT.getCode())
.gameId(gamesDataDTO.getSystemGameId()) .gameId(gamesDataDTO.getSystemGameId())
.gameName(gamesDataDTO.getCnName()) .gameName(gamesDataDTO.getCnName())
.gameStatus(compareResult > 0 ? GameStatus.WIN.getCode() : compareResult < 0 ? GameStatus.FAIL.getCode() : GameStatus.FLAT.getCode()) .gameStatus(compareResult > 0 ? GameStatus.WIN.getCode() : compareResult < 0 ? GameStatus.FAIL.getCode() : GameStatus.FLAT.getCode())

View File

@ -2,7 +2,6 @@ package com.ff.game.api.ng.service.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.ff.base.config.RedisConfig;
import com.ff.base.constant.CacheConstants; import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants; import com.ff.base.constant.Constants;
import com.ff.base.core.redis.RedisCache; import com.ff.base.core.redis.RedisCache;
@ -11,19 +10,14 @@ import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException; import com.ff.base.exception.base.BaseException;
import com.ff.base.system.service.ISysConfigService; import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils; import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.SleepUtil; import com.ff.base.utils.SleepUtil;
import com.ff.base.utils.StringUtils; import com.ff.base.utils.StringUtils;
import com.ff.base.utils.sign.Md5Utils; import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.config.KeyConfig; import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService; import com.ff.game.api.IGamesService;
import com.ff.game.api.jili.dto.*;
import com.ff.game.api.ng.client.NGClient; import com.ff.game.api.ng.client.NGClient;
import com.ff.game.api.ng.dto.*; import com.ff.game.api.ng.dto.*;
import com.ff.game.api.request.*; import com.ff.game.api.request.*;
import com.ff.game.api.xk.dto.XKBetRecordResponseDTO;
import com.ff.game.api.xk.dto.XKGamesDTO;
import com.ff.game.domain.*; import com.ff.game.domain.*;
import com.ff.game.dto.*; import com.ff.game.dto.*;
import com.ff.game.service.*; import com.ff.game.service.*;
@ -42,15 +36,12 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -228,7 +219,7 @@ public class GamesPGServiceImpl implements IGamesService {
paramsMap.put("lang", gamesLogin.getLang()); paramsMap.put("lang", gamesLogin.getLang());
paramsMap.put("gameCode", gamesLogin.getGameId()); paramsMap.put("gameCode", gamesLogin.getGameId());
paramsMap.put("returnUrl", gamesLogin.getHomeUrl()); paramsMap.put("returnUrl", gamesLogin.getHomeUrl());
paramsMap.put("ingress", PlatformHomeType.WEB.getValue().equals(gamesLogin.getPlatform()) ? IngressType.PC_WEB.getValue() : IngressType.MOBILE_WEB.getValue()); paramsMap.put("ingress", PlatformHomeType.WEB.getValue().equals(gamesLogin.getVendor()) ? IngressType.PC_WEB.getValue() : IngressType.MOBILE_WEB.getValue());
Map<String, String> headerMap = this.getKey(gamesLogin); Map<String, String> headerMap = this.getKey(gamesLogin);
ApiNGResponseDTO<ApiLoginResponseDTO> apiLoginResponseDTOApiNGResponseDTO = ngClient.loginWithoutRedirect(paramsMap, headerMap); ApiNGResponseDTO<ApiLoginResponseDTO> apiLoginResponseDTOApiNGResponseDTO = ngClient.loginWithoutRedirect(paramsMap, headerMap);
if (this.getIsSuccess(apiLoginResponseDTOApiNGResponseDTO.getCode())) { if (this.getIsSuccess(apiLoginResponseDTOApiNGResponseDTO.getCode())) {

View File

@ -1,7 +1,8 @@
package com.ff.game.api.request; package com.ff.game.api.request;
import com.ff.game.domain.KeyInfo;
import com.ff.game.domain.Platform;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@ -36,12 +37,14 @@ public class GamesBaseRequestDTO implements Serializable {
private String query; private String query;
/** /**
* *
*/ */
private String currency; private String currency;
private Platform vendor;
private KeyInfo keyInfo;
} }

View File

@ -11,7 +11,6 @@ import com.ff.base.exception.base.BaseException;
import com.ff.base.system.service.ISysConfigService; import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils; import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil; import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.sign.Md5Utils; import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils; import com.ff.base.utils.uuid.IdUtils;
import com.ff.config.KeyConfig; import com.ff.config.KeyConfig;
@ -210,7 +209,7 @@ public class GamesXKServiceImpl implements IGamesService {
params.put("key", key); params.put("key", key);
params.put("disableFullScreen", gamesLogin.getDisableFullScreen()); params.put("disableFullScreen", gamesLogin.getDisableFullScreen());
params.put("homeUrl", gamesLogin.getHomeUrl()); params.put("homeUrl", gamesLogin.getHomeUrl());
params.put("platform", gamesLogin.getPlatform()); params.put("platform", gamesLogin.getVendor());
XKLoginWithoutRedirectResponseDTO xkLoginWithoutRedirectResponseDTO = xkClient.loginWithoutRedirect(params); XKLoginWithoutRedirectResponseDTO xkLoginWithoutRedirectResponseDTO = xkClient.loginWithoutRedirect(params);
//判断是否获取成功 //判断是否获取成功
if (this.getIsSuccess(xkLoginWithoutRedirectResponseDTO.getCode())) { if (this.getIsSuccess(xkLoginWithoutRedirectResponseDTO.getCode())) {

View File

@ -6,5 +6,6 @@ import java.util.HashMap;
/** /**
* @author cengy * @author cengy
*/ */
public class CurrencyInfo extends HashMap<String, Object> implements Serializable { public class CurrencyInfo extends HashMap<String, String> implements Serializable {
} }

View File

@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ff.base.annotation.Excel; import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity; import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@ -20,24 +19,31 @@ import lombok.experimental.SuperBuilder;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class Game extends BaseEntity public class Game extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键id */ /**
* id
*/
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
/** 排序 */ /**
*
*/
@Excel(name = "排序") @Excel(name = "排序")
private Integer sortNo; private Integer sortNo;
/** 游戏平台id */ /**
* id
*/
@Excel(name = "游戏平台id") @Excel(name = "游戏平台id")
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long platformId; private Long platformId;
/** 游戏第三方id */ /**
* id
*/
@Excel(name = "游戏第三方id") @Excel(name = "游戏第三方id")
private String gameCode; private String gameCode;
@ -46,27 +52,44 @@ public class Game extends BaseEntity
*/ */
private Integer ingress; private Integer ingress;
/** 第三方来源分类 */ /**
*
*/
@Excel(name = "第三方来源分类") @Excel(name = "第三方来源分类")
private String gameSourceType; private String gameSourceType;
/** 游戏名称 */ /**
*
*/
@Excel(name = "游戏名称") @Excel(name = "游戏名称")
private String gameName; private String gameName;
/** 是否支持免费游戏 1 支持 0 不支持 */ /**
* 1 0
*/
@Excel(name = "是否支持免费游戏 1 支持 0 不支持") @Excel(name = "是否支持免费游戏 1 支持 0 不支持")
private Boolean freespin; private Boolean freespin;
/** 是否支持试玩 0关闭 1开启 */ /**
* 0 1
*/
@Excel(name = "是否支持试玩 0关闭 1开启") @Excel(name = "是否支持试玩 0关闭 1开启")
private Boolean demoStatus; private Boolean demoStatus;
/** 维护开关 维护状态 */ /**
*
*/
@Excel(name = "维护开关 ") @Excel(name = "维护开关 ")
private Boolean stopStatus; private Boolean stopStatus;
/**
* code
*/
private String platformCode;
/**
*
*/
private Integer platformType;
} }

View File

@ -220,7 +220,7 @@ public class GameTask {
Long endTime = DateUtils.getNowDate(); Long endTime = DateUtils.getNowDate();
//捞取指定分钟前的数据 //捞取指定分钟前的数据
gameService.insertGameBettingDetails(startTime, endTime, GamePlatforms.MeiTian.getCode()); gameService.insertGameBettingDetails(startTime, endTime, GamePlatforms.MT.getCode());
} }