diff --git a/model/token.go b/model/token.go index eb69bac5..9616d236 100644 --- a/model/token.go +++ b/model/token.go @@ -254,17 +254,14 @@ func PreConsumeTokenQuota(tokenId int, quota int64) (err error) { func PostConsumeTokenQuota(tokenId int, quota int64) (err error) { token, err := GetTokenById(tokenId) - if err == nil { - if quota > 0 { - err = DecreaseUserQuota(token.UserId, quota) - } else { - err = IncreaseUserQuota(token.UserId, -quota) - } - } - if err != nil { return err } + if quota > 0 { + err = DecreaseUserQuota(token.UserId, quota) + } else { + err = IncreaseUserQuota(token.UserId, -quota) + } if !token.UnlimitedQuota { if quota > 0 { err = DecreaseTokenQuota(tokenId, quota)