补齐创作生成订阅消息通知

订阅消息任务名称改为玩法模板名。

拼图、敲木鱼、抓大鹅、跳一跳、方洞、视觉小说在草稿生成成功或失败终态发送通知。

订阅消息泥点字段按本次生成结算后的实际扣除展示,失败退款后显示0。

更新微信订阅消息运维和支付方案文档口径。
This commit is contained in:
kdletters
2026-06-08 19:21:05 +08:00
parent a4ee6ff698
commit 11c5e3edf4
10 changed files with 349 additions and 56 deletions

View File

@@ -81,12 +81,18 @@ use crate::{
SquareHoleAgentTurnRequest, build_finalize_record_input, run_square_hole_agent_turn,
},
state::AppState,
wechat_subscribe_message::{
GenerationResultSubscribeMessage, GenerationResultSubscribeMessageStatus,
send_generation_result_subscribe_message_after_completion,
},
work_play_tracking::{WorkPlayTrackingDraft, record_work_play_start_after_success},
};
const SQUARE_HOLE_AGENT_PROVIDER: &str = "square-hole-agent";
const SQUARE_HOLE_WORKS_PROVIDER: &str = "square-hole-works";
const SQUARE_HOLE_RUNTIME_PROVIDER: &str = "square-hole-runtime";
const SQUARE_HOLE_TEMPLATE_ID: &str = "square-hole";
const SQUARE_HOLE_TEMPLATE_NAME: &str = "方洞";
const SQUARE_HOLE_DEFAULT_THEME: &str = "纸箱";
const SQUARE_HOLE_DEFAULT_TWIST_RULE: &str = "方洞万能";
const SQUARE_HOLE_DEFAULT_SHAPE_COUNT: u32 = 12;
@@ -1112,14 +1118,21 @@ async fn compile_square_hole_draft_for_session(
.as_ref()
.map(|tags| serde_json::to_string(&normalize_tags(tags.clone())).unwrap_or_default());
state
let resolved_game_name = game_name.or_else(|| Some(format!("{}方洞挑战", config.theme_text)));
let generation_points_cost = crate::creation_entry_config::resolve_creation_entry_mud_point_cost(
state,
SQUARE_HOLE_TEMPLATE_ID,
u64::from(shared_contracts::creation_entry_config::DEFAULT_UNIFIED_CREATION_MUD_POINT_COST),
)
.await;
let result = state
.spacetime_client()
.compile_square_hole_draft(SquareHoleCompileDraftRecordInput {
session_id,
owner_user_id,
owner_user_id: owner_user_id.clone(),
profile_id: build_prefixed_uuid_id(SQUARE_HOLE_PROFILE_ID_PREFIX),
author_display_name: resolve_author_display_name(state, authenticated),
game_name: game_name.or_else(|| Some(format!("{}方洞挑战", config.theme_text))),
game_name: resolved_game_name.clone(),
summary_text: summary,
tags_json,
cover_image_src,
@@ -1132,7 +1145,43 @@ async fn compile_square_hole_draft_for_session(
SQUARE_HOLE_AGENT_PROVIDER,
map_square_hole_client_error(error),
)
})
});
match result {
Ok(session) => {
send_generation_result_subscribe_message_after_completion(
state,
GenerationResultSubscribeMessage {
owner_user_id,
task_name: Some(SQUARE_HOLE_TEMPLATE_NAME.to_string()),
work_name: session.draft.as_ref().map(|draft| draft.game_name.clone()),
status: GenerationResultSubscribeMessageStatus::Succeeded,
consumed_points: generation_points_cost,
completed_at_micros: current_utc_micros(),
page: Some("/pages/web-view/index".to_string()),
},
)
.await;
Ok(session)
}
Err(response) => {
if response.status().is_server_error() {
send_generation_result_subscribe_message_after_completion(
state,
GenerationResultSubscribeMessage {
owner_user_id,
task_name: Some(SQUARE_HOLE_TEMPLATE_NAME.to_string()),
work_name: resolved_game_name,
status: GenerationResultSubscribeMessageStatus::Failed,
consumed_points: 0,
completed_at_micros: current_utc_micros(),
page: Some("/pages/web-view/index".to_string()),
},
)
.await;
}
Err(response)
}
}
}
mod visual_assets;