feat(api): 添加会员信息全部查询功能

- 新增 ApiGameController 中的 exchangeBalanceAll 方法
- 新增 ApiMemberController 中的 infoAll 方法
- 新增 ApiTenantController 类和 info 方法
- 添加相关请求和响应对象
- 修改 GameExchangeMoney 类和相关 mapper- 更新 HeaderCheckAspect 中的检查逻辑
main-p
shi 2025-02-14 17:31:52 +08:00
parent 4f39ae7038
commit 5526ad34c5
27 changed files with 741 additions and 138 deletions

View File

@ -61,6 +61,8 @@ public class HeaderCheckAspect {
TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyByTenantKey(key); TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyByTenantKey(key);
Assert.notNull(tenantSecretKey, "key不存在"); Assert.notNull(tenantSecretKey, "key不存在");
Assert.isTrue(tenantSecretKey.getTenantStatus(), "当前租户已停用");
String keyG = Md5Utils.md5New(random + key + tenantSecretKey.getTenantSecret()); String keyG = Md5Utils.md5New(random + key + tenantSecretKey.getTenantSecret());
Assert.isTrue(keyG.equals(sign), "签名错误"); Assert.isTrue(keyG.equals(sign), "签名错误");
//保存 //保存

View File

@ -7,11 +7,14 @@ import com.dtflys.forest.annotation.Post;
import com.ff.annotation.CheckHeader; import com.ff.annotation.CheckHeader;
import com.ff.api.request.*; import com.ff.api.request.*;
import com.ff.api.response.GameExchangeBalanceResponse; import com.ff.api.response.GameExchangeBalanceResponse;
import com.ff.api.response.MemberInfoAllResponse;
import com.ff.base.constant.Constants; import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController; import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult; import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.page.TableDataInfo; import com.ff.base.core.page.TableDataInfo;
import com.ff.base.enums.OperationType; import com.ff.base.enums.OperationType;
import com.ff.base.enums.TransferType;
import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.StringUtils; import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils; import com.ff.base.utils.bean.BeanUtils;
import com.ff.common.domain.TenantGameQuotaFlow; import com.ff.common.domain.TenantGameQuotaFlow;
@ -27,7 +30,10 @@ import com.ff.game.service.*;
import com.ff.member.domain.Member; import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService; import com.ff.member.service.IMemberService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; 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.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -39,8 +45,11 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.*;
import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/** /**
* api * api
@ -51,6 +60,7 @@ import java.util.Map;
@RestController @RestController
@CheckHeader @CheckHeader
@RequestMapping("/api/game") @RequestMapping("/api/game")
@Slf4j
public class ApiGameController extends BaseController { public class ApiGameController extends BaseController {
@ -89,6 +99,10 @@ public class ApiGameController extends BaseController {
@Resource @Resource
private IGameExchangeMoneyService gameExchangeMoneyService; private IGameExchangeMoneyService gameExchangeMoneyService;
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
/** /**
* *
* *
@ -187,7 +201,7 @@ public class ApiGameController extends BaseController {
balanceRequestAmount = NumberUtil.sub(balanceOut, balanceInto); balanceRequestAmount = NumberUtil.sub(balanceOut, balanceInto);
} }
} }
//余额扣除 //租户余额操作
tenantGameQuotaService.balanceChanges(BalanceChangesDTO.builder() tenantGameQuotaService.balanceChanges(BalanceChangesDTO.builder()
.isOut(isOut) .isOut(isOut)
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(tenantSecretKey.getTenantKey())
@ -202,10 +216,10 @@ public class ApiGameController extends BaseController {
.agentId(gameSecretKey.getCode()) .agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(gameSecretKey.getKey())
.account(member.getGameAccount()) .account(member.getGameAccount())
.tenantKey(tenantSecretKey.getTenantKey())
.quota(balanceRequestAmount) .quota(balanceRequestAmount)
.amount(gameExchangeBalanceRequest.getAmount()) .amount(gameExchangeBalanceRequest.getAmount())
.transferType(gameExchangeBalanceRequest.getTransferType()) .transferType(gameExchangeBalanceRequest.getTransferType())
.orderId(gameExchangeBalanceRequest.getOrderId())
.build(); .build();
Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO); Long exchangeTransferId = iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId); GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(exchangeTransferId);
@ -261,7 +275,7 @@ public class ApiGameController extends BaseController {
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/get/bet/record") @PostMapping("/get/bet/record")
public TableDataInfo createFreeSpin(@Validated @RequestBody GameGetBetRecordRequest gameCreateFreeSpinRequest) { public TableDataInfo getBetRecord(@Validated @RequestBody GameGetBetRecordRequest gameCreateFreeSpinRequest) {
startPage(); startPage();
PageHelper.startPage(gameCreateFreeSpinRequest.getPageNo(), gameCreateFreeSpinRequest.getPageSize(), "wagers_time desc"); PageHelper.startPage(gameCreateFreeSpinRequest.getPageNo(), gameCreateFreeSpinRequest.getPageSize(), "wagers_time desc");
GameBettingDetails gameBettingDetails = GameBettingDetails.builder() GameBettingDetails gameBettingDetails = GameBettingDetails.builder()
@ -393,4 +407,110 @@ public class ApiGameController extends BaseController {
.build()); .build());
return AjaxResult.success(cancelFreeSpin); return AjaxResult.success(cancelFreeSpin);
} }
/**
*
*
* @param gameExchangeBalanceAllRequest api
* @return {@link AjaxResult }
*/
@PostMapping("/exchange/balance/all")
public AjaxResult exchangeBalanceAll(@Validated @RequestBody GameExchangeBalanceAllRequest gameExchangeBalanceAllRequest) {
TenantSecretKey tenantSecretKey = keyConfig.get();
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameExchangeBalanceAllRequest.getAccount(), gameExchangeBalanceAllRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
List<GameSecretKey> gameSecretKeys = gameSecretKeyService.selectGameSecretKeyList(GameSecretKey.builder().systemCode(gameExchangeBalanceAllRequest.getCurrencyCode()).build());
// 创建线程池
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size());
// 使用List存储Future对象用于获取异步执行的结果
List<Future<Long>> futures = new ArrayList<>();
// 提交异步任务到线程池
for (GameSecretKey gameSecretKey : gameSecretKeys) {
futures.add(threadPoolTaskExecutor.submit(() -> {
try {
IGamesService iGamesService = gamesService.get(gameSecretKey.getPlatform() + Constants.SERVICE);
//操作第三方钱包
ExchangeTransferMoneyRequestDTO exchangeTransferMoneyRequestDTO = ExchangeTransferMoneyRequestDTO.builder()
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.amount(BigDecimal.ONE)
.tenantKey(tenantSecretKey.getTenantKey())
.account(member.getGameAccount())
.transferType(TransferType.ALL.getCode())
.build();
return iGamesService.exchangeTransferByAgentId(exchangeTransferMoneyRequestDTO);
} catch (Exception e) {
return 0L;
} finally {
latch.countDown(); // 任务完成后减少计数
}
}));
}
BigDecimal balanceAll = BigDecimal.ZERO;
try {
// 等待所有线程执行完毕
latch.await();
// 获取每个Future的结果
for (Future<Long> future : futures) {
// 汇总结果
Long id = future.get();
GameExchangeMoney gameExchangeMoney = gameExchangeMoneyService.selectGameExchangeMoneyById(id);
if (ObjectUtils.isEmpty(gameExchangeMoney)) {
continue;
}
balanceMap.put(gameExchangeMoney.getPlatformCode(), gameExchangeMoney.getBalance());
BigDecimal balance = gameExchangeMoney.getBalance();
balanceAll = NumberUtil.add(balanceAll, balance);
//转入金额
BigDecimal balanceInto = tenantGameQuotaFlowService.getBalanceByMemberId(TenantGameQuotaFlow.builder()
.isOut(Boolean.TRUE)
.tenantKey(tenantSecretKey.getTenantKey())
.memberId(member.getId())
.build());
//转出金额
BigDecimal balanceOut = tenantGameQuotaFlowService.getBalanceByMemberId(TenantGameQuotaFlow.builder()
.isOut(Boolean.FALSE)
.tenantKey(tenantSecretKey.getTenantKey())
.memberId(member.getId())
.build());
//如果转入金额+本次转入金额 大于转出额度则取差值
if (NumberUtil.add(balanceInto, balance).compareTo(NumberUtil.add(balanceOut, BigDecimal.ZERO)) > 0) {
balance = NumberUtil.sub(balanceOut, balanceInto);
}
//更新租户额度
gameExchangeMoney.setQuota(balance);
gameExchangeMoneyService.updateGameExchangeMoney(gameExchangeMoney);
//余额扣除
tenantGameQuotaService.balanceChanges(BalanceChangesDTO.builder()
.isOut(Boolean.TRUE)
.tenantKey(tenantSecretKey.getTenantKey())
.balance(balance)
.memberId(member.getId())
.operationType(OperationType.API_BALANCE.getCode())
.remark(OperationType.API_BALANCE.getDescription())
.build());
}
} catch (Exception e) {
log.error("拉回用户余额失败", e);
throw new BaseException("拉回用户余额失败");
}
balanceMap.put("balanceAll", balanceAll);
return AjaxResult.success(balanceMap);
}
} }

