会员充值下单不再接受客户端时间参数

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 单测调用
This commit is contained in:
2026-10-03 16:15:36 +08:00
parent f9b0cf786d
commit 3e2ab3cf78
8 changed files with 10 additions and 26 deletions
@@ -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(
@@ -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<RuntimeProfileRechargeOrderCreateInput, RuntimeProfileFieldError> {
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,
})
}
@@ -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))]
@@ -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");
@@ -170,7 +170,6 @@ impl From<module_runtime::RuntimeProfileRechargeOrderCreateInput>
user_id: input.user_id,
product_id: input.product_id,
payment_channel: input.payment_channel,
created_at_micros: input.created_at_micros,
}
}
}
@@ -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",
@@ -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 {
@@ -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,
);