fix(model): centralize row locking in transactional flows

This commit is contained in:
CaIon
2026-07-07 12:40:09 +08:00
parent bae799ccb1
commit 70ea899e37
7 changed files with 177 additions and 25 deletions
+1 -1
View File
@@ -456,7 +456,7 @@ func (user *User) TransferAffQuotaToQuota(quota int) error {
defer tx.Rollback() // 确保在函数退出时事务能回滚
// 加锁查询用户以确保数据一致性
err := tx.Set("gorm:query_option", "FOR UPDATE").First(&user, user.Id).Error
err := lockForUpdate(tx).First(&user, user.Id).Error
if err != nil {
return err
}