View File

@ -1,32 +1,47 @@
package com.ff.api.controller; package com.ff.api.controller;
import cn.hutool.core.bean.BeanUtil;
import com.ff.annotation.CheckHeader; import com.ff.annotation.CheckHeader;
import com.ff.api.request.MemberCreateApiRequest; import com.ff.api.request.MemberCreateApiRequest;
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.Constants; import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController; import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult; import com.ff.base.core.domain.AjaxResult;
import com.ff.base.exception.base.BaseException;
import com.ff.base.manager.AsyncManager;
import com.ff.base.utils.StringUtils; import com.ff.base.utils.StringUtils;
import com.ff.common.domain.TenantSecretKey; import com.ff.common.domain.TenantSecretKey;
import com.ff.config.KeyConfig; import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService; import com.ff.game.api.IGamesService;
import com.ff.game.api.request.CreateMemberRequestDTO; import com.ff.game.api.request.*;
import com.ff.game.api.request.GamesBaseRequestDTO;
import com.ff.game.api.request.MemberInfoRequestDTO;
import com.ff.game.domain.GameSecretKey; import com.ff.game.domain.GameSecretKey;
import com.ff.game.service.IGameSecretKeyService; import com.ff.game.service.IGameSecretKeyService;
import com.ff.game.service.IGameService; import com.ff.game.service.IGameService;
import com.ff.member.domain.Member; import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService; import com.ff.member.service.IMemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
/** /**
* api * api
@ -37,6 +52,7 @@ import java.util.Map;
@RestController @RestController
@CheckHeader @CheckHeader
@RequestMapping("/api/member") @RequestMapping("/api/member")
@Slf4j
public class ApiMemberController extends BaseController { public class ApiMemberController extends BaseController {
@ -58,6 +74,10 @@ public class ApiMemberController extends BaseController {
private IMemberService memberService; private IMemberService memberService;
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
/** /**
* *
* *
@ -106,20 +126,20 @@ public class ApiMemberController extends BaseController {
/** /**
* *
* *
* @param memberCreateApiRequest api * @param memberInfoApiRequest api
* @return {@link AjaxResult } * @return {@link AjaxResult }
*/ */
@PostMapping("/info") @PostMapping("/info")
public AjaxResult getMemberInfo(@Validated @RequestBody MemberCreateApiRequest memberCreateApiRequest) { public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest memberInfoApiRequest) {
IGamesService iGamesService = gamesService.get(memberCreateApiRequest.getPlatformCode() + Constants.SERVICE); IGamesService iGamesService = gamesService.get(memberInfoApiRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "平台不存在"); Assert.notNull(iGamesService, "平台不存在");
TenantSecretKey tenantSecretKey = keyConfig.get(); TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(memberCreateApiRequest.getPlatformCode(), memberCreateApiRequest.getCurrencyCode()); GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(memberInfoApiRequest.getPlatformCode(), memberInfoApiRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在"); Assert.notNull(gameSecretKey, "货币游戏平台不存在");
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn())); Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberInfoApiRequest.getAccount(), memberInfoApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在"); Assert.notNull(member, "会员不存在");
//向第三方查询账号 //向第三方查询账号
@ -128,8 +148,81 @@ public class ApiMemberController extends BaseController {
.agentId(gameSecretKey.getCode()) .agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey()) .agentKey(gameSecretKey.getKey())
.build(); .build();
return AjaxResult.success(iGamesService.getMemberInfo(gamesBaseRequestDTO)); MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO);
MemberInfoResponse memberInfoResponse=new MemberInfoResponse();
BeanUtils.copyProperties(memberInfo,memberInfoResponse);
return AjaxResult.success(memberInfoResponse);
} }
/**
*
*
* @param memberInfoAllApiRequest api
* @return {@link AjaxResult }
*/
@PostMapping("/info/all")
public AjaxResult infoAll(@Validated @RequestBody MemberInfoAllApiRequest memberInfoAllApiRequest) {
TenantSecretKey tenantSecretKey = keyConfig.get();
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberInfoAllApiRequest.getAccount(), memberInfoAllApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
List<GameSecretKey> gameSecretKeys = gameSecretKeyService.selectGameSecretKeyList(GameSecretKey.builder().systemCode(memberInfoAllApiRequest.getCurrencyCode()).build());
// 创建线程池
Map<String, BigDecimal> balanceMap = new LinkedHashMap<>();
CountDownLatch latch = new CountDownLatch(gameSecretKeys.size());
// 使用List存储Future对象用于获取异步执行的结果
List<Future<MemberInfoAllResponse>> futures = new ArrayList<>();
// 提交异步任务到线程池
for (GameSecretKey gameSecretKey : gameSecretKeys) {
futures.add(threadPoolTaskExecutor.submit(() -> {
try {
IGamesService iGamesService = gamesService.get(gameSecretKey.getPlatform() + Constants.SERVICE);
MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder()
.accounts(member.getGameAccount())
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.build();
//查询余额
MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO);
return MemberInfoAllResponse.builder()
.account(member.getGameAccount())
.balance(memberInfo.getBalance())
.status(memberInfo.getStatus())
.platformCode(gameSecretKey.getPlatform())
.build();
} finally {
latch.countDown(); // 任务完成后减少计数
}
}));
}
// 等待所有线程执行完毕
try {
latch.await();
// 获取每个Future的结果
for (Future<MemberInfoAllResponse> future : futures) {
// 汇总结果
MemberInfoAllResponse memberInfoAllResponse = future.get();
balanceMap.put(memberInfoAllResponse.getPlatformCode(), memberInfoAllResponse.getBalance());
}
} catch (Exception e) {
log.error("获取会员信息失败", e);
throw new BaseException("获取会员信息失败");
}
return AjaxResult.success(balanceMap);
}
} }

