Commit c19767b9 by CalciumIon

feat: 统计无限令牌的已用额度 (close #308)

parent e78289d1
...@@ -250,11 +250,9 @@ func PreConsumeTokenQuota(tokenId int, quota int) (userQuota int, err error) { ...@@ -250,11 +250,9 @@ func PreConsumeTokenQuota(tokenId int, quota int) (userQuota int, err error) {
if userQuota < quota { if userQuota < quota {
return 0, errors.New(fmt.Sprintf("用户额度不足,剩余额度为 %d", userQuota)) return 0, errors.New(fmt.Sprintf("用户额度不足,剩余额度为 %d", userQuota))
} }
if !token.UnlimitedQuota { err = DecreaseTokenQuota(tokenId, quota)
err = DecreaseTokenQuota(tokenId, quota) if err != nil {
if err != nil { return 0, err
return 0, err
}
} }
err = DecreaseUserQuota(token.UserId, quota) err = DecreaseUserQuota(token.UserId, quota)
return userQuota - quota, err return userQuota - quota, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment