🐛 fix: 修复余额的问题

This commit is contained in:
MartialBE
2023-12-02 19:54:21 +08:00
parent 58fc40a744
commit c97c8a0f65
14 changed files with 158 additions and 37 deletions

View File

@@ -4,10 +4,11 @@ import (
"errors"
"one-api/common"
"one-api/model"
"one-api/providers/base"
)
func (p *Api2dProvider) Balance(channel *model.Channel) (float64, error) {
fullRequestURL := "https://api.aigc2d.com/dashboard/billing/credit_grants"
fullRequestURL := p.GetFullRequestURL("/dashboard/billing/credit_grants", "")
headers := p.GetRequestHeaders()
client := common.NewClient()
@@ -17,7 +18,7 @@ func (p *Api2dProvider) Balance(channel *model.Channel) (float64, error) {
}
// 发送请求
var response APGC2DGPTUsageResponse
var response base.BalanceResponse
_, errWithCode := common.SendRequest(req, &response, false)
if errWithCode != nil {
return 0, errors.New(errWithCode.OpenAIError.Message)

View File

@@ -1,9 +0,0 @@
package api2d
type APGC2DGPTUsageResponse struct {
//Grants interface{} `json:"grants"`
Object string `json:"object"`
TotalAvailable float64 `json:"total_available"`
TotalGranted float64 `json:"total_granted"`
TotalUsed float64 `json:"total_used"`
}