View File

@ -0,0 +1,87 @@
package com.ff.api.controller;
import cn.hutool.core.util.NumberUtil;
import com.ff.annotation.CheckHeader;
import com.ff.api.request.*;
import com.ff.api.response.GameExchangeBalanceResponse;
import com.ff.api.response.TenantInfoResponse;
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.page.TableDataInfo;
import com.ff.base.enums.OperationType;
import com.ff.base.enums.TenantQuotaType;
import com.ff.base.enums.TransferType;
import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.common.domain.TenantGameQuota;
import com.ff.common.domain.TenantGameQuotaFlow;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.common.service.ITenantGameQuotaService;
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.service.*;
import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
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.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
/**
* api
*
* @author shi
* @date 2025/02/10
*/
@RestController
@CheckHeader
@RequestMapping("/api/tenant")
@Slf4j
public class ApiTenantController extends BaseController {
@Resource
private ITenantGameQuotaService tenantGameQuotaService;
@Resource
private KeyConfig keyConfig;
/**
*
*
* @return {@link AjaxResult }
*/
@PostMapping("/info")
public AjaxResult info() {
TenantSecretKey tenantSecretKey = keyConfig.get();
TenantGameQuota tenantGameQuota = tenantGameQuotaService.selectTenantGameQuotaByTenantKey(tenantSecretKey.getTenantKey(), TenantQuotaType.BALANCE.getCode());
TenantInfoResponse tenantInfoResponse= new TenantInfoResponse();
BeanUtils.copyProperties(tenantGameQuota,tenantInfoResponse);
return AjaxResult.success(tenantInfoResponse);
}
}

View File

@ -0,0 +1,42 @@
package com.ff.api.request;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*
*
* @author shi
* @date 2025/02/11
*/
@Data
public class GameExchangeBalanceAllRequest implements Serializable {
private final static long serialVersionUID = -881298930995538038L;
/**
*
*/
@NotBlank(message = "account不能为空")
private String account;
/** 币种编码 */
@NotBlank(message = "currencyCode不能为空")
private String currencyCode;
}

View File

@ -57,12 +57,6 @@ public class GameExchangeBalanceRequest implements Serializable {
@Max(value = 2, message = "transferType最大值为2") @Max(value = 2, message = "transferType最大值为2")
private Integer transferType; private Integer transferType;
/**
* id
*/
@NotBlank(message = "orderId不能为空")
@Length(min = 32,max = 32, message = "orderId长度不能超过32个字符")
private String orderId;
} }

View File

@ -0,0 +1,34 @@
package com.ff.api.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
*
*
* @author shi
* @date 2025/02/10
*/
@Data
public class MemberInfoAllApiRequest implements Serializable{
private static final long serialVersionUID = 8071608271351542925L;
/**
*
*/
@NotBlank(message = "account不能为空")
private String account;
/**
*
*/
@NotBlank(message = "currencyCode不能为空")
private String currencyCode;
}

View File

@ -0,0 +1,50 @@
package com.ff.api.response;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* ff_game_exchange_money
*
* @author shi
* @date 2025-02-12
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MemberInfoAllResponse implements Serializable
{
private static final long serialVersionUID = 1L;
/**
*
*/
private String account;
/**
*
*/
private BigDecimal balance;
/**
*
* 1: 线
* 2:
* 3:
*/
private Integer status;
/**
*
*/
private String platformCode;
}

View File

@ -0,0 +1,42 @@
package com.ff.api.response;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* ff_game_exchange_money
*
* @author shi
* @date 2025-02-12
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MemberInfoResponse implements Serializable
{
private static final long serialVersionUID = 1L;
/**
*
*/
private BigDecimal balance;
/**
*
* 1: 线
* 2:
* 3:
*/
private Integer status;
}

View File

@ -0,0 +1,30 @@
package com.ff.api.response;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*
*
* @author shi
* @date 2025/02/14
*/
@Data
public class TenantInfoResponse implements Serializable {
/**
*
*/
private String tenantKey;
/**
*
*/
private BigDecimal balance;
}

View File

@ -8,13 +8,11 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/** /**
* ff_tenant_game_quota * ff_tenant_game_quota
* *
* @author shi * @author shi
* @date 2025-02-12 * @date 2025-02-14
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@ -35,7 +33,9 @@ public class TenantGameQuota extends BaseEntity
@Excel(name = "游戏额度") @Excel(name = "游戏额度")
private BigDecimal balance; private BigDecimal balance;
/** 额度类型 TenantQuotaType 枚举 */
@Excel(name = "额度类型 TenantQuotaType 枚举")
private Integer quotaType;
/** 版本号 */ /** 版本号 */
@Excel(name = "版本号") @Excel(name = "版本号")

View File

@ -2,14 +2,21 @@ package com.ff.common.domain;
import com.ff.base.annotation.Excel; import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity; import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* ff_tenant_secret_key * ff_tenant_secret_key
* *
* @author shi * @author shi
* @date 2025-02-11 * @date 2025-02-14
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TenantSecretKey extends BaseEntity public class TenantSecretKey extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -29,9 +36,12 @@ public class TenantSecretKey extends BaseEntity
@Excel(name = "租户密钥") @Excel(name = "租户密钥")
private String tenantSecret; private String tenantSecret;
/** 租户状态0正常 1停用 */ /** 租户状态 1正常 0停用 */
@Excel(name = "租户状态", readConverterExp = "0=正常,1=停用") private Boolean tenantStatus;
private String tenantStatus;
/** 租户类型 TenantType 枚举 */
@Excel(name = "租户类型 TenantType 枚举")
private Integer tenantType;
} }

View File

@ -1,7 +1,9 @@
package com.ff.common.mapper; package com.ff.common.mapper;
import java.util.List; import java.util.List;
import com.ff.common.domain.TenantGameQuota; import com.ff.common.domain.TenantGameQuota;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -9,8 +11,7 @@ import com.ff.common.domain.TenantGameQuota;
* @author shi * @author shi
* @date 2025-02-12 * @date 2025-02-12
*/ */
public interface TenantGameQuotaMapper public interface TenantGameQuotaMapper {
{
/** /**
* *
* *
@ -26,7 +27,7 @@ public interface TenantGameQuotaMapper
* @param tenantKey * @param tenantKey
* @return * @return
*/ */
TenantGameQuota selectTenantGameQuotaByTenantKey(String tenantKey); TenantGameQuota selectTenantGameQuotaByTenantKey(@Param("tenantKey") String tenantKey,@Param("quotaType") Integer quotaType);
/** /**
* *

View File

@ -3,6 +3,7 @@ package com.ff.common.service;
import java.util.List; import java.util.List;
import com.ff.common.domain.TenantGameQuota; import com.ff.common.domain.TenantGameQuota;
import com.ff.common.dto.BalanceChangesDTO; import com.ff.common.dto.BalanceChangesDTO;
import org.apache.ibatis.annotations.Param;
/** /**
* Service * Service
@ -67,4 +68,13 @@ public interface ITenantGameQuotaService
* @return {@link Boolean } * @return {@link Boolean }
*/ */
Boolean balanceChanges(BalanceChangesDTO balanceChangesDTO); Boolean balanceChanges(BalanceChangesDTO balanceChangesDTO);
/**
*
*
* @param tenantKey
* @return
*/
TenantGameQuota selectTenantGameQuotaByTenantKey(String tenantKey, Integer quotaType);
} }

View File

