This commit is contained in:
2026-04-22 17:49:20 +08:00
parent a2fad4a095
commit f545aee45e
15 changed files with 268 additions and 140 deletions

View File

@@ -1,11 +1,11 @@
package admin_agent
import (
"bdrp-server/app/main/model"
"bdrp-server/common/xerr"
"context"
"database/sql"
"time"
"bdrp-server/app/main/model"
"bdrp-server/common/xerr"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/stores/sqlx"
@@ -164,7 +164,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveBankCardWithdrawal(ctx conte
frozenBalanceBefore := wallet.FrozenBalance
// 更新钱包(减少冻结余额)
wallet.FrozenBalance -= record.Amount
wallet.FrozenBalance = roundMoney(wallet.FrozenBalance - record.Amount)
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(ctx, session, wallet); err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新钱包失败: %v", err)
}
@@ -175,14 +175,14 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveBankCardWithdrawal(ctx conte
session,
wallet.AgentId,
model.WalletTransactionTypeWithdraw,
-record.Amount, // 变动金额(负数表示减少)
wallet.Balance, // 变动前余额(不变)
wallet.Balance, // 变动后余额(不变)
frozenBalanceBefore, // 变动前冻结余额
wallet.FrozenBalance, // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现审核通过", // 备注
roundMoney(-record.Amount), // 变动金额(负数表示减少)
roundMoney(wallet.Balance), // 变动前余额(不变)
roundMoney(wallet.Balance), // 变动后余额(不变)
roundMoney(frozenBalanceBefore), // 变动前冻结余额
roundMoney(wallet.FrozenBalance), // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现审核通过", // 备注
)
if err != nil {
return err
@@ -234,8 +234,8 @@ func (l *AdminReviewBankCardWithdrawalLogic) rejectWithdrawal(ctx context.Contex
frozenBalanceBefore := wallet.FrozenBalance
// 更新钱包(余额增加,冻结余额减少)
wallet.Balance += record.Amount
wallet.FrozenBalance -= record.Amount
wallet.Balance = roundMoney(wallet.Balance + record.Amount)
wallet.FrozenBalance = roundMoney(wallet.FrozenBalance - record.Amount)
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(ctx, session, wallet); err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新钱包失败: %v", err)
}
@@ -246,14 +246,14 @@ func (l *AdminReviewBankCardWithdrawalLogic) rejectWithdrawal(ctx context.Contex
session,
wallet.AgentId,
model.WalletTransactionTypeUnfreeze,
record.Amount, // 变动金额(正数表示增加)
balanceBefore, // 变动前余额
wallet.Balance, // 变动后余额
frozenBalanceBefore, // 变动前冻结余额
wallet.FrozenBalance, // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现拒绝,解冻资金", // 备注
roundMoney(record.Amount), // 变动金额(正数表示增加)
roundMoney(balanceBefore), // 变动前余额
roundMoney(wallet.Balance), // 变动后余额
roundMoney(frozenBalanceBefore), // 变动前冻结余额
roundMoney(wallet.FrozenBalance), // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现拒绝,解冻资金", // 备注
)
if err != nil {
return err
@@ -295,7 +295,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx conte
frozenBalanceBefore := wallet.FrozenBalance
// 更新钱包(减少冻结余额)
wallet.FrozenBalance -= record.Amount
wallet.FrozenBalance = roundMoney(wallet.FrozenBalance - record.Amount)
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(ctx, session, wallet); err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新钱包失败: %v", err)
}
@@ -306,14 +306,14 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx conte
session,
wallet.AgentId,
model.WalletTransactionTypeWithdraw,
-record.Amount, // 变动金额(负数表示减少)
wallet.Balance, // 变动前余额(不变)
wallet.Balance, // 变动后余额(不变)
frozenBalanceBefore, // 变动前冻结余额
wallet.FrozenBalance, // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现成功", // 备注
roundMoney(-record.Amount), // 变动金额(负数表示减少)
roundMoney(wallet.Balance), // 变动前余额(不变)
roundMoney(wallet.Balance), // 变动后余额(不变)
roundMoney(frozenBalanceBefore), // 变动前冻结余额
roundMoney(wallet.FrozenBalance), // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现成功", // 备注
)
if err != nil {
return err
@@ -365,8 +365,8 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalFailure(ctx conte
frozenBalanceBefore := wallet.FrozenBalance
// 更新钱包(余额增加,冻结余额减少)
wallet.Balance += record.Amount
wallet.FrozenBalance -= record.Amount
wallet.Balance = roundMoney(wallet.Balance + record.Amount)
wallet.FrozenBalance = roundMoney(wallet.FrozenBalance - record.Amount)
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(ctx, session, wallet); err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新钱包失败: %v", err)
}
@@ -377,14 +377,14 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalFailure(ctx conte
session,
wallet.AgentId,
model.WalletTransactionTypeUnfreeze,
record.Amount, // 变动金额(正数表示增加)
balanceBefore, // 变动前余额
wallet.Balance, // 变动后余额
frozenBalanceBefore, // 变动前冻结余额
wallet.FrozenBalance, // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现失败,解冻资金", // 备注
roundMoney(record.Amount), // 变动金额(正数表示增加)
roundMoney(balanceBefore), // 变动前余额
roundMoney(wallet.Balance), // 变动后余额
roundMoney(frozenBalanceBefore), // 变动前冻结余额
roundMoney(wallet.FrozenBalance), // 变动后冻结余额
record.WithdrawNo, // 关联交易ID
0, // 关联用户ID
"提现失败,解冻资金", // 备注
)
if err != nil {
return err