feat: update refund issues

This commit is contained in:
Rogee
2025-05-13 14:24:55 +08:00
parent 610eb8d553
commit 2cf3b858b7
2 changed files with 37 additions and 1 deletions

View File

@@ -492,3 +492,21 @@ func (m *usersModel) SetBalance(ctx context.Context, id int64, balance int64) er
}
return nil
}
// AddBalance adds the given amount to the user's balance
func (m *usersModel) AddBalance(ctx context.Context, id int64, amount int64) error {
tbl := table.Users
stmt := tbl.
UPDATE(tbl.Balance).
SET(tbl.Balance.ADD(Int64(amount))).
WHERE(
tbl.ID.EQ(Int64(id)),
)
m.log.Infof("sql: %s", stmt.DebugSql())
if _, err := stmt.ExecContext(ctx, db); err != nil {
m.log.Errorf("error updating user balance: %v", err)
return err
}
return nil
}