f add
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user