feat(game): 增加按时间查询游戏投注记录功能
- 新增 GameBettingDetailsDTO 类,用于游戏投注详情查询 - 在 GameBettingDetailsMapper 中添加按时间查询的 SQL 语句 - 修改 GameBettingDetailsServiceImpl 中的查询方法,支持按时间查询 - 更新相关控制器和接口,增加按时间查询游戏记录的功能main-cf
parent
7c77aa5555
commit
d59232a9cc
|
@ -121,11 +121,7 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>3.23.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- excel工具 -->
|
||||
|
|
|
@ -7,11 +7,9 @@ import com.ff.api.request.MemberInfoAllApiRequest;
|
|||
import com.ff.api.request.MemberInfoApiRequest;
|
||||
import com.ff.api.response.MemberInfoAllResponse;
|
||||
import com.ff.api.response.MemberInfoResponse;
|
||||
import com.ff.base.constant.CacheLockConstants;
|
||||
import com.ff.base.constant.Constants;
|
||||
import com.ff.base.core.controller.BaseController;
|
||||
import com.ff.base.core.domain.AjaxResult;
|
||||
import com.ff.base.core.redis.RedisCacheLock;
|
||||
import com.ff.base.enums.ErrorCode;
|
||||
import com.ff.base.exception.base.ApiException;
|
||||
import com.ff.base.exception.base.BaseException;
|
||||
|
@ -20,6 +18,7 @@ import com.ff.base.system.domain.TenantSecretKey;
|
|||
import com.ff.config.KeyConfig;
|
||||
import com.ff.game.api.IGamesService;
|
||||
import com.ff.game.api.request.*;
|
||||
import com.ff.game.domain.GameSecretKey;
|
||||
import com.ff.game.dto.GameSecretKeyCurrencyDTO;
|
||||
import com.ff.game.service.IGameSecretKeyCurrencyService;
|
||||
import com.ff.game.service.IGameSecretKeyService;
|
||||
|
@ -31,9 +30,9 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -85,10 +84,6 @@ public class ApiMemberController extends BaseController {
|
|||
@Resource
|
||||
private IGameSecretKeyCurrencyService gameSecretKeyCurrencyService;
|
||||
|
||||
@Resource
|
||||
private RedisCacheLock redisCacheLock;
|
||||
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
|
@ -96,60 +91,53 @@ public class ApiMemberController extends BaseController {
|
|||
* @return {@link AjaxResult }
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public AjaxResult createMember(@Validated @RequestBody MemberCreateApiRequest memberCreateApiRequest) {
|
||||
@Transactional
|
||||
public synchronized AjaxResult createMember(@Validated @RequestBody MemberCreateApiRequest memberCreateApiRequest) {
|
||||
|
||||
IGamesService iGamesService = gamesService.get(memberCreateApiRequest.getPlatformCode() + Constants.SERVICE);
|
||||
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
||||
|
||||
TenantSecretKey tenantSecretKey = keyConfig.get();
|
||||
String lockName = CacheLockConstants.CREATE_MEMBER + memberCreateApiRequest.getAccount() + memberCreateApiRequest.getCurrencyCode() + memberCreateApiRequest.getPlatformCode() + tenantSecretKey.getTenantSn();
|
||||
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||
.platformCode(memberCreateApiRequest.getPlatformCode())
|
||||
.systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
|
||||
|
||||
//加锁防止重复
|
||||
boolean tryLock = redisCacheLock.tryLock(lockName, 10, 10);
|
||||
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
||||
|
||||
try {
|
||||
if (tryLock) {
|
||||
IGamesService iGamesService = gamesService.get(memberCreateApiRequest.getPlatformCode() + Constants.SERVICE);
|
||||
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
|
||||
String gameAccount = StringUtils.addSuffix(memberService.getMemberGameAccount(), tenantSecretKey.getTenantSn());
|
||||
|
||||
|
||||
GameSecretKeyCurrencyDTO gameSecretKey = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTO(GameSecretKeyCurrencyDTO.builder()
|
||||
.platformCode(memberCreateApiRequest.getPlatformCode())
|
||||
.systemCurrency(memberCreateApiRequest.getCurrencyCode()).build());
|
||||
|
||||
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
|
||||
|
||||
String gameAccount = StringUtils.addSuffix(memberService.getMemberGameAccount(), tenantSecretKey.getTenantSn());
|
||||
|
||||
// 获取用户信息
|
||||
Member gameMember = memberService.selectMemberByAccount(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode(), memberCreateApiRequest.getPlatformCode());
|
||||
if (!ObjectUtils.isEmpty(gameMember)) {
|
||||
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
|
||||
}
|
||||
//注册本地账号
|
||||
Member member = Member.builder()
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.memberAccount(memberCreateApiRequest.getAccount())
|
||||
.gameAccount(gameAccount)
|
||||
.platformCode(memberCreateApiRequest.getPlatformCode())
|
||||
.currencyCode(memberCreateApiRequest.getCurrencyCode())
|
||||
.build();
|
||||
int insertMember = memberService.insertMember(member);
|
||||
Assert.isTrue(insertMember > 0, "建立游戏账号失败");
|
||||
|
||||
//向第三方注册账号
|
||||
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
|
||||
.account(gameAccount)
|
||||
.agentId(gameSecretKey.getCode())
|
||||
.agentKey(gameSecretKey.getKey())
|
||||
.currency(gameSecretKey.getCurrency())
|
||||
.build();
|
||||
Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
|
||||
Assert.isTrue(result, "建立游戏账号失败");
|
||||
} else {
|
||||
throw new ApiException(ErrorCode.FREQUENT_INTERFACE_REQUESTS.getCode());
|
||||
}
|
||||
return toAjax(Boolean.TRUE);
|
||||
} finally {
|
||||
redisCacheLock.unlock(lockName);
|
||||
// 获取用户信息
|
||||
Member gameMember = memberService.selectMemberByAccount(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode(), memberCreateApiRequest.getPlatformCode());
|
||||
if (!ObjectUtils.isEmpty(gameMember)){
|
||||
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//注册本地账号
|
||||
Member member = Member.builder()
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.memberAccount(memberCreateApiRequest.getAccount())
|
||||
.gameAccount(gameAccount)
|
||||
.platformCode(memberCreateApiRequest.getPlatformCode())
|
||||
.currencyCode(memberCreateApiRequest.getCurrencyCode())
|
||||
.build();
|
||||
int insertMember = memberService.insertMember(member);
|
||||
Assert.isTrue(insertMember > 0, "建立游戏账号失败");
|
||||
|
||||
//向第三方注册账号
|
||||
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
|
||||
.account(gameAccount)
|
||||
.agentId(gameSecretKey.getCode())
|
||||
.agentKey(gameSecretKey.getKey())
|
||||
.currency(gameSecretKey.getCurrency())
|
||||
.build();
|
||||
Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
|
||||
Assert.isTrue(result, "建立游戏账号失败");
|
||||
return toAjax(Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,6 +166,7 @@ public class ApiMemberController extends BaseController {
|
|||
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
|
||||
|
||||
|
||||
|
||||
//向第三方查询账号
|
||||
MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder()
|
||||
.accounts(member.getGameAccount())
|
||||
|
@ -202,6 +191,9 @@ public class ApiMemberController extends BaseController {
|
|||
public AjaxResult infoAll(@Validated @RequestBody MemberInfoAllApiRequest memberInfoAllApiRequest) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List<GameSecretKeyCurrencyDTO> gameSecretKeys = gameSecretKeyCurrencyService.findByGameSecretKeyCurrencyDTOList(GameSecretKeyCurrencyDTO.builder()
|
||||
.systemCurrency(memberInfoAllApiRequest.getCurrencyCode()).build());
|
||||
|
||||
|
|
Loading…
Reference in New Issue