(channel *model.Channel)
| 250 | } |
| 251 | |
| 252 | func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) { |
| 253 | url := "https://api.deepseek.com/user/balance" |
| 254 | body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key)) |
| 255 | if err != nil { |
| 256 | return 0, err |
| 257 | } |
| 258 | response := DeepSeekUsageResponse{} |
| 259 | err = json.Unmarshal(body, &response) |
| 260 | if err != nil { |
| 261 | return 0, err |
| 262 | } |
| 263 | index := -1 |
| 264 | for i, balanceInfo := range response.BalanceInfos { |
| 265 | if balanceInfo.Currency == "CNY" { |
| 266 | index = i |
| 267 | break |
| 268 | } |
| 269 | } |
| 270 | if index == -1 { |
| 271 | return 0, errors.New("currency CNY not found") |
| 272 | } |
| 273 | balance, err := strconv.ParseFloat(response.BalanceInfos[index].TotalBalance, 64) |
| 274 | if err != nil { |
| 275 | return 0, err |
| 276 | } |
| 277 | channel.UpdateBalance(balance) |
| 278 | return balance, nil |
| 279 | } |
| 280 | |
| 281 | func updateChannelAIGC2DBalance(channel *model.Channel) (float64, error) { |
| 282 | url := "https://api.aigc2d.com/dashboard/billing/credit_grants" |
no test coverage detected