fix(game): 修复美天平台同步异常问题
- 修正平台代码和游戏类型获取逻辑 - 优化数据同步流程,支持按日期同步 - 增加错误日志记录 - 完善配置插入和更新逻辑main-KM
parent
953c94ff3f
commit
d3fcfad870
|
@ -11,7 +11,7 @@ public enum GamePlatforms {
|
||||||
FC("FC", "FC"),
|
FC("FC", "FC"),
|
||||||
SA("SA", "SA"),
|
SA("SA", "SA"),
|
||||||
DG("DG", "DG"),
|
DG("DG", "DG"),
|
||||||
MeiTian("MeiTIan","美天棋牌"),
|
MeiTian("MeiTian","美天棋牌"),
|
||||||
AE("AE", "AE"),
|
AE("AE", "AE"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -448,8 +448,8 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
recordID = Long.parseLong(lastRecordID);
|
recordID = Long.parseLong(lastRecordID);
|
||||||
}
|
}
|
||||||
String merchantId = betRecordByTimeDTO.getAgentId();
|
String merchantId = betRecordByTimeDTO.getAgentId();
|
||||||
Map<String, String> rawMap = new LinkedHashMap<>();
|
Map<String, Object> rawMap = new LinkedHashMap<>();
|
||||||
rawMap.put("recordID", recordID + "");
|
rawMap.put("recordID", recordID);
|
||||||
String rawData = JSON.toJSONString(rawMap);
|
String rawData = JSON.toJSONString(rawMap);
|
||||||
String data = null;
|
String data = null;
|
||||||
try {
|
try {
|
||||||
|
@ -473,22 +473,29 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
this.batchInsert(recordResponse);
|
this.batchInsert(recordResponse);
|
||||||
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
||||||
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
||||||
|
if (config == null) {
|
||||||
|
config = new SysConfig();
|
||||||
|
config.setConfigKey(configKey);
|
||||||
|
config.setConfigValue(dataBean.getRecordID());
|
||||||
|
sysConfigServiceImpl.insertConfig(config);
|
||||||
|
} else {
|
||||||
config.setConfigValue(dataBean.getRecordID());
|
config.setConfigValue(dataBean.getRecordID());
|
||||||
sysConfigServiceImpl.updateConfig(config);
|
sysConfigServiceImpl.updateConfig(config);
|
||||||
|
}
|
||||||
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
||||||
if (dataList.size() >= 25000) {
|
if (dataList.size() >= 25000) {
|
||||||
doSyncRecordByRecordID(betRecordByTimeDTO);
|
doSyncRecordByRecordID(betRecordByTimeDTO);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.error("[MeiTian] syncRecordByRecordID failure, errorCode:{}", recordResponse.getErrorCode());
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO) {
|
boolean doSyncRecordByDate(BetRecordByTimeDTO betRecordByTimeDTO, int daysToSubtract) {
|
||||||
|
|
||||||
String date = getDateStr(0);
|
String date = getDateStr(daysToSubtract);
|
||||||
String configKey = GamePlatforms.MeiTian.getCode() + ":lastSyncDate";
|
String configKey = GamePlatforms.MeiTian.getCode() + ":lastSyncDate";
|
||||||
String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey);
|
String syncDateStr = sysConfigServiceImpl.selectConfigByKey(configKey);
|
||||||
Map<String, Long> syncDateMap = new HashMap<>();
|
Map<String, Long> syncDateMap = new HashMap<>();
|
||||||
|
@ -507,8 +514,8 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
syncDateMap.put(date, recordID);
|
syncDateMap.put(date, recordID);
|
||||||
}
|
}
|
||||||
String merchantId = betRecordByTimeDTO.getAgentId();
|
String merchantId = betRecordByTimeDTO.getAgentId();
|
||||||
Map<String, String> rawMap = new LinkedHashMap<>();
|
Map<String, Object> rawMap = new LinkedHashMap<>();
|
||||||
rawMap.put("recordID", recordID + "");
|
rawMap.put("rowID", recordID);
|
||||||
rawMap.put("startTime", date);
|
rawMap.put("startTime", date);
|
||||||
rawMap.put("endTime", date);
|
rawMap.put("endTime", date);
|
||||||
String rawData = JSON.toJSONString(rawMap);
|
String rawData = JSON.toJSONString(rawMap);
|
||||||
|
@ -522,7 +529,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
|
|
||||||
//获取key
|
//获取key
|
||||||
MeiTianBetRecordResponseDTO recordResponse =
|
MeiTianBetRecordResponseDTO recordResponse =
|
||||||
meiTianClient.syncRecordByRecordID(merchantId, data);
|
meiTianClient.syncRecordByDate(merchantId, data);
|
||||||
|
|
||||||
//判断是否获取成功
|
//判断是否获取成功
|
||||||
if (this.isSuccess(recordResponse.getErrorCode())) {
|
if (this.isSuccess(recordResponse.getErrorCode())) {
|
||||||
|
@ -533,15 +540,24 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
//数据插入
|
//数据插入
|
||||||
this.batchInsert(recordResponse);
|
this.batchInsert(recordResponse);
|
||||||
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
MeiTianBetRecordResponseDTO.DataBean dataBean = dataList.get(dataList.size() - 1);
|
||||||
|
syncDateMap.put(date, Long.parseLong(dataBean.getRowID()));
|
||||||
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
SysConfig config = sysConfigServiceImpl.getByConfigKey(configKey);
|
||||||
|
if (null == config) {
|
||||||
|
config = new SysConfig();
|
||||||
|
config.setConfigKey(configKey);
|
||||||
|
config.setConfigValue(JSON.toJSONString(syncDateMap));
|
||||||
|
sysConfigServiceImpl.insertConfig(config);
|
||||||
|
} else {
|
||||||
config.setConfigValue(JSON.toJSONString(syncDateMap));
|
config.setConfigValue(JSON.toJSONString(syncDateMap));
|
||||||
sysConfigServiceImpl.updateConfig(config);
|
sysConfigServiceImpl.updateConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
// 它每次返回25000条,所以需要判断,如果大于25000条,则继续拉取
|
||||||
if (dataList.size() >= 25000) {
|
if (dataList.size() >= 25000) {
|
||||||
doSyncRecordByDate(betRecordByTimeDTO);
|
doSyncRecordByDate(betRecordByTimeDTO, daysToSubtract);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.error("[MeiTian] syncRecordByDate error, errorCode:{}", recordResponse.getErrorCode());
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
|
@ -555,7 +571,10 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||||
return doSyncRecordByDate(betRecordByTimeDTO);
|
doSyncRecordByDate(betRecordByTimeDTO, 0);
|
||||||
|
doSyncRecordByDate(betRecordByTimeDTO, 1); // yesterday
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -717,7 +736,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
GameSecretKeyCurrencyDTO gameSecretKey =
|
GameSecretKeyCurrencyDTO gameSecretKey =
|
||||||
gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||||
.currency(dataBean.getCurrency())
|
.currency(dataBean.getCurrency())
|
||||||
.platformCode(GamePlatforms.MeiTian.getInfo()).build());
|
.platformCode(GamePlatforms.MeiTian.getCode()).build());
|
||||||
|
|
||||||
|
|
||||||
Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName());
|
Member member = memberService.selectMemberByGameAccount(dataBean.getPlayerName());
|
||||||
|
@ -738,7 +757,7 @@ public class MeiTianGameServiceImpl implements IGamesService {
|
||||||
.currencyCode(gameSecretKey.getSystemCurrency())
|
.currencyCode(gameSecretKey.getSystemCurrency())
|
||||||
.memberId(member.getId())
|
.memberId(member.getId())
|
||||||
.gameCode(dataBean.getGameCode())
|
.gameCode(dataBean.getGameCode())
|
||||||
.gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameCode())))
|
.gameType(MeiTianGameType.findSystemByCode(Integer.parseInt(dataBean.getGameType())))
|
||||||
.platformCode(GamePlatforms.MeiTian.getCode())
|
.platformCode(GamePlatforms.MeiTian.getCode())
|
||||||
.gameId(gamesDataDTO.getSystemGameId())
|
.gameId(gamesDataDTO.getSystemGameId())
|
||||||
.gameName(gamesDataDTO.getCnName())
|
.gameName(gamesDataDTO.getCnName())
|
||||||
|
|
Loading…
Reference in New Issue