From 3e2ab3cf78ef1953c8a65129bf086376f3169ae7 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 16:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=85=85=E5=80=BC=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E4=B8=8D=E5=86=8D=E6=8E=A5=E5=8F=97=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E6=97=B6=E9=97=B4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RuntimeProfileRechargeOrderCreateInput 删除 created_at_micros 字段,procedure 入参不再携带时间 build_runtime_profile_recharge_order_create_input 同步去掉时间参数 spacetime-module 建单时刻改用 ctx.timestamp,避免客户端把时间设到会员到期前夕压低补差金额 spacetime-client facade 与 mapper、生成绑定同步去掉该字段 api-server 不再自算 current_unix_micros 传入 更新受影响的 module-runtime 单测调用 --- server-rs/crates/api-server/src/runtime_profile.rs | 8 +------- server-rs/crates/module-runtime/src/commands.rs | 2 -- server-rs/crates/module-runtime/src/domain.rs | 1 - server-rs/crates/module-runtime/src/lib.rs | 2 -- .../src/active/mapper/runtime_profile.rs | 1 - .../crates/spacetime-client/src/active/runtime.rs | 13 ++++--------- ...time_profile_recharge_order_create_input_type.rs | 1 - .../spacetime-module/src/runtime/active/profile.rs | 8 +++++--- 8 files changed, 10 insertions(+), 26 deletions(-) diff --git a/server-rs/crates/api-server/src/runtime_profile.rs b/server-rs/crates/api-server/src/runtime_profile.rs index 8b3964b82..9d585f6c5 100644 --- a/server-rs/crates/api-server/src/runtime_profile.rs +++ b/server-rs/crates/api-server/src/runtime_profile.rs @@ -301,15 +301,9 @@ pub async fn create_profile_recharge_order( .map_err(|error| runtime_profile_error_response(&request_context, error))?; validate_recharge_payment_channel(&state, &payment_channel) .map_err(|error| runtime_profile_error_response(&request_context, error))?; - let created_at_micros = current_unix_micros(); let (center, order) = state .spacetime_client() - .create_profile_recharge_order( - user_id, - payload.product_id, - payment_channel.clone(), - created_at_micros, - ) + .create_profile_recharge_order(user_id, payload.product_id, payment_channel.clone()) .await .map_err(|error| { runtime_profile_error_response( diff --git a/server-rs/crates/module-runtime/src/commands.rs b/server-rs/crates/module-runtime/src/commands.rs index 8e6b39f53..702bc8398 100644 --- a/server-rs/crates/module-runtime/src/commands.rs +++ b/server-rs/crates/module-runtime/src/commands.rs @@ -357,7 +357,6 @@ pub fn build_runtime_profile_recharge_order_create_input( user_id: String, product_id: String, payment_channel: String, - created_at_micros: i64, ) -> Result { let user_id = normalize_runtime_profile_user_id(user_id)?; let product_id = @@ -369,7 +368,6 @@ pub fn build_runtime_profile_recharge_order_create_input( user_id, product_id, payment_channel, - created_at_micros, }) } diff --git a/server-rs/crates/module-runtime/src/domain.rs b/server-rs/crates/module-runtime/src/domain.rs index 5583aedae..3fd46f4ac 100644 --- a/server-rs/crates/module-runtime/src/domain.rs +++ b/server-rs/crates/module-runtime/src/domain.rs @@ -1916,7 +1916,6 @@ pub struct RuntimeProfileRechargeOrderCreateInput { pub user_id: String, pub product_id: String, pub payment_channel: String, - pub created_at_micros: i64, } #[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))] diff --git a/server-rs/crates/module-runtime/src/lib.rs b/server-rs/crates/module-runtime/src/lib.rs index fe77d4f1e..801644791 100644 --- a/server-rs/crates/module-runtime/src/lib.rs +++ b/server-rs/crates/module-runtime/src/lib.rs @@ -1000,7 +1000,6 @@ mod tests { "user-1".to_string(), "custom-points-600".to_string(), "mock".to_string(), - 1, ) .expect("product existence is validated against database config later"); @@ -1014,7 +1013,6 @@ mod tests { "user-1".to_string(), "points_60".to_string(), " ".to_string(), - 1, ) .expect_err("missing payment channel should fail"); diff --git a/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs b/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs index e1aa0a557..c65d6ab68 100644 --- a/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs +++ b/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs @@ -170,7 +170,6 @@ impl From user_id: input.user_id, product_id: input.product_id, payment_channel: input.payment_channel, - created_at_micros: input.created_at_micros, } } } diff --git a/server-rs/crates/spacetime-client/src/active/runtime.rs b/server-rs/crates/spacetime-client/src/active/runtime.rs index 88e7bc888..7c5c4bb34 100644 --- a/server-rs/crates/spacetime-client/src/active/runtime.rs +++ b/server-rs/crates/spacetime-client/src/active/runtime.rs @@ -399,7 +399,6 @@ impl SpacetimeClient { user_id: String, product_id: String, payment_channel: String, - created_at_micros: i64, ) -> Result< ( RuntimeProfileRechargeCenterRecord, @@ -407,14 +406,10 @@ impl SpacetimeClient { ), SpacetimeClientError, > { - let procedure_input = build_runtime_profile_recharge_order_create_input( - user_id, - product_id, - payment_channel, - created_at_micros, - ) - .map_err(SpacetimeClientError::validation_failed)? - .into(); + let procedure_input = + build_runtime_profile_recharge_order_create_input(user_id, product_id, payment_channel) + .map_err(SpacetimeClientError::validation_failed)? + .into(); self.call_after_connect( "create_profile_recharge_order_and_return", diff --git a/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_recharge_order_create_input_type.rs b/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_recharge_order_create_input_type.rs index 7a4c7ee43..0697f06f2 100644 --- a/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_recharge_order_create_input_type.rs +++ b/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_recharge_order_create_input_type.rs @@ -10,7 +10,6 @@ pub struct RuntimeProfileRechargeOrderCreateInput { pub user_id: String, pub product_id: String, pub payment_channel: String, - pub created_at_micros: i64, } impl __sdk::InModule for RuntimeProfileRechargeOrderCreateInput { diff --git a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs index 2ffc40acc..17811db29 100644 --- a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs +++ b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs @@ -4766,12 +4766,14 @@ fn create_profile_recharge_order_record( input.user_id, input.product_id, input.payment_channel, - input.created_at_micros, ) .map_err(|error| error.to_string())?; let product = resolve_enabled_profile_recharge_order_product(ctx, &validated_input.product_id) .ok_or_else(|| "recharge.product_id 不存在或已下架".to_string())?; - let created_at = Timestamp::from_micros_since_unix_epoch(validated_input.created_at_micros); + // 中文注释:建单时刻一律取服务端事务时间,procedure 入参不再携带时间; + // 否则客户端可把时间设到会员到期前夕,压低升级补差金额。 + let created_at_micros = ctx.timestamp.to_micros_since_unix_epoch(); + let created_at = Timestamp::from_micros_since_unix_epoch(created_at_micros); let should_settle_immediately = validated_input.payment_channel == PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK; // 会员订单:建单时冻结档位、价格与补点快照,之后支付只认这份快照(改价 / 下架都不影响)。 @@ -4792,7 +4794,7 @@ fn create_profile_recharge_order_record( .unwrap_or(product.price_cents); let order_id = build_runtime_profile_recharge_order_id( &validated_input.user_id, - validated_input.created_at_micros, + created_at_micros, &product.product_id, );