@ -5,10 +5,13 @@ import java.util.List;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.ff.base.constant.Constants; import com.ff.base.constant.Constants;
import com.ff.base.enums.TenantQuotaType;
import com.ff.base.enums.TenantType;
import com.ff.base.utils.DateUtils; import com.ff.base.utils.DateUtils;
import com.ff.base.utils.MessageUtils; import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.SecurityUtils; import com.ff.base.utils.SecurityUtils;
import com.ff.common.domain.TenantGameQuotaFlow; import com.ff.common.domain.TenantGameQuotaFlow;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO; import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.mapper.TenantGameQuotaFlowMapper; import com.ff.common.mapper.TenantGameQuotaFlowMapper;
import com.ff.common.service.ITenantGameQuotaFlowService; import com.ff.common.service.ITenantGameQuotaFlowService;
@ -30,8 +33,7 @@ import javax.annotation.Resource;
* @date 2025-02-12 * @date 2025-02-12
*/ */
@Service @Service
public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
{
@Autowired @Autowired
private TenantGameQuotaMapper tenantGameQuotaMapper; private TenantGameQuotaMapper tenantGameQuotaMapper;
@ -39,6 +41,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
@Resource @Resource
private ITenantGameQuotaFlowService tenantGameQuotaFlowService; private ITenantGameQuotaFlowService tenantGameQuotaFlowService;
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
/** /**
* *
@ -47,8 +51,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public TenantGameQuota selectTenantGameQuotaById(Long id) public TenantGameQuota selectTenantGameQuotaById(Long id) {
{
return tenantGameQuotaMapper.selectTenantGameQuotaById(id); return tenantGameQuotaMapper.selectTenantGameQuotaById(id);
} }
@ -59,8 +62,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public List<TenantGameQuota> selectTenantGameQuotaList(TenantGameQuota tenantGameQuota) public List<TenantGameQuota> selectTenantGameQuotaList(TenantGameQuota tenantGameQuota) {
{
return tenantGameQuotaMapper.selectTenantGameQuotaList(tenantGameQuota); return tenantGameQuotaMapper.selectTenantGameQuotaList(tenantGameQuota);
} }
@ -71,8 +73,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public int insertTenantGameQuota(TenantGameQuota tenantGameQuota) public int insertTenantGameQuota(TenantGameQuota tenantGameQuota) {
{
tenantGameQuota.setCreateTime(DateUtils.getNowDate()); tenantGameQuota.setCreateTime(DateUtils.getNowDate());
return tenantGameQuotaMapper.insertTenantGameQuota(tenantGameQuota); return tenantGameQuotaMapper.insertTenantGameQuota(tenantGameQuota);
} }
@ -84,8 +85,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public int updateTenantGameQuota(TenantGameQuota tenantGameQuota) public int updateTenantGameQuota(TenantGameQuota tenantGameQuota) {
{
tenantGameQuota.setUpdateTime(DateUtils.getNowDate()); tenantGameQuota.setUpdateTime(DateUtils.getNowDate());
return tenantGameQuotaMapper.updateTenantGameQuota(tenantGameQuota); return tenantGameQuotaMapper.updateTenantGameQuota(tenantGameQuota);
} }
@ -97,8 +97,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public int deleteTenantGameQuotaByIds(Long[] ids) public int deleteTenantGameQuotaByIds(Long[] ids) {
{
return tenantGameQuotaMapper.deleteTenantGameQuotaByIds(ids); return tenantGameQuotaMapper.deleteTenantGameQuotaByIds(ids);
} }
@ -109,8 +108,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
* @return * @return
*/ */
@Override @Override
public int deleteTenantGameQuotaById(Long id) public int deleteTenantGameQuotaById(Long id) {
{
return tenantGameQuotaMapper.deleteTenantGameQuotaById(id); return tenantGameQuotaMapper.deleteTenantGameQuotaById(id);
} }
@ -122,7 +120,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
*/ */
@Override @Override
public Boolean balanceChanges(BalanceChangesDTO balanceChangesDTO) { public Boolean balanceChanges(BalanceChangesDTO balanceChangesDTO) {
TenantGameQuota tenantGameQuota = tenantGameQuotaMapper.selectTenantGameQuotaByTenantKey(balanceChangesDTO.getTenantKey()); TenantGameQuota tenantGameQuota = tenantGameQuotaMapper.selectTenantGameQuotaByTenantKey(balanceChangesDTO.getTenantKey(), TenantQuotaType.BALANCE.getCode());
Assert.isTrue(!ObjectUtils.isEmpty(tenantGameQuota), "余额额度不足"); Assert.isTrue(!ObjectUtils.isEmpty(tenantGameQuota), "余额额度不足");
BigDecimal balanceBefore = tenantGameQuota.getBalance(); BigDecimal balanceBefore = tenantGameQuota.getBalance();
@ -137,12 +136,24 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
} else { } else {
balanceAfter = NumberUtil.sub(balanceBefore, balance); balanceAfter = NumberUtil.sub(balanceBefore, balance);
} }
//判断剩余额度是否大于0
TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyByTenantKey(balanceChangesDTO.getTenantKey());
if (TenantType.DEPOSIT.getCode().equals(tenantSecretKey.getTenantType())) {
TenantGameQuota depositQuota = tenantGameQuotaMapper.selectTenantGameQuotaByTenantKey(balanceChangesDTO.getTenantKey(), TenantQuotaType.DEPOSIT.getCode());
//判断剩余额度是否大于0
Assert.isTrue(balanceAfter.compareTo(depositQuota.getBalance().negate()) >= 0, "余额额度不足");
} else {
//判断剩余额度是否大于0 //判断剩余额度是否大于0
Assert.isTrue(balanceAfter.compareTo(BigDecimal.ZERO) >= 0, "余额额度不足"); Assert.isTrue(balanceAfter.compareTo(BigDecimal.ZERO) >= 0, "余额额度不足");
}
//修改余额 //修改余额
Boolean changedBalanceResult = tenantGameQuotaMapper.changeBalance(TenantGameQuota.builder() Boolean changedBalanceResult = tenantGameQuotaMapper.changeBalance(TenantGameQuota.builder()
.tenantKey(balanceChangesDTO.getTenantKey()) .tenantKey(balanceChangesDTO.getTenantKey())
.balance(balanceAfter) .balance(balanceAfter)
.quotaType(TenantQuotaType.BALANCE.getCode())
.version(tenantGameQuota.getVersion()) .version(tenantGameQuota.getVersion())
.build()); .build());
Assert.isTrue(changedBalanceResult, "租户游戏额度操作失败"); Assert.isTrue(changedBalanceResult, "租户游戏额度操作失败");
@ -163,4 +174,16 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService
tenantGameQuotaFlowService.insertTenantGameQuotaFlow(tenantGameQuotaFlow); tenantGameQuotaFlowService.insertTenantGameQuotaFlow(tenantGameQuotaFlow);
return changedBalanceResult; return changedBalanceResult;
} }
/**
*
*
* @param tenantKey
* @param quotaType
* @return {@link TenantGameQuota }
*/
@Override
public TenantGameQuota selectTenantGameQuotaByTenantKey(String tenantKey, Integer quotaType) {
return tenantGameQuotaMapper.selectTenantGameQuotaByTenantKey(tenantKey, quotaType);
}
} }

View File

@ -293,27 +293,20 @@ public class GamesJILIServiceImpl implements IGamesService {
String systemByCode = gameSecretKeyService.findSystemByCode(exchangeTransferMoneyRequestDTO.getAgentId(), GamePlatforms.JILI.getInfo()); String systemByCode = gameSecretKeyService.findSystemByCode(exchangeTransferMoneyRequestDTO.getAgentId(), GamePlatforms.JILI.getInfo());
Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount()); Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount());
String transactionId = GamePlatforms.JILI.getCode() + IdUtils.simpleUUID(); String transactionId = GamePlatforms.JILI.getCode() + IdUtils.simpleUUID();
TenantSecretKey tenantSecretKey = keyConfig.get();
List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList(
GameExchangeMoney.builder()
.tenantKey(tenantSecretKey.getTenantKey())
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
.build()
);
Assert.isTrue(CollectionUtils.isEmpty(gameExchangeMonies), "订单号重复");
//获取下一个自增id //获取下一个自增id
GameExchangeMoney exchangeMoney = GameExchangeMoney GameExchangeMoney exchangeMoney = GameExchangeMoney
.builder() .builder()
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(exchangeTransferMoneyRequestDTO.getTenantKey())
.quota(exchangeTransferMoneyRequestDTO.getQuota()) .quota(exchangeTransferMoneyRequestDTO.getQuota())
.balance(exchangeTransferMoneyRequestDTO.getAmount()) .balance(exchangeTransferMoneyRequestDTO.getAmount())
.exchangeType(exchangeTransferMoneyRequestDTO.getTransferType()) .exchangeType(exchangeTransferMoneyRequestDTO.getTransferType())
.currencyCode(systemByCode) .currencyCode(systemByCode)
.memberId(member.getId()) .memberId(member.getId())
.transactionId(transactionId) .transactionId(transactionId)
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
.platformCode(GamePlatforms.JILI.getCode()) .platformCode(GamePlatforms.JILI.getCode())
.build(); .build();
exchangeMoney.setCreateBy(Constants.SYSTEM); exchangeMoney.setCreateBy(Constants.SYSTEM);

View File

@ -27,7 +27,10 @@ public class ExchangeTransferMoneyRequestDTO extends GamesBaseRequestDTO {
*/ */
private String account; private String account;
/**
*
*/
private String tenantKey;
/** /**
@ -51,8 +54,4 @@ public class ExchangeTransferMoneyRequestDTO extends GamesBaseRequestDTO {
*/ */
private Integer transferType; private Integer transferType;
/**
* id
*/
private String orderId;
} }

