From aca58b6b2503a94cac2db607544601a459b8d776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 3 Oct 2026 14:59:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3):=20?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=8D=87=E7=BA=A7=E4=B8=8E=E6=A1=A3=E4=BD=8D?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9A=84=E4=B8=9A=E5=8A=A1=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - runtime_profile.rs:新增 is_runtime_profile_membership_domain_error,会员升级报价(非会员 / 重复购买 / 月年互换 / 档位下架 / 非法报价入参)与会员档位目录校验失败统一映射为 400,基础设施错误仍保持 502 Co-authored-by: Junie --- .../crates/api-server/src/runtime_profile.rs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/server-rs/crates/api-server/src/runtime_profile.rs b/server-rs/crates/api-server/src/runtime_profile.rs index da0dd03d0..4854fff94 100644 --- a/server-rs/crates/api-server/src/runtime_profile.rs +++ b/server-rs/crates/api-server/src/runtime_profile.rs @@ -1484,14 +1484,14 @@ pub async fn get_profile_play_stats( } fn map_runtime_profile_client_error(error: SpacetimeClientError) -> AppError { - let is_redeem_code_domain_error = matches!( + let is_domain_error = matches!( &error, SpacetimeClientError::Procedure(message) - if is_runtime_profile_redeem_code_domain_error(message) + if is_runtime_profile_domain_error(message) ); let (status, provider) = match &error { SpacetimeClientError::Runtime(_) => (StatusCode::BAD_REQUEST, "runtime-profile"), - SpacetimeClientError::Procedure(_) if is_redeem_code_domain_error => { + SpacetimeClientError::Procedure(_) if is_domain_error => { (StatusCode::BAD_REQUEST, "runtime-profile") } _ => (StatusCode::BAD_GATEWAY, "spacetimedb"), @@ -1501,12 +1501,29 @@ fn map_runtime_profile_client_error(error: SpacetimeClientError) -> AppError { "provider": provider, "message": error.to_string(), })); - if is_redeem_code_domain_error { + if is_domain_error { return app_error.with_message(error.to_string()); } app_error } +/// 模块侧的可读业务拒绝以 400 返回,基础设施错误保持 502。 +fn is_runtime_profile_domain_error(message: &str) -> bool { + is_runtime_profile_redeem_code_domain_error(message) + || is_runtime_profile_membership_domain_error(message) +} + +fn is_runtime_profile_membership_domain_error(message: &str) -> bool { + message.starts_with("会员升级被拒绝: ") + || message.starts_with("会员档位") + || matches!( + message, + "当前不是会员,请直接选择套餐购买" + | "当前套餐已生效,无需重复购买" + | "当前会员有效期内不支持月付 / 年付转换,到期后可重新选择" + ) +} + fn is_runtime_profile_redeem_code_domain_error(message: &str) -> bool { matches!( message,