diff --git a/ff-game/src/main/java/com/ff/game/api/sv388/impl/SV388GamesServiceImpl.java b/ff-game/src/main/java/com/ff/game/api/sv388/impl/SV388GamesServiceImpl.java index a49ef4b..75ea9f0 100644 --- a/ff-game/src/main/java/com/ff/game/api/sv388/impl/SV388GamesServiceImpl.java +++ b/ff-game/src/main/java/com/ff/game/api/sv388/impl/SV388GamesServiceImpl.java @@ -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 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 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; + } + /** * 赠送免费局数 *