1、response修改 2、负数扣款

This commit is contained in:
2024-10-15 20:52:51 +08:00
parent 8c14915955
commit d63d70847b
67 changed files with 368 additions and 202 deletions

View File

@@ -51,11 +51,6 @@ func (m *customWalletsModel) UpdateBalance(session sqlx.Session, ctx context.Con
return err
}
// 检查余额是否足够
if wallet.Balance+amount < 0 {
return ErrBalanceNotEnough
}
// 使用乐观锁更新余额
result, err := session.Exec("UPDATE wallets SET balance = balance + ?, version = version + 1 WHERE user_id = ? AND version = ?", amount, userId, wallet.Version)
if err != nil {