feat(game): 添加 PGT 游戏接口实现

- 新增 PGT 游戏列表获取功能- 实现 PGT 投注记录获取和处理
- 添加 PGT 成员踢出功能
- 优化 PGT 客户端接口定义
- 新增相关枚举类和数据传输对象
main-meitian
shi 2025-04-07 14:44:55 +08:00
parent 4e5fb79858
commit 905893df96
18 changed files with 480 additions and 382 deletions

View File

@ -68,6 +68,11 @@ public class CacheConstants {
*/ */
public static final String PG_GAMES = "pg_games:"; public static final String PG_GAMES = "pg_games:";
/**
* pgt
*/
public static final String PGT_GAMES = "pgt_games:";
/** /**
* fc * fc
@ -89,6 +94,12 @@ public class CacheConstants {
*/ */
public static final String PG_GAMES_BET_CURRENCY = "pg_games:bet:currency"; public static final String PG_GAMES_BET_CURRENCY = "pg_games:bet:currency";
/**
* pgtid
*/
public static final String PGT_NEXT_ID = "pgt_next:id:";
/** /**
* ae * ae
*/ */

View File

@ -0,0 +1,24 @@
package com.ff.base.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
/**
*
*
* @author shi
* @date 2025/04/07
*/
@Getter
@AllArgsConstructor
public enum PGTBetStatus {
OPEN(1, "打开 或 未结算", "OPEN"),
SETTLED(2, "已结算", "SETTLED"),
UNSETTLED(1, "未结算", "UNSETTLED"),
VOID(3, "作废 或 无效", "VOID");
private final int code;
private final String description;
private final String type;
}

View File

@ -0,0 +1,43 @@
package com.ff.base.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Optional;
import java.util.stream.Stream;
/**
* pgt
*
* @author shi
* @date 2025/04/07
*/
@Getter
@AllArgsConstructor
public enum PGTGameType {
EGAMES("EGAMES",1, "游戏老虎机"),
LIVECASINO("LIVECASINO",2, "现场赌场"),
SPORT("SPORT",8, "体育"),
POKER("POKER",2, "扑克"),
TRADING("TRADING",1, "贸易");
// 枚举字段
private final String code;
private final Integer systemCode;
private final String description;
/**
*
*
* @param code
* @return {@link Integer }
*/
public static Integer findSystemByCode(String code) {
Optional<Integer> system = Stream.of(PGTGameType.values())
.filter(gameType -> gameType.getCode().equals(code))
.map(PGTGameType::getSystemCode)
.findFirst();
return system.orElse(null);
}
}

View File

@ -0,0 +1,35 @@
package com.ff.base.enums;
import com.dtflys.forest.annotation.Get;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
/**
* pgtplayout
*
* @author shi
* @date 2025/04/07
*/
@Getter
@AllArgsConstructor
public enum PGTPayoutStatus {
LOSE("LOSE", 2, "输"),
WIN("WIN",1, "赢"),
DRAW("DRAW",3, "平"),
UNKNOWN("UNKNOWN",4, "未知");
private final String code;
private final Integer systemCode;
private final String description;
public static PGTPayoutStatus getByCode(String code) {
for (PGTPayoutStatus status : PGTPayoutStatus.values()) {
if (status.getCode().equals(code)) {
return status;
}
}
return UNKNOWN;
}
}

View File

@ -40,6 +40,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static final String ISO_8601_FORMAT= "yyyy-MM-dd'T'HH:mm:ss"; public static final String ISO_8601_FORMAT= "yyyy-MM-dd'T'HH:mm:ss";
public static final String ISO_8601_FORMAT_Z= "yyyy-MM-dd'T'HH:mm:ss'Z'";
/** /**
* Date * Date
* *

View File

@ -2,12 +2,14 @@ package com.ff.game.api.pgt.client;
import com.dtflys.forest.annotation.*; import com.dtflys.forest.annotation.*;
import com.ff.game.api.dg.dto.DGResponse; import com.ff.game.api.dg.dto.DGResponse;
import com.ff.game.api.fc.dto.ApiFCGameListResponseDTO;
import com.ff.game.api.jili.dto.JILIKickMemberAllDTO; import com.ff.game.api.jili.dto.JILIKickMemberAllDTO;
import com.ff.game.api.jili.dto.JILIKickMemberDTO; import com.ff.game.api.jili.dto.JILIKickMemberDTO;
import com.ff.game.api.ng.dto.ApiExchangeTransferStatusResponseDTO; import com.ff.game.api.ng.dto.ApiExchangeTransferStatusResponseDTO;
import com.ff.game.api.ng.dto.ApiNGResponseDTO; import com.ff.game.api.ng.dto.ApiNGResponseDTO;
import com.ff.game.api.pgt.address.MyPGTAddressSource; import com.ff.game.api.pgt.address.MyPGTAddressSource;
import com.ff.game.api.pgt.dto.*; import com.ff.game.api.pgt.dto.*;
import com.ff.game.api.pgx.dto.PGXPlayerStatusResponse;
import com.ff.game.api.success.MySuccessCondition; import com.ff.game.api.success.MySuccessCondition;
import com.ff.game.api.xk.dto.XKKickMemberAllDTO; import com.ff.game.api.xk.dto.XKKickMemberAllDTO;
@ -42,14 +44,7 @@ public interface PGTClient {
PGTBalanceResponse getMemberInfo(@Var("parameters") String parameters, @Header Map<String, String> headerMap); PGTBalanceResponse getMemberInfo(@Var("parameters") String parameters, @Header Map<String, String> headerMap);
/**
* JD.
*
* @param parameters
* @return {@link PGXPlayerStatusResponse }
*/
@Get("/isPlayerIngame.ashx?${parameters}")
PGXPlayerStatusResponse getMemberPlayInfo(@Var("parameters") String parameters);
/** /**
@ -62,6 +57,17 @@ public interface PGTClient {
PGTLoginResponse loginWithoutRedirect(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap); PGTLoginResponse loginWithoutRedirect(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap);
/**
*
*
* @param parameters
* @param headerMap
* @return {@link PGTGameListResponse }
*/
@Get("/GetGameIconList")
PGTGameListResponse getGameList(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap);
/** /**
* *
* *
@ -101,32 +107,24 @@ public interface PGTClient {
* @param headerMap * @param headerMap
* @return {@link PGTTransactionDetailsResponse } * @return {@link PGTTransactionDetailsResponse }
*/ */
@Get(url = "/betTransactionsV2") @Get(url = "/betTransactionsV2?{parameters}")
PGTTransactionDetailsResponse getBetRecordByTime(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap); PGTTransactionDetailsResponse getBetRecordByTime(@Var("parameters") String parameters, @Header Map<String, String> headerMap);
@Get(url = "h/fetchArchieve.aspx?{parameters}")
PGXBetHistoryResponse getBetRecordByHistoryTime(@Var("parameters") String parameters);
/** /**
* *
* *
* @param parameters * @param parameters
* @return {@link JILIKickMemberDTO } * @param headerMap
* @return {@link PGTKickMemberResponse }
*/ */
@Post("/kickPlayerFromProduct.ashx?{parameters}") @Post("/seamless/kickOutPlayer")
PGXErrorResponse kickMember(@Var("parameters") String parameters); PGTKickMemberResponse kickMember(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap);
/**
*
*
* @param params
* @return {@link JILIKickMemberAllDTO }
*/
@Get("/kickMemberAll")
XKKickMemberAllDTO kickMemberAll(@JSONBody Map<String, Object> params);
} }

