Merge pull request #841 from touwaeriol/feature/account-periodic-quota

feat(account): 为 API Key 账号新增日/周周期性配额限制
This commit is contained in:
Wesley Liddick
2026-03-08 20:34:15 +08:00
committed by GitHub
21 changed files with 627 additions and 136 deletions

View File

@@ -6478,7 +6478,7 @@ func postUsageBilling(ctx context.Context, p *postUsageBillingParams, deps *bill
}
// 4. 账号配额用量账号口径TotalCost × 账号计费倍率)
if cost.TotalCost > 0 && p.Account.Type == AccountTypeAPIKey && p.Account.GetQuotaLimit() > 0 {
if cost.TotalCost > 0 && p.Account.Type == AccountTypeAPIKey && p.Account.HasAnyQuotaLimit() {
accountCost := cost.TotalCost * p.AccountRateMultiplier
if err := deps.accountRepo.IncrementQuotaUsed(ctx, p.Account.ID, accountCost); err != nil {
slog.Error("increment account quota used failed", "account_id", p.Account.ID, "cost", accountCost, "error", err)