refactor(会员报价): 升级报价快照档位与周期改用枚举
- RuntimeProfileMembershipUpgradeQuoteSnapshot 的 current_plan / target_plan / cycle_kind 由 String 改为 RuntimeProfileMembershipPlan / RuntimeProfileMembershipCycleKind,把非法值挡在类型边界外。 - 模块构造点直接写入枚举;记录侧在 build_runtime_profile_membership_upgrade_quote_record 用 as_str() 转回对外 token,HTTP 契约不变。 - spacetime-client 映射改用 plan / cycle_kind 的 back 映射还原枚举;重新生成 module_bindings。
This commit is contained in:
@@ -1132,9 +1132,9 @@ pub fn build_runtime_profile_membership_upgrade_quote_record(
|
||||
snapshot: RuntimeProfileMembershipUpgradeQuoteSnapshot,
|
||||
) -> RuntimeProfileMembershipUpgradeQuoteRecord {
|
||||
RuntimeProfileMembershipUpgradeQuoteRecord {
|
||||
current_plan: snapshot.current_plan,
|
||||
target_plan: snapshot.target_plan,
|
||||
cycle_kind: snapshot.cycle_kind,
|
||||
current_plan: snapshot.current_plan.as_str().to_string(),
|
||||
target_plan: snapshot.target_plan.as_str().to_string(),
|
||||
cycle_kind: snapshot.cycle_kind.as_str().to_string(),
|
||||
cycle_index: snapshot.cycle_index,
|
||||
cycle_count: snapshot.cycle_count,
|
||||
amount_cents: snapshot.amount_cents,
|
||||
|
||||
@@ -1892,9 +1892,9 @@ pub struct RuntimeProfileMembershipUpgradeQuoteGetInput {
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RuntimeProfileMembershipUpgradeQuoteSnapshot {
|
||||
pub current_plan: String,
|
||||
pub target_plan: String,
|
||||
pub cycle_kind: String,
|
||||
pub current_plan: RuntimeProfileMembershipPlan,
|
||||
pub target_plan: RuntimeProfileMembershipPlan,
|
||||
pub cycle_kind: RuntimeProfileMembershipCycleKind,
|
||||
pub cycle_index: u32,
|
||||
pub cycle_count: u32,
|
||||
pub amount_cents: u64,
|
||||
|
||||
@@ -2119,9 +2119,9 @@ pub(crate) fn map_runtime_profile_membership_upgrade_quote_procedure_result(
|
||||
|
||||
Ok(build_runtime_profile_membership_upgrade_quote_record(
|
||||
module_runtime::RuntimeProfileMembershipUpgradeQuoteSnapshot {
|
||||
current_plan: quote.current_plan,
|
||||
target_plan: quote.target_plan,
|
||||
cycle_kind: quote.cycle_kind,
|
||||
current_plan: map_runtime_profile_membership_plan_back(quote.current_plan),
|
||||
target_plan: map_runtime_profile_membership_plan_back(quote.target_plan),
|
||||
cycle_kind: map_runtime_profile_membership_cycle_kind_back(quote.cycle_kind),
|
||||
cycle_index: quote.cycle_index,
|
||||
cycle_count: quote.cycle_count,
|
||||
amount_cents: quote.amount_cents,
|
||||
|
||||
+6
-3
@@ -4,12 +4,15 @@
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::runtime_profile_membership_cycle_kind_type::RuntimeProfileMembershipCycleKind;
|
||||
use super::runtime_profile_membership_plan_type::RuntimeProfileMembershipPlan;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct RuntimeProfileMembershipUpgradeQuoteSnapshot {
|
||||
pub current_plan: String,
|
||||
pub target_plan: String,
|
||||
pub cycle_kind: String,
|
||||
pub current_plan: RuntimeProfileMembershipPlan,
|
||||
pub target_plan: RuntimeProfileMembershipPlan,
|
||||
pub cycle_kind: RuntimeProfileMembershipCycleKind,
|
||||
pub cycle_index: u32,
|
||||
pub cycle_count: u32,
|
||||
pub amount_cents: u64,
|
||||
|
||||
@@ -8279,9 +8279,9 @@ fn build_profile_membership_upgrade_quote_record(
|
||||
.map_err(|rejection| format!("会员升级被拒绝: {}", rejection.as_str()))?;
|
||||
|
||||
Ok(RuntimeProfileMembershipUpgradeQuoteSnapshot {
|
||||
current_plan: current.plan.as_str().to_string(),
|
||||
target_plan: target.plan.as_str().to_string(),
|
||||
cycle_kind: target.cycle_kind.as_str().to_string(),
|
||||
current_plan: current.plan,
|
||||
target_plan: target.plan,
|
||||
cycle_kind: target.cycle_kind,
|
||||
cycle_index: quote.cycle_index,
|
||||
cycle_count: target.cycle_count,
|
||||
amount_cents: quote.amount_cents,
|
||||
|
||||
Reference in New Issue
Block a user