feat: 支持充值商品配置和档位首充
This commit is contained in:
@@ -24,9 +24,13 @@
|
||||
| `points_1280` | 1280 | 12800 | 首充双倍 | 首充送1280泥点 |
|
||||
| `points_3280` | 3280 | 32800 | 首充双倍 | 首充送3280泥点 |
|
||||
|
||||
泥点充值固定为 `¥6 / ¥18 / ¥30 / ¥68 / ¥128 / ¥328` 六个档位。全部档位参与首充双倍:用户历史上没有 `points_recharge` 流水时,本次购买到账泥点为基础泥点与等额赠送泥点之和;已有充值流水后只到账基础泥点。实际到账泥点写入交易流水,余额以 SpacetimeDB projection 为准。
|
||||
泥点充值默认初始化 `¥6 / ¥18 / ¥30 / ¥68 / ¥128 / ¥328` 六个档位。默认档位只作为空库种子写入 `profile_recharge_product_config`,运行时充值中心展示、下单校验和支付确认结算都以 SpacetimeDB 配置表为准,不再把代码中的商品目录作为业务真相源。
|
||||
|
||||
充值中心返回的 `hasPointsRecharged` 是首充资格的展示与结算共同依据:当它为 `true` 时,后端下发的泥点套餐应只保留基础泥点、清空首充徽标与赠送文案;前端即使收到旧版本快照中残留的 `bonusPoints` / `badgeLabel`,也必须按 `hasPointsRecharged` 隐藏“首充双倍”和 `基础+赠送` 展示。这样可以避免第二次充值只到账基础泥点时,弹窗仍显示 `60+60` 等已失效权益。
|
||||
全部泥点档位参与档位首充双倍:首充资格按 `productId` 独立判断。用户购买过 `points_60` 后,再次购买 `points_60` 只到账基础泥点;但 `points_180`、`points_300` 等未购买过的档位仍保留各自的首充赠送。实际到账泥点写入 `profile_recharge_order.points_delta` 与钱包流水,余额以 SpacetimeDB projection 为准。
|
||||
|
||||
充值中心返回的 `pointProducts` 已由后端按当前账号和每个 `productId` 计算有效展示状态:已完成首充的档位清空 `bonusPoints`、`badgeLabel` 与首充说明,未完成首充的档位继续显示 `首充双倍` 和 `基础+赠送`。`hasPointsRecharged` 仅保留为兼容字段,表示账号是否发生过任一泥点充值,不再作为隐藏所有档位首充或计算结算金额的依据。前端不得再用 `hasPointsRecharged` 对所有泥点商品做统一屏蔽。
|
||||
|
||||
后台通过“充值商品”页维护 `profile_recharge_product_config`,字段包括 `productId`、标题、商品类型、金额分、基础泥点、首充赠送泥点、会员天数、徽标、说明、会员层级、启用状态和排序。保存后新的充值中心快照、下单与支付确认立即读取配置表;历史订单继续保留下单当时写入的商品标题、金额和状态。
|
||||
|
||||
### 2.2 会员卡套餐
|
||||
|
||||
@@ -157,7 +161,7 @@
|
||||
|
||||
1. 普通用户打开弹窗能看到泥点与会员套餐。
|
||||
2. 泥点购买后余额增加,流水来源为 `points_recharge`。
|
||||
3. 首充赠送只在首次泥点充值时生效。
|
||||
4. 已产生 `points_recharge` 流水后,再打开充值弹窗不应展示“首充双倍”徽标或 `60+60` 等赠送泥点组合。
|
||||
3. 首充赠送按泥点档位独立生效。
|
||||
4. 某个 `productId` 已成功完成泥点充值后,再打开充值弹窗时仅该档位不再展示“首充双倍”徽标或 `60+60` 等赠送泥点组合,其他未购买过的泥点档位仍展示各自首充权益。
|
||||
5. 会员购买后会员状态与到期时间立即更新。
|
||||
6. 移动端弹窗单列可滚动,桌面端接近参考图卡片网格。
|
||||
|
||||
@@ -24,7 +24,7 @@ spacetime sql <db> "SELECT * FROM custom_world_gallery_entry"
|
||||
| --- | --- |
|
||||
| 运维迁移 | `database_migration_operator`, `database_migration_import_chunk` |
|
||||
| 认证 | `auth_store_snapshot`, `auth_store_projection_meta`, `user_account`, `auth_identity`, `refresh_session` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `analytics_date_dimension`, `tracking_event`, `tracking_daily_stat`, `profile_task_config`, `profile_task_progress`, `profile_task_reward_claim`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_invite_code`, `profile_referral_relation`, `profile_played_world`, `profile_membership`, `profile_recharge_order`, `profile_feedback_submission`, `profile_save_archive` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `analytics_date_dimension`, `tracking_event`, `tracking_daily_stat`, `profile_task_config`, `profile_task_progress`, `profile_task_reward_claim`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_invite_code`, `profile_referral_relation`, `profile_played_world`, `profile_membership`, `profile_recharge_product_config`, `profile_recharge_order`, `profile_feedback_submission`, `profile_save_archive` |
|
||||
| RPG 运行时 | `story_session`, `story_event`, `npc_state`, `inventory_slot`, `battle_state`, `treasure_record`, `quest_record`, `quest_log`, `player_progression`, `chapter_progression` |
|
||||
| 世界创作 | `custom_world_profile`, `custom_world_session`, `custom_world_agent_session`, `custom_world_agent_message`, `custom_world_agent_operation`, `custom_world_draft_card`, `custom_world_gallery_entry` |
|
||||
| 拼图 | `puzzle_agent_session`, `puzzle_agent_message`, `puzzle_work_profile`, `puzzle_event`, `puzzle_runtime_run`, `puzzle_leaderboard_entry` |
|
||||
@@ -336,11 +336,23 @@ SELECT * FROM public_work_like WHERE user_id = '<user_id>';
|
||||
SELECT * FROM profile_membership WHERE user_id = '<user_id>';
|
||||
```
|
||||
|
||||
### `profile_recharge_product_config`
|
||||
|
||||
- 作用:充值商品配置表,是泥点和会员充值商品的运行时真相源;默认商品只在空库时作为种子写入,后台“充值商品”页后续维护该表。
|
||||
- 结构:`product_id PK: String`, `title: String`, `price_cents: u64`, `kind: RuntimeProfileRechargeProductKind`, `points_amount: u64`, `bonus_points: u64`, `duration_days: u32`, `badge_label: String`, `description: String`, `tier: RuntimeProfileMembershipTier`, `enabled: bool`, `sort_order: i32`, `created_by: String`, `created_at: Timestamp`, `updated_by: String`, `updated_at: Timestamp`。
|
||||
- 索引:主键 `product_id`。
|
||||
- 充值口径:下单只允许读取 `enabled = true` 的商品;支付确认允许按订单 `product_id` 读取已存在商品完成历史 pending 订单。泥点首充按 `user_id + product_id` 独立判断,只清空已购买档位的 `bonus_points`、`badge_label` 和首充说明。
|
||||
|
||||
```sql
|
||||
SELECT * FROM profile_recharge_product_config ORDER BY sort_order;
|
||||
SELECT * FROM profile_recharge_product_config WHERE product_id = '<product_id>';
|
||||
```
|
||||
|
||||
### `profile_recharge_order`
|
||||
|
||||
- 作用:充值订单表,记录用户购买泥点或会员的订单、支付渠道、支付时间、积分变更和会员到期时间。
|
||||
- 结构:`order_id PK: String`, `user_id: String`, `product_id: String`, `product_title: String`, `kind: RuntimeProfileRechargeProductKind`, `amount_cents: u64`, `status: RuntimeProfileRechargeOrderStatus`, `payment_channel: String`, `paid_at: Option<Timestamp>`, `provider_transaction_id: Option<String>`, `created_at: Timestamp`, `points_delta: i64`, `membership_expires_at: Option<Timestamp>`。
|
||||
- 支付口径:`mock` 渠道创建后立即 `paid` 并入账;微信小程序 `wechat_mp` 渠道创建时为 `pending`,微信支付通知确认后改为 `paid`,`provider_transaction_id` 保存微信支付平台订单号。
|
||||
- 支付口径:`mock` 渠道创建后立即 `paid` 并入账;微信小程序 `wechat_mp` 渠道创建时为 `pending`,微信支付通知确认后改为 `paid`,`provider_transaction_id` 保存微信支付平台订单号。订单商品信息来自 `profile_recharge_product_config`,泥点首充赠送按同一用户的同一 `product_id` 历史 `paid` 订单独立计算。
|
||||
- 索引:`user_id`, `(user_id, created_at)`。
|
||||
|
||||
```sql
|
||||
|
||||
Reference in New Issue
Block a user