View File

@ -303,25 +303,16 @@ public class GamesXKServiceImpl implements IGamesService {
String systemByCode = gameSecretKeyService.findSystemByCode(exchangeTransferMoneyRequestDTO.getAgentId(), GamePlatforms.XK.getInfo()); String systemByCode = gameSecretKeyService.findSystemByCode(exchangeTransferMoneyRequestDTO.getAgentId(), GamePlatforms.XK.getInfo());
Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount()); Member member = memberService.selectMemberByGameAccount(exchangeTransferMoneyRequestDTO.getAccount());
String transactionId = GamePlatforms.XK.getCode() + IdUtils.simpleUUID(); String transactionId = GamePlatforms.XK.getCode() + IdUtils.simpleUUID();
TenantSecretKey tenantSecretKey = keyConfig.get();
List<GameExchangeMoney> gameExchangeMonies = gameExchangeMoneyService.selectGameExchangeMoneyList(
GameExchangeMoney.builder()
.tenantKey(tenantSecretKey.getTenantKey())
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
.build()
);
Assert.isTrue(CollectionUtils.isEmpty(gameExchangeMonies), "订单号重复");
//获取下一个自增id //获取下一个自增id
GameExchangeMoney exchangeMoney = GameExchangeMoney GameExchangeMoney exchangeMoney = GameExchangeMoney
.builder() .builder()
.tenantKey(tenantSecretKey.getTenantKey()) .tenantKey(exchangeTransferMoneyRequestDTO.getTenantKey())
.quota(exchangeTransferMoneyRequestDTO.getQuota()) .quota(exchangeTransferMoneyRequestDTO.getQuota())
.balance(exchangeTransferMoneyRequestDTO.getAmount()) .balance(exchangeTransferMoneyRequestDTO.getAmount())
.exchangeType(exchangeTransferMoneyRequestDTO.getTransferType()) .exchangeType(exchangeTransferMoneyRequestDTO.getTransferType())
.currencyCode(systemByCode) .currencyCode(systemByCode)
.memberId(member.getId()) .memberId(member.getId())
.transactionId(transactionId) .transactionId(transactionId)
.orderId(exchangeTransferMoneyRequestDTO.getOrderId())
.platformCode(GamePlatforms.XK.getCode()) .platformCode(GamePlatforms.XK.getCode())
.build(); .build();
exchangeMoney.setCreateBy(Constants.SYSTEM); exchangeMoney.setCreateBy(Constants.SYSTEM);

View File

@ -69,9 +69,7 @@ public class GameExchangeMoney extends BaseEntity
@Excel(name = "转账后金额(指定货币)") @Excel(name = "转账后金额(指定货币)")
private BigDecimal currencyAfter; private BigDecimal currencyAfter;
/** 系统订单id */
@Excel(name = "系统订单id")
private String orderId;
/** 转出类型 1游戏商转入到用户全部转出 2 用户转移到游戏商 3 游戏商转移额度到平台商 */ /** 转出类型 1游戏商转入到用户全部转出 2 用户转移到游戏商 3 游戏商转移额度到平台商 */
@Excel(name = "转出类型 1游戏商转入到用户全部转出 2 用户转移到游戏商 3 游戏商转移额度到平台商") @Excel(name = "转出类型 1游戏商转入到用户全部转出 2 用户转移到游戏商 3 游戏商转移额度到平台商")

View File

@ -105,7 +105,7 @@
</delete> </delete>
<select id="getBalanceByMemberId" parameterType="TenantGameQuotaFlow" resultType="java.math.BigDecimal"> <select id="getBalanceByMemberId" parameterType="TenantGameQuotaFlow" resultType="java.math.BigDecimal">
select sum(balance) from ff_tenant_game_quota_flow select ifnull(sum(balance),0) from ff_tenant_game_quota_flow
<where> <where>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if> <if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="memberId != null "> and member_id = #{memberId}</if> <if test="memberId != null "> and member_id = #{memberId}</if>

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="tenantKey" column="tenant_key" /> <result property="tenantKey" column="tenant_key" />
<result property="balance" column="balance" /> <result property="balance" column="balance" />
<result property="quotaType" column="quota_type" />
<result property="version" column="version" /> <result property="version" column="version" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
@ -16,14 +17,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectTenantGameQuotaVo"> <sql id="selectTenantGameQuotaVo">
select id, tenant_key, balance, version, create_by, create_time, update_by, update_time from ff_tenant_game_quota select id, tenant_key, balance, quota_type, version, create_by, create_time, update_by, update_time from ff_tenant_game_quota
</sql> </sql>
<select id="selectTenantGameQuotaByTenantKey" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
where tenant_key = #{tenantKey} and quota_type = #{quotaType}
</select>
<select id="selectTenantGameQuotaList" parameterType="TenantGameQuota" resultMap="TenantGameQuotaResult"> <select id="selectTenantGameQuotaList" parameterType="TenantGameQuota" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/> <include refid="selectTenantGameQuotaVo"/>
<where> <where>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if> <if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="balance != null "> and balance = #{balance}</if> <if test="balance != null "> and balance = #{balance}</if>
<if test="quotaType != null "> and quota_type = #{quotaType}</if>
<if test="version != null "> and version = #{version}</if> <if test="version != null "> and version = #{version}</if>
</where> </where>
</select> </select>
@ -33,16 +40,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</select> </select>
<select id="selectTenantGameQuotaByTenantKey" parameterType="String" resultMap="TenantGameQuotaResult"> <update id="changeBalance" parameterType="TenantGameQuota">
<include refid="selectTenantGameQuotaVo"/> update ff_tenant_game_quota set balance = #{balance},version =version+1
where tenant_key = #{tenantKey} where tenant_key = #{tenantKey} and quota_type = #{quotaType} and version = #{version}
</select> </update>
<insert id="insertTenantGameQuota" parameterType="TenantGameQuota" useGeneratedKeys="true" keyProperty="id"> <insert id="insertTenantGameQuota" parameterType="TenantGameQuota" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota insert into ff_tenant_game_quota
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if> <if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="balance != null">balance,</if> <if test="balance != null">balance,</if>
<if test="quotaType != null">quota_type,</if>
<if test="version != null">version,</if> <if test="version != null">version,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
@ -52,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if> <if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="balance != null">#{balance},</if> <if test="balance != null">#{balance},</if>
<if test="quotaType != null">#{quotaType},</if>
<if test="version != null">#{version},</if> <if test="version != null">#{version},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
@ -65,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if> <if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="balance != null">balance = #{balance},</if> <if test="balance != null">balance = #{balance},</if>
<if test="quotaType != null">quota_type = #{quotaType},</if>
<if test="version != null">version = #{version},</if> <if test="version != null">version = #{version},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
@ -74,13 +84,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<update id="changeBalance" parameterType="TenantGameQuota">
update ff_tenant_game_quota set balance = #{balance},version =version+1
where tenant_key = #{tenantKey} and version = #{version}
</update>
<delete id="deleteTenantGameQuotaById" parameterType="Long"> <delete id="deleteTenantGameQuotaById" parameterType="Long">
delete from ff_tenant_game_quota where id = #{id} delete from ff_tenant_game_quota where id = #{id}
</delete> </delete>

