This commit is contained in:
@@ -250,5 +250,4 @@ impl SpacetimeClient {
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ use module_runtime::{
|
||||
build_runtime_profile_recharge_center_record,
|
||||
build_runtime_profile_recharge_order_create_input,
|
||||
build_runtime_profile_save_archive_list_input, build_runtime_profile_save_archive_record,
|
||||
build_runtime_profile_save_archive_resume_input,
|
||||
build_runtime_profile_save_archive_resume_input, build_runtime_profile_wallet_adjustment_input,
|
||||
build_runtime_profile_wallet_ledger_entry_record,
|
||||
build_runtime_profile_wallet_ledger_list_input, build_runtime_referral_invite_center_get_input,
|
||||
build_runtime_referral_invite_center_record, build_runtime_referral_redeem_input,
|
||||
|
||||
@@ -125,6 +125,19 @@ impl From<module_runtime::RuntimeProfileWalletLedgerListInput>
|
||||
}
|
||||
}
|
||||
|
||||
impl From<module_runtime::RuntimeProfileWalletAdjustmentInput>
|
||||
for RuntimeProfileWalletAdjustmentInput
|
||||
{
|
||||
fn from(input: module_runtime::RuntimeProfileWalletAdjustmentInput) -> Self {
|
||||
Self {
|
||||
user_id: input.user_id,
|
||||
amount: input.amount,
|
||||
ledger_id: input.ledger_id,
|
||||
created_at_micros: input.created_at_micros,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<module_runtime::RuntimeProfileRechargeCenterGetInput>
|
||||
for RuntimeProfileRechargeCenterGetInput
|
||||
{
|
||||
@@ -663,6 +676,28 @@ pub(crate) fn map_runtime_profile_wallet_ledger_procedure_result(
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub(crate) fn map_runtime_profile_wallet_adjustment_procedure_result(
|
||||
result: RuntimeProfileWalletAdjustmentProcedureResult,
|
||||
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
||||
if !result.ok {
|
||||
return Err(SpacetimeClientError::Procedure(
|
||||
result
|
||||
.error_message
|
||||
.unwrap_or_else(|| "SpacetimeDB procedure 返回未知错误".to_string()),
|
||||
));
|
||||
}
|
||||
|
||||
let snapshot = result.record.ok_or_else(|| {
|
||||
SpacetimeClientError::Procedure(
|
||||
"SpacetimeDB procedure 未返回 profile dashboard 快照".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(build_runtime_profile_dashboard_record(
|
||||
map_runtime_profile_dashboard_snapshot(snapshot),
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn map_runtime_profile_recharge_center_procedure_result(
|
||||
result: RuntimeProfileRechargeCenterProcedureResult,
|
||||
) -> Result<RuntimeProfileRechargeCenterRecord, SpacetimeClientError> {
|
||||
@@ -3236,6 +3271,12 @@ pub(crate) fn map_runtime_profile_wallet_ledger_source_type_back(
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::PointsRecharge => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::PointsRecharge
|
||||
}
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::AssetGenerationConsume => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::AssetGenerationConsume
|
||||
}
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::AssetGenerationRefund => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::AssetGenerationRefund
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ pub mod complete_ai_task_and_return_procedure;
|
||||
pub mod confirm_asset_object_and_return_procedure;
|
||||
pub mod confirm_asset_object_reducer;
|
||||
pub mod consume_inventory_item_input_type;
|
||||
pub mod consume_profile_wallet_points_and_return_procedure;
|
||||
pub mod continue_story_and_return_procedure;
|
||||
pub mod continue_story_reducer;
|
||||
pub mod create_ai_task_and_return_procedure;
|
||||
@@ -343,6 +344,7 @@ pub mod quest_step_snapshot_type;
|
||||
pub mod quest_treasure_inspected_signal_type;
|
||||
pub mod quest_turn_in_input_type;
|
||||
pub mod redeem_profile_referral_invite_code_procedure;
|
||||
pub mod refund_profile_wallet_points_and_return_procedure;
|
||||
pub mod refresh_session_type;
|
||||
pub mod resolve_combat_action_and_return_procedure;
|
||||
pub mod resolve_combat_action_input_type;
|
||||
@@ -405,6 +407,8 @@ pub mod runtime_profile_save_archive_list_input_type;
|
||||
pub mod runtime_profile_save_archive_procedure_result_type;
|
||||
pub mod runtime_profile_save_archive_resume_input_type;
|
||||
pub mod runtime_profile_save_archive_snapshot_type;
|
||||
pub mod runtime_profile_wallet_adjustment_input_type;
|
||||
pub mod runtime_profile_wallet_adjustment_procedure_result_type;
|
||||
pub mod runtime_profile_wallet_ledger_entry_snapshot_type;
|
||||
pub mod runtime_profile_wallet_ledger_list_input_type;
|
||||
pub mod runtime_profile_wallet_ledger_procedure_result_type;
|
||||
@@ -583,6 +587,7 @@ pub use complete_ai_task_and_return_procedure::complete_ai_task_and_return;
|
||||
pub use confirm_asset_object_and_return_procedure::confirm_asset_object_and_return;
|
||||
pub use confirm_asset_object_reducer::confirm_asset_object;
|
||||
pub use consume_inventory_item_input_type::ConsumeInventoryItemInput;
|
||||
pub use consume_profile_wallet_points_and_return_procedure::consume_profile_wallet_points_and_return;
|
||||
pub use continue_story_and_return_procedure::continue_story_and_return;
|
||||
pub use continue_story_reducer::continue_story;
|
||||
pub use create_ai_task_and_return_procedure::create_ai_task_and_return;
|
||||
@@ -808,6 +813,7 @@ pub use quest_step_snapshot_type::QuestStepSnapshot;
|
||||
pub use quest_treasure_inspected_signal_type::QuestTreasureInspectedSignal;
|
||||
pub use quest_turn_in_input_type::QuestTurnInInput;
|
||||
pub use redeem_profile_referral_invite_code_procedure::redeem_profile_referral_invite_code;
|
||||
pub use refund_profile_wallet_points_and_return_procedure::refund_profile_wallet_points_and_return;
|
||||
pub use refresh_session_type::RefreshSession;
|
||||
pub use resolve_combat_action_and_return_procedure::resolve_combat_action_and_return;
|
||||
pub use resolve_combat_action_input_type::ResolveCombatActionInput;
|
||||
@@ -870,6 +876,8 @@ pub use runtime_profile_save_archive_list_input_type::RuntimeProfileSaveArchiveL
|
||||
pub use runtime_profile_save_archive_procedure_result_type::RuntimeProfileSaveArchiveProcedureResult;
|
||||
pub use runtime_profile_save_archive_resume_input_type::RuntimeProfileSaveArchiveResumeInput;
|
||||
pub use runtime_profile_save_archive_snapshot_type::RuntimeProfileSaveArchiveSnapshot;
|
||||
pub use runtime_profile_wallet_adjustment_input_type::RuntimeProfileWalletAdjustmentInput;
|
||||
pub use runtime_profile_wallet_adjustment_procedure_result_type::RuntimeProfileWalletAdjustmentProcedureResult;
|
||||
pub use runtime_profile_wallet_ledger_entry_snapshot_type::RuntimeProfileWalletLedgerEntrySnapshot;
|
||||
pub use runtime_profile_wallet_ledger_list_input_type::RuntimeProfileWalletLedgerListInput;
|
||||
pub use runtime_profile_wallet_ledger_procedure_result_type::RuntimeProfileWalletLedgerProcedureResult;
|
||||
|
||||
@@ -15,6 +15,10 @@ pub enum RuntimeProfileWalletLedgerSourceType {
|
||||
InviteInviteeReward,
|
||||
|
||||
PointsRecharge,
|
||||
|
||||
AssetGenerationConsume,
|
||||
|
||||
AssetGenerationRefund,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RuntimeProfileWalletLedgerSourceType {
|
||||
|
||||
@@ -89,6 +89,67 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn consume_profile_wallet_points(
|
||||
&self,
|
||||
user_id: String,
|
||||
amount: u64,
|
||||
ledger_id: String,
|
||||
created_at_micros: i64,
|
||||
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
||||
let procedure_input = build_runtime_profile_wallet_adjustment_input(
|
||||
user_id,
|
||||
amount,
|
||||
ledger_id,
|
||||
created_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
|
||||
.into();
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.consume_profile_wallet_points_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_wallet_adjustment_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn refund_profile_wallet_points(
|
||||
&self,
|
||||
user_id: String,
|
||||
amount: u64,
|
||||
ledger_id: String,
|
||||
created_at_micros: i64,
|
||||
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
||||
let procedure_input = build_runtime_profile_wallet_adjustment_input(
|
||||
user_id,
|
||||
amount,
|
||||
ledger_id,
|
||||
created_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
|
||||
.into();
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.refund_profile_wallet_points_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_wallet_adjustment_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_profile_recharge_center(
|
||||
&self,
|
||||
user_id: String,
|
||||
|
||||
Reference in New Issue
Block a user