Merge remote-tracking branch 'upstream/main'

This commit is contained in:
ckt1031
2023-07-16 13:12:45 +08:00
2 changed files with 22 additions and 16 deletions

View File

@@ -8,7 +8,8 @@ import (
)
func GetSubscription(c *gin.Context) {
var quota int
var remainQuota int
var usedQuota int
var err error
var expirationDate int64
@@ -18,10 +19,14 @@ func GetSubscription(c *gin.Context) {
expirationDate = token.ExpiredTime
if common.DisplayTokenStatEnabled {
quota = token.RemainQuota
tokenId := c.GetInt("token_id")
token, err = model.GetTokenById(tokenId)
remainQuota = token.RemainQuota
usedQuota = token.UsedQuota
} else {
userId := c.GetInt("id")
quota, err = model.GetUserQuota(userId)
remainQuota, err = model.GetUserQuota(userId)
usedQuota, err = model.GetUserUsedQuota(userId)
}
if err != nil {
openAIError := OpenAIError{
@@ -33,6 +38,7 @@ func GetSubscription(c *gin.Context) {
})
return
}
quota := remainQuota + usedQuota
amount := float64(quota)
if common.DisplayInCurrencyEnabled {
amount /= common.QuotaPerUnit