View File

@ -0,0 +1,133 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
/**
* pgtgame
*
* @author shi
* @date 2025/04/07
*/
@Data
public class PGTGameListResponse {
/**
*
*/
@JsonProperty("reqId")
private String reqId;
/**
* 0
*/
@JsonProperty("code")
private int code;
/**
*
*/
@JsonProperty("message")
private String message;
/**
*
*/
@JsonProperty("data")
private GameData data;
@Data
public static class GameData {
/**
*
*/
@JsonProperty("games")
private List<Game> games;
}
@Data
public static class Game {
/**
*
*/
@JsonProperty("name")
private String name;
/**
*
*/
@JsonProperty("category")
private String category;
/**
*
*/
@JsonProperty("type")
private String type;
/**
*
*/
@JsonProperty("code")
private String code;
/**
*
*/
@JsonProperty("img")
private String img;
/**
* id
*/
private Long systemGameId;
/**
*
*/
@JsonProperty("rank")
private int rank;
/**
*
*/
@JsonProperty("providerCode")
private String providerCode;
/**
*
*/
@JsonProperty("locale")
private Locale locale;
}
/**
*
*
* @author shi
* @date 2025/04/07
*/
@Data
public class Locale {
/**
*
*/
@JsonProperty("TH")
private String th;
/**
*
*/
@JsonProperty("EN")
private String en;
/**
*
*/
@JsonProperty("CN")
private String cn;
}
}

View File

@ -0,0 +1,56 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
* pgtkick
*
* @author shi
* @date 2025/04/07
*/
@Data
public class PGTKickMemberResponse {
/**
*
*/
@JsonProperty("reqId")
private String reqId;
/**
*
* 0
*/
@JsonProperty("code")
private int code;
/**
*
*/
@JsonProperty("message")
private String message;
/**
*
*/
@JsonProperty("data")
private TransactionData data;
@Data
public static class TransactionData {
/**
*
*/
@JsonProperty("status")
private String status;
/**
*
*/
@JsonProperty("username")
private String username;
}
}

View File

@ -3,6 +3,8 @@ package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -85,25 +87,25 @@ public class PGTTransactionDetailsResponse {
* *
*/ */
@JsonProperty("accountingDate") @JsonProperty("accountingDate")
private String accountingDate; private Date accountingDate;
/** /**
* *
*/ */
@JsonProperty("updatedDate") @JsonProperty("updatedDate")
private String updatedDate; private Date updatedDate;
/** /**
* *
*/ */
@JsonProperty("stake") @JsonProperty("stake")
private double stake; private BigDecimal stake;
/** /**
* *
*/ */
@JsonProperty("payout") @JsonProperty("payout")
private double payout; private BigDecimal payout;
/** /**
* ID * ID
@ -131,6 +133,7 @@ public class PGTTransactionDetailsResponse {
/** /**
* *
* OPEN, SETTLED, UNSETTLED, VOID
*/ */
@JsonProperty("betStatus") @JsonProperty("betStatus")
private String betStatus; private String betStatus;

View File

@ -1,148 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
*
*
* @author shi
* @date 2025/03/28
*/
@Data
public class PGXBetHistoryResponse {
/**
*
*/
@JsonProperty("errCode")
private Integer errCode;
/**
* JSON (String)
*/
@JsonProperty("result")
private String result;
/**
* (String)
*/
@JsonProperty("errMsg")
private String errMsg;
/**
* AIO
*/
@Data
public class Result {
/**
* AIO () (Long)
*/
@JsonProperty("id")
private Long id;
/**
* (Long)
*/
@JsonProperty("ref_no")
private Long refNo;
/**
* (String)
*/
@JsonProperty("site")
private String site;
/**
* (String)
*/
@JsonProperty("product")
private String product;
/**
* (String)
*/
@JsonProperty("member")
private String member;
/**
* (String)
*/
@JsonProperty("game_id")
private String gameId;
/**
* () GMT/UTC +0
*/
@JsonProperty("start_time")
private Date startTime;
/**
* (String) GMT/UTC +0
*/
@JsonProperty("end_time")
private Date endTime;
/**
* (String) GMT/UTC +0
*/
@JsonProperty("match_time")
private String matchTime;
/**
* (String)
*/
@JsonProperty("bet_detail")
private String betDetail;
/**
* (Double)
*/
@JsonProperty("turnover")
private BigDecimal turnover;
/**
* (Double)
*/
@JsonProperty("bet")
private BigDecimal bet;
/**
* (Double)
*/
@JsonProperty("payout")
private BigDecimal payout;
/**
* (Double)
*/
@JsonProperty("commission")
private BigDecimal commission;
/**
* (Double)
*/
@JsonProperty("p_share")
private BigDecimal pShare;
/**
* (Double)
*/
@JsonProperty("p_win")
private BigDecimal pWin;
/**
* (Int)
* 1 (valid bet record )
* 0 (running/ongoing match )
* -1 (invalid bet record e.g. voided , canceled )
*/
@JsonProperty("status")
private int status;
}
}

View File

@ -1,26 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*
* @author shi
* @date 2025/03/27
*/
@Data
public class PGXErrorResponse {
/** 错误码 */
@JsonProperty("errCode")
private Integer errCode;
/** 内部参考代码 (字符串类型) */
@JsonProperty("innerCode")
private String innerCode;
/** 错误信息 (字符串类型) */
@JsonProperty("errMsg")
private String errMsg;
}

View File

@ -1,67 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
* pgxexchange
*
* @author shi
* @date 2025/03/28
*/
@Data
public class PGXExchangeTransferStatusResponse {
/** 错误码 */
@JsonProperty("errCode")
private Integer errCode;
/** 错误信息 (字符串类型) */
@JsonProperty("errMsg")
private String errMsg;
/** GSC生成的转账ID (String类型) */
@JsonProperty("trans_id")
private String transId;
/** 交易时间GMT+0 (String类型) */
@JsonProperty("trans_time")
private String transTime;
/** 玩家姓名 (String类型) */
@JsonProperty("username")
private String username;
/** 交易类型 (String类型)0为存款1为取款 */
@JsonProperty("type")
private String type;
/** 提供商 (String类型) */
@JsonProperty("provider")
private String provider;
/** 交易金额 (double类型) */
@JsonProperty("amount")
private double amount;
/** 运营商的参考ID (String类型) */
@JsonProperty("ref_id")
private String refId;
/** (String)SUCCESS
PROCESSING
FAILED */
@JsonProperty("status")
private String status;
/** GSC操作员代码 (String类型) */
@JsonProperty("operator")
private String operator;
/** 交易备注 (String类型) */
@JsonProperty("remark")
private String remark;
}

View File

@ -1,30 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*/
@Data
public class PGXGameLoginResponse {
/**
* (String)
*/
@JsonProperty("errCode")
private Integer errCode;
/**
* (String)
*/
@JsonProperty("gameUrl")
private String gameUrl;
/**
* (String)
*/
@JsonProperty("errMsg")
private String errMsg;
}

View File

@ -1,26 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
*
*/
@Data
public class PGXMemberResponse {
/** 错误码 */
@JsonProperty("errCode")
private Integer errCode;
/** 账户余额 (小数类型) */
@JsonProperty("balance")
private BigDecimal balance;
/** 错误信息 (字符串类型) */
@JsonProperty("errMsg")
private String errMsg;
}

View File

@ -1,26 +0,0 @@
package com.ff.game.api.pgt.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
*
*
* @author shi
* @date 2025/03/28
*/
@Data
public class PGXPlayerStatusResponse {
/** 错误码 (字符串类型) */
@JsonProperty("errCode")
private Integer errCode;
/** 玩家是否在游戏中 (字符串类型) "true" 表示在游戏中,"false" 表示不在游戏中 */
@JsonProperty("result")
private Boolean result;
/** 错误信息 (字符串类型) */
@JsonProperty("errMsg")
private String errMsg;
}

View File

@ -1,7 +1,9 @@
package com.ff.game.api.pgt.impl; package com.ff.game.api.pgt.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
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;
@ -9,13 +11,18 @@ import com.ff.base.enums.*;
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.service.ISysConfigService; import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil; import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.sign.Base64; import com.ff.base.utils.sign.Base64;
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.fc.dto.ApiFCGameListResponseDTO;
import com.ff.game.api.fc.dto.ApiFCResult;
import com.ff.game.api.pgt.client.PGTClient; import com.ff.game.api.pgt.client.PGTClient;
import com.ff.game.api.pgt.dto.*; import com.ff.game.api.pgt.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.GameSecretKeyCurrencyDTO; import com.ff.game.dto.GameSecretKeyCurrencyDTO;
import com.ff.game.service.*; import com.ff.game.service.*;
@ -32,10 +39,8 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedHashMap; import java.util.concurrent.TimeUnit;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -206,9 +211,60 @@ public class GamesPGTServiceImpl implements IGamesService {
@Transactional @Transactional
@Override @Override
public String getGameList(GamesBaseRequestDTO gamesBaseRequestDTO) { public String getGameList(GamesBaseRequestDTO gamesBaseRequestDTO) {
List<PGTGameListResponse.Game> apiGameInfoResponseDTOS = redisCache.getCacheList(CacheConstants.PGT_GAMES);
if (!CollectionUtils.isEmpty(apiGameInfoResponseDTOS)) {
return CacheConstants.PGT_GAMES;
}
return CacheConstants.PGX_GAMES; log.info("GamesPGTServiceImpl [getGameList] 请求参数 {}", gamesBaseRequestDTO);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("productId", productId);
PGTGameListResponse gameList = pgtClient.getGameList(paramsMap, this.getKey(gamesBaseRequestDTO));
if (this.getIsSuccess(gameList.getCode())) {
//新增游戏
for (PGTGameListResponse.Game gameIdKey : gameList.getData().getGames()) {
Game game = Game.builder()
.platformCode(GamePlatforms.PGT.getCode())
.gameCode(gameIdKey.getCode())
.build();
List<Game> games = gameService.selectGameList(game);
int platformType = PGTGameType.findSystemByCode(gameIdKey.getCategory());
//不存在这个游戏
if (CollectionUtils.isEmpty(games)) {
game.setGameSourceType(gameIdKey.getCategory());
game.setFreespin(Boolean.FALSE);
game.setDemoStatus(Boolean.FALSE);
game.setPlatformCode(GamePlatforms.PGT.getCode());
game.setPlatformType(platformType);
game.setSortNo(gameService.selectMaxSortNo(platformType, GamePlatforms.PGT.getCode()) + 1);
game.setGameName(gameIdKey.getLocale().getCn());
game.setCreateBy(Constants.SYSTEM);
List<NameInfo> nameInfos = new ArrayList<>();
nameInfos.add(NameInfo.builder().lang("zh-CN").name(gameIdKey.getLocale().getCn()).build());
nameInfos.add(NameInfo.builder().lang("en-US").name(gameIdKey.getLocale().getEn()).build());
nameInfos.add(NameInfo.builder().lang("th-TH").name(gameIdKey.getLocale().getTh()).build());
game.setNameInfo(nameInfos);
gameService.insertGame(game);
} else {
game = games.get(0);
}
gameIdKey.setSystemGameId(game.getId());
}
redisCache.deleteObject(CacheConstants.PGT_GAMES);
redisCache.setCacheList(CacheConstants.PGT_GAMES, gameList.getData().getGames());
redisCache.expire(CacheConstants.PGT_GAMES, 5L, TimeUnit.HOURS);
} else {
throw new ApiException(ErrorCode.ERROR.getCode());
}
return CacheConstants.PGT_GAMES;
} }
/** /**
@ -361,23 +417,31 @@ public class GamesPGTServiceImpl implements IGamesService {
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) { public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
//请求参数 //请求参数
log.info("GamesPGTServiceImpl [getBetRecordByTime] 请求参数 {}", betRecordByTimeDTO); log.info("GamesPGTServiceImpl [getBetRecordByTime] 请求参数 {}", betRecordByTimeDTO);
String startTime = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getStartTime(), DateUtils.ISO_8601_FORMAT_Z, "GMT+8");
String endTime = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getEndTime(), DateUtils.ISO_8601_FORMAT_Z, "GMT+8");
String nextId = redisCache.getCacheObject(CacheConstants.PGT_NEXT_ID);
Map<String, Object> paramsMap = new LinkedHashMap<>(); Map<String, Object> paramsMap = new LinkedHashMap<>();
paramsMap.put("productId", productId); paramsMap.put("productId", productId);
paramsMap.put("date", productId); paramsMap.put("startTime", startTime);
paramsMap.put("startTime", productId); paramsMap.put("endTime", endTime);
paramsMap.put("endTime", productId); paramsMap.put("nextId", nextId);
paramsMap.put("nextId", productId);
Map<String, String> key = this.getKey(betRecordByTimeDTO); Map<String, String> key = this.getKey(betRecordByTimeDTO);
PGTTransactionDetailsResponse betRecordByTime = pgtClient.getBetRecordByTime(paramsMap, key); PGTTransactionDetailsResponse betRecordByTime = pgtClient.getBetRecordByTime(JsonUtil.mapToQueryString(paramsMap), key);
if (this.getIsSuccess(betRecordByTime.getCode())) { if (this.getIsSuccess(betRecordByTime.getCode())) {
List<PGTTransactionDetailsResponse.Transaction> txns = betRecordByTime.getData().getTxns(); List<PGTTransactionDetailsResponse.Transaction> txns = betRecordByTime.getData().getTxns();
this.batchInsert(txns, betRecordByTimeDTO); this.batchInsert(txns, betRecordByTimeDTO);
//保存本次请求的id
redisCache.setCacheObject(CacheConstants.PGT_NEXT_ID, betRecordByTime.getData().getNextId());
return Boolean.TRUE; return Boolean.TRUE;
} else { } else {
log.error("GamesPGXServiceImpl [getBetRecordByTime] 获取投注记录失败,错误代码{},错误信息{}", betRecordByTime.getErrCode(), betRecordByTime.getErrMsg()); log.error("GamesPGXServiceImpl [getBetRecordByTime] 获取投注记录失败,错误代码{},错误信息{}", betRecordByTime.getCode(), betRecordByTime.getMessage());
throw new BaseException(betRecordByTime.getErrMsg()); throw new BaseException(betRecordByTime.getMessage());
} }
} }
@ -389,21 +453,7 @@ public class GamesPGTServiceImpl implements IGamesService {
*/ */
@Override @Override
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) { public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
//请求参数 throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
log.info("GamesPGXServiceImpl [getBetRecordByHistoryTime] 请求参数 {}", betRecordByTimeDTO);
Map<String, Object> paramsMap = new LinkedHashMap<>();
paramsMap.put("operatorcode", betRecordByTimeDTO.getAgentId());
paramsMap.put("versionkey", 0);
PGXBetHistoryResponse betRecordByTime = pgtClient.getBetRecordByHistoryTime(JsonUtil.mapToQueryString(paramsMap));
if (this.getIsSuccess(betRecordByTime.getErrCode())) {
List<PGXBetHistoryResponse.Result> results = JSON.parseArray(betRecordByTime.getResult(), PGXBetHistoryResponse.Result.class);
this.batchInsert(results, betRecordByTimeDTO);
return Boolean.TRUE;
} else {
log.error("GamesPGXServiceImpl [getBetRecordByHistoryTime] 获取投注记录失败,错误代码{},错误信息{}", betRecordByTime.getErrCode(), betRecordByTime.getErrMsg());
throw new BaseException(betRecordByTime.getErrMsg());
}
} }
/** /**
@ -436,7 +486,18 @@ public class GamesPGTServiceImpl implements IGamesService {
*/ */
@Override @Override
public Boolean kickMember(KickMemberRequestDTO kickMemberRequestDTO) { public Boolean kickMember(KickMemberRequestDTO kickMemberRequestDTO) {
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode()); log.info("GamesPGTServiceImpl [kickMember] 请求参数 {}", kickMemberRequestDTO);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("username", kickMemberRequestDTO.getAccount());
paramsMap.put("productId", productId);
Map<String, String> key = this.getKey(kickMemberRequestDTO);
PGTKickMemberResponse pgtKickMemberResponse = pgtClient.kickMember(paramsMap, key);
if (this.getIsSuccess(pgtKickMemberResponse.getCode())&&"SUCCESS".equals(pgtKickMemberResponse.getData().getStatus())) {
return Boolean.TRUE;
} else {
throw new ApiException(ErrorCode.KICK_OUT_AILED.getCode());
}
} }
/** /**
@ -495,7 +556,9 @@ public class GamesPGTServiceImpl implements IGamesService {
//数据转化 //数据转化
for (PGTTransactionDetailsResponse.Transaction bean : dataBean) { for (PGTTransactionDetailsResponse.Transaction bean : dataBean) {
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().agentId(gamesBaseRequestDTO.getAgentId()).data(bean).build()); GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().agentId(gamesBaseRequestDTO.getAgentId())
.platform(gamesBaseRequestDTO.getVendor())
.data(bean).build());
if (!ObjectUtils.isEmpty(bettingDetails)) { if (!ObjectUtils.isEmpty(bettingDetails)) {
bettingDetails.setId(IdUtil.getSnowflakeNextId()); bettingDetails.setId(IdUtil.getSnowflakeNextId());
gameBettingDetails.add(bettingDetails); gameBettingDetails.add(bettingDetails);
@ -527,7 +590,51 @@ public class GamesPGTServiceImpl implements IGamesService {
@Override @Override
public GameBettingDetails dataBuild(GamesDataBuildDTO gamesDataBuildDTO) { public GameBettingDetails dataBuild(GamesDataBuildDTO gamesDataBuildDTO) {
//转化类 //转化类
PGTTransactionDetailsResponse.Transaction resultBean = (PGTTransactionDetailsResponse.Transaction) gamesDataBuildDTO.getData();
return new GameBettingDetails();
//只要结算的数据
if (!PGTBetStatus.SETTLED.getType().equals(resultBean.getBetStatus())) {
return null;
}
Member member = memberService.selectMemberByGameAccount(resultBean.getUsername());
if (ObjectUtils.isEmpty(member)) {
return null;
}
List<PGTGameListResponse.Game> gamesDatas = redisCache.getCacheList(CacheConstants.PGT_GAMES);
Map<String, PGTGameListResponse.Game> dataDTOMap = gamesDatas.stream().collect(Collectors.toMap(PGTGameListResponse.Game::getCode, e -> e));
PGTGameListResponse.Game gamesDataDTO = dataDTOMap.get(resultBean.getGameCode());
//数据构造
GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
.tenantKey(member.getTenantKey())
//保存我们的币种id
.currencyCode(gamesDataBuildDTO.getPlatform().getOurCurrency(resultBean.getCurrency()))
.memberId(member.getId())
.gameCode(resultBean.getGameCode())
.gameType(PGTGameType.findSystemByCode(gamesDataDTO.getCategory()))
.platformCode(GamePlatforms.PGT.getCode())
.gameId(gamesDataDTO.getSystemGameId())
.gameName(gamesDataDTO.getName())
.gameStatus(PGTPayoutStatus.getByCode(resultBean.getPayoutStatus()).getSystemCode())
.gameStatusType(1)
.gameCurrencyCode(resultBean.getCurrency())
.account(resultBean.getUsername())
.wagersId(resultBean.getBetId())
.wagersTime(resultBean.getAccountingDate().getTime())
.betAmount(resultBean.getPayout())
.payoffTime(resultBean.getAccountingDate().getTime())
.payoffAmount(resultBean.getStake())
.settlementTime(resultBean.getAccountingDate().getTime())
.turnover(resultBean.getPayout())
.orderNo(resultBean.getRoundId())
.settlementStatus(SettlementStatusEnum.COMPLETED.getCode())
.build();
gameBettingDetails.setCreateBy(Constants.SYSTEM);
gameBettingDetails.setCreateTime(DateUtils.getNowDate());
return gameBettingDetails;
} }
} }

View File

@ -67,8 +67,8 @@ public class GameBettingDetails extends BaseEntity
@Excel(name = "游戏名称") @Excel(name = "游戏名称")
private String gameName; private String gameName;
/** 注单状态 1: 赢 2: 输 3: 平局 */ /** 注单状态 1: 赢 2: 输 3: 平局 4 未知 */
@Excel(name = "注单状态 1: 赢 2: 输 3: 平局") @Excel(name = "注单状态 1: 赢 2: 输 3: 平局 4 未知")
private Integer gameStatus; private Integer gameStatus;
/** /**

View File

@ -64,6 +64,12 @@ public class Platform extends BaseEntity {
return this.type == Type.MULTI.getCode(); return this.type == Type.MULTI.getCode();
} }
/**
*
*
* @param currency
* @return {@link String }
*/
public String getOurCurrency(String currency) { public String getOurCurrency(String currency) {
Set<Map.Entry<String, String>> entrySet= currencyInfo.entrySet(); Set<Map.Entry<String, String>> entrySet= currencyInfo.entrySet();
for (Map.Entry<String, String> entry : entrySet) { for (Map.Entry<String, String> entry : entrySet) {