fix: 三端联调测试 2 P1 + 2 P2 + 4 P3 修复

P1-07: billing get_or_create_usage 同步 max_* 列到当前计划限额
P1-08: relay handler 增加直接配额检查 (relay_requests/input/output_tokens)
P2-09: relay failover 成功后记录 tokens 并标记 completed
P2-10: Tauri agentStore saas-relay 模式下从 SaaS API 获取真实用量
P2-14: super_admin 合成 subscription + check_quota 放行
P3-19: 新建 ApiKeys.tsx 页面替代 ModelServices 路由
P3-15: antd destroyOnClose → destroyOnHidden (3处)
P3-16: ProTable onSearch → onSubmit (2处)
This commit is contained in:
iven
2026-04-14 17:48:22 +08:00
parent 45fd9fee7b
commit dd854479eb
11 changed files with 259 additions and 12 deletions

View File

@@ -39,9 +39,23 @@ pub async fn get_subscription(
let sub = service::get_active_subscription(&state.db, &ctx.account_id).await?;
let usage = service::get_or_create_usage(&state.db, &ctx.account_id).await?;
// P2-14 修复: super_admin 无订阅时合成一个 "active" subscription
let sub_value = if sub.is_none() && ctx.role == "super_admin" {
Some(serde_json::json!({
"id": format!("sub-admin-{}", &ctx.account_id.chars().take(8).collect::<String>()),
"account_id": ctx.account_id,
"plan_id": plan.id,
"status": "active",
"current_period_start": usage.period_start,
"current_period_end": usage.period_end,
}))
} else {
sub.map(|s| serde_json::to_value(s).unwrap_or_default())
};
Ok(Json(serde_json::json!({
"plan": plan,
"subscription": sub,
"subscription": sub_value,
"usage": usage,
})))
}