refactor(balance): 补充冻结金额和可提现余额字段
This commit is contained in:
@@ -141,9 +141,10 @@ public class TenantBalanceController {
|
||||
@Operation(summary = "获得租户积分记录分页")
|
||||
@Parameter(name = "tenantId", description = "租户 Id")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:query')")
|
||||
public CommonResult<PageResult<TenantBalanceTransactionDO>> getTenantBalanceTransactionPage(PageParam pageReqVO,
|
||||
public CommonResult<PageResult<TenantBalanceTransactionRespVO>> getTenantBalanceTransactionPage(PageParam pageReqVO,
|
||||
@RequestParam("tenantId") Long tenantId) {
|
||||
return success(tenantBalanceService.getTenantBalanceTransactionPage(pageReqVO, tenantId));
|
||||
PageResult<TenantBalanceTransactionDO> pageResult = tenantBalanceService.getTenantBalanceTransactionPage(pageReqVO, tenantId);
|
||||
return success(BeanUtils.toBean(pageResult, TenantBalanceTransactionRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/tenant-balance-transaction/create")
|
||||
@@ -183,7 +184,8 @@ public class TenantBalanceController {
|
||||
@Operation(summary = "获得租户积分记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:query')")
|
||||
public CommonResult<TenantBalanceTransactionDO> getTenantBalanceTransaction(@RequestParam("id") Long id) {
|
||||
return success(tenantBalanceService.getTenantBalanceTransaction(id));
|
||||
public CommonResult<TenantBalanceTransactionRespVO> getTenantBalanceTransaction(@RequestParam("id") Long id) {
|
||||
TenantBalanceTransactionDO transaction = tenantBalanceService.getTenantBalanceTransaction(id);
|
||||
return success(BeanUtils.toBean(transaction, TenantBalanceTransactionRespVO.class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.yolo.keyboard.controller.admin.tenantbalance.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 租户积分记录 Response VO")
|
||||
@Data
|
||||
public class TenantBalanceTransactionRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||
private BigDecimal points;
|
||||
|
||||
@Schema(description = "变动后余额快照", example = "1000.00")
|
||||
private BigDecimal balance;
|
||||
|
||||
@Schema(description = "变动后冻结金额快照", example = "200.00")
|
||||
private BigDecimal frozenAmt;
|
||||
|
||||
@Schema(description = "变动后可提现余额快照", example = "800.00")
|
||||
private BigDecimal withdrawableBalance;
|
||||
|
||||
@Schema(description = "变动类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "RECHARGE")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "变动描述", example = "余额充值")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "订单Id/业务单号", example = "ORD123456")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "业务流水号", example = "BIZ123456")
|
||||
private String bizNo;
|
||||
|
||||
@Schema(description = "操作人Id", example = "1")
|
||||
private Long operatorId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "备注", example = "管理员充值")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "租户Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
@@ -67,4 +67,8 @@ public class TenantBalanceTransactionDO {
|
||||
private String remark;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private BigDecimal frozenAmt;
|
||||
|
||||
private BigDecimal withdrawableBalance;
|
||||
}
|
||||
@@ -101,6 +101,8 @@ public class CommissionWithdrawableJob implements JobHandler {
|
||||
.bizNo(bizNo)
|
||||
.points(tenantTotalAmount)
|
||||
.balance(balance.getBalance())
|
||||
.frozenAmt(balance.getFrozenAmt() != null ? balance.getFrozenAmt() : BigDecimal.ZERO)
|
||||
.withdrawableBalance(newWithdrawable)
|
||||
.tenantId(tenantId)
|
||||
.type(WITHDRAWABLE_TYPE)
|
||||
.description("分成转可提现")
|
||||
|
||||
@@ -288,6 +288,8 @@ public class TenantCommissionCalculateJob implements JobHandler {
|
||||
.bizNo(bizNo)
|
||||
.points(commissionAmount)
|
||||
.balance(balance.getBalance())
|
||||
.frozenAmt(balance.getFrozenAmt() != null ? balance.getFrozenAmt() : BigDecimal.ZERO)
|
||||
.withdrawableBalance(balance.getWithdrawableBalance() != null ? balance.getWithdrawableBalance() : BigDecimal.ZERO)
|
||||
.tenantId(tenantId)
|
||||
.type(COMMISSION_TYPE)
|
||||
.description("邀请用户内购分成")
|
||||
|
||||
@@ -140,6 +140,8 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
||||
.bizNo(BizNoGenerator.generate("RECHARGE")) // 生成充值业务编号
|
||||
.points(new BigDecimal(String.valueOf(addReqVO.getAmount()))) // 充值金额
|
||||
.balance(newBalance) // 充值后余额
|
||||
.frozenAmt(balance.getFrozenAmt() != null ? balance.getFrozenAmt() : BigDecimal.ZERO) // 当前冻结金额
|
||||
.withdrawableBalance(balance.getWithdrawableBalance() != null ? balance.getWithdrawableBalance() : BigDecimal.ZERO) // 当前可提现金额
|
||||
.tenantId(addReqVO.getId())
|
||||
.type("RECHARGE") // 交易类型:充值
|
||||
.description("余额充值") // 交易描述
|
||||
@@ -268,8 +270,10 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
||||
// 6. 创建冻结交易记录
|
||||
TenantBalanceTransactionDO transaction = TenantBalanceTransactionDO.builder()
|
||||
.bizNo(bizNo)
|
||||
.points(withdrawAmount.negate()) // 冻结金额(负数表示冻结扣减)
|
||||
.balance(newWithdrawableBalance) // 扣减后的可提现余额
|
||||
.points(withdrawAmount.negate()) // 冻结金额(负数表示冻结扣减)
|
||||
.balance(balance.getBalance()) // 当前总余额
|
||||
.frozenAmt(newFrozenAmt) // 冻结后的冻结金额
|
||||
.withdrawableBalance(newWithdrawableBalance) // 扣减后的可提现余额
|
||||
.tenantId(tenantId)
|
||||
.type("FREEZE")
|
||||
.description("提现冻结")
|
||||
|
||||
@@ -115,10 +115,13 @@ public class KeyboardTenantWithdrawOrderServiceImpl implements KeyboardTenantWit
|
||||
tenantBalanceMapper.updateById(balance);
|
||||
|
||||
// 创建提现成功的流水记录
|
||||
BigDecimal currentWithdrawableBalance = balance.getWithdrawableBalance() != null ? balance.getWithdrawableBalance() : BigDecimal.ZERO;
|
||||
TenantBalanceTransactionDO transaction = TenantBalanceTransactionDO.builder()
|
||||
.bizNo(order.getBizNo())
|
||||
.points(withdrawAmount.negate()) // 提现金额(负数表示支出)
|
||||
.balance(balance.getWithdrawableBalance() != null ? balance.getWithdrawableBalance() : BigDecimal.ZERO)
|
||||
.balance(balance.getBalance()) // 当前总余额
|
||||
.frozenAmt(newFrozenAmt) // 扣除后的冻结金额
|
||||
.withdrawableBalance(currentWithdrawableBalance) // 当前可提现余额
|
||||
.tenantId(order.getTenantId())
|
||||
.type("WITHDRAW_SUCCESS")
|
||||
.description("提现成功")
|
||||
@@ -187,7 +190,9 @@ public class KeyboardTenantWithdrawOrderServiceImpl implements KeyboardTenantWit
|
||||
TenantBalanceTransactionDO transaction = TenantBalanceTransactionDO.builder()
|
||||
.bizNo(order.getBizNo())
|
||||
.points(withdrawAmount) // 退还金额(正数表示收入)
|
||||
.balance(newWithdrawableBalance) // 退还后的可提现余额
|
||||
.balance(balance.getBalance()) // 当前总余额
|
||||
.frozenAmt(newFrozenAmt) // 扣除后的冻结金额
|
||||
.withdrawableBalance(newWithdrawableBalance) // 退还后的可提现余额
|
||||
.tenantId(order.getTenantId())
|
||||
.type(type)
|
||||
.description(description)
|
||||
|
||||
Reference in New Issue
Block a user