2025-02-11 15:27:15 +08:00
|
|
|
|
package com.ff.api.controller;
|
|
|
|
|
|
|
|
|
|
|
2025-02-12 13:42:52 +08:00
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import com.ff.annotation.CheckHeader;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import com.ff.api.request.*;
|
2025-02-18 11:24:27 +08:00
|
|
|
|
import com.ff.api.response.*;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import com.ff.base.constant.Constants;
|
|
|
|
|
import com.ff.base.core.controller.BaseController;
|
|
|
|
|
import com.ff.base.core.domain.AjaxResult;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import com.ff.base.core.page.TableDataInfo;
|
2025-02-21 14:39:21 +08:00
|
|
|
|
import com.ff.base.enums.*;
|
2025-02-19 16:41:44 +08:00
|
|
|
|
import com.ff.base.exception.base.ApiException;
|
2025-02-14 17:31:52 +08:00
|
|
|
|
import com.ff.base.exception.base.BaseException;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import com.ff.base.utils.StringUtils;
|
2025-02-13 16:52:54 +08:00
|
|
|
|
import com.ff.base.utils.bean.BeanUtils;
|
2025-02-25 10:05:13 +08:00
|
|
|
|
import com.ff.base.system.domain.TenantSecretKey;
|
2025-02-21 14:39:21 +08:00
|
|
|
|
import com.ff.common.dto.GameBalanceExchange;
|
2025-02-12 13:42:52 +08:00
|
|
|
|
import com.ff.common.service.ITenantGameQuotaFlowService;
|
|
|
|
|
import com.ff.common.service.ITenantGameQuotaService;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import com.ff.config.KeyConfig;
|
|
|
|
|
import com.ff.game.api.IGamesService;
|
2025-02-12 13:42:52 +08:00
|
|
|
|
import com.ff.game.api.request.*;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import com.ff.game.domain.*;
|
2025-03-14 13:31:17 +08:00
|
|
|
|
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
|
|
|
|
|
import com.ff.game.dto.GameSecretKeyLangDTO;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import com.ff.game.service.*;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import com.ff.member.domain.Member;
|
|
|
|
|
import com.ff.member.service.IMemberService;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import com.github.pagehelper.PageHelper;
|
2025-02-14 17:31:52 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2025-02-14 17:31:52 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
2025-02-12 13:42:52 +08:00
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import org.springframework.util.Assert;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
import org.springframework.util.ObjectUtils;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
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;
|
2025-02-12 13:42:52 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2025-02-14 17:31:52 +08:00
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
import java.util.concurrent.Future;
|
2025-02-17 11:28:17 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* api控制器
|
|
|
|
|
*
|
|
|
|
|
* @author shi
|
|
|
|
|
* @date 2025/02/10
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@CheckHeader
|
|
|
|
|
@RequestMapping("/api/game")
|
2025-02-14 17:31:52 +08:00
|
|
|
|
@Slf4j
|
2025-02-11 15:27:15 +08:00
|
|
|
|
public class ApiGameController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private Map<String, IGamesService> gamesService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IGameService gameService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private KeyConfig keyConfig;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IGameSecretKeyService gameSecretKeyService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IMemberService memberService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IGamePlatformService gamePlatformService;
|
|
|
|
|
|
|
|
|
|
|
2025-02-12 13:42:52 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private ITenantGameQuotaService tenantGameQuotaService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ITenantGameQuotaFlowService tenantGameQuotaFlowService;
|
|
|
|
|
|
2025-02-13 15:43:13 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private IGameBettingDetailsService gameBettingDetailsService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IGameFreeRecordService gameFreeRecordService;
|
2025-02-13 16:52:54 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private IGameExchangeMoneyService gameExchangeMoneyService;
|
2025-02-12 13:42:52 +08:00
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IGameSecretKeyLangService gameSecretKeyLangService;
|
|
|
|
|
|
2025-02-14 17:31:52 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
@Qualifier("threadPoolTaskExecutor")
|
|
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
|
|
|
2025-02-17 11:28:17 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
*
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public AjaxResult list() {
|
|
|
|
|
List<GameResponse> gameResponses = gameService.selectGameResponseList();
|
|
|
|
|
for (GameResponse gameRespons : gameResponses) {
|
2025-03-14 13:31:17 +08:00
|
|
|
|
|
|
|
|
|
List<GameSecretKeyCurrency> gameSecretKeyCurrencies = gameSecretKeyCurrencyService.selectGameSecretKeyCurrencyList(GameSecretKeyCurrencyDTO.builder().platformCode(gameRespons.getPlatformCode()).build());
|
|
|
|
|
List<String> currencyCode = gameSecretKeyCurrencies.stream().map(GameSecretKeyCurrency::getSystemCurrency).collect(Collectors.toList());
|
2025-02-17 11:28:17 +08:00
|
|
|
|
gameRespons.setCurrencyCode(currencyCode);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(gameResponses);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 15:27:15 +08:00
|
|
|
|
/**
|
|
|
|
|
* 登录
|
|
|
|
|
*
|
|
|
|
|
* @param memberCreateApiRequest 成员创建api请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/login")
|
|
|
|
|
public AjaxResult login(@Validated @RequestBody GameLoginRequest memberCreateApiRequest) {
|
|
|
|
|
|
|
|
|
|
Game game = gameService.selectGameById(memberCreateApiRequest.getGameId());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
|
|
|
|
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gamePlatform.getPlatformCode() + Constants.SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
2025-03-14 13:31:17 +08:00
|
|
|
|
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());
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
|
|
|
|
GamesLogin gamesLogin = GamesLogin.builder()
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.agentId(secretKeyCurrencyDTO.getCode())
|
|
|
|
|
.agentKey(secretKeyCurrencyDTO.getKey())
|
2025-02-11 15:27:15 +08:00
|
|
|
|
.account(member.getGameAccount())
|
2025-03-12 17:55:57 +08:00
|
|
|
|
.gameType(game.getGameSourceType())
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.currency(secretKeyCurrencyDTO.getCurrency())
|
2025-02-11 15:27:15 +08:00
|
|
|
|
.gameId(game.getGameCode())
|
|
|
|
|
.homeUrl(memberCreateApiRequest.getHomeUrl())
|
|
|
|
|
.platform(memberCreateApiRequest.getPlatform())
|
|
|
|
|
.disableFullScreen(memberCreateApiRequest.getDisableFullScreen())
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.lang(gameSecretKeyLangDTO.getLang())
|
2025-02-11 15:27:15 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
String login = iGamesService.loginWithoutRedirect(gamesLogin);
|
|
|
|
|
|
2025-02-17 11:28:17 +08:00
|
|
|
|
return AjaxResult.success("操作成功", login);
|
2025-02-11 15:27:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-02-12 13:42:52 +08:00
|
|
|
|
/**
|
|
|
|
|
* 汇兑差额
|
|
|
|
|
*
|
|
|
|
|
* @param gameExchangeBalanceRequest 游戏兑换余额请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/exchange/balance")
|
|
|
|
|
@Transactional
|
|
|
|
|
public AjaxResult exchangeBalance(@Validated @RequestBody GameExchangeBalanceRequest gameExchangeBalanceRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameExchangeBalanceRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-21 14:39:21 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
2025-02-12 13:42:52 +08:00
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
2025-02-21 14:39:21 +08:00
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameExchangeBalanceRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameExchangeBalanceRequest.getCurrencyCode()).build());
|
|
|
|
|
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-12 13:42:52 +08:00
|
|
|
|
|
2025-02-21 14:39:21 +08:00
|
|
|
|
BigDecimal quota = tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder()
|
|
|
|
|
.platformCode(gameExchangeBalanceRequest.getPlatformCode())
|
2025-02-27 16:26:02 +08:00
|
|
|
|
.sourceId(gameExchangeBalanceRequest.getOrderId())
|
2025-02-21 14:39:21 +08:00
|
|
|
|
.currencyCode(gameExchangeBalanceRequest.getCurrencyCode())
|
|
|
|
|
.transferType(gameExchangeBalanceRequest.getTransferType())
|
|
|
|
|
.amount(gameExchangeBalanceRequest.getAmount())
|
|
|
|
|
.account(gameExchangeBalanceRequest.getAccount())
|
2025-02-12 13:42:52 +08:00
|
|
|
|
.tenantKey(tenantSecretKey.getTenantKey())
|
|
|
|
|
.build());
|
|
|
|
|
|
2025-02-21 14:39:21 +08:00
|
|
|
|
// 获取用户信息
|
|
|
|
|
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameExchangeBalanceRequest.getAccount(), gameExchangeBalanceRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
|
2025-02-12 13:42:52 +08:00
|
|
|
|
|
2025-02-21 14:39:21 +08:00
|
|
|
|
|
|
|
|
|
//操作第三方额度接口
|
2025-02-12 13:42:52 +08:00
|
|
|
|
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
2025-02-22 10:58:23 +08:00
|
|
|
|
.orderId(gameExchangeBalanceRequest.getOrderId())
|
2025-02-12 13:42:52 +08:00
|
|
|
|
.account(member.getGameAccount())
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.currency(gameSecretKey.getCurrency())
|
2025-02-14 17:31:52 +08:00
|
|
|
|
.tenantKey(tenantSecretKey.getTenantKey())
|
2025-02-21 14:39:21 +08:00
|
|
|
|
.quota(quota)
|
2025-02-12 13:42:52 +08:00
|
|
|
|
.amount(gameExchangeBalanceRequest.getAmount())
|
|
|
|
|
.transferType(gameExchangeBalanceRequest.getTransferType())
|
|
|
|
|
.build();
|
2025-02-13 16:52:54 +08:00
|
|
|
|
Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
|
|
|
|
|
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId);
|
2025-02-14 17:31:52 +08:00
|
|
|
|
GameExchangeBalanceResponse gameExchangeBalanceResponse = new GameExchangeBalanceResponse();
|
|
|
|
|
BeanUtils.copyProperties(gameExchangeMoney, gameExchangeBalanceResponse);
|
2025-02-13 16:52:54 +08:00
|
|
|
|
return AjaxResult.success(gameExchangeBalanceResponse);
|
2025-02-12 13:42:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 15:27:15 +08:00
|
|
|
|
|
2025-02-13 15:43:13 +08:00
|
|
|
|
/**
|
|
|
|
|
* 赠送免费局数
|
|
|
|
|
*
|
|
|
|
|
* @param gameCreateFreeSpinRequest 游戏创建免费旋转请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/create/free/spin")
|
|
|
|
|
public AjaxResult createFreeSpin(@Validated @RequestBody GameCreateFreeSpinRequest gameCreateFreeSpinRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameCreateFreeSpinRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
2025-03-14 13:31:17 +08:00
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameCreateFreeSpinRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameCreateFreeSpinRequest.getCurrencyCode()).build());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameCreateFreeSpinRequest.getAccount(), gameCreateFreeSpinRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
CreateFreeSpinRequestDTO createFreeSpinRequestDTO = CreateFreeSpinRequestDTO.builder()
|
|
|
|
|
.account(member.getGameAccount())
|
|
|
|
|
.currency(gameCreateFreeSpinRequest.getCurrencyCode())
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
|
|
|
|
.referenceId(gameCreateFreeSpinRequest.getReferenceId())
|
|
|
|
|
.freeSpinValidity(gameCreateFreeSpinRequest.getFreeSpinValidity())
|
|
|
|
|
.numberOfRounds(gameCreateFreeSpinRequest.getNumberOfRounds())
|
|
|
|
|
.gameIds(gameCreateFreeSpinRequest.getGameIds())
|
|
|
|
|
.betValue(gameCreateFreeSpinRequest.getBetValue())
|
|
|
|
|
.startTime(gameCreateFreeSpinRequest.getStartTime())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(iGamesService.createFreeSpin(createFreeSpinRequestDTO));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取投注记录
|
|
|
|
|
*
|
|
|
|
|
* @param gameCreateFreeSpinRequest 游戏创建免费旋转请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/get/bet/record")
|
2025-02-14 17:31:52 +08:00
|
|
|
|
public TableDataInfo getBetRecord(@Validated @RequestBody GameGetBetRecordRequest gameCreateFreeSpinRequest) {
|
2025-02-17 15:03:59 +08:00
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
|
|
|
|
|
2025-02-13 15:43:13 +08:00
|
|
|
|
startPage();
|
|
|
|
|
PageHelper.startPage(gameCreateFreeSpinRequest.getPageNo(), gameCreateFreeSpinRequest.getPageSize(), "wagers_time desc");
|
|
|
|
|
GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
|
|
|
|
|
.platformCode(gameCreateFreeSpinRequest.getPlatformCode())
|
|
|
|
|
.currencyCode(gameCreateFreeSpinRequest.getCurrencyCode())
|
2025-02-17 15:03:59 +08:00
|
|
|
|
.tenantKey(tenantSecretKey.getTenantKey())
|
2025-02-13 15:43:13 +08:00
|
|
|
|
.build();
|
|
|
|
|
Map<String, Object> params = gameBettingDetails.getParams();
|
|
|
|
|
params.put("beginTime", gameCreateFreeSpinRequest.getBeginTime());
|
|
|
|
|
params.put("endTime", gameCreateFreeSpinRequest.getEndTime());
|
|
|
|
|
List<GameBettingDetails> bettingDetails = gameBettingDetailsService.selectGameBettingDetailsList(gameBettingDetails);
|
2025-02-17 15:03:59 +08:00
|
|
|
|
TableDataInfo dataTable = getDataTable(bettingDetails);
|
2025-02-21 14:39:21 +08:00
|
|
|
|
List<GameBettingDetailsResponse> result = new ArrayList<>();
|
2025-02-17 15:03:59 +08:00
|
|
|
|
for (GameBettingDetails row : (List<GameBettingDetails>) dataTable.getRows()) {
|
2025-02-21 14:39:21 +08:00
|
|
|
|
GameBettingDetailsResponse gameBettingDetailsResponse = new GameBettingDetailsResponse();
|
2025-02-17 15:03:59 +08:00
|
|
|
|
BeanUtils.copyProperties(row, gameBettingDetailsResponse);
|
|
|
|
|
Member member = memberService.selectMemberById(row.getMemberId());
|
|
|
|
|
gameBettingDetailsResponse.setAccount(member.getMemberAccount());
|
|
|
|
|
result.add(gameBettingDetailsResponse);
|
|
|
|
|
}
|
|
|
|
|
dataTable.setRows(result);
|
|
|
|
|
|
|
|
|
|
return dataTable;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取详细信息
|
|
|
|
|
*
|
|
|
|
|
* @param gameGetDetailRequest 游戏获取详细信息请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/get/detail")
|
|
|
|
|
public AjaxResult getDetail(@Validated @RequestBody GameGetDetailRequest gameGetDetailRequest) {
|
|
|
|
|
|
2025-02-18 11:24:27 +08:00
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
|
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameGetDetailRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameGetDetailRequest.getCurrencyCode()).build());
|
|
|
|
|
|
|
|
|
|
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameGetDetailRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GameSecretKeyLangDTO gameSecretKeyLang = gameSecretKeyLangService.findGameSecretKeyLangDTO(GameSecretKeyLangDTO.builder()
|
|
|
|
|
.platformCode(gameGetDetailRequest.getPlatformCode())
|
|
|
|
|
.systemLangCode(gameGetDetailRequest.getLangCode())
|
|
|
|
|
.build());
|
|
|
|
|
ApiException.notNull(gameSecretKeyLang, ErrorCode.LANG_NOT_EXIST.getCode());
|
|
|
|
|
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetGameDetailResponseDTO gameDetail = iGamesService.getGameDetail(GetGameDetailRequestDTO.builder()
|
|
|
|
|
.wagersId(gameGetDetailRequest.getWagersId())
|
|
|
|
|
.lang(gameSecretKeyLang.getLang())
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
|
|
|
|
.build());
|
|
|
|
|
return AjaxResult.success(gameDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 踢腿队员
|
|
|
|
|
*
|
|
|
|
|
* @param gameKickMemeberRequest 游戏踢迷请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/kick/member")
|
|
|
|
|
public AjaxResult kickMember(@Validated @RequestBody GameKickMemeberRequest gameKickMemeberRequest) {
|
2025-03-14 13:31:17 +08:00
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameKickMemeberRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameKickMemeberRequest.getCurrencyCode()).build());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
|
|
|
|
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameKickMemeberRequest.getAccount(), gameKickMemeberRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameKickMemeberRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(iGamesService.kickMember(KickMemberRequestDTO.builder()
|
|
|
|
|
.account(member.getGameAccount())
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
|
|
|
|
.build()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/kick/member/all")
|
|
|
|
|
public AjaxResult kickMemberAll(@Validated @RequestBody GameKickMemeberAllRequest gameKickMemeberAllRequest) {
|
2025-03-14 13:31:17 +08:00
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameKickMemeberAllRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameKickMemeberAllRequest.getCurrencyCode()).build());
|
|
|
|
|
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameKickMemeberAllRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
KickMemberAllDTO kickMemberAllDTO = KickMemberAllDTO.builder()
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
|
|
|
|
.build();
|
|
|
|
|
if (!ObjectUtils.isEmpty(gameKickMemeberAllRequest.getGameId())) {
|
|
|
|
|
Game game = gameService.selectGameById(gameKickMemeberAllRequest.getGameId());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
kickMemberAllDTO.setGameId(game.getGameCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(iGamesService.kickMemberAll(kickMemberAllDTO));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得自由旋转气流
|
|
|
|
|
*
|
|
|
|
|
* @param gameGetFreeSpinDashflowRequest 游戏获得免费旋转dashflow请求
|
|
|
|
|
* @return {@link TableDataInfo }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/get/free/spin/dashflow")
|
|
|
|
|
public TableDataInfo getFreeSpinDashflow(@Validated @RequestBody GameGetFreeSpinDashflowRequest gameGetFreeSpinDashflowRequest) {
|
|
|
|
|
PageHelper.startPage(gameGetFreeSpinDashflowRequest.getPageNo(), gameGetFreeSpinDashflowRequest.getPageSize(), "free_update_time desc");
|
2025-02-18 11:24:27 +08:00
|
|
|
|
GameFreeRecord gameFreeRecord = GameFreeRecord.builder()
|
2025-02-13 15:43:13 +08:00
|
|
|
|
.gameId(gameGetFreeSpinDashflowRequest.getGameId())
|
|
|
|
|
.platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode())
|
|
|
|
|
.currencyCode(gameGetFreeSpinDashflowRequest.getCurrencyCode())
|
2025-02-18 11:24:27 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = gameFreeRecord.getParams();
|
|
|
|
|
params.put("beginTime", gameGetFreeSpinDashflowRequest.getBeginTime());
|
|
|
|
|
params.put("endTime", gameGetFreeSpinDashflowRequest.getEndTime());
|
|
|
|
|
List<GameFreeRecord> gameFreeRecords = gameFreeRecordService.selectGameFreeRecordList(gameFreeRecord);
|
|
|
|
|
TableDataInfo dataTable = getDataTable(gameFreeRecords);
|
2025-02-21 14:39:21 +08:00
|
|
|
|
List<GameFreeRecordResponse> result = new ArrayList<>();
|
2025-02-18 11:24:27 +08:00
|
|
|
|
for (GameFreeRecord row : (List<GameFreeRecord>) dataTable.getRows()) {
|
2025-02-21 14:39:21 +08:00
|
|
|
|
GameFreeRecordResponse gameFreeRecordResponse = new GameFreeRecordResponse();
|
2025-02-18 11:24:27 +08:00
|
|
|
|
BeanUtils.copyProperties(row, gameFreeRecordResponse);
|
|
|
|
|
Member member = memberService.selectMemberById(row.getMemberId());
|
|
|
|
|
gameFreeRecordResponse.setMemberAccount(member.getMemberAccount());
|
|
|
|
|
result.add(gameFreeRecordResponse);
|
|
|
|
|
}
|
|
|
|
|
dataTable.setRows(result);
|
|
|
|
|
return dataTable;
|
2025-02-13 15:43:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 取消自由旋转
|
|
|
|
|
*
|
|
|
|
|
* @param gameGetFreeSpinDashflowRequest 游戏获得免费旋转dashflow请求
|
|
|
|
|
* @return {@link TableDataInfo }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/cancel/free/spin")
|
|
|
|
|
public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest gameGetFreeSpinDashflowRequest) {
|
2025-03-14 13:31:17 +08:00
|
|
|
|
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.platformCode(gameGetFreeSpinDashflowRequest.getPlatformCode())
|
|
|
|
|
.systemCurrency(gameGetFreeSpinDashflowRequest.getCurrencyCode()).build());
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
IGamesService iGamesService = gamesService.get(gameGetFreeSpinDashflowRequest.getPlatformCode() + Constants.SERVICE);
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
2025-02-13 15:43:13 +08:00
|
|
|
|
|
|
|
|
|
Boolean cancelFreeSpin = iGamesService.cancelFreeSpin(CancelFreeSpinRequestDTO.builder()
|
|
|
|
|
.agentId(gameSecretKey.getCode())
|
|
|
|
|
.agentKey(gameSecretKey.getKey())
|
|
|
|
|
.referenceId(gameGetFreeSpinDashflowRequest.getReferenceId())
|
|
|
|
|
.build());
|
|
|
|
|
return AjaxResult.success(cancelFreeSpin);
|
|
|
|
|
}
|
2025-02-14 17:31:52 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 信息全部
|
|
|
|
|
*
|
|
|
|
|
* @param gameExchangeBalanceAllRequest 成员信息所有api请求
|
|
|
|
|
* @return {@link AjaxResult }
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/exchange/balance/all")
|
|
|
|
|
public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest gameExchangeBalanceAllRequest) {
|
|
|
|
|
|
|
|
|
|
TenantSecretKey tenantSecretKey = keyConfig.get();
|
|
|
|
|
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameExchangeBalanceAllRequest.getAccount(), gameExchangeBalanceAllRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
|
2025-02-19 16:41:44 +08:00
|
|
|
|
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
2025-02-14 17:31:52 +08:00
|
|
|
|
|
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
|
|
|
|
|
.systemCurrency(gameExchangeBalanceAllRequest.getCurrencyCode()).build());
|
2025-02-14 17:31:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建线程池
|
|
|
|
|
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size());
|
|
|
|
|
|
|
|
|
|
// 使用List存储Future对象,用于获取异步执行的结果
|
|
|
|
|
List<Future<Long>> futures = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 提交异步任务到线程池
|
2025-03-14 13:31:17 +08:00
|
|
|
|
for (GameSecretKeyCurrencyDTO gameSecretKeyCurrencyDTO : gameSecretKeys) {
|
2025-02-14 17:31:52 +08:00
|
|
|
|
futures.add(threadPoolTaskExecutor.submit(() -> {
|
|
|
|
|
try {
|
|
|
|
|
|
2025-03-14 13:31:17 +08:00
|
|
|
|
IGamesService iGamesService = gamesService.get(gameSecretKeyCurrencyDTO.getPlatformCode() + Constants.SERVICE);
|
2025-02-14 17:31:52 +08:00
|
|
|
|
//操作第三方钱包
|
|
|
|
|
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.agentId(gameSecretKeyCurrencyDTO.getCode())
|
|
|
|
|
.agentKey(gameSecretKeyCurrencyDTO.getKey())
|
2025-02-22 10:58:23 +08:00
|
|
|
|
.orderId(gameExchangeBalanceAllRequest.getOrderId())
|
2025-02-14 17:31:52 +08:00
|
|
|
|
.amount(BigDecimal.ONE)
|
2025-03-14 13:31:17 +08:00
|
|
|
|
.currency(gameSecretKeyCurrencyDTO.getCurrency())
|
2025-02-14 17:31:52 +08:00
|
|
|
|
.tenantKey(tenantSecretKey.getTenantKey())
|
|
|
|
|
.account(member.getGameAccount())
|
|
|
|
|
.transferType(TransferType.ALL.getCode())
|
|
|
|
|
.build();
|
|
|
|
|
return iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return 0L;
|
|
|
|
|
} finally {
|
|
|
|
|
latch.countDown(); // 任务完成后减少计数
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal balanceAll = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 等待所有线程执行完毕
|
|
|
|
|
latch.await();
|
|
|
|
|
// 获取每个Future的结果
|
|
|
|
|
for (Future<Long> future : futures) {
|
|
|
|
|
// 汇总结果
|
|
|
|
|
Long id = future.get();
|
|
|
|
|
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(id);
|
|
|
|
|
if (ObjectUtils.isEmpty(gameExchangeMoney)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
balanceMap.put(gameExchangeMoney.getPlatformCode(), gameExchangeMoney.getBalance());
|
|
|
|
|
BigDecimal balance = gameExchangeMoney.getBalance();
|
|
|
|
|
balanceAll = NumberUtil.add(balanceAll, balance);
|
|
|
|
|
|
2025-02-27 16:26:02 +08:00
|
|
|
|
//操作租户额度
|
2025-02-21 14:39:21 +08:00
|
|
|
|
tenantGameQuotaService.gameBalanceExchange(GameBalanceExchange.builder()
|
|
|
|
|
.platformCode(gameExchangeMoney.getPlatformCode())
|
|
|
|
|
.currencyCode(gameExchangeMoney.getCurrencyCode())
|
2025-02-27 16:26:02 +08:00
|
|
|
|
.sourceId(gameExchangeBalanceAllRequest.getOrderId())
|
2025-02-21 14:39:21 +08:00
|
|
|
|
.transferType(TransferType.ALL.getCode())
|
|
|
|
|
.amount(gameExchangeMoney.getBalance())
|
|
|
|
|
.account(member.getMemberAccount())
|
2025-02-14 17:31:52 +08:00
|
|
|
|
.tenantKey(tenantSecretKey.getTenantKey())
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("拉回用户余额失败", e);
|
|
|
|
|
throw new BaseException("拉回用户余额失败");
|
|
|
|
|
}
|
|
|
|
|
balanceMap.put("balanceAll", balanceAll);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(balanceMap);
|
|
|
|
|
}
|
2025-02-11 15:27:15 +08:00
|
|
|
|
}
|