View File

@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tenantSn" column="tenant_sn" /> <result property="tenantSn" column="tenant_sn" />
<result property="tenantSecret" column="tenant_secret" /> <result property="tenantSecret" column="tenant_secret" />
<result property="tenantStatus" column="tenant_status" /> <result property="tenantStatus" column="tenant_status" />
<result property="tenantType" column="tenant_type" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectTenantSecretKeyVo"> <sql id="selectTenantSecretKeyVo">
select id, tenant_key, tenant_sn, tenant_secret, tenant_status, create_by, create_time, update_by, update_time from ff_tenant_secret_key select id, tenant_key, tenant_sn, tenant_secret, tenant_status, tenant_type, create_by, create_time, update_by, update_time from ff_tenant_secret_key
</sql> </sql>
<select id="selectTenantSecretKeyList" parameterType="TenantSecretKey" resultMap="TenantSecretKeyResult"> <select id="selectTenantSecretKeyList" parameterType="TenantSecretKey" resultMap="TenantSecretKeyResult">
@ -26,7 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if> <if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="tenantSn != null and tenantSn != ''"> and tenant_sn = #{tenantSn}</if> <if test="tenantSn != null and tenantSn != ''"> and tenant_sn = #{tenantSn}</if>
<if test="tenantSecret != null and tenantSecret != ''"> and tenant_secret = #{tenantSecret}</if> <if test="tenantSecret != null and tenantSecret != ''"> and tenant_secret = #{tenantSecret}</if>
<if test="tenantStatus != null and tenantStatus != ''"> and tenant_status = #{tenantStatus}</if> <if test="tenantStatus != null "> and tenant_status = #{tenantStatus}</if>
<if test="tenantType != null "> and tenant_type = #{tenantType}</if>
</where> </where>
</select> </select>
@ -46,7 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if> <if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="tenantSn != null">tenant_sn,</if> <if test="tenantSn != null">tenant_sn,</if>
<if test="tenantSecret != null and tenantSecret != ''">tenant_secret,</if> <if test="tenantSecret != null and tenantSecret != ''">tenant_secret,</if>
<if test="tenantStatus != null and tenantStatus != ''">tenant_status,</if> <if test="tenantStatus != null">tenant_status,</if>
<if test="tenantType != null">tenant_type,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
@ -56,7 +59,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if> <if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="tenantSn != null">#{tenantSn},</if> <if test="tenantSn != null">#{tenantSn},</if>
<if test="tenantSecret != null and tenantSecret != ''">#{tenantSecret},</if> <if test="tenantSecret != null and tenantSecret != ''">#{tenantSecret},</if>
<if test="tenantStatus != null and tenantStatus != ''">#{tenantStatus},</if> <if test="tenantStatus != null">#{tenantStatus},</if>
<if test="tenantType != null">#{tenantType},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
@ -70,7 +74,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if> <if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="tenantSn != null">tenant_sn = #{tenantSn},</if> <if test="tenantSn != null">tenant_sn = #{tenantSn},</if>
<if test="tenantSecret != null and tenantSecret != ''">tenant_secret = #{tenantSecret},</if> <if test="tenantSecret != null and tenantSecret != ''">tenant_secret = #{tenantSecret},</if>
<if test="tenantStatus != null and tenantStatus != ''">tenant_status = #{tenantStatus},</if> <if test="tenantStatus != null">tenant_status = #{tenantStatus},</if>
<if test="tenantType != null">tenant_type = #{tenantType},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>

View File

@ -17,7 +17,6 @@
<result property="coinAfter" column="coin_after" /> <result property="coinAfter" column="coin_after" />
<result property="currencyBefore" column="currency_before" /> <result property="currencyBefore" column="currency_before" />
<result property="currencyAfter" column="currency_after" /> <result property="currencyAfter" column="currency_after" />
<result property="orderId" column="order_id" />
<result property="exchangeType" column="exchange_type" /> <result property="exchangeType" column="exchange_type" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -27,7 +26,7 @@
</resultMap> </resultMap>
<sql id="selectGameExchangeMoneyVo"> <sql id="selectGameExchangeMoneyVo">
select id, tenant_key, currency_code, transaction_id, member_id, platform_code, balance, quota, coin_before, coin_after, currency_before, currency_after, order_id, exchange_type, status, create_by, create_time, update_by, update_time from ff_game_exchange_money select id, tenant_key, currency_code, transaction_id, member_id, platform_code, balance, quota, coin_before, coin_after, currency_before, currency_after, exchange_type, status, create_by, create_time, update_by, update_time from ff_game_exchange_money
</sql> </sql>
<select id="selectGameExchangeMoneyList" parameterType="GameExchangeMoney" resultMap="GameExchangeMoneyResult"> <select id="selectGameExchangeMoneyList" parameterType="GameExchangeMoney" resultMap="GameExchangeMoneyResult">
@ -44,7 +43,6 @@
<if test="coinAfter != null "> and coin_after = #{coinAfter}</if> <if test="coinAfter != null "> and coin_after = #{coinAfter}</if>
<if test="currencyBefore != null "> and currency_before = #{currencyBefore}</if> <if test="currencyBefore != null "> and currency_before = #{currencyBefore}</if>
<if test="currencyAfter != null "> and currency_after = #{currencyAfter}</if> <if test="currencyAfter != null "> and currency_after = #{currencyAfter}</if>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="exchangeType != null "> and exchange_type = #{exchangeType}</if> <if test="exchangeType != null "> and exchange_type = #{exchangeType}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
</where> </where>
@ -69,7 +67,6 @@
<if test="coinAfter != null">coin_after,</if> <if test="coinAfter != null">coin_after,</if>
<if test="currencyBefore != null">currency_before,</if> <if test="currencyBefore != null">currency_before,</if>
<if test="currencyAfter != null">currency_after,</if> <if test="currencyAfter != null">currency_after,</if>
<if test="orderId != null">order_id,</if>
<if test="exchangeType != null">exchange_type,</if> <if test="exchangeType != null">exchange_type,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
@ -89,7 +86,6 @@
<if test="coinAfter != null">#{coinAfter},</if> <if test="coinAfter != null">#{coinAfter},</if>
<if test="currencyBefore != null">#{currencyBefore},</if> <if test="currencyBefore != null">#{currencyBefore},</if>
<if test="currencyAfter != null">#{currencyAfter},</if> <if test="currencyAfter != null">#{currencyAfter},</if>
<if test="orderId != null">#{orderId},</if>
<if test="exchangeType != null">#{exchangeType},</if> <if test="exchangeType != null">#{exchangeType},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
@ -113,7 +109,6 @@
<if test="coinAfter != null">coin_after = #{coinAfter},</if> <if test="coinAfter != null">coin_after = #{coinAfter},</if>
<if test="currencyBefore != null">currency_before = #{currencyBefore},</if> <if test="currencyBefore != null">currency_before = #{currencyBefore},</if>
<if test="currencyAfter != null">currency_after = #{currencyAfter},</if> <if test="currencyAfter != null">currency_after = #{currencyAfter},</if>
<if test="orderId != null">order_id = #{orderId},</if>
<if test="exchangeType != null">exchange_type = #{exchangeType},</if> <if test="exchangeType != null">exchange_type = #{exchangeType},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>

View File

@ -17,7 +17,6 @@
<result property="coinAfter" column="coin_after" /> <result property="coinAfter" column="coin_after" />
<result property="currencyBefore" column="currency_before" /> <result property="currencyBefore" column="currency_before" />
<result property="currencyAfter" column="currency_after" /> <result property="currencyAfter" column="currency_after" />
<result property="orderId" column="order_id" />
<result property="exchangeType" column="exchange_type" /> <result property="exchangeType" column="exchange_type" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -27,7 +26,7 @@
</resultMap> </resultMap>
<sql id="selectGameExchangeMoneyVo"> <sql id="selectGameExchangeMoneyVo">
select id, tenant_key, currency_code, transaction_id, member_id, platform_code, balance, quota, coin_before, coin_after, currency_before, currency_after, order_id, exchange_type, status, create_by, create_time, update_by, update_time from ff_game_exchange_money select id, tenant_key, currency_code, transaction_id, member_id, platform_code, balance, quota, coin_before, coin_after, currency_before, currency_after, exchange_type, status, create_by, create_time, update_by, update_time from ff_game_exchange_money
</sql> </sql>
<select id="selectGameExchangeMoneyList" parameterType="GameExchangeMoney" resultMap="GameExchangeMoneyResult"> <select id="selectGameExchangeMoneyList" parameterType="GameExchangeMoney" resultMap="GameExchangeMoneyResult">
@ -44,7 +43,6 @@
<if test="coinAfter != null "> and coin_after = #{coinAfter}</if> <if test="coinAfter != null "> and coin_after = #{coinAfter}</if>
<if test="currencyBefore != null "> and currency_before = #{currencyBefore}</if> <if test="currencyBefore != null "> and currency_before = #{currencyBefore}</if>
<if test="currencyAfter != null "> and currency_after = #{currencyAfter}</if> <if test="currencyAfter != null "> and currency_after = #{currencyAfter}</if>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="exchangeType != null "> and exchange_type = #{exchangeType}</if> <if test="exchangeType != null "> and exchange_type = #{exchangeType}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
</where> </where>
@ -69,7 +67,6 @@
<if test="coinAfter != null">coin_after,</if> <if test="coinAfter != null">coin_after,</if>
<if test="currencyBefore != null">currency_before,</if> <if test="currencyBefore != null">currency_before,</if>
<if test="currencyAfter != null">currency_after,</if> <if test="currencyAfter != null">currency_after,</if>
<if test="orderId != null">order_id,</if>
<if test="exchangeType != null">exchange_type,</if> <if test="exchangeType != null">exchange_type,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
@ -89,7 +86,6 @@
<if test="coinAfter != null">#{coinAfter},</if> <if test="coinAfter != null">#{coinAfter},</if>
<if test="currencyBefore != null">#{currencyBefore},</if> <if test="currencyBefore != null">#{currencyBefore},</if>
<if test="currencyAfter != null">#{currencyAfter},</if> <if test="currencyAfter != null">#{currencyAfter},</if>
<if test="orderId != null">#{orderId},</if>
<if test="exchangeType != null">#{exchangeType},</if> <if test="exchangeType != null">#{exchangeType},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
@ -113,7 +109,6 @@
<if test="coinAfter != null">coin_after = #{coinAfter},</if> <if test="coinAfter != null">coin_after = #{coinAfter},</if>
<if test="currencyBefore != null">currency_before = #{currencyBefore},</if> <if test="currencyBefore != null">currency_before = #{currencyBefore},</if>
<if test="currencyAfter != null">currency_after = #{currencyAfter},</if> <if test="currencyAfter != null">currency_after = #{currencyAfter},</if>
<if test="orderId != null">order_id = #{orderId},</if>
<if test="exchangeType != null">exchange_type = #{exchangeType},</if> <if test="exchangeType != null">exchange_type = #{exchangeType},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>

View File

@ -0,0 +1,28 @@
package com.ff.base.enums;
/**
*
*
* @author shi
* @date 2025/02/14
*/
public enum TenantQuotaType {
BALANCE(1, "余额"),
DEPOSIT(2, "押金");
private final Integer code;
private final String info;
TenantQuotaType(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}

View File

@ -0,0 +1,28 @@
package com.ff.base.enums;
/**
*
*
* @author shi
* @date 2025/02/14
*/
public enum TenantType {
NORMAL(1, "正常开户"),
DEPOSIT(2, "押金开户");
private final Integer code;
private final String info;
TenantType(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}

View File

@ -0,0 +1,30 @@
package com.ff.base.enums;
/**
*
*
* @author shi
* @date 2024/10/29
*/
public enum TransferType {
ALL(1, "从游戏商转移额度到平台商(不看amount值全部转出"),
GAMES(2, "从平台商转移额度到游戏商"),
SYSTEM(3, "从游戏商转移额度到平台商 无用");
private final Integer code;
private final String info;
TransferType(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}