feat(ff-admin): 增加平台和币种代码字段并优化余额计算逻辑
- 在 BalanceChangesDTO 中添加 platformCode 和 currencyCode 字段 - 优化 TenantGameQuotaServiceImpl 中的余额计算逻辑 - 新增 TenantQuotaTask 类,用于更新租户实际配额main-p
parent
d717350e61
commit
7df30a21e1
|
@ -53,4 +53,10 @@ public class BalanceChangesDTO implements Serializable {
|
|||
* 汇率 传值计算
|
||||
*/
|
||||
private BigDecimal actualBalance;
|
||||
|
||||
/** 平台 */
|
||||
private String platformCode;
|
||||
|
||||
/** 币种代码 */
|
||||
private String currencyCode;
|
||||
}
|
||||
|
|
|
@ -195,6 +195,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
.quotaType(balanceChangesDTO.getQuotaType())
|
||||
.tenantKey(balanceChangesDTO.getTenantKey())
|
||||
.isOut(balanceChangesDTO.getIsOut())
|
||||
.platformCode(balanceChangesDTO.getPlatformCode())
|
||||
.currencyCode(balanceChangesDTO.getCurrencyCode())
|
||||
.balanceAfter(balanceAfter)
|
||||
.exchangeRatio(balanceChangesDTO.getActualBalance())
|
||||
.exchangeMoney(balanceChangesDTO.getBalance())
|
||||
|
@ -286,6 +288,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
if (platformBalance.compareTo(BigDecimal.ZERO) > 0) {
|
||||
this.balanceChanges(BalanceChangesDTO.builder()
|
||||
.isOut(Boolean.TRUE)
|
||||
.platformCode(gameBalanceExchange.getPlatformCode())
|
||||
.currencyCode(gameBalanceExchange.getCurrencyCode())
|
||||
.tenantKey(gameBalanceExchange.getTenantKey())
|
||||
.balance(platformBalance)
|
||||
.memberId(member.getId())
|
||||
|
@ -298,6 +302,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
// 进行租户余额调整
|
||||
this.balanceChanges(BalanceChangesDTO.builder()
|
||||
.isOut(isOut)
|
||||
.platformCode(gameBalanceExchange.getPlatformCode())
|
||||
.currencyCode(gameBalanceExchange.getCurrencyCode())
|
||||
.actualBalance(tenantQuotaExchange.getActualBalance())
|
||||
.tenantKey(gameBalanceExchange.getTenantKey())
|
||||
.balance(balanceRequestAmount)
|
||||
|
@ -318,6 +324,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
// 假额度足够扣除本次所需金额
|
||||
this.balanceChanges(BalanceChangesDTO.builder()
|
||||
.isOut(Boolean.FALSE)
|
||||
.platformCode(gameBalanceExchange.getPlatformCode())
|
||||
.currencyCode(gameBalanceExchange.getCurrencyCode())
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.balance(amountToDeduct)
|
||||
.memberId(member.getId())
|
||||
|
@ -331,6 +339,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
balanceRequestAmount = amountToDeduct.subtract(falseQuotaBalance);
|
||||
this.balanceChanges(BalanceChangesDTO.builder()
|
||||
.isOut(Boolean.FALSE)
|
||||
.platformCode(gameBalanceExchange.getPlatformCode())
|
||||
.currencyCode(gameBalanceExchange.getCurrencyCode())
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.balance(falseQuotaBalance)
|
||||
.memberId(member.getId())
|
||||
|
@ -344,6 +354,8 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
|
|||
if (balanceRequestAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
this.balanceChanges(BalanceChangesDTO.builder()
|
||||
.isOut(Boolean.FALSE)
|
||||
.platformCode(gameBalanceExchange.getPlatformCode())
|
||||
.currencyCode(gameBalanceExchange.getCurrencyCode())
|
||||
.actualBalance(tenantQuotaExchange.getActualBalance())
|
||||
.tenantKey(tenantSecretKey.getTenantKey())
|
||||
.balance(balanceRequestAmount)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.ff.quartz.task;
|
||||
|
||||
|
||||
import com.ff.common.domain.TenantGameQuota;
|
||||
import com.ff.common.service.ITenantGameQuotaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户配额任务
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/02/22
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("tenantQuotaTask")
|
||||
public class TenantQuotaTask {
|
||||
|
||||
@Resource
|
||||
private ITenantGameQuotaService tenantGameQuotaService;
|
||||
|
||||
/**
|
||||
* 更新租户实际配额
|
||||
*/
|
||||
// public void updateTenantRealQuota() {
|
||||
// List<TenantGameQuota> tenantGameQuotas = tenantGameQuotaService.selectTenantGameQuotaList(TenantGameQuota.builder()
|
||||
// .quotaType(TenantGameQuota.TenantQuotaType.TENANT_REAL_QUOTA.getCode())
|
||||
// .build());
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue