Preserve usage provider identity

This commit is contained in:
fawney19
2026-05-20 20:56:36 +08:00
parent c972bbd397
commit 57910f906d
21 changed files with 340 additions and 104 deletions
@@ -53,6 +53,15 @@ fn admin_usage_aggregation_by_provider_json(
json!(rows
.iter()
.map(|row| {
let identity_source = match row.secondary_name.as_deref() {
Some("legacy_name") => "legacy_name",
_ => "provider_id",
};
let provider_id = if identity_source == "provider_id" {
json!(row.group_key)
} else {
serde_json::Value::Null
};
let success_count = row.success_count.unwrap_or_default();
let error_count = row.request_count.saturating_sub(success_count);
let success_rate = if row.request_count == 0 {
@@ -67,7 +76,9 @@ fn admin_usage_aggregation_by_provider_json(
.filter(|value| !value.is_empty())
.unwrap_or(row.group_key.as_str());
json!({
"provider_id": row.group_key,
"provider_id": provider_id,
"provider_key": row.group_key,
"provider_identity_source": identity_source,
"provider": provider_name,
"request_count": row.request_count,
"total_tokens": row.total_tokens,
@@ -115,6 +115,30 @@ pub(crate) const ADMIN_MODULE_DEFINITIONS: &[AdminModuleDefinition] = &[
admin_menu_group: Some("system"),
admin_menu_order: 60,
},
AdminModuleDefinition {
name: "payment_gateways",
display_name: "支付配置",
description: "配置易支付、支付宝官方、微信支付官方和 Stripe 等支付网关",
category: "integration",
env_key: "PAYMENT_GATEWAYS_AVAILABLE",
default_available: true,
admin_route: Some("/admin/payment-gateways"),
admin_menu_icon: Some("CreditCard"),
admin_menu_group: None,
admin_menu_order: 70,
},
AdminModuleDefinition {
name: "referral",
display_name: "邀请返利",
description: "管理用户邀请关系与返利记录,支持比例返利和人头返利",
category: "integration",
env_key: "REFERRAL_AVAILABLE",
default_available: true,
admin_route: Some("/admin/referrals"),
admin_menu_icon: Some("Gift"),
admin_menu_group: Some("management"),
admin_menu_order: 75,
},
];
#[derive(Debug, Clone, serde::Deserialize)]