mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-18 17:46:37 +08:00
Fix
This commit is contained in:
parent
7d5c0959b2
commit
b3b3c59aac
@ -109,7 +109,7 @@ type DeepSeekUsageResponse struct {
|
||||
TotalBalance string `json:"total_balance"`
|
||||
GrantedBalance string `json:"granted_balance"`
|
||||
ToppedUpBalance string `json:"topped_up_balance"`
|
||||
}
|
||||
} `json:"balance_infos"`
|
||||
}
|
||||
|
||||
// GetAuthHeader get auth header
|
||||
@ -267,7 +267,17 @@ func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
balance, err := strconv.ParseFloat(response.BalanceInfos[0].TotalBalance, 64)
|
||||
index := -1
|
||||
for i, balanceInfo := range response.BalanceInfos {
|
||||
if balanceInfo.Currency == "CNY" {
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if index == -1 {
|
||||
return 0, errors.New("currency CNY not found")
|
||||
}
|
||||
balance, err := strconv.ParseFloat(response.BalanceInfos[index].TotalBalance, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user