feat(game): 增加按时间查询游戏投注记录功能
- 新增 GameBettingDetailsDTO 类,用于游戏投注详情查询 - 在 GameBettingDetailsMapper 中添加按时间查询的 SQL 语句 - 修改 GameBettingDetailsServiceImpl 中的查询方法,支持按时间查询 - 更新相关控制器和接口,增加按时间查询游戏记录的功能main-cf
parent
59af0c07a7
commit
7c77aa5555
|
@ -22,6 +22,7 @@ import com.ff.config.KeyConfig;
|
|||
import com.ff.game.api.IGamesService;
|
||||
import com.ff.game.api.request.*;
|
||||
import com.ff.game.domain.*;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
|
||||
import com.ff.game.dto.GameSecretKeyLangDTO;
|
||||
import com.ff.game.service.*;
|
||||
|
@ -316,10 +317,11 @@ public class ApiGameController extends BaseController {
|
|||
|
||||
startPage();
|
||||
PageHelper.startPage(gameCreateFreeSpinRequest.getPageNo(), gameCreateFreeSpinRequest.getPageSize(), "wagers_time desc");
|
||||
GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
|
||||
GameBettingDetailsDTO gameBettingDetails = GameBettingDetailsDTO.builder()
|
||||
.platformCode(gameCreateFreeSpinRequest.getPlatformCode())
|
||||
.currencyCode(gameCreateFreeSpinRequest.getCurrencyCode())
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.timeType(gameCreateFreeSpinRequest.getTimeType())
|
||||
.build();
|
||||
Map<String, Object> params = gameBettingDetails.getParams();
|
||||
params.put("beginTime", gameCreateFreeSpinRequest.getBeginTime());
|
||||
|
|
|
@ -49,6 +49,12 @@ public class GameGetBetRecordRequest implements Serializable {
|
|||
private Long endTime;
|
||||
|
||||
|
||||
/**
|
||||
* 时间类型 1 按投注时间 2 按入库时间
|
||||
*/
|
||||
private Integer timeType=1;
|
||||
|
||||
|
||||
/**
|
||||
* 页码,默认第1页,按订单更新时间正序返回数据
|
||||
*/
|
||||
|
|
|
@ -96,4 +96,16 @@ public interface NGClient {
|
|||
*/
|
||||
@Post(url = "server/recordAll")
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> getBetRecordByTime(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap);
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
*
|
||||
* @param parameters 范围
|
||||
* @param headerMap 标题映射
|
||||
* @return {@link ApiNGResponseDTO }<{@link ApiGameBetRecordPageResponseDTO }>
|
||||
*/
|
||||
@Post(url = "server/recordHistory")
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> getBetRecordByHistoryTime(@JSONBody Map<String, Object> parameters, @Header Map<String, String> headerMap);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -503,15 +503,88 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
.build());
|
||||
|
||||
|
||||
// String startTime = DateTimeFormatter
|
||||
// .ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
// .withZone(ZoneId.of("Asia/Shanghai"))
|
||||
// .format(Instant.ofEpochMilli(betRecordByTimeDTO.getStartTime()));
|
||||
//
|
||||
// String endTime = DateTimeFormatter
|
||||
// .ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
// .withZone(ZoneId.of("Asia/Shanghai"))
|
||||
// .format(Instant.ofEpochMilli(betRecordByTimeDTO.getEndTime()));
|
||||
betRecordByTimeDTO.setAgentId(currencyDTO.getCode());
|
||||
betRecordByTimeDTO.setAgentKey(currencyDTO.getKey());
|
||||
int pageNo = 1;
|
||||
int pageSize = 2000;
|
||||
Map<String, Object> paramsMap = new HashMap<>();
|
||||
paramsMap.put("currency", currencyDTO.getCurrency());
|
||||
paramsMap.put("pageNo", pageNo);
|
||||
paramsMap.put("pageSize", pageSize);
|
||||
Map<String, String> key = this.getKey(betRecordByTimeDTO);
|
||||
|
||||
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> betRecordByTime = ngClient.getBetRecordByTime(paramsMap, key);
|
||||
|
||||
if (this.getIsSuccess(betRecordByTime.getCode())) {
|
||||
cacheSet.add(firstCurrency);
|
||||
redisCache.setCacheSet(CacheConstants.PG_GAMES_BET_CURRENCY, cacheSet);
|
||||
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> result = betRecordByTime;
|
||||
AtomicInteger pageNoAtomic = new AtomicInteger(pageNo);
|
||||
|
||||
|
||||
ApiGameBetRecordPageResponseDTO data = result.getData();
|
||||
//数据组装
|
||||
this.batchInsert(data);
|
||||
|
||||
//总页数
|
||||
// 计算总页数,确保不会遗漏
|
||||
int totalPage = (int) Math.ceil((double) data.getTotal() / pageSize);
|
||||
|
||||
// 获取下一页数据
|
||||
while (pageNoAtomic.get() < totalPage && data.getTotal() > 0) {
|
||||
pageNoAtomic.incrementAndGet();
|
||||
//请求参数
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("currency", currencyDTO.getCurrency());
|
||||
paramMap.put("pageNo", pageNoAtomic.get());
|
||||
paramMap.put("pageSize", pageSize);
|
||||
SleepUtil.sleep(10000);
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> betRecordByTimePage = ngClient.getBetRecordByTime(paramMap, key);
|
||||
data = betRecordByTimePage.getData();
|
||||
//数据组装
|
||||
this.batchInsert(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
getBetRecordByHistoryTime(betRecordByTimeDTO, currencyDTO);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按历史时间获取投注记录
|
||||
*
|
||||
* @param betRecordByTimeDTO 按时间dto投注记录
|
||||
* @param currencyDTO 货币dto
|
||||
*/
|
||||
private void getBetRecordByHistoryTime(BetRecordByTimeDTO betRecordByTimeDTO, GameSecretKeyCurrencyDTO currencyDTO) {
|
||||
|
||||
//捞取指定30分钟前的数据
|
||||
Long startTimes = DateUtils.addOrSubtractMinutes(DateUtils.getNowDate(), -30);
|
||||
Long endTimes = DateUtils.getNowDate();
|
||||
betRecordByTimeDTO.setStartTime(startTimes);
|
||||
betRecordByTimeDTO.setEndTime(endTimes);
|
||||
|
||||
|
||||
int currentMinute = java.time.LocalTime.now().getMinute();
|
||||
// 判断当前分钟是否是 20 分、40 分或 0 分,如果不是,跳过当前执行
|
||||
if (currentMinute != 20 && currentMinute != 40 && currentMinute != 0) {
|
||||
// 当前时间不是 20 分、40 分、0 分,跳过执行
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String startTime = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.of("Asia/Shanghai"))
|
||||
.format(Instant.ofEpochMilli(betRecordByTimeDTO.getStartTime()));
|
||||
|
||||
String endTime = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.of("Asia/Shanghai"))
|
||||
.format(Instant.ofEpochMilli(betRecordByTimeDTO.getEndTime()));
|
||||
|
||||
|
||||
betRecordByTimeDTO.setAgentId(currencyDTO.getCode());
|
||||
|
@ -522,17 +595,14 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
paramsMap.put("currency", currencyDTO.getCurrency());
|
||||
paramsMap.put("pageNo", pageNo);
|
||||
paramsMap.put("pageSize", pageSize);
|
||||
// paramsMap.put("startTime", startTime);
|
||||
// paramsMap.put("endTime",endTime);
|
||||
paramsMap.put("startTime", startTime);
|
||||
paramsMap.put("endTime", endTime);
|
||||
Map<String, String> key = this.getKey(betRecordByTimeDTO);
|
||||
|
||||
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> betRecordByTime = ngClient.getBetRecordByTime(paramsMap, key);
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> betRecordByTime = ngClient.getBetRecordByHistoryTime(paramsMap, key);
|
||||
|
||||
if (this.getIsSuccess(betRecordByTime.getCode())) {
|
||||
cacheSet.add(firstCurrency);
|
||||
redisCache.setCacheSet(CacheConstants.PG_GAMES_BET_CURRENCY, cacheSet);
|
||||
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> result = betRecordByTime;
|
||||
AtomicInteger pageNoAtomic = new AtomicInteger(pageNo);
|
||||
|
||||
|
@ -554,8 +624,8 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
paramMap.put("currency", currencyDTO.getCurrency());
|
||||
paramMap.put("pageNo", pageNoAtomic.get());
|
||||
paramMap.put("pageSize", pageSize);
|
||||
// paramMap.put("startTime", startTime);
|
||||
// paramMap.put("endTime", endTime);
|
||||
paramMap.put("startTime", startTime);
|
||||
paramMap.put("endTime", endTime);
|
||||
SleepUtil.sleep(10000);
|
||||
ApiNGResponseDTO<ApiGameBetRecordPageResponseDTO> betRecordByTimePage = ngClient.getBetRecordByTime(paramMap, key);
|
||||
data = betRecordByTimePage.getData();
|
||||
|
@ -566,9 +636,9 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
|
||||
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 赠送免费局数
|
||||
*
|
||||
|
@ -591,7 +661,7 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
@Override
|
||||
public GetGameDetailResponseDTO getGameDetail(GetGameDetailRequestDTO getGameDetailRequestDTO) {
|
||||
|
||||
List<GameBettingDetails> gameBettingDetails = gameBettingDetailsService.selectGameBettingDetailsList(GameBettingDetails.builder().wagersId(getGameDetailRequestDTO.getWagersId()).build());
|
||||
List<GameBettingDetails> gameBettingDetails = gameBettingDetailsService.selectGameBettingDetailsList(GameBettingDetailsDTO.builder().wagersId(getGameDetailRequestDTO.getWagersId()).build());
|
||||
if (!CollectionUtils.isEmpty(gameBettingDetails)) {
|
||||
GetGameDetailResponseDTO getGameDetailResponseDTO = new GetGameDetailResponseDTO();
|
||||
getGameDetailResponseDTO.setUrl(gameBettingDetails.get(0).getBetContent());
|
||||
|
@ -732,7 +802,7 @@ public class GamesPGServiceImpl implements IGamesService {
|
|||
*
|
||||
* @param data 数据
|
||||
*/
|
||||
private void batchInsert(ApiGameBetRecordPageResponseDTO data) {
|
||||
private synchronized void batchInsert(ApiGameBetRecordPageResponseDTO data) {
|
||||
List<GameBettingDetails> gameBettingDetails = new ArrayList<>();
|
||||
List<Long> wagersIds = new ArrayList<>();
|
||||
//数据转化
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.ff.game.controller;
|
|||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -39,7 +41,7 @@ public class GameBettingDetailsController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('game:details:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GameBettingDetails gameBettingDetails)
|
||||
public TableDataInfo list(GameBettingDetailsDTO gameBettingDetails)
|
||||
{
|
||||
startPage();
|
||||
List<GameBettingDetails> list = gameBettingDetailsService.selectGameBettingDetailsList(gameBettingDetails);
|
||||
|
@ -52,7 +54,7 @@ public class GameBettingDetailsController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('game:details:export')")
|
||||
@Log(title = "会员投注细目", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, GameBettingDetails gameBettingDetails)
|
||||
public void export(HttpServletResponse response, GameBettingDetailsDTO gameBettingDetails)
|
||||
{
|
||||
List<GameBettingDetails> list = gameBettingDetailsService.selectGameBettingDetailsList(gameBettingDetails);
|
||||
ExcelUtil<GameBettingDetails> util = new ExcelUtil<GameBettingDetails>(GameBettingDetails.class);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.ff.game.dto;
|
||||
|
||||
import com.ff.game.domain.GameBettingDetails;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* 游戏投注详情dto
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/24
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class GameBettingDetailsDTO extends GameBettingDetails {
|
||||
/**
|
||||
* 时间类型 1 按投注时间 2 按入库时间
|
||||
*/
|
||||
private Integer timeType;
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.ff.game.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.ff.game.domain.GameBettingDetails;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
|
||||
|
@ -34,10 +35,10 @@ public interface GameBettingDetailsMapper
|
|||
/**
|
||||
* 查询会员投注细目列表
|
||||
*
|
||||
* @param gameBettingDetails 会员投注细目
|
||||
* @param gameBettingDetailsDTO 会员投注细目
|
||||
* @return 会员投注细目集合
|
||||
*/
|
||||
List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetails gameBettingDetails);
|
||||
List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetailsDTO gameBettingDetailsDTO);
|
||||
|
||||
/**
|
||||
* 新增会员投注细目
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.ff.game.domain.Game;
|
||||
import com.ff.game.domain.GameBettingDetails;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
|
@ -36,10 +37,10 @@ public interface IGameBettingDetailsService
|
|||
/**
|
||||
* 查询会员投注细目列表
|
||||
*
|
||||
* @param gameBettingDetails 会员投注细目
|
||||
* @param gameBettingDetailsDTO 会员投注细目
|
||||
* @return 会员投注细目集合
|
||||
*/
|
||||
List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetails gameBettingDetails);
|
||||
List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetailsDTO gameBettingDetailsDTO);
|
||||
|
||||
/**
|
||||
* 新增会员投注细目
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.ff.base.utils.DateUtils;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ff.game.mapper.GameBettingDetailsMapper;
|
||||
|
@ -49,13 +50,13 @@ public class GameBettingDetailsServiceImpl implements IGameBettingDetailsService
|
|||
/**
|
||||
* 查询会员投注细目列表
|
||||
*
|
||||
* @param gameBettingDetails 会员投注细目
|
||||
* @param gameBettingDetailsDTO 会员投注细目
|
||||
* @return 会员投注细目
|
||||
*/
|
||||
@Override
|
||||
public List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetails gameBettingDetails)
|
||||
public List<GameBettingDetails> selectGameBettingDetailsList(GameBettingDetailsDTO gameBettingDetailsDTO)
|
||||
{
|
||||
return gameBettingDetailsMapper.selectGameBettingDetailsList(gameBettingDetails);
|
||||
return gameBettingDetailsMapper.selectGameBettingDetailsList(gameBettingDetailsDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.ff.base.system.service.ITenantSecretKeyService;
|
|||
import com.ff.common.domain.TenantGameQuota;
|
||||
import com.ff.common.service.ITenantGameQuotaService;
|
||||
import com.ff.game.domain.GameBettingDetails;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import com.ff.game.service.IGameBettingDetailsService;
|
||||
import com.ff.tenant.dto.TenantDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -45,7 +46,7 @@ public class TenantBettingDetailsController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('tenant:betting:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GameBettingDetails gameBettingDetails)
|
||||
public TableDataInfo list(GameBettingDetailsDTO gameBettingDetails)
|
||||
{
|
||||
gameBettingDetails.setTenantKey(getUsername());
|
||||
startPage();
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ff.tenant.controller;
|
|||
import com.ff.base.core.controller.BaseController;
|
||||
import com.ff.base.core.page.TableDataInfo;
|
||||
import com.ff.game.domain.GameBettingDetails;
|
||||
import com.ff.game.dto.GameBettingDetailsDTO;
|
||||
import com.ff.game.service.IGameBettingDetailsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -37,7 +38,7 @@ public class TenantQuotaController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('tenant:betting:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GameBettingDetails gameBettingDetails)
|
||||
public TableDataInfo list(GameBettingDetailsDTO gameBettingDetails)
|
||||
{
|
||||
gameBettingDetails.setTenantKey(getUsername());
|
||||
startPage();
|
||||
|
|
|
@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select id,tenant_key, currency_code, member_id, game_code, game_id, game_type, platform_code, game_name, game_status, game_status_type, game_currency_code, account, round, `table`, seat, bet_content, wagers_id, wagers_time, bet_amount, payoff_time, payoff_amount, settlement_time, turnover, order_no, settlement_status, create_by, create_time, update_by, update_time from ff_game_betting_details
|
||||
</sql>
|
||||
|
||||
<select id="selectGameBettingDetailsList" parameterType="GameBettingDetails" resultMap="GameBettingDetailsResult">
|
||||
<select id="selectGameBettingDetailsList" parameterType="com.ff.game.dto.GameBettingDetailsDTO" resultMap="GameBettingDetailsResult">
|
||||
<include refid="selectGameBettingDetailsVo"/>
|
||||
<where>
|
||||
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
|
||||
|
@ -66,13 +66,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="turnover != null "> and turnover = #{turnover}</if>
|
||||
<if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
|
||||
<if test="settlementStatus != null "> and settlement_status = #{settlementStatus}</if>
|
||||
<if test="params.beginTime != null">
|
||||
<if test="params.beginTime != null and timeType !=null and timeType==1">
|
||||
AND wagers_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null">
|
||||
<if test="params.endTime != null and timeType !=null and timeType==1">
|
||||
AND wagers_time <= #{params.endTime}
|
||||
|
||||
</if>
|
||||
<if test="params.beginTime != null and timeType !=null and timeType ==2">
|
||||
AND create_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and timeType !=null and timeType==2">
|
||||
AND create_time <= #{params.endTime}
|
||||
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
Loading…
Reference in New Issue