refactor(ff-game): 重构美天游戏记录同步逻辑
- 修改类名和字段名以适应新的数据结构 - 实现按记录ID和日期同步游戏记录的功能- 优化数据处理和插入逻辑 - 更新游戏平台枚举和游戏类型枚举 - 新增系统配置相关方法main-KM
parent
1c498595e1
commit
c520a5fa24
|
@ -11,7 +11,7 @@ public enum GamePlatforms {
|
|||
FC("FC", "FC"),
|
||||
SA("SA", "SA"),
|
||||
DG("DG", "DG"),
|
||||
MeiTIan("MeiTIan","美天棋牌"),
|
||||
MeiTian("MeiTIan","美天棋牌"),
|
||||
AE("AE", "AE"),
|
||||
;
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ public enum MeiTianGameType {
|
|||
ELECTRON(4, 1, "电子"),
|
||||
CHESS(2, 2, "棋牌"),
|
||||
GAME_HALL(0, 3, "游戏大厅"),
|
||||
CATCH_FISH(3, 4, "捕鱼")
|
||||
//bai_ren(1, 5,"白人")
|
||||
CATCH_FISH(3, 4, "捕鱼"),
|
||||
bai_ren(1, 5,"百人场")
|
||||
,
|
||||
;
|
||||
private final Integer code;
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.List;
|
|||
*/
|
||||
public interface ISysConfigService
|
||||
{
|
||||
|
||||
SysConfig getByConfigKey(String configKey);
|
||||
/**
|
||||
* 查询参数配置信息
|
||||
*
|
||||
|
|
|
@ -32,6 +32,12 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public SysConfig getByConfigKey(String configKey) {
|
||||
SysConfig config = new SysConfig();
|
||||
config.setConfigKey(configKey);
|
||||
return configMapper.selectConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询参数配置信息
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.ff.game.api.meitian.client;
|
||||
|
||||
import com.dtflys.forest.annotation.Address;
|
||||
import com.dtflys.forest.annotation.Body;
|
||||
import com.dtflys.forest.annotation.Post;
|
||||
import com.dtflys.forest.annotation.Var;
|
||||
import com.ff.game.api.meitian.address.MeiTianAddressSource;
|
||||
|
@ -105,17 +104,28 @@ public interface MeiTianClient {
|
|||
);
|
||||
|
||||
/**
|
||||
* 按时间获取投注记录
|
||||
* 按recordId获取投注记录
|
||||
*
|
||||
* @param parameters 参数
|
||||
* @param agentId 代理id
|
||||
* @return {@link JILIBetRecordResponseDTO }
|
||||
* @param merchantId 代理id
|
||||
* @param data
|
||||
* @return {@link MeiTianBetRecordResponseDTO }
|
||||
*/
|
||||
@Post(url = "/GetBetRecordByTime?${parameters}")
|
||||
JILIBetRecordResponseDTO getBetRecordByTime(
|
||||
@Var("parameters") String parameters,
|
||||
@Body("AgentId") String agentId);
|
||||
@Post(url = "/dg/player/queryMerchantGameRecord2/{merchantId}/{data}")
|
||||
MeiTianBetRecordResponseDTO syncRecordByRecordID(
|
||||
@Var("merchantId") String merchantId,
|
||||
@Var("data") String data);
|
||||
|
||||
/**
|
||||
* 按照日期获取投注记录
|
||||
*
|
||||
* @param merchantId
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Post(url = "/dg/player/queryMerchantGameRecord3/{merchantId}/{data}")
|
||||
MeiTianBetRecordResponseDTO syncRecordByDate(
|
||||
@Var("merchantId") String merchantId,
|
||||
@Var("data") String data);
|
||||
|
||||
/**
|
||||
* 踢出
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package com.ff.game.api.meitian.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JiLi游戏纪录查询返回值
|
||||
*
|
||||
* @author shi
|
||||
* @date 2024/10/21
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class JILIBetRecordResponseDTO {
|
||||
|
||||
|
||||
@JsonProperty("ErrorCode")
|
||||
private int errorCode;
|
||||
@JsonProperty("Message")
|
||||
private String message;
|
||||
@JsonProperty("Data")
|
||||
private DataBean data;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DataBean {
|
||||
@JsonProperty("Result")
|
||||
private List<JILIBetRecordDataResponseDTO> result;
|
||||
@JsonProperty("Pagination")
|
||||
private PaginationBean pagination;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class PaginationBean {
|
||||
/**
|
||||
* 当前页面
|
||||
*/
|
||||
@JsonProperty("CurrentPage")
|
||||
private int currentPage;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
@JsonProperty("TotalPages")
|
||||
private int totalPages;
|
||||
/**
|
||||
* 页数限制
|
||||
*/
|
||||
@JsonProperty("PageLimit")
|
||||
private int pageLimit;
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
@JsonProperty("TotalNumber")
|
||||
private int totalNumber;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.ff.game.api.meitian.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 游戏纪录查询返回值
|
||||
*
|
||||
* @author shi
|
||||
* @date 2024/10/21
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class MeiTianBetRecordResponseDTO {
|
||||
|
||||
@JsonProperty("resultCode")
|
||||
private int errorCode;
|
||||
|
||||
@JsonProperty("transList")
|
||||
private List<DataBean> dataList;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DataBean {
|
||||
@JsonProperty("rowID")
|
||||
private String rowID; // 美天棋牌交易流水号
|
||||
@JsonProperty("playerName")
|
||||
private String playerName;
|
||||
@JsonProperty("gameDate")
|
||||
private String gameDate;
|
||||
@JsonProperty("gameCode")
|
||||
private String gameCode;
|
||||
@JsonProperty("period")
|
||||
private String period; // 游戏局ID
|
||||
@JsonProperty("betAmount")
|
||||
private String betAmount; // 下注金额
|
||||
@JsonProperty("commissionable")
|
||||
private String commissionable; // 有效投注量
|
||||
private String roomFee;// 房费
|
||||
private String income; // 赢得金额-下注金额-房费
|
||||
@JsonProperty("recordID")
|
||||
private String recordID; // 游戏记录ID
|
||||
private String gameType; // 游戏类型 1表示百人场,2表示对战,3表示捕鱼,4表示街机
|
||||
private String timeZone; // 时区
|
||||
private String currency; // 币种
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ResultMessage {
|
||||
QueryException(0, "查询异常"),
|
||||
QuerySuccess(1, "查询成功"),
|
||||
MerchantNotExist(2, "商户不存在"),
|
||||
MerchantInvalid(3, "商户无效"),
|
||||
IPLimited(15, "IP被限制"),
|
||||
OptionalParameterError(32, "可选参数错误"),
|
||||
MaintenanceMode(40, "维护模式"),
|
||||
Unknown(-1, "未知错误"),
|
||||
;
|
||||
private final int code;
|
||||
private final String message;
|
||||
}
|
||||
|
||||
public static ResultMessage get(int code) {
|
||||
for (ResultMessage message : ResultMessage.values()) {
|
||||
if (message.code == code) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return ResultMessage.Unknown;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.ff.game.api.meitian.impl;
|
|||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ff.base.constant.CacheConstants;
|
||||
import com.ff.base.constant.Constants;
|
||||
|
@ -10,7 +9,9 @@ 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.domain.SysConfig;
|
||||
import com.ff.base.system.service.ISysConfigService;
|
||||
import com.ff.base.system.service.impl.SysConfigServiceImpl;
|
||||
import com.ff.base.utils.DateUtils;
|
||||
import com.ff.base.utils.sign.Md5Utils;
|
||||
import com.ff.base.utils.uuid.IdUtils;
|
||||
|
@ -24,6 +25,7 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -34,10 +36,11 @@ import javax.annotation.Resource;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -88,6 +91,8 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
|
||||
@Resource
|
||||
private IGameNameService gameNameService;
|
||||
@Autowired
|
||||
private SysConfigServiceImpl sysConfigServiceImpl;
|
||||
|
||||
/**
|
||||
* 获得就是成功
|
||||
|
@ -233,12 +238,12 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
for (MeiTianGameDataDTO gamesDataDTO : gameList.getData()) {
|
||||
GamePlatform gamePlatform = GamePlatform.builder()
|
||||
.platformType(MeiTianGameType.findSystemByCode(gamesDataDTO.getGameCategoryId()))
|
||||
.platformCode(GamePlatforms.MeiTIan.getCode())
|
||||
.platformCode(GamePlatforms.MeiTian.getCode())
|
||||
.build();
|
||||
List<GamePlatform> gamePlatforms = gamePlatformService.selectGamePlatformList(gamePlatform);
|
||||
//没有此平台就新增一个平台
|
||||
if (CollectionUtils.isEmpty(gamePlatforms)) {
|
||||
gamePlatform.setPlatformName(GamePlatforms.MeiTIan.getInfo() + MeiTianGameType.findInfoByCode(gamesDataDTO.getGameCategoryId()));
|
||||
gamePlatform.setPlatformName(GamePlatforms.MeiTian.getInfo() + MeiTianGameType.findInfoByCode(gamesDataDTO.getGameCategoryId()));
|
||||
gamePlatform.setSortNo(gamePlatformService.selectMaxSortNo() + 1);
|
||||
gamePlatform.setCreateBy(Constants.SYSTEM);
|
||||
gamePlatformService.insertGamePlatform(gamePlatform);
|
||||
|
@ -304,7 +309,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
.currency(exchangeTransferMoneyRequestDTO.getCurrency()).build());
|
||||
|
||||
Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount());
|
||||
String transactionId = GamePlatforms.MeiTIan.getCode() + IdUtils.simpleUUID();
|
||||
String transactionId = GamePlatforms.MeiTian.getCode() + IdUtils.simpleUUID();
|
||||
|
||||
List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList(
|
||||
GameExchangeMoney.builder()
|
||||
|
@ -326,7 +331,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
.currencyCode(gameSecretKey.getSystemCurrency())
|
||||
.memberId(member.getId())
|
||||
.transactionId(transactionId)
|
||||
.platformCode(GamePlatforms.MeiTIan.getCode())
|
||||
.platformCode(GamePlatforms.MeiTian.getCode())
|
||||
.build();
|
||||
exchangeMoney.setCreateBy(Constants.SYSTEM);
|
||||
//接口限制限制50字符
|
||||
|
@ -430,38 +435,117 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
return doSyncRecordByRecordID(betRecordByTimeDTO);
|
||||
}
|
||||
|
||||
/*//获取key
|
||||
JILIBetRecordResponseDTO betRecordJILIResponse = meiTianClient.getBetRecordByTime(query + "&Key=" + key, betRecordByTimeDTO.getAgentId());
|
||||
boolean doSyncRecordByRecordID(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
String configKey = GamePlatforms.MeiTian.getCode() + ":lastRecordID";
|
||||
String lastRecordID = sysConfigServiceImpl.selectConfigByKey(configKey);
|
||||
long recordID = 0;
|
||||
if (lastRecordID == null || lastRecordID.isEmpty()) {
|
||||
|
||||
} else {
|
||||
recordID = Long.parseLong(lastRecordID);
|
||||
}
|
||||
String merchantId = betRecordByTimeDTO.getAgentId();
|
||||
Map<String, String> rawMap = new LinkedHashMap<>();
|
||||
rawMap.put("recordID", recordID + "");
|
||||
String rawData = JSON.toJSONString(rawMap);
|
||||
String data = null;
|
||||
try {
|
||||
data = Base64.encode(rawData.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (Exception e) {
|
||||
log.error("[MeiTian] base64 rawData failure", e);
|
||||
throw new ApiException(ErrorCode.ERROR.getCode());
|
||||
}
|
||||
|
||||
//获取key
|
||||
MeiTianBetRecordResponseDTO recordResponse =
|
||||
meiTianClient.syncRecordByRecordID(merchantId, data);
|
||||
|
||||
//判断是否获取成功
|
||||
if (this.isSuccess(betRecordJILIResponse.getErrorCode())) {
|
||||
if (this.isSuccess(recordResponse.getErrorCode())) {
|
||||
List<MeiTianBetRecordResponseDTO.DataBean> dataList = recordResponse.getDataList();
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
//数据插入
|
||||
this.batchInsert(betRecordJILIResponse);
|
||||
JILIBetRecordResponseDTO.DataBean dataBean = betRecordJILIResponse.getData();
|
||||
//获取下一页数据
|
||||
while (dataBean.getPagination().getCurrentPage() != dataBean.getPagination().getTotalPages() && dataBean.getPagination().getTotalPages() > 0) {
|
||||
betRecordByTimeDTO.setPage(dataBean.getPagination().getCurrentPage() + 1);
|
||||
//请求参数
|
||||
query = "StartTime=" + startTime + "&EndTime=" + endTime + "&Page=" + betRecordByTimeDTO.getPage() + "&PageLimit=" + betRecordByTimeDTO.getPageLimit() + "&AgentId=" + betRecordByTimeDTO.getAgentId();
|
||||
log.info("GamesJILIServiceImpl [getBetRecordByTime] 请求参数 {}", query);
|
||||
betRecordByTimeDTO.setQuery(query);
|
||||
key = this.getKey(betRecordByTimeDTO);
|
||||
betRecordJILIResponse = meiTianClient.getBetRecordByTime(query + "&Key=" + key, betRecordByTimeDTO.getAgentId());
|
||||
dataBean = betRecordJILIResponse.getData();
|
||||
if (this.isSuccess(betRecordJILIResponse.getErrorCode())) {
|
||||
//数据插入
|
||||
this.batchInsert(betRecordJILIResponse);
|
||||
} else {
|
||||
log.error("GameBettingDataJILIServiceImpl [getBetRecordByTime] 获取投注记录失败,错误代码{},错误信息{}", betRecordJILIResponse.getErrorCode(), betRecordJILIResponse.getMessage());
|
||||
}
|
||||
this.batchInsert(recordResponse);
|
||||
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
||||
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
||||
config.setConfigValue(dataBean.getRecordID());
|
||||
sysConfigServiceImpl.updateConfig(config);
|
||||
|
||||
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
||||
if (dataList.size() >= 25000) {
|
||||
doSyncRecordByRecordID(betRecordByTimeDTO);
|
||||
}
|
||||
} else {
|
||||
return Boolean.FALSE;
|
||||
}*/
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
|
||||
String date = getDateStr(0);
|
||||
String configKey = GamePlatforms.MeiTian.getCode() + ":lastSyncDate";
|
||||
String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey);
|
||||
Map<String, Long> syncDateMap = new HashMap<>();
|
||||
long recordID = 0;
|
||||
if (syncDateStr == null || syncDateStr.isEmpty()) {
|
||||
} else {
|
||||
syncDateMap = JSON.parseObject(syncDateStr, Map.class);
|
||||
}
|
||||
if (syncDateMap.containsKey(date)) {
|
||||
recordID = syncDateMap.get(date);
|
||||
if (syncDateMap.size() > 10) {
|
||||
syncDateMap.clear();
|
||||
syncDateMap.put(date, recordID);
|
||||
}
|
||||
} else {
|
||||
syncDateMap.put(date, recordID);
|
||||
}
|
||||
String merchantId = betRecordByTimeDTO.getAgentId();
|
||||
Map<String, String> rawMap = new LinkedHashMap<>();
|
||||
rawMap.put("recordID", recordID + "");
|
||||
rawMap.put("startTime", date);
|
||||
rawMap.put("endTime", date);
|
||||
String rawData = JSON.toJSONString(rawMap);
|
||||
String data = null;
|
||||
try {
|
||||
data = Base64.encode(rawData.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (Exception e) {
|
||||
log.error("[MeiTian] base64 rawData failure", e);
|
||||
throw new ApiException(ErrorCode.ERROR.getCode());
|
||||
}
|
||||
|
||||
//获取key
|
||||
MeiTianBetRecordResponseDTO recordResponse =
|
||||
meiTianClient.syncRecordByRecordID(merchantId, data);
|
||||
|
||||
//判断是否获取成功
|
||||
if (this.isSuccess(recordResponse.getErrorCode())) {
|
||||
List<MeiTianBetRecordResponseDTO.DataBean> dataList = recordResponse.getDataList();
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
//数据插入
|
||||
this.batchInsert(recordResponse);
|
||||
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
||||
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
||||
config.setConfigValue(JSON.toJSONString(syncDateMap));
|
||||
sysConfigServiceImpl.updateConfig(config);
|
||||
|
||||
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
||||
if (dataList.size() >= 25000) {
|
||||
doSyncRecordByDate(betRecordByTimeDTO);
|
||||
}
|
||||
} else {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
|
@ -471,7 +555,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
return null;
|
||||
return doSyncRecordByDate(betRecordByTimeDTO);
|
||||
}
|
||||
|
||||
|
||||
|
@ -584,26 +668,30 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param betRecordJILIResponse 投注记录jiliresponse
|
||||
* @return {@link Integer }
|
||||
* @param recordResponse 投注记录
|
||||
*/
|
||||
private void batchInsert(JILIBetRecordResponseDTO betRecordJILIResponse) {
|
||||
private void batchInsert(MeiTianBetRecordResponseDTO recordResponse) {
|
||||
List<GameBettingDetails> gameBettingDetails = new ArrayList<>();
|
||||
List<String> wagersIds = new ArrayList<>();
|
||||
//数据组装
|
||||
JILIBetRecordResponseDTO.DataBean dataBean = betRecordJILIResponse.getData();
|
||||
List<MeiTianBetRecordResponseDTO.DataBean> dataList = recordResponse.getDataList();
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//数据转化
|
||||
for (JILIBetRecordDataResponseDTO jiliBetRecordDataResponseDTO : dataBean.getResult()) {
|
||||
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().data(jiliBetRecordDataResponseDTO).build());
|
||||
for (MeiTianBetRecordResponseDTO.DataBean dataBean : dataList) {
|
||||
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder()
|
||||
.data(dataBean).build());
|
||||
if (!ObjectUtils.isEmpty(bettingDetails)) {
|
||||
bettingDetails.setId(IdUtil.getSnowflakeNextId());
|
||||
gameBettingDetails.add(bettingDetails);
|
||||
}
|
||||
wagersIds.add(jiliBetRecordDataResponseDTO.getWagersId());
|
||||
wagersIds.add(dataBean.getRowID());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(gameBettingDetails)) {
|
||||
//查询重复数据id
|
||||
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds);
|
||||
List<String> removeWagersIds = gameBettingDetailsService.selectGameBettingDetailsByWagersId(wagersIds, GamePlatforms.MeiTian.getCode());
|
||||
//用steam流清除list中与wagersIds集合相同的数据
|
||||
gameBettingDetails = gameBettingDetails.stream()
|
||||
.filter(detail -> !removeWagersIds.contains(detail.getWagersId()))
|
||||
|
@ -625,53 +713,77 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
|||
public GameBettingDetails dataBuild(GamesDataBuildDTO gamesDataBuildDTO) {
|
||||
|
||||
//转化类
|
||||
JILIBetRecordDataResponseDTO jiliBetRecordDataResponseDTO = (JILIBetRecordDataResponseDTO) gamesDataBuildDTO.getData();
|
||||
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||
.code(jiliBetRecordDataResponseDTO.getAgentId())
|
||||
.platformCode(GamePlatforms.MeiTIan.getInfo()).build());
|
||||
MeiTianBetRecordResponseDTO.DataBean dataBean = (MeiTianBetRecordResponseDTO.DataBean) gamesDataBuildDTO.getData();
|
||||
GameSecretKeyCurrencyDTO gameSecretKey =
|
||||
gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||
.currency(dataBean.getCurrency())
|
||||
.platformCode(GamePlatforms.MeiTian.getInfo()).build());
|
||||
|
||||
|
||||
Member member = memberService.selectMemberByGameAccount(jiliBetRecordDataResponseDTO.getAccount());
|
||||
Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName());
|
||||
if (ObjectUtils.isEmpty(member)) {
|
||||
return null;
|
||||
}
|
||||
List<MeiTianGameDataDTO> gamesDatas = redisCache.getCacheList(CacheConstants.JILI_GAMES);
|
||||
Map<String, MeiTianGameDataDTO> dataDTOMap = gamesDatas.stream().collect(Collectors.toMap(MeiTianGameDataDTO::getGameId, e -> e));
|
||||
MeiTianGameDataDTO gamesDataDTO = dataDTOMap.get(jiliBetRecordDataResponseDTO.getGameId());
|
||||
BigDecimal payoffAmount = BigDecimal.ZERO;
|
||||
if (GameStatus.WIN.getCode().equals(jiliBetRecordDataResponseDTO.getStatus())) {
|
||||
payoffAmount = NumberUtil.sub(jiliBetRecordDataResponseDTO.getPayoffAmount(), jiliBetRecordDataResponseDTO.getTurnover());
|
||||
} else if (GameStatus.FAIL.getCode().equals(jiliBetRecordDataResponseDTO.getStatus())) {
|
||||
payoffAmount = NumberUtil.sub(jiliBetRecordDataResponseDTO.getPayoffAmount(), jiliBetRecordDataResponseDTO.getTurnover()).negate();
|
||||
}
|
||||
List<MeiTianGameDataDTO> gameDatas = redisCache.getCacheList(CacheConstants.MeiTian_GAMES);
|
||||
Map<String, MeiTianGameDataDTO> dataDTOMap = gameDatas.stream().collect(Collectors.toMap(MeiTianGameDataDTO::getGameId, e -> e));
|
||||
MeiTianGameDataDTO gamesDataDTO = dataDTOMap.get(dataBean.getGameCode());
|
||||
BigDecimal originPayoffAmount = new BigDecimal(dataBean.getIncome()); // 这个值是到手的
|
||||
|
||||
int compareResult = originPayoffAmount.compareTo(BigDecimal.ZERO);
|
||||
long gameTime = getTime(dataBean.getGameDate());
|
||||
//数据构造
|
||||
GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
|
||||
.tenantKey(member.getTenantKey())
|
||||
//保存我们的币种id
|
||||
.currencyCode(gameSecretKey.getSystemCurrency())
|
||||
.memberId(member.getId())
|
||||
.gameCode(jiliBetRecordDataResponseDTO.getGameId())
|
||||
.gameType(JILIGameType.findSystemByCode(jiliBetRecordDataResponseDTO.getGameCategoryId()))
|
||||
.platformCode(GamePlatforms.MeiTIan.getCode())
|
||||
.gameCode(dataBean.getGameCode())
|
||||
.gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameCode())))
|
||||
.platformCode(GamePlatforms.MeiTian.getCode())
|
||||
.gameId(gamesDataDTO.getSystemGameId())
|
||||
.gameName(gamesDataDTO.getCnName())
|
||||
.gameStatus(jiliBetRecordDataResponseDTO.getStatus())
|
||||
.gameStatusType(jiliBetRecordDataResponseDTO.getType())
|
||||
.gameCurrencyCode(jiliBetRecordDataResponseDTO.getAgentId())
|
||||
.account(String.valueOf(jiliBetRecordDataResponseDTO.getAccount()))
|
||||
.wagersId(jiliBetRecordDataResponseDTO.getWagersId())
|
||||
.wagersTime(jiliBetRecordDataResponseDTO.getWagersTime())
|
||||
.betAmount(jiliBetRecordDataResponseDTO.getBetAmount().abs())
|
||||
.payoffTime(jiliBetRecordDataResponseDTO.getPayoffTime())
|
||||
.payoffAmount(payoffAmount)
|
||||
.settlementTime(jiliBetRecordDataResponseDTO.getSettlementTime())
|
||||
.turnover(jiliBetRecordDataResponseDTO.getTurnover())
|
||||
.orderNo(String.valueOf(jiliBetRecordDataResponseDTO.getRoundIndex()))
|
||||
.gameStatus(compareResult > 0 ? GameStatus.WIN.getCode() : compareResult < 0 ? GameStatus.FAIL.getCode() : GameStatus.FLAT.getCode())
|
||||
.gameStatusType(1) // 一般下注
|
||||
.gameCurrencyCode(dataBean.getCurrency())
|
||||
.account(dataBean.getPlayerName())
|
||||
.wagersId(dataBean.getRowID())
|
||||
.wagersTime(gameTime)
|
||||
.betAmount(new BigDecimal(dataBean.getBetAmount()))
|
||||
.payoffTime(gameTime)
|
||||
.payoffAmount(originPayoffAmount.abs())
|
||||
.settlementTime(gameTime)
|
||||
.turnover(new BigDecimal(dataBean.getCommissionable()))
|
||||
.orderNo(dataBean.getRowID())
|
||||
.settlementStatus(SettlementStatusEnum.COMPLETED.getCode())
|
||||
.build();
|
||||
gameBettingDetails.setCreateBy(Constants.SYSTEM);
|
||||
gameBettingDetails.setCreateTime(DateUtils.getNowDate());
|
||||
return gameBettingDetails;
|
||||
}
|
||||
|
||||
public long getTime(String date) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
return parse.getTime();
|
||||
} catch (ParseException e) {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public LocalDate getDate(int daysToSubtract) {
|
||||
return LocalDate.now().minusDays(daysToSubtract); // 获取当前日期减去两天
|
||||
}
|
||||
|
||||
public String getDateStr(int daysToSubtract) {
|
||||
// 获取当前日期减去指定天数
|
||||
LocalDate date = LocalDate.now().minusDays(daysToSubtract);
|
||||
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
// 返回格式化日期字符串
|
||||
return date.format(formatter);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue