feat(ff-game): 添加 PT 平台支持
- 在 GamePlatforms枚举中添加 PT 平台 - 实现 PT 平台的会员创建、信息获取、登录等功能 - 添加 PT 平台的错误处理和 SSL 证书加载逻辑 - 更新 MemberService 以支持 PT 平台的会员账户生成 - 删除不必要的接口和类,精简代码结构main-pt
parent
f229c9ca4f
commit
26e8e1986d
|
|
@ -11,6 +11,7 @@ public enum GamePlatforms {
|
||||||
FC("FC", "FC"),
|
FC("FC", "FC"),
|
||||||
SA("SA", "SA"),
|
SA("SA", "SA"),
|
||||||
DG("DG", "DG"),
|
DG("DG", "DG"),
|
||||||
|
PT("PT", "PT"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
package com.ff.game.api.pt.address;
|
|
||||||
|
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
|
||||||
import com.ff.base.constant.Constants;
|
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 我jili address来源
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2025/02/10
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class MyPTAddressSource implements AddressSource {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISysConfigService configService;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.PT_API_BASE_URL);
|
|
||||||
return new ForestAddress("https",apiBaseUrl, 443,"api");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
package com.ff.game.api.pt.client;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import javax.net.ssl.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
|
|
||||||
public class PTAPIClient {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
CallAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CallAPI() {
|
|
||||||
try {
|
|
||||||
KeyStore ks = KeyStore.getInstance("PKCS12");
|
|
||||||
//get certificate file from test/resources as InputFileStream & load to existing keystore
|
|
||||||
Path path = Paths.get(System.getProperty("user.dir"),"pp_p12");
|
|
||||||
URL fileURL = new File(path.resolve("AGDRA_UAT.p12").toAbsolutePath().toString()).toURI().toURL();
|
|
||||||
|
|
||||||
File file = new File(fileURL.getFile());
|
|
||||||
FileInputStream fis = new FileInputStream(file);
|
|
||||||
ks.load(fis, "A6ZCfYoycq5tDa5p".toCharArray());
|
|
||||||
|
|
||||||
|
|
||||||
//Create KeyManagerFactory using loaded keystore
|
|
||||||
KeyManagerFactory kmf =
|
|
||||||
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
|
||||||
kmf.init(ks, "A6ZCfYoycq5tDa5p".toCharArray());
|
|
||||||
KeyManager[] kms = kmf.getKeyManagers();
|
|
||||||
//Create TrustManager to bypass trusted certificate check
|
|
||||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
|
||||||
new X509TrustManager() {
|
|
||||||
@Override
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkClientTrusted(X509Certificate[] certs, String
|
|
||||||
authType) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkServerTrusted(X509Certificate[] certs, String
|
|
||||||
authType) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//Hostname verification bypass method
|
|
||||||
HostnameVerifier allHostsValid = new HostnameVerifier() {
|
|
||||||
@Override
|
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//Set connection properties to use bypass certificate/hostname check methods
|
|
||||||
|
|
||||||
SSLContext sslContext = null;
|
|
||||||
sslContext = SSLContext.getInstance("TLS");
|
|
||||||
sslContext.init(kms, trustAllCerts, new SecureRandom());
|
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
|
||||||
//Send API call together with entity key for validation
|
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) new
|
|
||||||
URL("https://kioskpublicapi.88shared.com/api/player/create/").openConnection();
|
|
||||||
connection.setRequestProperty("Pragma", "2e51a98e76df7e2e22d720b13ffdb5cd05a90a921e46d54651b046ba08ae7d55f47bbd23e81fba733c170271f9789e16b21b4501ee026271bce0bb357cceaaba");
|
|
||||||
InputStream response = connection.getInputStream();
|
|
||||||
String resp = IOUtils.toString(response);
|
|
||||||
System.out.println(resp);
|
|
||||||
connection.disconnect();
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,100 +1,105 @@
|
||||||
package com.ff.game.api.pt.client;
|
package com.ff.game.api.pt.client;
|
||||||
|
|
||||||
import com.dtflys.forest.annotation.*;
|
import com.ff.base.exception.base.BaseException;
|
||||||
import com.ff.game.api.jili.dto.*;
|
import org.apache.commons.io.IOUtils;
|
||||||
import com.ff.game.api.pt.address.MyPTAddressSource;
|
|
||||||
import com.ff.game.api.pt.dto.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import javax.net.ssl.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
public class PTClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xk 请求
|
* 发送 POST 请求,带有 SSL 客户端证书和请求参数
|
||||||
*
|
*
|
||||||
* @author shi
|
* @param url 请求的 URL
|
||||||
* @date 2025/02/10
|
* @param entityKey 请求头中的 X_ENTITY_KEY
|
||||||
|
* @param params 表单参数,使用 URL 编码
|
||||||
|
* @return 响应内容
|
||||||
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
@Address(source = MyPTAddressSource.class)
|
public static String sendPostRequest(String url, String entityKey,String pwd, String params) {
|
||||||
@Headers({
|
try {
|
||||||
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
// 加载证书
|
||||||
"Cache-Control: max-age=0",
|
KeyStore ks = KeyStore.getInstance("PKCS12");
|
||||||
"Connection: keep-alive",
|
Path path = Paths.get(System.getProperty("user.dir"), "pp_p12");
|
||||||
"Keep-Alive: timeout=5, max=100",
|
URL fileURL = new File(path.resolve("AGDRA_UAT.p12").toAbsolutePath().toString()).toURI().toURL();
|
||||||
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3",
|
File file = new File(fileURL.getFile());
|
||||||
"Accept-Language: es-ES,es;q=0.8"
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
})
|
ks.load(fis, pwd.toCharArray());
|
||||||
public interface PTClient {
|
}
|
||||||
/**
|
|
||||||
* 创建成员
|
|
||||||
*
|
|
||||||
* @param params 参数
|
|
||||||
* @return {@link String }
|
|
||||||
*/
|
|
||||||
@Post("/player/create/")
|
|
||||||
XKCreateMemberResponseDTO createMember(@Body Map<String, Object> params,@Header Map<String, Object> header);
|
|
||||||
|
|
||||||
/**
|
// 创建 KeyManagerFactory
|
||||||
* 获取会员信息
|
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||||
*
|
kmf.init(ks, pwd.toCharArray());
|
||||||
* @param params 参数
|
KeyManager[] kms = kmf.getKeyManagers();
|
||||||
* @return {@link XKMemberInfoDTO }
|
|
||||||
*/
|
|
||||||
@Post("/getMemberInfo")
|
|
||||||
XKMemberInfoDTO getMemberInfo(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
// 创建 TrustManager 来绕过证书验证
|
||||||
* 无重定向登录
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
*
|
new X509TrustManager() {
|
||||||
* @param params 参数
|
@Override
|
||||||
* @return {@link JILILoginWithoutRedirectResponseDTO }
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
*/
|
return null;
|
||||||
@Post("/loginWithoutRedirect")
|
}
|
||||||
XKLoginWithoutRedirectResponseDTO loginWithoutRedirect(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 获取游戏列表
|
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||||
*
|
}
|
||||||
* @param params 参数
|
|
||||||
* @return {@link JILIGamesDTO }
|
|
||||||
*/
|
|
||||||
@Post("/getGameList")
|
|
||||||
XKGamesDTO getGameList(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 按代理id进行交换转账
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||||
*
|
}
|
||||||
* @param params 参数
|
}
|
||||||
* @return {@link JILIExchangeMoneyResponseDTO }
|
};
|
||||||
*/
|
|
||||||
@Post(url = "/exchangeTransferByAgentId")
|
|
||||||
XKExchangeMoneyResponseDTO exchangeTransferByAgentId(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
// 创建 SSLContext
|
||||||
* 按时间获取投注记录
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
*
|
sslContext.init(kms, trustAllCerts, new SecureRandom());
|
||||||
* @param params 参数
|
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
||||||
* @return {@link XKBetRecordResponseDTO }
|
|
||||||
*/
|
|
||||||
@Post(url = "/getGameRecordByTime")
|
|
||||||
XKBetRecordResponseDTO getBetRecordByTime(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
|
// 设置 HostnameVerifier 跳过主机名验证
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true);
|
||||||
|
|
||||||
/**
|
// 创建请求连接
|
||||||
* 踢出队员
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
*
|
connection.setRequestMethod("POST");
|
||||||
* @param params 参数
|
|
||||||
* @return {@link JILIKickMemberDTO }
|
|
||||||
*/
|
|
||||||
@Post("/kickMember")
|
|
||||||
XKKickMemberDTO kickMember(@JSONBody Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
// 设置请求头
|
||||||
* 踢出所有队员
|
connection.setRequestProperty("X_ENTITY_KEY", entityKey);
|
||||||
*
|
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
* @param params 参数
|
|
||||||
* @return {@link JILIKickMemberAllDTO }
|
// 启用输入输出流
|
||||||
*/
|
connection.setDoOutput(true);
|
||||||
@Get("/kickMemberAll")
|
|
||||||
XKKickMemberAllDTO kickMemberAll(@JSONBody Map<String, Object> params);
|
// 写入请求体
|
||||||
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
|
byte[] input = params.getBytes(StandardCharsets.UTF_8);
|
||||||
|
os.write(input, 0, input.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取响应
|
||||||
|
try (InputStream response = connection.getInputStream()) {
|
||||||
|
return IOUtils.toString(response, StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// 处理错误响应
|
||||||
|
try (InputStream errorStream = connection.getErrorStream()) {
|
||||||
|
return IOUtils.toString(errorStream, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new BaseException("请求失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.ff.game.api.pt.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ptcreate播放器响应
|
||||||
|
*
|
||||||
|
* @author shi
|
||||||
|
* @date 2025/03/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PTCreatePlayerResponse {
|
||||||
|
private Result result;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Result {
|
||||||
|
private String result;
|
||||||
|
private String playername;
|
||||||
|
private String password;
|
||||||
|
private ExecutionTime executiontime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ExecutionTime {
|
||||||
|
private String webapi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.ff.game.api.pt.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ptlogin响应dto
|
||||||
|
*
|
||||||
|
* @author shi
|
||||||
|
* @date 2025/03/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PTMemberInfoResponse {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应结果,包含玩家的详细信息
|
||||||
|
*/
|
||||||
|
@JsonProperty("result")
|
||||||
|
private Result result;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Result {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("playername")
|
||||||
|
private String playerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家奖金余额
|
||||||
|
*/
|
||||||
|
@JsonProperty("bonusbalance")
|
||||||
|
private BigDecimal bonusBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家余额
|
||||||
|
*/
|
||||||
|
@JsonProperty("rc_balance")
|
||||||
|
private BigDecimal balance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ISO 货币代码
|
||||||
|
*/
|
||||||
|
@JsonProperty("currencycode")
|
||||||
|
private String currencyCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ff.game.api.pt.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pt会员在线回复
|
||||||
|
*
|
||||||
|
* @author shi
|
||||||
|
* @date 2025/03/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PTMemberOnlineResponse {
|
||||||
|
/**
|
||||||
|
* 响应结果,表示操作是否成功,1 为成功,0 为失败
|
||||||
|
*/
|
||||||
|
@JsonProperty("result")
|
||||||
|
private Integer result;
|
||||||
|
}
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import io.jsonwebtoken.lang.Collections;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKBetRecordResponseDTO {
|
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
private String msg;
|
|
||||||
private DataBean data;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DataBean {
|
|
||||||
private Integer currentPage;
|
|
||||||
private Integer totalPages;
|
|
||||||
private Integer pageLimit;
|
|
||||||
private Integer totalNumber;
|
|
||||||
private List<ResultBean> result;
|
|
||||||
|
|
||||||
public List<ResultBean> getResult() {
|
|
||||||
if (Collections.isEmpty(result)) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class ResultBean {
|
|
||||||
private String account;
|
|
||||||
private Long wagersId;
|
|
||||||
private String gameId;
|
|
||||||
private Long wagersTime;
|
|
||||||
private BigDecimal betAmount;
|
|
||||||
private Long payoffTime;
|
|
||||||
private BigDecimal payoffAmount;
|
|
||||||
private Integer status;
|
|
||||||
private Long settlementTime;
|
|
||||||
private Integer gameCategoryId;
|
|
||||||
private Integer type;
|
|
||||||
private String agentId;
|
|
||||||
private BigDecimal turnover;
|
|
||||||
private Long roundIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ff.game.api.request.GamesBaseRequestDTO;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建成员响应dto
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2024/10/22
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKCreateMemberResponseDTO extends GamesBaseRequestDTO {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码
|
|
||||||
*/
|
|
||||||
private int code;
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
private String data;
|
|
||||||
/**
|
|
||||||
* msg
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKExchangeMoneyResponseDTO {
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
private String msg;
|
|
||||||
private DataBean data;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DataBean {
|
|
||||||
/**
|
|
||||||
* 交易序号,额度转移纪录唯一值, 长度上限 50
|
|
||||||
*/
|
|
||||||
private String transactionId;
|
|
||||||
/**
|
|
||||||
* 转账前金额(游戏币)
|
|
||||||
*/
|
|
||||||
private BigDecimal coinBefore;
|
|
||||||
/**
|
|
||||||
* 转账后金额(游戏币)
|
|
||||||
*/
|
|
||||||
private BigDecimal coinAfter;
|
|
||||||
/**
|
|
||||||
* 转账前金额(指定货币)
|
|
||||||
*/
|
|
||||||
private BigDecimal currencyBefore;
|
|
||||||
/**
|
|
||||||
* 转账后金额(指定货币)
|
|
||||||
*/
|
|
||||||
private BigDecimal currencyAfter;
|
|
||||||
/**
|
|
||||||
* 状态:
|
|
||||||
* 1: 成功
|
|
||||||
* 2: 失败
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xkgames数据
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2024/11/13
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKGamesDTO {
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
/**
|
|
||||||
* msg
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
private List<DataBean> data;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DataBean {
|
|
||||||
/**
|
|
||||||
* 游戏id
|
|
||||||
*/
|
|
||||||
private String gameId;
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 游戏类别id
|
|
||||||
*/
|
|
||||||
private int gameCategoryId;
|
|
||||||
/**
|
|
||||||
*自己系统游戏id
|
|
||||||
*/
|
|
||||||
private Long systemGameId;
|
|
||||||
/**
|
|
||||||
* jp
|
|
||||||
*/
|
|
||||||
private boolean jp;
|
|
||||||
/**
|
|
||||||
* 是否免费
|
|
||||||
*/
|
|
||||||
private boolean freeSpin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xkkick会员全部dto
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2024/11/13
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class XKKickMemberAllDTO {
|
|
||||||
/**
|
|
||||||
* 代码
|
|
||||||
*/
|
|
||||||
private int code;
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
private String data;
|
|
||||||
/**
|
|
||||||
* msg
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKKickMemberDTO {
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
private String msg;
|
|
||||||
private Object data;
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录时不重定向响应dto
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2024/10/22
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKLoginWithoutRedirectResponseDTO {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码
|
|
||||||
*/
|
|
||||||
private int code;
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
private String data;
|
|
||||||
/**
|
|
||||||
* msg
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package com.ff.game.api.pt.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 会员信息dto
|
|
||||||
*
|
|
||||||
* @author shi
|
|
||||||
* @date 2024/10/30
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class XKMemberInfoDTO {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码
|
|
||||||
*/
|
|
||||||
private Integer code;
|
|
||||||
/**
|
|
||||||
* msg
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
private List<DataBean> data;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DataBean {
|
|
||||||
/**
|
|
||||||
* 账户
|
|
||||||
*/
|
|
||||||
private String account;
|
|
||||||
/**
|
|
||||||
* 平衡
|
|
||||||
*/
|
|
||||||
private BigDecimal balance;
|
|
||||||
/**
|
|
||||||
* 地位
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ff.game.api.pt.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
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;
|
||||||
|
|
@ -17,6 +18,7 @@ import com.ff.game.api.IGamesService;
|
||||||
import com.ff.game.api.pt.client.PTClient;
|
import com.ff.game.api.pt.client.PTClient;
|
||||||
import com.ff.game.api.pt.dto.*;
|
import com.ff.game.api.pt.dto.*;
|
||||||
import com.ff.game.api.request.*;
|
import com.ff.game.api.request.*;
|
||||||
|
import com.ff.game.api.xk.dto.*;
|
||||||
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.*;
|
||||||
|
|
@ -76,9 +78,6 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
@Resource
|
@Resource
|
||||||
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
|
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PTClient PTClient;
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private KeyConfig keyConfig;
|
private KeyConfig keyConfig;
|
||||||
|
|
@ -102,17 +101,19 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取密钥
|
* 发送
|
||||||
*
|
*
|
||||||
* @param gamesBaseRequestDTO 游戏请求dto
|
* @param url 网址
|
||||||
|
* @param params 参数
|
||||||
|
* @param gamesBaseRequestDTO 游戏基础请求dto
|
||||||
* @return {@link String }
|
* @return {@link String }
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getKey(GamesBaseRequestDTO gamesBaseRequestDTO) {
|
private String send(String url, Map<String, Object> params, GamesBaseRequestDTO gamesBaseRequestDTO) {
|
||||||
Map<String, Object> headerMap = new LinkedHashMap<>();
|
return PTClient.sendPostRequest(configService.selectConfigByKey(Constants.PT_API_BASE_URL) + url, gamesBaseRequestDTO.getAgentKey(), gamesBaseRequestDTO.getAgentId(), JsonUtil.mapToQueryString(params));
|
||||||
headerMap.put("Pragma", gamesBaseRequestDTO.getAgentKey());
|
|
||||||
return headerMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建成员
|
* 创建成员
|
||||||
*
|
*
|
||||||
|
|
@ -121,23 +122,19 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) {
|
public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) {
|
||||||
log.info("GamesXKServiceImpl [createMember] 请求参数 {}", createMemberRequestDTO);
|
log.info("GamesPTServiceImpl [createMember] 请求参数 {}", createMemberRequestDTO);
|
||||||
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(createMemberRequestDTO.getAgentId());
|
GameSecretKey gameSecretKey = gameSecretKeyService.selectGameSecretKeyByCode(createMemberRequestDTO.getAgentId());
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
Map<String, Object> params = new LinkedHashMap<>();
|
||||||
params.put("playername", createMemberRequestDTO.getAccount());
|
params.put("playername", createMemberRequestDTO.getAccount());
|
||||||
params.put("currency", createMemberRequestDTO.getCurrency());
|
params.put("currency", createMemberRequestDTO.getCurrency());
|
||||||
params.put("password", gameSecretKey.getPassword());
|
params.put("password", gameSecretKey.getPassword());
|
||||||
Map<String, Object> headerMap = this.getKey(createMemberRequestDTO);
|
String result = this.send("/player/create/", params, createMemberRequestDTO);
|
||||||
XKCreateMemberResponseDTO xkCreateMemberResponseDTO = PTClient.createMember(params,headerMap);
|
PTCreatePlayerResponse ptCreatePlayerResponse = JSON.parseObject(result, PTCreatePlayerResponse.class);
|
||||||
int errorCode = xkCreateMemberResponseDTO.getCode();
|
if (ObjectUtils.isEmpty(ptCreatePlayerResponse.getResult())) {
|
||||||
if (0 == errorCode) {
|
return Boolean.FALSE;
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (101 == errorCode) {
|
|
||||||
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
|
|
||||||
}
|
}
|
||||||
//判断是否获取成功
|
//判断是否获取成功
|
||||||
return Boolean.FALSE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -149,29 +146,24 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MemberInfoResponseDTO getMemberInfo(MemberInfoRequestDTO memberInfoRequestDTO) {
|
public MemberInfoResponseDTO getMemberInfo(MemberInfoRequestDTO memberInfoRequestDTO) {
|
||||||
log.info("GamesXKServiceImpl [getMemberInfo] 请求参数 {}", memberInfoRequestDTO);
|
log.info("GamesPTServiceImpl [getMemberInfo] 请求参数 {}", memberInfoRequestDTO);
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
Map<String, Object> params = new LinkedHashMap<>();
|
||||||
params.put("accounts", memberInfoRequestDTO.getAccounts());
|
params.put("playername", memberInfoRequestDTO.getAccounts());
|
||||||
params.put("agentId", memberInfoRequestDTO.getAgentId());
|
String result = this.send("/player/balance/", params, memberInfoRequestDTO);
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
PTMemberInfoResponse memberInfoResponse = JSON.parseObject(result, PTMemberInfoResponse.class);
|
||||||
memberInfoRequestDTO.setQuery(query);
|
if (ObjectUtils.isEmpty(memberInfoResponse.getResult())) {
|
||||||
Map<String, Object> key = this.getKey(memberInfoRequestDTO);
|
throw new ApiException(ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
||||||
params.put("key", key);
|
|
||||||
XKMemberInfoDTO xkMemberInfoDTO = PTClient.getMemberInfo(params);
|
|
||||||
//判断是否获取成功
|
|
||||||
if (this.getIsSuccess(xkMemberInfoDTO.getCode())) {
|
|
||||||
List<MemberInfoResponseDTO> memberInfoResponseDTOS = new ArrayList<>();
|
|
||||||
xkMemberInfoDTO.getData().forEach(e -> {
|
|
||||||
memberInfoResponseDTOS.add(MemberInfoResponseDTO.builder()
|
|
||||||
.status(e.getStatus())
|
|
||||||
.balance(e.getBalance())
|
|
||||||
.account(e.getAccount())
|
|
||||||
.build());
|
|
||||||
});
|
|
||||||
return memberInfoResponseDTOS.get(0);
|
|
||||||
} else {
|
|
||||||
throw new BaseException(xkMemberInfoDTO.getMsg());
|
|
||||||
}
|
}
|
||||||
|
PTMemberInfoResponse.Result results = memberInfoResponse.getResult();
|
||||||
|
//查询在线状态
|
||||||
|
params = new LinkedHashMap<>();
|
||||||
|
params.put("playername", memberInfoRequestDTO.getAccounts());
|
||||||
|
result = this.send("/player/online/", params, memberInfoRequestDTO);
|
||||||
|
PTMemberOnlineResponse ptMemberOnlineResponse = JSON.parseObject(result, PTMemberOnlineResponse.class);
|
||||||
|
|
||||||
|
|
||||||
|
//判断是否获取成功
|
||||||
|
return MemberInfoResponseDTO.builder().balance(results.getBalance()).status(ptMemberOnlineResponse.getResult()==1 ? GameMemberStatus.ONLINE.getCode() : GameMemberStatus.OFFLINE.getCode()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,27 +174,7 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String loginWithoutRedirect(GamesLogin gamesLogin) {
|
public String loginWithoutRedirect(GamesLogin gamesLogin) {
|
||||||
log.info("GamesXKServiceImpl [loginWithoutRedirect] 请求参数 {}", gamesLogin);
|
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||||
|
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
|
||||||
params.put("account", gamesLogin.getAccount());
|
|
||||||
params.put("gameId", Integer.valueOf(gamesLogin.getGameId()));
|
|
||||||
params.put("lang", gamesLogin.getLang());
|
|
||||||
params.put("agentId", gamesLogin.getAgentId());
|
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
|
||||||
gamesLogin.setQuery(query);
|
|
||||||
Map<String, Object> key = this.getKey(gamesLogin);
|
|
||||||
params.put("key", key);
|
|
||||||
params.put("disableFullScreen", gamesLogin.getDisableFullScreen());
|
|
||||||
params.put("homeUrl", gamesLogin.getHomeUrl());
|
|
||||||
params.put("platform", gamesLogin.getPlatform());
|
|
||||||
XKLoginWithoutRedirectResponseDTO xkLoginWithoutRedirectResponseDTO = PTClient.loginWithoutRedirect(params);
|
|
||||||
//判断是否获取成功
|
|
||||||
if (this.getIsSuccess(xkLoginWithoutRedirectResponseDTO.getCode())) {
|
|
||||||
return xkLoginWithoutRedirectResponseDTO.getData();
|
|
||||||
} else {
|
|
||||||
throw new BaseException(xkLoginWithoutRedirectResponseDTO.getMsg());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -215,77 +187,7 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public String getGameList(GamesBaseRequestDTO gamesBaseRequestDTO) {
|
public String getGameList(GamesBaseRequestDTO gamesBaseRequestDTO) {
|
||||||
|
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||||
List<XKGamesDTO.DataBean> gamesDatas = redisCache.getCacheList(CacheConstants.XK_GAMES);
|
|
||||||
if (!CollectionUtils.isEmpty(gamesDatas)) {
|
|
||||||
return CacheConstants.XK_GAMES;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
|
||||||
params.put("agentId", gamesBaseRequestDTO.getAgentId());
|
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
|
||||||
gamesBaseRequestDTO.setQuery(query);
|
|
||||||
Map<String, Object> key = this.getKey(gamesBaseRequestDTO);
|
|
||||||
params.put("key", key);
|
|
||||||
|
|
||||||
XKGamesDTO xkGamesDTO = PTClient.getGameList(params);
|
|
||||||
//判断是否获取成功
|
|
||||||
if (this.getIsSuccess(xkGamesDTO.getCode())) {
|
|
||||||
|
|
||||||
for (XKGamesDTO.DataBean gamesDataDTO : xkGamesDTO.getData()) {
|
|
||||||
GamePlatform gamePlatform = GamePlatform.builder()
|
|
||||||
.platformType(XKGameType.findSystemByCode(gamesDataDTO.getGameCategoryId()))
|
|
||||||
.platformCode(GamePlatforms.XK.getCode())
|
|
||||||
.build();
|
|
||||||
List<GamePlatform> gamePlatforms = gamePlatformService.selectGamePlatformList(gamePlatform);
|
|
||||||
//没有此平台就新增一个平台
|
|
||||||
if (CollectionUtils.isEmpty(gamePlatforms)) {
|
|
||||||
gamePlatform.setPlatformName(GamePlatforms.XK.getInfo() + XKGameType.findInfoByCode(gamesDataDTO.getGameCategoryId()));
|
|
||||||
gamePlatform.setSortNo(gamePlatformService.selectMaxSortNo() + 1);
|
|
||||||
gamePlatform.setCreateBy(Constants.SYSTEM);
|
|
||||||
gamePlatformService.insertGamePlatform(gamePlatform);
|
|
||||||
} else {
|
|
||||||
gamePlatform = gamePlatforms.get(0);
|
|
||||||
}
|
|
||||||
Game game = Game.builder()
|
|
||||||
.platformId(gamePlatform.getId())
|
|
||||||
.gameCode(String.valueOf(gamesDataDTO.getGameId()))
|
|
||||||
.build();
|
|
||||||
List<Game> games = gameService.selectGameList(game);
|
|
||||||
//不存在这个游戏
|
|
||||||
if (CollectionUtils.isEmpty(games)) {
|
|
||||||
game.setGameSourceType(String.valueOf(gamesDataDTO.getGameCategoryId()));
|
|
||||||
game.setFreespin(gamesDataDTO.isFreeSpin());
|
|
||||||
game.setSortNo(gameService.selectMaxSortNoByPlatformId(gamePlatform.getId()) + 1);
|
|
||||||
game.setGameName(gamesDataDTO.getName());
|
|
||||||
game.setCreateBy(Constants.SYSTEM);
|
|
||||||
gameService.insertGame(game);
|
|
||||||
} else {
|
|
||||||
game = games.get(0);
|
|
||||||
}
|
|
||||||
gamesDataDTO.setSystemGameId(game.getId());
|
|
||||||
List<GameName> gameNames = gameNameService.selectGameNameList(GameName.builder().gameId(game.getId()).gameName(game.getGameName()).build());
|
|
||||||
if (CollectionUtils.isEmpty(gameNames)){
|
|
||||||
gameNameService.insertGameName(GameName.builder()
|
|
||||||
.gameId(game.getId())
|
|
||||||
.gameName(game.getGameName())
|
|
||||||
.langCode("zh-CN")
|
|
||||||
.createBy(Constants.SYSTEM)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
redisCache.deleteObject(CacheConstants.XK_GAMES);
|
|
||||||
redisCache.setCacheList(CacheConstants.XK_GAMES, xkGamesDTO.getData());
|
|
||||||
redisCache.expire(CacheConstants.XK_GAMES, 5L, TimeUnit.HOURS);
|
|
||||||
} else {
|
|
||||||
throw new BaseException(xkGamesDTO.getMsg());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return CacheConstants.XK_GAMES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -297,68 +199,7 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Long exchangeTransferByAgentId(ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO) {
|
public Long exchangeTransferByAgentId(ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO) {
|
||||||
log.info("GamesXKServiceImpl [exchangeTransferByAgentId] 请求参数 {}", exchangeTransferMoneyRequestDTO);
|
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||||
GameSecretKeyCurrency currencyDTO = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
|
||||||
.platformCode(GamePlatforms.XK.getInfo())
|
|
||||||
.code(exchangeTransferMoneyRequestDTO.getAgentId())
|
|
||||||
.build());
|
|
||||||
|
|
||||||
Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount());
|
|
||||||
String transactionId = GamePlatforms.XK.getCode() + IdUtils.simpleUUID();
|
|
||||||
List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList(
|
|
||||||
GameExchangeMoney.builder()
|
|
||||||
.tenantKey(exchangeTransferMoneyRequestDTO.getTenantKey())
|
|
||||||
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
Assert.isTrue(CollectionUtils.isEmpty(gameExchangeMonies), "订单号重复");
|
|
||||||
|
|
||||||
//获取下一个自增id
|
|
||||||
GameExchangeMoney exchangeMoney = GameExchangeMoney
|
|
||||||
.builder()
|
|
||||||
.tenantKey(exchangeTransferMoneyRequestDTO.getTenantKey())
|
|
||||||
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
|
|
||||||
.quota(exchangeTransferMoneyRequestDTO.getQuota())
|
|
||||||
.balance(exchangeTransferMoneyRequestDTO.getAmount())
|
|
||||||
.exchangeType(exchangeTransferMoneyRequestDTO.getTransferType())
|
|
||||||
.currencyCode(currencyDTO.getSystemCurrency())
|
|
||||||
.memberId(member.getId())
|
|
||||||
.transactionId(transactionId)
|
|
||||||
.platformCode(GamePlatforms.XK.getCode())
|
|
||||||
.build();
|
|
||||||
exchangeMoney.setCreateBy(Constants.SYSTEM);
|
|
||||||
//接口限制限制50字符
|
|
||||||
exchangeMoney.setTransactionId(GamePlatforms.XK.getCode() + IdUtils.simpleUUID());
|
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
|
||||||
params.put("account", exchangeTransferMoneyRequestDTO.getAccount());
|
|
||||||
params.put("transactionId", exchangeMoney.getTransactionId());
|
|
||||||
params.put("amount", exchangeTransferMoneyRequestDTO.getAmount().stripTrailingZeros().toPlainString());
|
|
||||||
params.put("transferType", exchangeTransferMoneyRequestDTO.getTransferType());
|
|
||||||
params.put("agentId", exchangeTransferMoneyRequestDTO.getAgentId());
|
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
|
||||||
exchangeTransferMoneyRequestDTO.setQuery(query);
|
|
||||||
Map<String, Object> key = this.getKey(exchangeTransferMoneyRequestDTO);
|
|
||||||
params.put("key", key);
|
|
||||||
XKExchangeMoneyResponseDTO exchangeMoneyResponse = PTClient.exchangeTransferByAgentId(params);
|
|
||||||
//判断是否转移成功
|
|
||||||
if (this.getIsSuccess(exchangeMoneyResponse.getCode())) {
|
|
||||||
XKExchangeMoneyResponseDTO.DataBean exchangeMoneyResponseData = exchangeMoneyResponse.getData();
|
|
||||||
ApiException.isTrue(!StatusType.FAILURE.getValue().equals(exchangeMoneyResponseData.getStatus()), ErrorCode.BALANCE_TRANSFER_FAILED.getCode());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
exchangeMoney.setBalance(NumberUtil.sub(exchangeMoneyResponseData.getCurrencyAfter(), exchangeMoneyResponseData.getCurrencyBefore()).abs());
|
|
||||||
exchangeMoney.setCoinBefore(exchangeMoneyResponseData.getCoinBefore());
|
|
||||||
exchangeMoney.setCoinAfter(exchangeMoneyResponseData.getCoinAfter());
|
|
||||||
exchangeMoney.setCurrencyBefore(exchangeMoneyResponseData.getCurrencyBefore());
|
|
||||||
exchangeMoney.setCurrencyAfter(exchangeMoneyResponseData.getCurrencyAfter());
|
|
||||||
exchangeMoney.setStatus(exchangeMoneyResponseData.getStatus());
|
|
||||||
gameExchangeMoneyService.insertGameExchangeMoney(exchangeMoney);
|
|
||||||
} else {
|
|
||||||
log.error("GamesXKServiceImpl [exchangeTransferByAgentId] 金额转移失败,错误代码{},错误信息{}", exchangeMoneyResponse.getCode(), exchangeMoneyResponse.getMsg());
|
|
||||||
throw new BaseException(exchangeMoneyResponse.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchangeMoney.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -381,51 +222,7 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||||
List<GameBettingDetails> gameBettingDetails = new ArrayList<>();
|
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||||
//请求参数
|
|
||||||
log.info("GamesXKServiceImpl [getBetRecordByTime] 请求参数 {}", betRecordByTimeDTO);
|
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
|
||||||
params.put("startTime", betRecordByTimeDTO.getStartTime());
|
|
||||||
params.put("endTime", betRecordByTimeDTO.getEndTime());
|
|
||||||
params.put("page", betRecordByTimeDTO.getPage());
|
|
||||||
params.put("pageLimit", betRecordByTimeDTO.getPageLimit());
|
|
||||||
params.put("agentId", betRecordByTimeDTO.getAgentId());
|
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
|
||||||
betRecordByTimeDTO.setQuery(query);
|
|
||||||
Map<String, Object> key = this.getKey(betRecordByTimeDTO);
|
|
||||||
params.put("key", key);
|
|
||||||
XKBetRecordResponseDTO xkBetRecordResponseDTO = PTClient.getBetRecordByTime(params);
|
|
||||||
|
|
||||||
//判断是否获取成功
|
|
||||||
if (this.getIsSuccess(xkBetRecordResponseDTO.getCode())) {
|
|
||||||
//数据组装
|
|
||||||
XKBetRecordResponseDTO.DataBean dataBean = xkBetRecordResponseDTO.getData();
|
|
||||||
this.batchInsert(xkBetRecordResponseDTO);
|
|
||||||
|
|
||||||
//获取下一页数据
|
|
||||||
while (!Objects.equals(dataBean.getCurrentPage(), dataBean.getTotalPages()) && dataBean.getTotalPages() > 0) {
|
|
||||||
betRecordByTimeDTO.setPage(dataBean.getCurrentPage() + 1);
|
|
||||||
//请求参数
|
|
||||||
params = new LinkedHashMap<>();
|
|
||||||
params.put("startTime", betRecordByTimeDTO.getStartTime());
|
|
||||||
params.put("endTime", betRecordByTimeDTO.getEndTime());
|
|
||||||
params.put("page", betRecordByTimeDTO.getPage());
|
|
||||||
params.put("pageLimit", betRecordByTimeDTO.getPageLimit());
|
|
||||||
params.put("agentId", betRecordByTimeDTO.getAgentId());
|
|
||||||
query = JsonUtil.mapToQueryString(params);
|
|
||||||
betRecordByTimeDTO.setQuery(query);
|
|
||||||
key = this.getKey(betRecordByTimeDTO);
|
|
||||||
params.put("key", key);
|
|
||||||
xkBetRecordResponseDTO = PTClient.getBetRecordByTime(params);
|
|
||||||
this.batchInsert(xkBetRecordResponseDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return Boolean.TRUE;
|
|
||||||
} else {
|
|
||||||
log.error("GamesXKServiceImpl [getBetRecordByTime] 获取投注记录失败,错误代码{},错误信息{}", xkBetRecordResponseDTO.getCode(), xkBetRecordResponseDTO.getMsg());
|
|
||||||
throw new BaseException(xkBetRecordResponseDTO.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,21 +267,7 @@ public class GamesPTServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean kickMember(KickMemberRequestDTO kickMemberRequestDTO) {
|
public Boolean kickMember(KickMemberRequestDTO kickMemberRequestDTO) {
|
||||||
log.info("GamesXKServiceImpl [kickMember] 请求参数 {}", kickMemberRequestDTO);
|
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
|
||||||
params.put("account", kickMemberRequestDTO.getAccount());
|
|
||||||
params.put("agentId", kickMemberRequestDTO.getAgentId());
|
|
||||||
String query = JsonUtil.mapToQueryString(params);
|
|
||||||
kickMemberRequestDTO.setQuery(query);
|
|
||||||
Map<String, Object> key = this.getKey(kickMemberRequestDTO);
|
|
||||||
params.put("key", key);
|
|
||||||
XKKickMemberDTO xkKickMemberDTO = PTClient.kickMember(params);
|
|
||||||
//判断是否获取成功
|
|
||||||
if (this.getIsSuccess(xkKickMemberDTO.getCode())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
} else {
|
|
||||||
throw new BaseException(xkKickMemberDTO.getMsg());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class MemberServiceImpl implements IMemberService {
|
||||||
@Override
|
@Override
|
||||||
public synchronized String getMemberGameAccount(String platformCode) {
|
public synchronized String getMemberGameAccount(String platformCode) {
|
||||||
String gameAccount = null;
|
String gameAccount = null;
|
||||||
if (GamePlatforms.DG.getInfo().equals(platformCode)) {
|
if (GamePlatforms.DG.getInfo().equals(platformCode)||GamePlatforms.PT.getInfo().equals(platformCode)) {
|
||||||
do {
|
do {
|
||||||
gameAccount = RandomGeneratorUtils.generateRandomAccountUpper();
|
gameAccount = RandomGeneratorUtils.generateRandomAccountUpper();
|
||||||
} while (!ObjectUtils.isEmpty(memberMapper.selectMemberByGameAccount(gameAccount)));
|
} while (!ObjectUtils.isEmpty(memberMapper.selectMemberByGameAccount(gameAccount)));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue