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.domain.AjaxResult;
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.BaseException;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.dto.GameBalanceExchange;
import com.ff.common.service.ITenantGameQuotaFlowService;
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.domain.*;
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.member.domain.Member;
import com.ff.member.service.IMemberService;
import com.github.pagehelper.PageHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
@ -45,10 +45,12 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
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.Future;
import java.util.stream.Collectors;
/**
* api
@ -74,16 +76,9 @@ public class ApiGameController extends BaseController {
@Resource
private KeyConfig keyConfig;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource
private IMemberService memberService;
@Resource
private IGamePlatformService gamePlatformService;
@Resource
private ITenantGameQuotaService tenantGameQuotaService;
@ -98,17 +93,12 @@ public class ApiGameController extends BaseController {
@Resource
private IGameExchangeMoneyService gameExchangeMoneyService;
@Resource
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
@Resource
private IGameSecretKeyLangService gameSecretKeyLangService;
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Resource
private IPlatformService platformService;
/**
*
@ -118,11 +108,20 @@ public class ApiGameController extends BaseController {
@PostMapping("/list")
public AjaxResult list() {
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 = gameSecretKeyCurrencies.stream().map(GameSecretKeyCurrencyDTO::getSystemCurrency).collect(Collectors.toList());
gameRespons.setCurrencyCode(currencyCode);
List<String> currencyCode = new ArrayList<>(platform.getCurrencyInfo().keySet());
gameResponse.setCurrencyCode(currencyCode);
}
return AjaxResult.success(gameResponses);
}
@ -131,50 +130,67 @@ public class ApiGameController extends BaseController {
/**
*
*
* @param memberCreateApiRequest api
* @param loginRequest
* @return {@link AjaxResult }
*/
@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());
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
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(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);
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());
Member member = memberService.selectMemberByAccount(loginRequest.getAccount(), loginRequest.getCurrencyCode(), platform.getPlatformCode());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
GamesLogin gamesLogin = GamesLogin.builder()
.agentId(secretKeyCurrencyDTO.getCode())
.agentKey(secretKeyCurrencyDTO.getKey())
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.account(member.getGameAccount())
.gameType(game.getGameSourceType())
.currency(secretKeyCurrencyDTO.getCurrency())
.currency(/*secretKeyCurrencyDTO.getCurrency()*/targetCurrency)
.gameId(game.getGameCode())
.homeUrl(memberCreateApiRequest.getHomeUrl())
.betLimit(memberCreateApiRequest.getBetLimit())
.platform(memberCreateApiRequest.getPlatform())
.disableFullScreen(memberCreateApiRequest.getDisableFullScreen())
.lang(gameSecretKeyLangDTO.getLang())
.homeUrl(loginRequest.getHomeUrl())
.betLimit(loginRequest.getBetLimit())
.platform(loginRequest.getPlatform())
.disableFullScreen(loginRequest.getDisableFullScreen())
.lang(/*gameSecretKeyLangDTO.getLang()*/ targetLang)
.vendor(platform)
.keyInfo(keyInfo)
.build();
String login = iGamesService.loginWithoutRedirect(gamesLogin);
@ -193,17 +209,33 @@ public class ApiGameController extends BaseController {
@Transactional
public AjaxResult exchangeBalance(@Validated @RequestBody GameExchangeBalanceRequest gameExchangeBalanceRequest) {
IGamesService iGamesService = gamesService.get(gameExchangeBalanceRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameExchangeBalanceRequest.getPlatformCode())
.systemCurrency(gameExchangeBalanceRequest.getCurrencyCode()).build());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameExchangeBalanceRequest.getPlatformCode())
// .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()
.platformCode(gameExchangeBalanceRequest.getPlatformCode())
@ -222,15 +254,17 @@ public class ApiGameController extends BaseController {
//操作第三方额度接口
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.orderId(gameExchangeBalanceRequest.getOrderId())
.account(member.getGameAccount())
.currency(gameSecretKey.getCurrency())
.currency(/*gameSecretKey.getCurrency()*/targetCurrency)
.tenantKey(tenantSecretKey.getTenantKey())
.quota(quota)
.amount(gameExchangeBalanceRequest.getAmount())
.transferType(gameExchangeBalanceRequest.getTransferType())
.vendor(platform)
.keyInfo(keyInfo)
.build();
Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId);
@ -276,12 +310,27 @@ public class ApiGameController extends BaseController {
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameCreateFreeSpinRequest.getPlatformCode())
.systemCurrency(gameCreateFreeSpinRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// TenantSecretKey tenantSecretKey = keyConfig.get();
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameCreateFreeSpinRequest.getPlatformCode())
// .systemCurrency(gameCreateFreeSpinRequest.getCurrencyCode()).build());
// 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());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
@ -289,15 +338,17 @@ public class ApiGameController extends BaseController {
CreateFreeSpinRequestDTO createFreeSpinRequestDTO = CreateFreeSpinRequestDTO.builder()
.account(member.getGameAccount())
.currency(gameCreateFreeSpinRequest.getCurrencyCode())
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.currency(/*gameCreateFreeSpinRequest.getCurrencyCode()*/targetCurrency)
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.referenceId(gameCreateFreeSpinRequest.getReferenceId())
.freeSpinValidity(gameCreateFreeSpinRequest.getFreeSpinValidity())
.numberOfRounds(gameCreateFreeSpinRequest.getNumberOfRounds())
.gameIds(gameCreateFreeSpinRequest.getGameIds())
.betValue(gameCreateFreeSpinRequest.getBetValue())
.startTime(gameCreateFreeSpinRequest.getStartTime())
.vendor(platform)
.keyInfo(keyInfo)
.build();
@ -350,32 +401,52 @@ public class ApiGameController extends BaseController {
*/
@PostMapping("/get/detail")
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()
.platformCode(gameGetDetailRequest.getPlatformCode())
.systemCurrency(gameGetDetailRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameGetDetailRequest.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
GameSecretKeyLangDTO gameSecretKeyLang = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
.platformCode(gameGetDetailRequest.getPlatformCode())
.systemLangCode(gameGetDetailRequest.getLangCode())
.build());
ApiException.notNull(gameSecretKeyLang, ErrorCode.LANG_NOT_EXIST.getCode());
// GameSecretKeyLangDTO gameSecretKeyLang = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
// .platformCode(gameGetDetailRequest.getPlatformCode())
// .systemLangCode(gameGetDetailRequest.getLangCode())
// .build());
// ApiException.notNull(gameSecretKeyLang, ErrorCode.LANG_NOT_EXIST.getCode());
GetGameDetailResponseDTO gameDetail = iGamesService.getGameDetail(GetGameDetailRequestDTO.builder()
.wagersId(gameGetDetailRequest.getWagersId())
.lang(gameSecretKeyLang.getLang())
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.lang(/*gameSecretKeyLang.getLang()*/targetLang)
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build());
return AjaxResult.success(gameDetail);
}
@ -388,44 +459,80 @@ public class ApiGameController extends BaseController {
*/
@PostMapping("/kick/member")
public AjaxResult kickMember(@Validated @RequestBody GameKickMemeberRequest gameKickMemeberRequest) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameKickMemeberRequest.getPlatformCode())
.systemCurrency(gameKickMemeberRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameKickMemeberRequest.getPlatformCode())
// .systemCurrency(gameKickMemeberRequest.getCurrencyCode()).build());
// 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());
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
String targetCurrency = platform.getCurrencyInfo().get(gameKickMemeberRequest.getCurrencyCode());
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);
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()
.account(member.getGameAccount())
.agentId(gameSecretKey.getCode())
.currency(gameSecretKey.getCurrency())
.agentKey(gameSecretKey.getKey())
.agentId(keyInfo.getCode())
.currency(targetCurrency)
.agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build()));
}
@PostMapping("/kick/member/all")
public AjaxResult kickMemberAll(@Validated @RequestBody GameKickMemeberAllRequest gameKickMemeberAllRequest) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameKickMemeberAllRequest.getPlatformCode())
.systemCurrency(gameKickMemeberAllRequest.getCurrencyCode()).build());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameKickMemeberAllRequest.getPlatformCode())
// .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);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
KickMemberAllDTO kickMemberAllDTO = KickMemberAllDTO.builder()
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.currency(gameSecretKey.getCurrency())
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.currency(/*gameSecretKey.getCurrency()*/targetCurrency)
.vendor(platform)
.keyInfo(keyInfo)
.build();
if (!ObjectUtils.isEmpty(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 }
*/
@PostMapping("/cancel/free/spin")
public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest gameGetFreeSpinDashflowRequest) {
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode())
.systemCurrency(gameGetFreeSpinDashflowRequest.getCurrencyCode()).build());
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest request) {
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode())
// .systemCurrency(gameGetFreeSpinDashflowRequest.getCurrencyCode()).build());
// 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());
Boolean cancelFreeSpin = iGamesService.cancelFreeSpin(CancelFreeSpinRequestDTO.builder()
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.referenceId(gameGetFreeSpinDashflowRequest.getReferenceId())
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.referenceId(request.getReferenceId())
.vendor(platform)
.keyInfo(keyInfo)
.build());
return AjaxResult.success(cancelFreeSpin);
}
@ -498,45 +624,79 @@ public class ApiGameController extends BaseController {
/**
*
*
* @param gameExchangeBalanceAllRequest api
* @param request api
* @return {@link AjaxResult }
*/
@PostMapping("/exchange/balance/all")
public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest gameExchangeBalanceAllRequest) {
public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest request) {
TenantSecretKey tenantSecretKey = keyConfig.get();
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
.systemCurrency(gameExchangeBalanceAllRequest.getCurrencyCode()).build());
// List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
// .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<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size());
CountDownLatch latch = new CountDownLatch(keys.size());
// 使用List存储Future对象用于获取异步执行的结果
List<Future<Long>> futures = new ArrayList<>();
// 提交异步任务到线程池
for (GameSecretKeyCurrencyDTO gameSecretKeyCurrencyDTO : gameSecretKeys) {
// for (GameSecretKeyCurrencyDTO gameSecretKeyCurrencyDTO : gameSecretKeys) {
for (Key key : keys) {
futures.add(threadPoolTaskExecutor.submit(() -> {
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());
//操作第三方钱包
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
.agentId(gameSecretKeyCurrencyDTO.getCode())
.agentKey(gameSecretKeyCurrencyDTO.getKey())
.orderId(gameExchangeBalanceAllRequest.getOrderId())
.agentId(key.getCode())
.agentKey(key.getKey())
.orderId(request.getOrderId())
.amount(BigDecimal.ONE)
.currency(gameSecretKeyCurrencyDTO.getCurrency())
.currency(/*gameSecretKeyCurrencyDTO.getCurrency()*/key.currency)
.tenantKey(tenantSecretKey.getTenantKey())
.account(member.getGameAccount())
.vendor(key.getPlatform())
.keyInfo(key.getKeyInfo())
.transferType(TransferType.ALL.getCode())
.build();
return iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
@ -571,7 +731,7 @@ public class ApiGameController extends BaseController {
tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder()
.platformCode(gameExchangeMoney.getPlatformCode())
.currencyCode(gameExchangeMoney.getCurrencyCode())
.sourceId(gameExchangeBalanceAllRequest.getOrderId())
.sourceId(request.getOrderId())
.transferType(TransferType.ALL.getCode())
.amount(gameExchangeMoney.getBalance())
.account(member.getMemberAccount())
@ -593,33 +753,54 @@ public class ApiGameController extends BaseController {
/**
*
*
* @param gameDemoLoginRequest
* @param request
* @return {@link AjaxResult }
*/
@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());
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
//GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
//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()
.platformCode(gamePlatform.getPlatformCode())
.systemLangCode(gameDemoLoginRequest.getLangCode())
.build());
ApiException.notNull(gameSecretKeyLangDTO, ErrorCode.LANG_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());
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()
.gameId(game.getGameCode())
.gameType(game.getGameSourceType())
.lang(gameSecretKeyLangDTO.getLang())
.lang(/*gameSecretKeyLangDTO.getLang()*/targetLang)
.vendor(platform)
.keyInfo(keyInfo)
.build();
GameDemoLoginResponseDTO gameDemoLoginResponseDTO = iGamesService.gameDemoLogin(gamesLogin);
@ -627,4 +808,14 @@ public class ApiGameController extends BaseController {
BeanUtils.copyProperties(gameDemoLoginResponseDTO, 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.domain.AjaxResult;
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.BaseException;
import com.ff.base.utils.StringUtils;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.utils.StringUtils;
import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService;
import com.ff.game.api.request.*;
import com.ff.game.domain.GameSecretKey;
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
import com.ff.game.service.IGameSecretKeyCurrencyService;
import com.ff.game.service.IGameSecretKeyService;
import com.ff.game.service.IGameService;
import com.ff.game.api.request.CreateMemberRequestDTO;
import com.ff.game.api.request.MemberInfoRequestDTO;
import com.ff.game.api.request.MemberInfoResponseDTO;
import com.ff.game.domain.KeyInfo;
import com.ff.game.domain.Platform;
import com.ff.game.service.IPlatformService;
import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
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.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
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 java.math.BigDecimal;
@ -58,31 +62,21 @@ import java.util.concurrent.Future;
@Slf4j
public class ApiMemberController extends BaseController {
@Autowired
private Map<String, IGamesService> gamesService;
@Resource
private IGameService gameService;
@Resource
private KeyConfig keyConfig;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource
private IMemberService memberService;
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Resource
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
private IPlatformService platformService;
/**
*
@ -98,24 +92,38 @@ public class ApiMemberController extends BaseController {
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
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());
// 获取用户信息
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());
}
//注册本地账号
Member member = Member.builder()
.tenantKey(tenantSecretKey.getTenantKey())
@ -130,11 +138,13 @@ public class ApiMemberController extends BaseController {
//向第三方注册账号
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
.account(gameAccount)
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.agentId(keyInfo.getCode())
.agentKey(keyInfo.getKey())
.betLimit(memberCreateApiRequest.getBetLimit())
.platformType(memberCreateApiRequest.getPlatformType())
.currency(gameSecretKey.getCurrency())
.currency(targetCurrency)
.vendor(platform)
.keyInfo(keyInfo)
.build();
Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
Assert.isTrue(result, "建立游戏账号失败");
@ -146,35 +156,51 @@ public class ApiMemberController extends BaseController {
/**
*
*
* @param memberInfoApiRequest api
* @param request api
* @return {@link AjaxResult }
*/
@PostMapping("/info")
public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest memberInfoApiRequest) {
IGamesService iGamesService = gamesService.get(memberInfoApiRequest.getPlatformCode() + Constants.SERVICE);
public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest request) {
IGamesService iGamesService = gamesService.get(request.getPlatformCode() + Constants.SERVICE);
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.platformCode(memberInfoApiRequest.getPlatformCode())
.systemCurrency(memberInfoApiRequest.getCurrencyCode()).build());
// GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
// .platformCode(memberInfoApiRequest.getPlatformCode())
// .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());
//向第三方查询账号
MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder()
.accounts(member.getGameAccount())
.agentId(gameSecretKey.getCode())
.currency(gameSecretKey.getCurrency())
.agentKey(gameSecretKey.getKey())
.agentId(keyInfo.getCode())
.currency(targetCurrency)
.agentKey(keyInfo.getKey())
.vendor(platform)
.keyInfo(keyInfo)
.build();
MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO);
MemberInfoResponse memberInfoResponse = new MemberInfoResponse();
@ -193,22 +219,49 @@ public class ApiMemberController extends BaseController {
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;
}
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
.systemCurrency(memberInfoAllApiRequest.getCurrencyCode()).build());
Key key = new Key();
key.setPlatformCode(platform.getPlatformCode());
key.setCode(keyInfo.getCode());
key.setKey(keyInfo.getKey());
key.setCurrency(targetCurrency);
keys.add(key);
}
// 创建线程池
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size());
CountDownLatch latch = new CountDownLatch(keys.size());
// 使用List存储Future对象用于获取异步执行的结果
List<Future<MemberInfoAllResponse>> futures = new ArrayList<>();
// 提交异步任务到线程池
for (GameSecretKeyCurrencyDTO gameSecretKey : gameSecretKeys) {
for (Key gameSecretKey : keys) {
futures.add(threadPoolTaskExecutor.submit(() -> {
try {
IGamesService iGamesService = gamesService.get(gameSecretKey.getPlatformCode() + Constants.SERVICE);
@ -256,5 +309,12 @@ public class ApiMemberController extends BaseController {
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;
/**
*
*/
@NotBlank(message = "currencyCode不能为空")
@Length(max = 32, message = "currencyCode长度不能超过32个字符")
private String currencyCode;
}

View File

@ -76,10 +76,6 @@ public class MeiTianGameServiceImpl implements IGamesService {
@Resource
private IMemberService memberService;
@Resource
private IGameSecretKeyService gameSecretKeyService;
@Resource
private MeiTianClient meiTianClient;
@ -112,11 +108,10 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/
@Override
public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(createMemberRequestDTO.getAgentId());
String playerName = createMemberRequestDTO.getAccount();
String merchantId = createMemberRequestDTO.getAgentId();
String md5Password = Md5Utils.md5New(gameSecretKey.getPassword());
String md5Password = Md5Utils.md5New(createMemberRequestDTO.getKeyInfo().getPassword());
Map<String, String> rawMap = new LinkedHashMap<>();
rawMap.put("nickname", createMemberRequestDTO.getAccount());
rawMap.put("playerLevel", "0");
@ -128,7 +123,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
log.error("[MeiTian] encode rawData failure", e);
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 =
meiTianClient.createMember(
playerName,
@ -181,11 +176,10 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/
@Override
public String loginWithoutRedirect(GamesLogin gamesLogin) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(gamesLogin.getAgentId());
String merchantId = gamesLogin.getAgentId();
String playerName = gamesLogin.getAccount();
String md5Password = Md5Utils.md5New(gameSecretKey.getPassword());
String md5Password = Md5Utils.md5New(gamesLogin.getKeyInfo().getPassword());
Map<String, String> rawMap = new LinkedHashMap<>();
/*rawMap.put("gameHall ", gamesLogin.getGameType());*/
rawMap.put("gameCode", gamesLogin.getGameId());
@ -200,7 +194,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
log.error("[MeiTian] encode rawData failure", e);
throw new ApiException(ErrorCode.ERROR.getCode());
}
String code = Md5Utils.md5New(gameSecretKey.getKey() + rawData);
String code = Md5Utils.md5New(gamesLogin.getKeyInfo().getKey() + rawData);
MeiTianLoginResultDTO loginWithoutRedirectResponseDTO =
meiTianClient.loginWithoutRedirect(
merchantId,
@ -238,12 +232,12 @@ public class MeiTianGameServiceImpl implements IGamesService {
for (MeiTianGameDataDTO gamesDataDTO : gameList.getData()) {
GamePlatform gamePlatform = GamePlatform.builder()
.platformType(MeiTianGameType.findSystemByCode(gamesDataDTO.getGameCategoryId()))
.platformCode(GamePlatforms.MeiTian.getCode())
.platformCode(GamePlatforms.MT.getCode())
.build();
List<GamePlatform> gamePlatforms = gamePlatformService.selectGamePlatformList(gamePlatform);
//没有此平台就新增一个平台
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.setCreateBy(Constants.SYSTEM);
gamePlatformService.insertGamePlatform(gamePlatform);
@ -309,7 +303,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.currency(exchangeTransferMoneyRequestDTO.getCurrency()).build());
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(
GameExchangeMoney.builder()
@ -331,7 +325,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.currencyCode(gameSecretKey.getSystemCurrency())
.memberId(member.getId())
.transactionId(transactionId)
.platformCode(GamePlatforms.MeiTian.getCode())
.platformCode(GamePlatforms.MT.getCode())
.build();
exchangeMoney.setCreateBy(Constants.SYSTEM);
//接口限制限制50字符
@ -439,7 +433,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
}
boolean doSyncRecordByRecordID(BetRecordByTimeDTO betRecordByTimeDTO) {
String configKey = GamePlatforms.MeiTian.getCode() + ":lastRecordID";
String configKey = GamePlatforms.MT.getCode() + ":lastRecordID";
String lastRecordID = sysConfigServiceImpl.selectConfigByKey(configKey);
long recordID = 0;
if (lastRecordID == null || lastRecordID.isEmpty()) {
@ -496,7 +490,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO, int daysToSubtract) {
String date = getDateStr(daysToSubtract);
String configKey = GamePlatforms.MeiTian.getCode() + ":lastSyncDate";
String configKey = GamePlatforms.MT.getCode() + ":lastSyncDate";
String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey);
Map<String, Long> syncDateMap = new HashMap<>();
long recordID = 0;
@ -597,9 +591,8 @@ public class MeiTianGameServiceImpl implements IGamesService {
*/
@Override
public GetGameDetailResponseDTO getGameDetail(GetGameDetailRequestDTO getGameDetailRequestDTO) {
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(getGameDetailRequestDTO.getAgentId());
String key = gameSecretKey.getKey();
String key = getGameDetailRequestDTO.getKeyInfo().getKey();
String merchantId = getGameDetailRequestDTO.getAgentId();
Map<String, String> rawMap = new LinkedHashMap<>();
rawMap.put("rowID", getGameDetailRequestDTO.getWagersId());
@ -721,7 +714,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
}
if (!CollectionUtils.isEmpty(gameBettingDetails)) {
//查询重复数据id
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds, GamePlatforms.MeiTian.getCode());
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds, GamePlatforms.MT.getCode());
//用steam流清除list中与wagersIds集合相同的数据
gameBettingDetails = gameBettingDetails.stream()
.filter(detail -> !removeWagersIds.contains(detail.getWagersId()))
@ -747,7 +740,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
GameSecretKeyCurrencyDTO gameSecretKey =
gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
.currency(dataBean.getCurrency())
.platformCode(GamePlatforms.MeiTian.getCode()).build());
.platformCode(GamePlatforms.MT.getCode()).build());
Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName());
@ -769,7 +762,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
.memberId(member.getId())
.gameCode(dataBean.getGameCode())
.gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameType())))
.platformCode(GamePlatforms.MeiTian.getCode())
.platformCode(GamePlatforms.MT.getCode())
.gameId(gamesDataDTO.getSystemGameId())
.gameName(gamesDataDTO.getCnName())
.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.NumberUtil;
import com.ff.base.config.RedisConfig;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
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.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.SleepUtil;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.config.KeyConfig;
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.dto.*;
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.dto.*;
import com.ff.game.service.*;
@ -42,15 +36,12 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -228,7 +219,7 @@ public class GamesPGServiceImpl implements IGamesService {
paramsMap.put("lang", gamesLogin.getLang());
paramsMap.put("gameCode", gamesLogin.getGameId());
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);
ApiNGResponseDTO<ApiLoginResponseDTO> apiLoginResponseDTOApiNGResponseDTO = ngClient.loginWithoutRedirect(paramsMap, headerMap);
if (this.getIsSuccess(apiLoginResponseDTOApiNGResponseDTO.getCode())) {

View File

@ -1,7 +1,8 @@
package com.ff.game.api.request;
import com.ff.game.domain.KeyInfo;
import com.ff.game.domain.Platform;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@ -36,12 +37,14 @@ public class GamesBaseRequestDTO implements Serializable {
private String query;
/**
*
*/
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.utils.DateUtils;
import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.config.KeyConfig;
@ -210,7 +209,7 @@ public class GamesXKServiceImpl implements IGamesService {
params.put("key", key);
params.put("disableFullScreen", gamesLogin.getDisableFullScreen());
params.put("homeUrl", gamesLogin.getHomeUrl());
params.put("platform", gamesLogin.getPlatform());
params.put("platform", gamesLogin.getVendor());
XKLoginWithoutRedirectResponseDTO xkLoginWithoutRedirectResponseDTO = xkClient.loginWithoutRedirect(params);
//判断是否获取成功
if (this.getIsSuccess(xkLoginWithoutRedirectResponseDTO.getCode())) {

View File

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

View File

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