refactor(ff-game): 重构 SV388 投注记录获取逻辑
- 引入 DelayService 和 DelayTask 机制,实现异步处理投注记录请求 -将原有的同步方法拆分为实时记录和历史记录两个异步任务- 优化了错误处理逻辑,移除了不必要的异常抛出 - 调整了参数处理和日志记录,提高了代码可读性和维护性main-meitian
parent
ff36a40799
commit
b0c058345d
|
@ -12,6 +12,8 @@ import com.ff.base.utils.DateUtils;
|
|||
import com.ff.base.utils.JsonUtil;
|
||||
import com.ff.base.utils.StringUtils;
|
||||
import com.ff.base.utils.uuid.IdUtils;
|
||||
import com.ff.delay.DelayService;
|
||||
import com.ff.delay.DelayTask;
|
||||
import com.ff.game.api.IGamesService;
|
||||
import com.ff.game.api.request.*;
|
||||
import com.ff.game.api.sv388.client.SV388Client;
|
||||
|
@ -65,6 +67,9 @@ public class SV388GamesServiceImpl implements IGamesService {
|
|||
@Resource
|
||||
private IGameBettingDetailsService gameBettingDetailsService;
|
||||
|
||||
@Resource
|
||||
private DelayService delayService;
|
||||
|
||||
/**
|
||||
* 游戏id
|
||||
*/
|
||||
|
@ -337,14 +342,20 @@ public class SV388GamesServiceImpl implements IGamesService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link List }<{@link GameBettingDetails }>
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
class GetRealtimeRecordTask extends DelayTask {
|
||||
BetRecordByTimeDTO betRecordByTimeDTO;
|
||||
|
||||
public GetRealtimeRecordTask(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
this.betRecordByTimeDTO = betRecordByTimeDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
getRealtimeRecord(betRecordByTimeDTO);
|
||||
}
|
||||
}
|
||||
|
||||
void getRealtimeRecord(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
//请求参数
|
||||
Map<String, Object> params = this.getKey(betRecordByTimeDTO);
|
||||
|
||||
|
@ -353,7 +364,6 @@ public class SV388GamesServiceImpl implements IGamesService {
|
|||
timeFrom = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getStartTime(), DateUtils.ISO_8601_FORMAT, "GMT+8") + "+08:00";
|
||||
}
|
||||
|
||||
|
||||
params.put("timeFrom", timeFrom);
|
||||
params.put("platform", GamePlatforms.SV388.getCode());
|
||||
params.put("delayTime", 10000);
|
||||
|
@ -363,27 +373,16 @@ public class SV388GamesServiceImpl implements IGamesService {
|
|||
if (this.getIsSuccess(aeBetRecordResponse.getStatus())) {
|
||||
//数据组装
|
||||
this.batchInsert(aeBetRecordResponse, betRecordByTimeDTO);
|
||||
return Boolean.TRUE;
|
||||
} else {
|
||||
redisCache.deleteObject(CacheConstants.SV388_TIME_FROM);
|
||||
log.error("获取投注记录失败,错误代码{},错误信息{}", aeBetRecordResponse.getStatus(), aeBetRecordResponse.getDesc());
|
||||
throw new BaseException(aeBetRecordResponse.getDesc());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
void getHistoryRecord(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
Map<String, Object> params = this.getKey(betRecordByTimeDTO);
|
||||
String startTime = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getStartTime(), DateUtils.ISO_8601_FORMAT, "GMT+8") + "+08:00";
|
||||
String endTime = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getEndTime(), DateUtils.ISO_8601_FORMAT, "GMT+8") + "+08:00";
|
||||
|
||||
String endTime = DateUtils.convertTimestampToFormattedDate(betRecordByTimeDTO.getStartTime(), DateUtils.ISO_8601_FORMAT, "GMT+8") + "+08:00";
|
||||
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
|
@ -395,13 +394,48 @@ public class SV388GamesServiceImpl implements IGamesService {
|
|||
if (this.getIsSuccess(aeBetRecordResponse.getStatus())) {
|
||||
//数据组装
|
||||
this.batchInsert(aeBetRecordResponse, betRecordByTimeDTO);
|
||||
return Boolean.TRUE;
|
||||
} else {
|
||||
log.error("获取投注记录失败,错误代码{},错误信息{}", aeBetRecordResponse.getStatus(), aeBetRecordResponse.getDesc());
|
||||
throw new BaseException(aeBetRecordResponse.getDesc());
|
||||
}
|
||||
}
|
||||
|
||||
class GetHistoryRecordTask extends DelayTask {
|
||||
BetRecordByTimeDTO betRecordByTimeDTO;
|
||||
|
||||
public GetHistoryRecordTask(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
this.betRecordByTimeDTO = betRecordByTimeDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
getHistoryRecord(betRecordByTimeDTO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link List }<{@link GameBettingDetails }>
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
delayService.addTask(new GetRealtimeRecordTask(betRecordByTimeDTO));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @return {@link Boolean }
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO) {
|
||||
delayService.addTask(new GetHistoryRecordTask(betRecordByTimeDTO));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送免费局数
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue