Merge remote-tracking branch 'origin/main-pp' into upgrade_s1
# Conflicts: # ff-base/src/main/java/com/ff/base/constant/CacheConstants.java # ff-bean/ff-domain/src/main/java/com/ff/agent/domain/TenantAgentCommission.java # ff-game/src/main/java/com/ff/base/constant/Constants.javaupgrade_s1
commit
b5a534d0c8
|
@ -0,0 +1,85 @@
|
|||
package com.ff.base.constant;
|
||||
|
||||
/**
|
||||
* 缓存的key 常量
|
||||
*
|
||||
* @author ff
|
||||
*/
|
||||
public class CacheConstants
|
||||
{
|
||||
/**
|
||||
* 登录用户 redis key
|
||||
*/
|
||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||
|
||||
/**
|
||||
* 限流 redis key
|
||||
*/
|
||||
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* jili 游戏
|
||||
*/
|
||||
public static final String JILI_GAMES= "jili_games:";
|
||||
|
||||
/**
|
||||
* xk 游戏
|
||||
*/
|
||||
public static final String XK_GAMES= "xk_games:";
|
||||
|
||||
/**
|
||||
* pg游戏
|
||||
*/
|
||||
public static final String PG_GAMES= "pg_games:";
|
||||
|
||||
/**
|
||||
* pp游戏
|
||||
*/
|
||||
public static final String PP_GAMES= "pp_games:";
|
||||
/**
|
||||
* fc游戏
|
||||
*/
|
||||
public static final String FC_GAMES= "fc_games:";
|
||||
|
||||
/**
|
||||
* sa游戏
|
||||
*/
|
||||
public static final String SA_GAMES= "sa_games:";
|
||||
|
||||
|
||||
/**
|
||||
* dg游戏
|
||||
*/
|
||||
public static final String DG_GAMES= "dg_games:";
|
||||
/**
|
||||
* pg游戏投注货币
|
||||
*/
|
||||
public static final String PG_GAMES_BET_CURRENCY= "pg_games:bet:currency";
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.ff.game.api.pp.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 MyPPAddressSource implements AddressSource {
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
|
||||
@Override
|
||||
public ForestAddress getAddress(ForestRequest request) {
|
||||
String apiBaseUrl = configService.selectConfigByKey(Constants.PP_API_BASE_URL);
|
||||
return new ForestAddress("https",apiBaseUrl, 443,"/IntegrationService/v3/http/CasinoGameAPI");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.ff.game.api.pp.client;
|
||||
|
||||
import com.dtflys.forest.annotation.*;
|
||||
import com.ff.game.api.jili.dto.JILIGamesDTO;
|
||||
import com.ff.game.api.pp.address.MyPPAddressSource;
|
||||
import com.ff.game.api.pp.dto.*;
|
||||
import com.ff.game.api.xk.dto.XKBetRecordResponseDTO;
|
||||
import com.ff.game.api.xk.dto.XKGamesDTO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* dg 请求
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/02/10
|
||||
*/
|
||||
@Address(source = MyPPAddressSource.class)
|
||||
public interface PPClient {
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
* @param params 参数
|
||||
* @param header 头球
|
||||
* @return {@link DGResponse }
|
||||
*/
|
||||
@Post("/v2/api/signup")
|
||||
DGResponse createMember(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
/**
|
||||
* 获取会员信息
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
@Post("/v2/api/balance")
|
||||
DGUserAccountResponse getMemberInfo(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
/**
|
||||
* 无重定向登录
|
||||
*
|
||||
* @param params 参数
|
||||
* @param header 头球
|
||||
* @return {@link DGLoginWithoutRedirectResponse }
|
||||
*/
|
||||
@Post("/v2/api/login")
|
||||
DGLoginWithoutRedirectResponse loginWithoutRedirect(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
/**
|
||||
* 获取游戏列表
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link PPGameResponseDTO }
|
||||
*/
|
||||
@Post( url ="/getCasinoGames/",
|
||||
headers = {
|
||||
"Content-type: application/x-www-form-urlencoded"
|
||||
})
|
||||
|
||||
PPGameResponseDTO getGameList(@Body Map<String, Object> params);
|
||||
/**
|
||||
* 按代理id进行交换转账
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link DGTransactionResponseDTO }
|
||||
*/
|
||||
@Post(url = "/v2/api/transfer")
|
||||
DGTransactionResponseDTO exchangeTransferByAgentId(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
/**
|
||||
* 按时间获取投注记录
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link XKBetRecordResponseDTO }
|
||||
*/
|
||||
@Post(url ="/v2/api/report",
|
||||
headers = {
|
||||
"Content-type: application/x-www-form-urlencoded"
|
||||
})
|
||||
DGBetRecordResponseDTO getBetRecordByTime(@Header Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 标记报告
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link DGResponse }
|
||||
*/
|
||||
@Post(url = "/v2/api/markReport")
|
||||
DGResponse markReport(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
/**
|
||||
* 踢出队员
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link DGResponse }
|
||||
*/
|
||||
@Post("/v2/api/offline")
|
||||
DGResponse kickMember(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
|
||||
@Post("/v2/api/offlineAll")
|
||||
DGResponse kickMemberAll(@JSONBody Map<String, Object> params, @Header Map<String, Object> header);
|
||||
|
||||
/**
|
||||
* 会员在线
|
||||
*
|
||||
* @param params 参数
|
||||
* @return {@link DGUserListResponseDTO }
|
||||
*/
|
||||
@Post(url ="/v2/api/online",
|
||||
headers = {
|
||||
"Content-type: application/x-www-form-urlencoded"
|
||||
})
|
||||
DGUserListResponseDTO memberOnlines(@Header Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* dgbet记录响应数据
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/27
|
||||
*/
|
||||
@Data
|
||||
public class DGBetRecordResponseDTO {
|
||||
|
||||
/** 错误码 (参考文档定义) */
|
||||
@JsonProperty("codeId")
|
||||
private Integer codeId;
|
||||
|
||||
/** 错误信息 */
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
|
||||
/** 注单报告 */
|
||||
@JsonProperty("list")
|
||||
private List<ReportDTO> list;
|
||||
|
||||
/**
|
||||
* 注单报告类
|
||||
*/
|
||||
@Data
|
||||
public static class ReportDTO {
|
||||
|
||||
/** 注单ID(唯一) */
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
/** 游戏桌号(红包小费记录没有) */
|
||||
@JsonProperty("tableId")
|
||||
private Integer tableId;
|
||||
|
||||
/** 游戏靴号(红包小费记录没有) */
|
||||
@JsonProperty("shoeId")
|
||||
private Long shoeId;
|
||||
|
||||
/** 当靴局号(红包小费记录没有) */
|
||||
@JsonProperty("playId")
|
||||
private Long playId;
|
||||
|
||||
/** 游戏厅号(1:旗舰厅;2:亚洲厅;3,4:现场厅;5:性感厅;8,9:区块链厅) */
|
||||
@JsonProperty("lobbyId")
|
||||
private Integer lobbyId;
|
||||
|
||||
/** 注单类型(1:注单,2:红包小费) */
|
||||
@JsonProperty("gameType")
|
||||
private Integer gameType;
|
||||
|
||||
/** 游戏类型(百家乐,龙虎等) */
|
||||
@JsonProperty("gameId")
|
||||
private Integer gameId;
|
||||
|
||||
/** 下注时间 */
|
||||
@JsonProperty("betTime")
|
||||
private Date betTime;
|
||||
|
||||
/** 结算时间 */
|
||||
@JsonProperty("calTime")
|
||||
private Date calTime;
|
||||
|
||||
/** 派彩金额(含本金) */
|
||||
@JsonProperty("winOrLoss")
|
||||
private BigDecimal winOrLoss;
|
||||
|
||||
/** 下注前余额(仅作参考) */
|
||||
@JsonProperty("balanceBefore")
|
||||
private BigDecimal balanceBefore;
|
||||
|
||||
/** 下注金额(下注扣款金额) */
|
||||
@JsonProperty("betPoints")
|
||||
private BigDecimal betPoints;
|
||||
|
||||
/** 洗码金额(用于计算佣金) */
|
||||
@JsonProperty("availableBet")
|
||||
private BigDecimal availableBet;
|
||||
|
||||
/** 会员账号 */
|
||||
@JsonProperty("userName")
|
||||
private String userName;
|
||||
|
||||
/** 游戏结果 */
|
||||
@JsonProperty("result")
|
||||
private String result;
|
||||
|
||||
/** 注单详情 */
|
||||
@JsonProperty("betDetail")
|
||||
private String betDetail;
|
||||
|
||||
/** 客户端IP */
|
||||
@JsonProperty("ip")
|
||||
private String ip;
|
||||
|
||||
/** 游戏唯一局号 */
|
||||
@JsonProperty("ext")
|
||||
private String ext;
|
||||
|
||||
/** 结算状态(0:未结算,1:已结算,2:已撤销,3:冻结) */
|
||||
@JsonProperty("isRevocation")
|
||||
private Integer isRevocation;
|
||||
|
||||
/** 更改单时对应的注单记录 */
|
||||
@JsonProperty("parentBetId")
|
||||
private Long parentBetId;
|
||||
|
||||
/** 币种ID(请参考对应关系说明) */
|
||||
@JsonProperty("currencyId")
|
||||
private Integer currencyId;
|
||||
|
||||
/** 客户端平台ID(1: PC 2: 安卓 3: 苹果 5: H5) */
|
||||
@JsonProperty("deviceType")
|
||||
private Integer deviceType;
|
||||
|
||||
/** 钱包扣款记录(转账模式API没有) */
|
||||
@JsonProperty("transfers")
|
||||
private String transfers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 响应结果类
|
||||
*/
|
||||
@Data
|
||||
public class DGLoginWithoutRedirectResponse {
|
||||
|
||||
/**
|
||||
* 响应的代码ID
|
||||
*/
|
||||
@JsonProperty("codeId")
|
||||
private int codeId;
|
||||
|
||||
/**
|
||||
* 响应的消息
|
||||
*/
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 响应的 token
|
||||
*/
|
||||
@JsonProperty("token")
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 响应的域名信息
|
||||
*/
|
||||
@JsonProperty("domains")
|
||||
private String domains;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
@JsonProperty("list")
|
||||
private List<String> list;
|
||||
|
||||
/**
|
||||
* 限制组
|
||||
*/
|
||||
@JsonProperty("limitGroup")
|
||||
private String limitGroup;
|
||||
|
||||
/**
|
||||
* 限制区间
|
||||
*/
|
||||
@JsonProperty("limits")
|
||||
private List<Limit> limits;
|
||||
|
||||
/**
|
||||
* 限制区间内部类
|
||||
*/
|
||||
@Data
|
||||
public static class Limit {
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
@JsonProperty("min")
|
||||
private int min;
|
||||
|
||||
/**
|
||||
* 最大值
|
||||
*/
|
||||
@JsonProperty("max")
|
||||
private int max;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 响应类,用于返回基本的状态信息。
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/26
|
||||
*/
|
||||
@Data
|
||||
public class DGResponse {
|
||||
|
||||
/**
|
||||
* 响应的代码ID。
|
||||
*/
|
||||
@JsonProperty("codeId")
|
||||
private int codeId;
|
||||
|
||||
/**
|
||||
* 响应的消息。
|
||||
*/
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 交易信息返回实体
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/27
|
||||
*/
|
||||
@Data
|
||||
public class DGTransactionResponseDTO {
|
||||
|
||||
|
||||
/** 响应代码 */
|
||||
@JsonProperty("codeId")
|
||||
private Integer codeId;
|
||||
|
||||
/** 响应消息 */
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
|
||||
/** 用户名 */
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
/** 交易金额 */
|
||||
@JsonProperty("amount")
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 账户余额 */
|
||||
@JsonProperty("balance")
|
||||
private BigDecimal balance;
|
||||
|
||||
/** 交易流水号 */
|
||||
@JsonProperty("serial")
|
||||
private String serial;
|
||||
|
||||
/** 交易时间 */
|
||||
@JsonProperty("time")
|
||||
private String time;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 用户账户信息响应类
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/26
|
||||
*/
|
||||
@Data
|
||||
public class DGUserAccountResponse {
|
||||
|
||||
/**
|
||||
* 响应的代码ID。
|
||||
*/
|
||||
@JsonProperty("codeId")
|
||||
private int codeId;
|
||||
|
||||
/**
|
||||
* 响应的消息。
|
||||
*/
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 用户名。
|
||||
*/
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户余额。
|
||||
*/
|
||||
@JsonProperty("balance")
|
||||
private BigDecimal balance;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户列表响应类
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/27
|
||||
*/
|
||||
@Data
|
||||
public class DGUserListResponseDTO {
|
||||
|
||||
/**
|
||||
* 响应的代码ID。
|
||||
*/
|
||||
@JsonProperty("codeId")
|
||||
private int codeId;
|
||||
|
||||
/**
|
||||
* 响应的消息。
|
||||
*/
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
/** 用户列表 */
|
||||
@JsonProperty("list")
|
||||
private List<UserDTO> list;
|
||||
|
||||
/**
|
||||
* 用户信息类
|
||||
*/
|
||||
@Data
|
||||
public static class UserDTO {
|
||||
|
||||
/** 用户名 */
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
/** 昵称 */
|
||||
@JsonProperty("nickname")
|
||||
private String nickname;
|
||||
|
||||
/** 币种名称 */
|
||||
@JsonProperty("currencyName")
|
||||
private String currencyName;
|
||||
|
||||
/** 用户IP */
|
||||
@JsonProperty("ip")
|
||||
private String ip;
|
||||
|
||||
/** 用户设备 */
|
||||
@JsonProperty("device")
|
||||
private String device;
|
||||
|
||||
/** 登录时间 */
|
||||
@JsonProperty("login")
|
||||
private String login;
|
||||
|
||||
/** 会员ID */
|
||||
@JsonProperty("memberId")
|
||||
private Long memberId;
|
||||
|
||||
/** 用户余额 */
|
||||
@JsonProperty("balance")
|
||||
private Double balance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.ff.game.api.pp.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 响应类 - 游戏信息列表
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/27
|
||||
*/
|
||||
@Data
|
||||
public class PPGameResponseDTO {
|
||||
|
||||
/** 错误码 (参考文档定义) */
|
||||
@JsonProperty("error")
|
||||
private String error;
|
||||
|
||||
/** 错误信息 */
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
/** 游戏信息列表 */
|
||||
@JsonProperty("gameList")
|
||||
private List<CasinoGame> gameList;
|
||||
|
||||
/**
|
||||
* 游戏信息类
|
||||
*/
|
||||
@Data
|
||||
public static class CasinoGame {
|
||||
|
||||
/** 游戏唯一标识符 */
|
||||
@JsonProperty("gameID")
|
||||
private String gameID;
|
||||
|
||||
/** 游戏名称 */
|
||||
@JsonProperty("gameName")
|
||||
private String gameName;
|
||||
|
||||
/** 游戏类型标识符 */
|
||||
@JsonProperty("gameTypeID")
|
||||
private String gameTypeID;
|
||||
|
||||
/** 游戏类型描述 */
|
||||
@JsonProperty("typeDescription")
|
||||
private String typeDescription;
|
||||
|
||||
/** 游戏技术描述 */
|
||||
@JsonProperty("technology")
|
||||
private String technology;
|
||||
|
||||
/** 游戏支持的平台 */
|
||||
@JsonProperty("platform")
|
||||
private String platform;
|
||||
|
||||
/** 是否提供演示游戏 */
|
||||
@JsonProperty("demoGameAvailable")
|
||||
private boolean demoGameAvailable;
|
||||
|
||||
/** 游戏宽高比 */
|
||||
@JsonProperty("aspectRatio")
|
||||
private String aspectRatio;
|
||||
|
||||
/** 游戏技术标识符 */
|
||||
@JsonProperty("technologyID")
|
||||
private String technologyID;
|
||||
|
||||
/** 数值型游戏 ID */
|
||||
@JsonProperty("gameIdNumeric")
|
||||
private Long gameIdNumeric;
|
||||
|
||||
/** 是否提供免费回合奖励 */
|
||||
@JsonProperty("frbAvailable")
|
||||
private boolean frbAvailable;
|
||||
|
||||
/** 是否提供可变免费回合奖励 */
|
||||
@JsonProperty("variableFrbAvailable")
|
||||
private boolean variableFrbAvailable;
|
||||
|
||||
/** 游戏的投注线数 */
|
||||
@JsonProperty("lines")
|
||||
private Integer lines;
|
||||
|
||||
/** 游戏支持的功能列表 */
|
||||
@JsonProperty("features")
|
||||
private List<String> features;
|
||||
|
||||
/** 游戏数据类型 */
|
||||
@JsonProperty("dataType")
|
||||
private String dataType;
|
||||
|
||||
/** 支持的司法管辖区列表 */
|
||||
@JsonProperty("jurisdictions")
|
||||
private List<String> jurisdictions;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,419 @@
|
|||
package com.ff.game.api.pp.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
import com.ff.base.constant.CacheConstants;
|
||||
import com.ff.base.constant.Constants;
|
||||
import com.ff.base.core.redis.RedisCache;
|
||||
import com.ff.base.enums.*;
|
||||
import com.ff.base.exception.base.ApiException;
|
||||
import com.ff.base.exception.base.BaseException;
|
||||
import com.ff.base.system.service.ISysConfigService;
|
||||
import com.ff.base.utils.DateUtils;
|
||||
import com.ff.base.utils.JsonUtil;
|
||||
import com.ff.base.utils.StringUtils;
|
||||
import com.ff.base.utils.sign.Md5Utils;
|
||||
import com.ff.base.utils.uuid.IdUtils;
|
||||
import com.ff.config.KeyConfig;
|
||||
import com.ff.game.api.IGamesService;
|
||||
import com.ff.game.api.pp.client.PPClient;
|
||||
import com.ff.game.api.pp.dto.*;
|
||||
import com.ff.game.api.request.*;
|
||||
import com.ff.game.api.xk.dto.XKGamesDTO;
|
||||
import com.ff.game.domain.*;
|
||||
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
|
||||
import com.ff.game.service.*;
|
||||
import com.ff.member.domain.Member;
|
||||
import com.ff.member.service.IMemberService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* DG 游戏 impl
|
||||
*
|
||||
* @author shi
|
||||
* @date 2024/11/12
|
||||
*/
|
||||
@Service("PPService")
|
||||
@Slf4j
|
||||
public class GamesPPServiceImpl implements IGamesService {
|
||||
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Resource
|
||||
private IGameExchangeMoneyService gameExchangeMoneyService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IGamePlatformService gamePlatformService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IGameService gameService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IMemberService memberService;
|
||||
|
||||
@Resource
|
||||
private IGameFreeRecordService gameFreeRecordService;
|
||||
@Resource
|
||||
private IGameSecretKeyService gameSecretKeyService;
|
||||
|
||||
@Resource
|
||||
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
|
||||
|
||||
@Resource
|
||||
private PPClient PPClient;
|
||||
|
||||
|
||||
@Resource
|
||||
private KeyConfig keyConfig;
|
||||
|
||||
@Resource
|
||||
private IGameBettingDetailsService gameBettingDetailsService;
|
||||
|
||||
@Resource
|
||||
private IGameNameService gameNameService;
|
||||
|
||||
|
||||
/**
|
||||
* 游戏id
|
||||
*/
|
||||
private static final Long GAME_ID = 1904452832756003817L;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
private static final Long PLATFORM_ID = 1904411420157108325L;
|
||||
|
||||
/**
|
||||
* 游戏名称id
|
||||
*/
|
||||
private static final Long GAME_NAME_ID = 1904452832756002317L;
|
||||
|
||||
/**
|
||||
* 获得就是成功
|
||||
*
|
||||
* @param errorCode 错误代码
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
private Boolean getIsSuccess(String errorCode) {
|
||||
return "0".equals(errorCode) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取密钥
|
||||
*
|
||||
* @param gamesBaseRequestDTO 游戏请求dto
|
||||
* @return {@link String }
|
||||
*/
|
||||
private String getKey(GamesBaseRequestDTO gamesBaseRequestDTO) {
|
||||
//取出对应的key跟密钥跟请求参数
|
||||
String agentKey = gamesBaseRequestDTO.getAgentKey();
|
||||
|
||||
return Md5Utils.md5New(gamesBaseRequestDTO.getQuery() + agentKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
* @param createMemberRequestDTO 创建成员请求dto
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean createMember(CreateMemberRequestDTO createMemberRequestDTO) {
|
||||
log.info("GamesDGServiceImpl [createMember] 请求参数 {}", createMemberRequestDTO);
|
||||
|
||||
//判断是否获取成功
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取会员信息
|
||||
*
|
||||
* @param memberInfoRequestDTO 会员信息请求dto
|
||||
* @return {@link MemberInfoResponseDTO }
|
||||
*/
|
||||
@Override
|
||||
public MemberInfoResponseDTO getMemberInfo(MemberInfoRequestDTO memberInfoRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 无重定向登录
|
||||
*
|
||||
* @param gamesLogin 游戏登录
|
||||
* @return {@link String }
|
||||
*/
|
||||
@Override
|
||||
public String loginWithoutRedirect(GamesLogin gamesLogin) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取游戏列表
|
||||
*
|
||||
* @param gamesBaseRequestDTO 游戏请求dto
|
||||
* @return {@link String }
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public String getGameList(GamesBaseRequestDTO gamesBaseRequestDTO) {
|
||||
List<XKGamesDTO.DataBean> gamesDatas = redisCache.getCacheList(CacheConstants.PP_GAMES);
|
||||
if (!CollectionUtils.isEmpty(gamesDatas)) {
|
||||
return CacheConstants.PP_GAMES;
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> params = new LinkedHashMap<>();
|
||||
params.put("secureLogin", gamesBaseRequestDTO.getAgentId());
|
||||
String query = JsonUtil.mapToQueryString(params);
|
||||
gamesBaseRequestDTO.setQuery(query);
|
||||
String key = this.getKey(gamesBaseRequestDTO);
|
||||
params.put("hash", key);
|
||||
|
||||
PPGameResponseDTO gameList = PPClient.getGameList(params);
|
||||
|
||||
|
||||
return CacheConstants.PP_GAMES;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按代理id进行交换转账
|
||||
*
|
||||
* @param exchangeTransferMoneyRequestDTO 外汇转账moeny dto
|
||||
* @return {@link Long }
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Long exchangeTransferByAgentId(ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇兑转移状态
|
||||
*
|
||||
* @param exchangeTransferMoneyRequestDTO 兑换转账请求dto
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean exchangeTransferStatus(ExchangeTransferStatusRequestDTO exchangeTransferMoneyRequestDTO) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link List }<{@link GameBettingDetails }>
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送免费局数
|
||||
*
|
||||
* @param createFreeSpinRequest 创建自由旋转请求
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean createFreeSpin(CreateFreeSpinRequestDTO createFreeSpinRequest) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏详细信息
|
||||
*
|
||||
* @param getGameDetailRequestDTO 获取游戏详细信息请求dto
|
||||
* @return {@link GetGameDetailResponseDTO }
|
||||
*/
|
||||
@Override
|
||||
public GetGameDetailResponseDTO getGameDetail(GetGameDetailRequestDTO getGameDetailRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制会员从游戏注销
|
||||
*
|
||||
* @param kickMemberRequestDTO 踢会员请求dto
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean kickMember(KickMemberRequestDTO kickMemberRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢成员全部
|
||||
*
|
||||
* @param kickMemberAllDTO 踢成员全部dto
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean kickMemberAll(KickMemberAllDTO kickMemberAllDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 免费游戏玩家使用的纪录
|
||||
*
|
||||
* @param getFreeSpinDashflowRequestDTO 获取自由旋转dashflow请求dto
|
||||
* @return {@link List }<{@link GameFreeRecord }>
|
||||
*/
|
||||
@Override
|
||||
public List<GameFreeRecord> getFreeSpinDashflow(GetFreeSpinDashflowRequestDTO getFreeSpinDashflowRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消赠送免费局数
|
||||
*
|
||||
* @param cancelFreeSpinRequestDTO 取消免费旋转请求
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean cancelFreeSpin(CancelFreeSpinRequestDTO cancelFreeSpinRequestDTO) {
|
||||
throw new ApiException(ErrorCode.PLATFORM_NOT_METHODS.getCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param dgBetRecordResponseDTO dg投注记录响应dto
|
||||
*/
|
||||
private void batchInsert(DGBetRecordResponseDTO dgBetRecordResponseDTO, GamesBaseRequestDTO gamesBaseRequestDTO) {
|
||||
List<GameBettingDetails> gameBettingDetails = new ArrayList<>();
|
||||
List<String> wagersIds = new ArrayList<>();
|
||||
//数据组装
|
||||
List<DGBetRecordResponseDTO.ReportDTO> report = dgBetRecordResponseDTO.getList();
|
||||
//数据转化
|
||||
for (DGBetRecordResponseDTO.ReportDTO bean : report) {
|
||||
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().data(bean).build());
|
||||
if (!ObjectUtils.isEmpty(bettingDetails)) {
|
||||
bettingDetails.setId(IdUtil.getSnowflakeNextId());
|
||||
gameBettingDetails.add(bettingDetails);
|
||||
}
|
||||
wagersIds.add(String.valueOf(bean.getId()));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(gameBettingDetails)) {
|
||||
//查询重复数据id
|
||||
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds);
|
||||
//用steam流清除list中与wagersIds集合相同的数据
|
||||
gameBettingDetails = gameBettingDetails.stream()
|
||||
.filter(detail -> !removeWagersIds.contains(detail.getWagersId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(gameBettingDetails)) {
|
||||
gameBettingDetailsService.batchInsert(gameBettingDetails);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据构建
|
||||
*
|
||||
* @param gamesDataBuildDTO 数据
|
||||
* @return {@link GameBettingDetails }
|
||||
*/
|
||||
@Override
|
||||
public GameBettingDetails dataBuild(GamesDataBuildDTO gamesDataBuildDTO) {
|
||||
//转化类
|
||||
DGBetRecordResponseDTO.ReportDTO resultBean = (DGBetRecordResponseDTO.ReportDTO) gamesDataBuildDTO.getData();
|
||||
|
||||
|
||||
GameSecretKeyCurrency currencyDTO = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||
.platformCode(GamePlatforms.DG.getInfo())
|
||||
.currencyId(String.valueOf(resultBean.getCurrencyId()))
|
||||
.build());
|
||||
|
||||
|
||||
Member member = memberService.selectMemberByGameAccount(resultBean.getUserName());
|
||||
if (ObjectUtils.isEmpty(member)) {
|
||||
return null;
|
||||
}
|
||||
//未结算的不要
|
||||
if (0 == resultBean.getIsRevocation()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BigDecimal payoffAmount = BigDecimal.ZERO;
|
||||
BigDecimal winOrLoss = resultBean.getWinOrLoss();
|
||||
//输赢状态
|
||||
Integer gameStatus = GameStatus.FLAT.getCode();
|
||||
if (winOrLoss.compareTo(resultBean.getBetPoints()) > 0) {
|
||||
payoffAmount = NumberUtil.sub(winOrLoss, resultBean.getBetPoints());
|
||||
gameStatus = GameStatus.WIN.getCode();
|
||||
} else if (winOrLoss.compareTo(resultBean.getBetPoints()) < 0) {
|
||||
payoffAmount = NumberUtil.sub(resultBean.getWinOrLoss(), resultBean.getBetPoints()).negate();
|
||||
gameStatus = GameStatus.FAIL.getCode();
|
||||
}
|
||||
Game game = gameService.selectGameById(GAME_ID);
|
||||
|
||||
|
||||
//数据构造
|
||||
GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
|
||||
.tenantKey(member.getTenantKey())
|
||||
//保存我们的币种id
|
||||
.currencyCode(currencyDTO.getSystemCurrency())
|
||||
.memberId(member.getId())
|
||||
.gameCode(String.valueOf(resultBean.getGameId()))
|
||||
.gameType(PlatformType.CARD_GAME.getCode())
|
||||
.platformCode(GamePlatforms.DG.getInfo())
|
||||
.gameId(GAME_ID)
|
||||
.gameName(game.getGameName())
|
||||
.gameStatus(gameStatus)
|
||||
.gameStatusType(resultBean.getGameType())
|
||||
.gameCurrencyCode(currencyDTO.getCurrency())
|
||||
.account(String.valueOf(resultBean.getUserName()))
|
||||
.wagersId(String.valueOf(resultBean.getId()))
|
||||
.wagersTime(resultBean.getBetTime().getTime())
|
||||
.betAmount(resultBean.getBetPoints())
|
||||
.betContent(resultBean.getBetDetail())
|
||||
.payoffTime(resultBean.getCalTime().getTime())
|
||||
.payoffAmount(payoffAmount)
|
||||
.settlementTime(resultBean.getCalTime().getTime())
|
||||
.turnover(resultBean.getAvailableBet())
|
||||
.settlementStatus(SettlementStatusEnum.COMPLETED.getCode())
|
||||
.build();
|
||||
gameBettingDetails.setCreateBy(Constants.SYSTEM);
|
||||
gameBettingDetails.setCreateTime(DateUtils.getNowDate());
|
||||
return gameBettingDetails;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue