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