This commit is contained in:
2026-01-07 16:50:42 +08:00
parent 9e42257e4e
commit ec72e47695
16 changed files with 981 additions and 27 deletions

View File

@@ -189,11 +189,36 @@ func (l *BankCardWithdrawalLogic) createBankCardWithdrawalRecord(session sqlx.Se
// 冻结资金(事务内操作)
func (l *BankCardWithdrawalLogic) freezeFunds(session sqlx.Session, wallet *model.AgentWallet, amount float64) error {
// 记录变动前的余额
balanceBefore := wallet.Balance
frozenBalanceBefore := wallet.FrozenBalance
// 更新钱包余额
wallet.Balance -= amount
wallet.FrozenBalance += amount
err := l.svcCtx.AgentWalletModel.UpdateWithVersion(l.ctx, session, wallet)
if err != nil {
return err
}
// 记录交易流水(冻结操作)
err = l.svcCtx.AgentService.CreateWalletTransaction(
l.ctx,
session,
wallet.AgentId,
model.WalletTransactionTypeFreeze,
amount, // 变动金额
balanceBefore, // 变动前余额
wallet.Balance, // 变动后余额
frozenBalanceBefore, // 变动前冻结余额
wallet.FrozenBalance, // 变动后冻结余额
"", // 关联交易ID暂时为空创建提现记录后可以更新
0, // 关联用户ID
"提现申请冻结资金", // 备注
)
if err != nil {
return err
}
return nil
}