统一泥点账户与每日免费额度
- 新增每日免费泥点独立余额桶,按北京时间零点固定重置20泥点 - 按每日免费、会员限时、永久顺序扣费并支持跨日退款按原分桶回补 - 统一主站与图片画板泥点入口,隐藏限时泥点、任务入口和会员购买入口 - 收敛四档充值商品与泥点购买弹窗,并接入后台动态商品配置 - 同步余额read model、SpacetimeDB迁移绑定、回归测试和工程文档 - 将泥点明细浮层圆角匹配首页卡片视觉规范
This commit is contained in:
@@ -49,10 +49,10 @@ export function AdminRechargeProductPage({
|
||||
const [priceCents, setPriceCents] = useState('600');
|
||||
const [kind, setKind] = useState<ProfileRechargeProductKind>('points');
|
||||
const [pointsAmount, setPointsAmount] = useState('60');
|
||||
const [bonusPoints, setBonusPoints] = useState('60');
|
||||
const [bonusPoints, setBonusPoints] = useState('0');
|
||||
const [durationDays, setDurationDays] = useState('0');
|
||||
const [badgeLabel, setBadgeLabel] = useState('首充双倍');
|
||||
const [description, setDescription] = useState('首充送60泥点');
|
||||
const [badgeLabel, setBadgeLabel] = useState('');
|
||||
const [description, setDescription] = useState('60泥点');
|
||||
const [tier, setTier] = useState<ProfileMembershipTier>('normal');
|
||||
const [membershipPeriodPoints, setMembershipPeriodPoints] = useState('0');
|
||||
const [membershipPeriodDays, setMembershipPeriodDays] = useState('0');
|
||||
|
||||
@@ -16,6 +16,22 @@
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-12 泥点充值收敛为四档并统一资产入口
|
||||
|
||||
- 背景:主站与图片画板的泥点余额入口、余额明细和充值弹窗存在不同实现,旧充值口径仍展示六档泥点、首充双倍和会员购买 / 升级入口,容易让展示、商品资格与后端余额真相发生漂移。
|
||||
- 决策:主站与图片画板统一复用公共泥点资产入口,收起态展示总额与充值,展开态只展示不限时泥点、每日免费泥点和使用详情;充值中心 BFF 继续统一下发总额、三桶余额、限时到期时间、每日免费基础重置额及下次重置时间,前端不得自行相减推算,但会员周期限时泥点仅用于存量兼容和后端结算,当前版本不在前台展示。默认泥点商品收敛为 `60 / ¥6`、`180 + 90 / ¥18`、`300 + 150 / ¥30`、`680 + 340 / ¥68` 四档,`60` 档无赠送,后三档按现有 `user_id + product_id` 独立资格规则首次购买加赠 `50%`。当前版本关闭会员购买页签、会员商品和购买 / 升级入口。
|
||||
- 影响范围:`profile_recharge_product_config` 默认商品、充值中心 read model、共享前后端契约、主站与图片画板泥点资产入口、充值弹窗、后台充值商品默认值。
|
||||
- 验证方式:充值与统一入口定向前端测试、`npm run typecheck`、充值商品定向 Rust 测试、`cargo check -p spacetime-module -p spacetime-client -p api-server --manifest-path server-rs/Cargo.toml`、`npm run check:encoding`、`git diff --check`。
|
||||
- 关联文档:`docs/【项目基线】当前产品与工程约束-2026-05-15.md`、`docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md`。
|
||||
|
||||
## 2026-07-12 每日免费泥点独立于任务并按北京时间日切
|
||||
|
||||
- 背景:现有“每日免费泥点”实际只是每日登录任务领取奖励,领取后进入普通永久余额,既不是独立余额桶,也不会在次日失效;同时主站仍展示每日任务卡片和任务中心入口,与新的产品口径不一致。
|
||||
- 决策:新增 `profile_daily_free_points` 作为每日免费泥点事实源,基础额度固定为 `20`,以北京时间 `day_key` 为业务日;跨日后的首次余额读取或扣费原子清除昨日剩余及退款叠加量,并把当日额度重置为 `20`,对外语义始终视为北京时间 `00:00` 已重置。扣费按“每日免费 -> 会员周期限时 -> 永久”顺序;资产退款在同一业务日恢复原每日免费额度,跨业务日时把原每日免费消费部分叠加到退款当日每日免费桶,当日允许超过 `20`,下一业务日仍统一重置为 `20`。每日任务系统和 `daily_task_reward` 保留为普通永久奖励,但主站隐藏每日任务卡片及任务中心入口。
|
||||
- 影响范围:`profile_daily_free_points`、`profile_wallet_ledger`、个人资金 read model、钱包扣费和退款 metadata、主站“我的”页、SpacetimeDB 迁移与生成绑定。
|
||||
- 验证方式:`npm run spacetime:generate`、`npm run check:spacetime-schema`、钱包定向 Rust 测试、个人中心定向前端测试、`npm run typecheck`、`npm run check:encoding`、`git diff --check`。
|
||||
- 关联文档:`docs/【项目基线】当前产品与工程约束-2026-05-15.md`、`docs/【后端架构】server-rs与SpacetimeDB数据契约-2026-05-15.md`。
|
||||
|
||||
## 2026-07-11 SpacetimeDB 工具链统一升级到 2.6.0
|
||||
|
||||
- 背景:生产数据副本验证已使用 2.6.0 standalone,而仓库 Rust crate、本地 CLI、生成 bindings、容器与 server provision 仍锁定 2.5.0 或更早版本,继续混用会增加 BSATN / procedure 返回值与发布产物错配风险。
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- 主站新增 `/editor/canvas` 路由,进入独立图片画布编辑器阶段。
|
||||
- 主站新增 `/project` 项目页,从“我的”页项目入口进入,展示当前用户所有图片画布工程;点击项目进入 `/editor/canvas?projectid=<projectId>`。
|
||||
- 创作 Tab 顶部提供编辑器入口,入口只负责跳转,不参与玩法创作链路。
|
||||
- 编辑器顶部栏采用紧凑高度,项目标题和重命名入口贴近返回项目按钮;右侧常驻展示当前账号泥点余额,样式对齐创作主页顶部钱包 chip,点击后复用创作主页右上角泥点入口的账户充值 / 兑换码弹窗与支付确认反馈。
|
||||
- 编辑器顶部栏采用紧凑高度,项目标题和重命名入口贴近返回项目按钮;右侧复用与主站相同的公共泥点资产入口,并以充值中心 `mudPointBalance` 为余额真相源。余额区只展开不限时、每日免费及重置信息,会员周期限时泥点保留在后端 read model 中用于存量兼容和结算但不展示;独立“充值”按钮进入“购买更多泥点”弹窗,“使用详情”进入泥点账单。
|
||||
- 编辑器左侧为图片素材栏,可展开 / 收起;移动端优先保持素材栏可折叠。
|
||||
- 中央画布支持背景拖拽平移、滚轮缩放、缩放百分比菜单、显示所有元素和固定比例缩放。
|
||||
- 画布左下角提供 Lovart 式状态控件:背景色圆点、素材 / 图层入口、小地图开关;小地图显示图层缩略分布和当前视口框,点击小地图执行显示所有元素。
|
||||
|
||||
@@ -189,18 +189,20 @@ npm run check:server-rs-ddd
|
||||
## 账户充值数据契约
|
||||
|
||||
1. `profile_recharge_product_config` 是泥点和会员商品配置真相源,默认商品只在表为空时由 SpacetimeDB 播种。`module-runtime` 中的默认商品 helper 只作为空库种子和兼容入口,不再作为运行期业务真相。
|
||||
2. 后台通过 `/admin/api/profile/recharge-products` 读写充值商品配置;字段覆盖 `productId`、标题、商品类型、金额分、基础泥点、首充赠送泥点、会员天数、徽标、说明、会员层级、会员每周期限时泥点、周期天数、队列上限、折扣率、启用状态和排序。
|
||||
3. 充值中心、下单校验和支付确认入账都读取 `profile_recharge_product_config`。历史订单保留下单时写入的商品标题、金额、渠道、状态和 provider transaction id,不随配置改动回写。
|
||||
4. 泥点首充资格按 `user_id + product_id` 的历史 `paid` 订单独立判断。某个档位已支付后,只隐藏该档位的首充赠送;其它未购买档位仍展示和结算首充赠送。
|
||||
5. `hasPointsRecharged` 只保留为账号是否发生过任一泥点充值的兼容字段,不得驱动所有商品展示隐藏或结算金额计算。前端只渲染后端返回的商品快照。
|
||||
6. 默认会员商品为空库播种时使用 `Starter / Basic / Pro / Ultimate` 四档,默认有效期均为 30 天,每周期限时泥点分别为 `200 / 800 / 2500 / 6000`,队列上限分别为 `2 / 2 / 5 / 10`。
|
||||
7. 会员有效期和周期重置时间是两条独立时间线。`expires_at` 只决定会员是否生效;`cycle_resets_at` 只决定当前周期限时泥点何时重置。会员升级只更新档位并补齐当前周期限时泥点差额,不延长 `expires_at`,不移动 `cycle_resets_at` 和周期天数。同级会员购买只从当前 `expires_at` 延长有效期,不发放额外当前周期泥点,也不移动重置时间。
|
||||
8. 会员周期刷新发生在个人中心、充值中心、任务中心、账单读取和钱包扣费入口:到达 `cycle_resets_at` 时先清除上周期剩余限时泥点,再发放当前会员档位周期额度;会员过期时清除剩余限时泥点并把状态降为普通。周期发放和重置流水分别使用 `membership_period_grant`、`membership_period_reset`。
|
||||
9. `paymentChannel` 缺失、未知或冒用小程序支付设备时必须拒绝;真实微信渠道只允许 `wechat_mp`、`wechat_mp_virtual`、`wechat_jsapi`、`wechat_h5`、`wechat_native`,生产配置不得把真实支付静默降级为 `mock`。
|
||||
10. access JWT 只携带最小设备快照 `device.client_type`、`device.client_runtime`、`device.client_platform`。充值下单按该快照拦截小程序渠道:小程序只允许 `wechat_mp` / `wechat_mp_virtual`;移动网页和微信内 H5 走 `wechat_h5`;桌面网页和桌面微信走 `wechat_native`;`wechat_jsapi` 仅保留后端能力,未接微信开放平台前不由前端自动选择。历史普通 Web 登录态若缺少设备快照也允许继续进入 JSAPI / H5 / Native 渠道的后续支付配置校验,但不放宽小程序虚拟支付。
|
||||
11. 所有微信真实渠道都以微信支付通知或服务端查单确认 `SUCCESS` 为到账事实;小程序、H5 跳转和 Native 二维码返回都不能直接发放泥点或会员。
|
||||
12. 微信 JSAPI / H5 / 小程序 / Native 下单统一显式传 5 分钟 `time_expire`,格式为 RFC3339 秒级时间;Native 额外通过 `wechatNativePayment.expiresAt` 下发给前端二维码弹窗展示。
|
||||
13. 真实微信渠道的新建 pending 充值订单会写入 SpacetimeDB 原生 scheduled 表 `profile_recharge_order_expiration_timer`。到期 reducer 只做数据库内状态转换:订单仍为 `pending` 时更新为 `expired` 并写 `expired_at`,同时删除 timer。HTTP `api-server` 订阅 `profile_recharge_order` 的 `Pending -> Expired` 更新并执行微信查单补偿:`SUCCESS` 可把 `expired` 补确认成 `paid` 入账;`NOTPAY` 会调用微信关单并把本地订单保持为 `expired`;`CLOSED` / `REVOKED` / `PAYERROR` / `ORDER_NOT_EXIST` 只记录检查结果。`external-generation-worker` / controller 不处理充值过期;`wechat_mp_virtual` 到期只记录虚拟渠道不可查,后续真实支付通知仍允许 `Expired -> Paid`。
|
||||
2. 默认泥点商品固定为四档:`points_60 = 60 泥点 / 600 分`、`points_180 = 180 + 90 泥点 / 1800 分`、`points_300 = 300 + 150 泥点 / 3000 分`、`points_680 = 680 + 340 泥点 / 6800 分`。`points_60` 的首充赠送为 `0`;后三档首次购买分别赠送基础泥点的 `50%`。
|
||||
3. 后台通过 `/admin/api/profile/recharge-products` 读写充值商品配置;字段覆盖 `productId`、标题、商品类型、金额分、基础泥点、首充赠送泥点、会员天数、徽标、说明、会员层级、会员每周期限时泥点、周期天数、队列上限、折扣率、启用状态和排序。
|
||||
4. 充值中心、下单校验和支付确认入账都读取 `profile_recharge_product_config`。充值中心 BFF 还必须在 `mudPointBalance` 下发 `totalPoints`、`permanentPoints`、`limitedPoints`、`limitedExpiresAt`、`dailyFreePoints`、`dailyFreeResetPoints` 和 `dailyFreeResetsAt`;前端以该 read model 为真相源,不得自行用总额相减推算余额桶。当前版本公开 UI 只渲染不限时泥点和每日免费泥点,`limitedPoints` 与 `limitedExpiresAt` 仅保留给存量兼容和后端结算。历史订单保留下单时写入的商品标题、金额、渠道、状态和 provider transaction id,不随配置改动回写。
|
||||
5. 泥点首充资格按 `user_id + product_id` 的历史 `paid` 订单独立判断。某个档位已支付后,只隐藏该档位的首充赠送;其它未购买档位仍展示和结算首充赠送。
|
||||
6. `hasPointsRecharged` 只保留为账号是否发生过任一泥点充值的兼容字段,不得驱动所有商品展示隐藏或结算金额计算。前端只渲染后端返回的商品快照。
|
||||
7. 当前版本公开充值 UI 只展示泥点商品,不渲染会员购买页签、会员商品、购买会员或升级会员入口。充值中心响应中的会员商品兼容字段、默认会员商品、`profile_membership` 和周期刷新逻辑继续保留;存量会员的 `cycle_remaining_points` 仍通过充值中心 read model 下发用于兼容和结算,但不作为限时泥点在当前版本前台展示。
|
||||
8. 默认会员商品为空库播种时使用 `Starter / Basic / Pro / Ultimate` 四档,默认有效期均为 30 天,每周期限时泥点分别为 `200 / 800 / 2500 / 6000`,队列上限分别为 `2 / 2 / 5 / 10`。
|
||||
9. 会员有效期和周期重置时间是两条独立时间线。`expires_at` 只决定会员是否生效;`cycle_resets_at` 只决定当前周期限时泥点何时重置。会员升级只更新档位并补齐当前周期限时泥点差额,不延长 `expires_at`,不移动 `cycle_resets_at` 和周期天数。同级会员购买只从当前 `expires_at` 延长有效期,不发放额外当前周期泥点,也不移动重置时间。
|
||||
10. 会员周期刷新发生在个人中心、充值中心、任务中心、账单读取和钱包扣费入口:到达 `cycle_resets_at` 时先清除上周期剩余限时泥点,再发放当前会员档位周期额度;会员过期时清除剩余限时泥点并把状态降为普通。周期发放和重置流水分别使用 `membership_period_grant`、`membership_period_reset`。
|
||||
11. `paymentChannel` 缺失、未知或冒用小程序支付设备时必须拒绝;真实微信渠道只允许 `wechat_mp`、`wechat_mp_virtual`、`wechat_jsapi`、`wechat_h5`、`wechat_native`,生产配置不得把真实支付静默降级为 `mock`。
|
||||
12. access JWT 只携带最小设备快照 `device.client_type`、`device.client_runtime`、`device.client_platform`。充值下单按该快照拦截小程序渠道:小程序只允许 `wechat_mp` / `wechat_mp_virtual`;移动网页和微信内 H5 走 `wechat_h5`;桌面网页和桌面微信走 `wechat_native`;`wechat_jsapi` 仅保留后端能力,未接微信开放平台前不由前端自动选择。历史普通 Web 登录态若缺少设备快照也允许继续进入 JSAPI / H5 / Native 渠道的后续支付配置校验,但不放宽小程序虚拟支付。
|
||||
13. 所有微信真实渠道都以微信支付通知或服务端查单确认 `SUCCESS` 为到账事实;小程序、H5 跳转和 Native 二维码返回都不能直接发放泥点或会员。
|
||||
14. 微信 JSAPI / H5 / 小程序 / Native 下单统一显式传 5 分钟 `time_expire`,格式为 RFC3339 秒级时间;Native 额外通过 `wechatNativePayment.expiresAt` 下发给前端二维码弹窗展示。
|
||||
15. 真实微信渠道的新建 pending 充值订单会写入 SpacetimeDB 原生 scheduled 表 `profile_recharge_order_expiration_timer`。到期 reducer 只做数据库内状态转换:订单仍为 `pending` 时更新为 `expired` 并写 `expired_at`,同时删除 timer。HTTP `api-server` 订阅 `profile_recharge_order` 的 `Pending -> Expired` 更新并执行微信查单补偿:`SUCCESS` 可把 `expired` 补确认成 `paid` 入账;`NOTPAY` 会调用微信关单并把本地订单保持为 `expired`;`CLOSED` / `REVOKED` / `PAYERROR` / `ORDER_NOT_EXIST` 只记录检查结果。`external-generation-worker` / controller 不处理充值过期;`wechat_mp_virtual` 到期只记录虚拟渠道不可查,后续真实支付通知仍允许 `Expired -> Paid`。
|
||||
|
||||
## 创作入口泥点扣费契约
|
||||
|
||||
@@ -215,13 +217,14 @@ npm run check:server-rs-ddd
|
||||
## 用户钱包与编辑器生成扣费契约
|
||||
|
||||
1. 新用户账号完成注册并成功同步正式认证表后,注册赠送金额读取 `profile_wallet_config.initial_mud_points`;后台通过 `/admin/api/profile/wallet-config` 维护“账号初始泥点数”。未写入配置时默认仍为 `100` 泥点。流水原因仍使用 `new_user_registration_reward`,流水 ID 继续保持幂等,重复发放请求不得叠加余额。
|
||||
2. 用户钱包余额对外仍暴露为一个总余额,但后端扣费时优先消耗 `profile_membership.cycle_remaining_points` 中的会员周期限时泥点,再消耗普通永久泥点;扣费流水 `metadata_json` 会记录 `membershipPeriodPointsDelta`、`permanentPointsDelta` 和限时泥点所属 `cycleResetsAtMicros`,退款会按原消费流水优先恢复同一周期的限时泥点,前端不得自行决定扣费桶。
|
||||
3. 每日免费泥点当前由每日任务体系发放,流水来源为 `daily_task_reward`,任务进度和可领取状态按北京时间每日刷新;它不参与会员 `cycle_resets_at`,也不由前端合并进会员周期泥点。
|
||||
4. 编辑器画板所有会调用外部生成 provider 的入口都不从前端请求接收 `priceMudPoints`;同步请求以 SpacetimeDB `editor_generation_pricing_config` 当前全局配置计算,外部生成队列则以 `external_generation_job.price_mud_points` 保存的入队价格为准,worker 的扣费、退款、响应和资产成本不得按执行时配置重算。前端按钮泥点只作为展示。
|
||||
5. 编辑器图片生成 / 图片修改 / 图标 spritesheet / UI 设计图提取素材 / 视频 / 角色动作 / 音效 / 背景音乐必须在后端计算模型价格后使用 `execute_billable_asset_operation_with_cost` 预扣泥点;预扣失败必须 fail-closed,不得继续提交 VectorEngine、Ark、Suno 或 Vidu 上游任务。
|
||||
6. 队列任务按 `job_id + claim_attempt` 使用独立 consume/refund ledger。新 attempt 结算旧 attempt 时必须先写 `asset_operation_wallet_settlement`:旧 consume 已存在则原子退款,尚不存在则写取消 intent;迟到 consume 在同一 SpacetimeDB 事务内看到 intent 后必须失败关闭。重复 consume/refund 只有用户、金额、来源和配对 ledger 全部一致时才可视为幂等成功。lease 过期时只有 `attempt < max_attempts` 才能递增并重领;最终 attempt 已耗尽时,claim transaction 必须直接把 job 收口为 `failed`、清理 lease、写失败事件并结算当前 attempt,不能再把任务返回 worker 或调用 provider。
|
||||
7. 音频生成的编辑器链路虽然任务提交和结果发布分离,仍必须把提交时后端计算出的模型价格写入 `AudioAssetBindingTarget.billing_points_cost`,最终发布落资产时按该价格扣费;创作音频目标未提供该字段时才使用旧的创作音频固定成本。
|
||||
8. 编辑器进入外部生成持久队列的图片生成、图片修改、去背景、图标 spritesheet、UI 设计图提取、角色动作和视频参考图,只允许提交已登记的 generated `objectKey`、`resourceId` 或 `assetId`;任务 `request_payload_json` / `result_payload_json` 任意层级都禁止 `data:` / `blob:`,并受统一字节上限保护。objectKey 必须归属于当前账号的 `editor_project_resource`、`editor_asset` 或 `asset_object`,后端通过归属校验后才签名读取 OSS。本地红框序号标注图必须先上传并确认对象,再把 objectKey 入队;不得把既有 objectKey 下载成 Data URL 后写入任务。图标素材和 UI 素材提取的额外参考图必须真正传入 provider,不得只写入 `generationInputs` 展示快照;图片快速编辑当前不开放额外参考图。UI 素材提取额外参考图上限为 5 张,普通图片生成上限 5 张,图标素材上限 8 张额外参考图。同步且不持久化的历史兼容入口即使仍能解析 Data URL,也不能把该值转存到工程、素材、元数据、审计或任务表。
|
||||
2. 用户钱包余额对外仍暴露为一个总余额,但后端扣费必须按“每日免费泥点 -> 会员周期限时泥点 -> 普通永久泥点”的顺序消耗,前端不得自行决定扣费桶。扣费流水 `metadata_json` 必须记录 `dailyFreePointsDelta`、`dailyFreeDayKey`、`membershipPeriodPointsDelta`、`permanentPointsDelta` 和会员限时泥点所属 `cycleResetsAtMicros`;资产退款中的会员限时泥点只在原周期仍有效时恢复会员额度,其余会员部分进入普通永久泥点。原每日免费消费部分在同一业务日退款时恢复原当日额度;跨北京时间业务日退款时叠加到退款当日每日免费桶,不进入普通永久泥点,当日 `granted_points` 与 `remaining_points` 均可因此超过 `20`。原永久泥点消费部分无论是否跨业务日,均按退款流水中的 `permanentPointsDelta` 退回普通永久泥点。
|
||||
3. 每日免费泥点是独立于每日任务和会员周期的正式余额额度,基础发放量固定为 `20`,不得由前端或后台任务配置改写。`profile_daily_free_points` 保存当前北京时间业务日、当日基础发放及跨日退款叠加后的总额度和剩余额度;北京时间每日 `00:00` 作为业务日边界,个人中心、充值中心、账单读取和钱包扣费入口在首次触达新业务日时原子清除昨日剩余及退款叠加量,并把今日 `granted_points`、`remaining_points` 重置为 `20`。首次初始化使用 `daily_free_grant` 流水,跨日重置使用 `daily_free_reset` 流水。惰性落库不能改变“北京时间 00:00 后读取即为新日额度”的对外语义。
|
||||
4. 每日任务奖励继续使用 `daily_task_reward` 流水并进入普通永久泥点,但主站隐藏每日任务卡片和任务中心入口,不再把每日登录任务描述为“每日免费泥点”。任务配置、进度、领取记录和后台管理能力暂时保留,除非后续需求明确删除。
|
||||
5. 编辑器画板所有会调用外部生成 provider 的入口都不从前端请求接收 `priceMudPoints`;同步请求以 SpacetimeDB `editor_generation_pricing_config` 当前全局配置计算,外部生成队列则以 `external_generation_job.price_mud_points` 保存的入队价格为准,worker 的扣费、退款、响应和资产成本不得按执行时配置重算。前端按钮泥点只作为展示。
|
||||
6. 编辑器图片生成 / 图片修改 / 图标 spritesheet / UI 设计图提取素材 / 视频 / 角色动作 / 音效 / 背景音乐必须在后端计算模型价格后使用 `execute_billable_asset_operation_with_cost` 预扣泥点;预扣失败必须 fail-closed,不得继续提交 VectorEngine、Ark、Suno 或 Vidu 上游任务。
|
||||
7. 队列任务按 `job_id + claim_attempt` 使用独立 consume/refund ledger。新 attempt 结算旧 attempt 时必须先写 `asset_operation_wallet_settlement`:旧 consume 已存在则原子退款,尚不存在则写取消 intent;迟到 consume 在同一 SpacetimeDB 事务内看到 intent 后必须失败关闭。重复 consume/refund 只有用户、金额、来源和配对 ledger 全部一致时才可视为幂等成功。lease 过期时只有 `attempt < max_attempts` 才能递增并重领;最终 attempt 已耗尽时,claim transaction 必须直接把 job 收口为 `failed`、清理 lease、写失败事件并结算当前 attempt,不能再把任务返回 worker 或调用 provider。
|
||||
8. 音频生成的编辑器链路虽然任务提交和结果发布分离,仍必须把提交时后端计算出的模型价格写入 `AudioAssetBindingTarget.billing_points_cost`,最终发布落资产时按该价格扣费;创作音频目标未提供该字段时才使用旧的创作音频固定成本。
|
||||
9. 编辑器进入外部生成持久队列的图片生成、图片修改、去背景、图标 spritesheet、UI 设计图提取、角色动作和视频参考图,只允许提交已登记的 generated `objectKey`、`resourceId` 或 `assetId`;任务 `request_payload_json` / `result_payload_json` 任意层级都禁止 `data:` / `blob:`,并受统一字节上限保护。objectKey 必须归属于当前账号的 `editor_project_resource`、`editor_asset` 或 `asset_object`,后端通过归属校验后才签名读取 OSS。本地红框序号标注图必须先上传并确认对象,再把 objectKey 入队;不得把既有 objectKey 下载成 Data URL 后写入任务。图标素材和 UI 素材提取的额外参考图必须真正传入 provider,不得只写入 `generationInputs` 展示快照;图片快速编辑当前不开放额外参考图。UI 素材提取额外参考图上限为 5 张,普通图片生成上限 5 张,图标素材上限 8 张额外参考图。同步且不持久化的历史兼容入口即使仍能解析 Data URL,也不能把该值转存到工程、素材、元数据、审计或任务表。
|
||||
|
||||
## 外部服务与资产
|
||||
|
||||
@@ -691,6 +694,12 @@ npm run check:server-rs-ddd
|
||||
- Rust 结构体:`ProfileDashboardState`
|
||||
- 源码:`server-rs/crates/spacetime-module/src/runtime/profile.rs`
|
||||
|
||||
### `profile_daily_free_points`
|
||||
|
||||
- Rust 结构体:`ProfileDailyFreePoints`
|
||||
- 源码:`server-rs/crates/spacetime-module/src/runtime/profile.rs`
|
||||
- 作用:每日免费泥点事实源。`day_key` 使用北京时间业务日,基础发放量固定为 `20`,`remaining_points` 保存当日剩余额度;跨业务日退款的每日免费消费部分会叠加到退款当日,使 `granted_points` 和 `remaining_points` 可暂时超过 `20`,下一业务日首次触达时旧余额与叠加量一并失效并重置为 `20`。
|
||||
|
||||
### `profile_feedback_submission`
|
||||
|
||||
- Rust 结构体:`ProfileFeedbackSubmission`
|
||||
@@ -717,7 +726,7 @@ npm run check:server-rs-ddd
|
||||
|
||||
- Rust 结构体:`ProfileRechargeProductConfig`
|
||||
- 源码:`server-rs/crates/spacetime-module/src/runtime/profile.rs`
|
||||
- 作用:泥点和会员充值商品配置真相源,供充值中心展示、下单校验、支付确认和后台“充值商品”页维护。
|
||||
- 作用:泥点和会员充值商品配置真相源,供充值中心展示、下单校验、支付确认和后台“充值商品”页维护;当前公开充值中心只展示四档泥点商品,会员商品配置留存但不公开购买或升级入口。
|
||||
- 字段补充:会员商品追加 `membership_period_points`、`membership_period_days`、`membership_queue_limit`、`membership_discount_bps`;泥点商品这些字段必须为 `0`。
|
||||
|
||||
### `profile_played_world`
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
旧库或旧迁移包没有 `event_banners_json` 时,后端读取层必须把 `eventBanners` 归一到 `module-runtime` 默认公告数组,不能把旧结构化 `eventBanner` 当成前端优先数组下发。默认公告引用的背景图必须指向 `public/` 下真实存在的站内静态资源,当前默认使用 `/creation-type-references/puzzle.webp`,避免创作入口顶部 banner 出现失效图片。
|
||||
|
||||
创作页和草稿页顶栏右上角的泥点余额胶囊是补足泥点入口:如果当前运行环境开启充值入口,点击后直接打开账户充值弹窗;否则直接打开运营兑换码弹窗。该入口不再跳到账户面板或泥点账单,头像 / 设置等账号入口继续保留各自语义。
|
||||
创作页和草稿页顶栏右上角统一复用公共泥点资产入口,不再把余额区本身作为直接充值按钮。余额区展开后只展示不限时泥点、每日免费泥点及重置口径;会员周期限时泥点仅由后端保留用于存量兼容和结算,当前版本不在前台展示。独立“充值”按钮进入“购买更多泥点”弹窗,“使用详情”进入泥点账单。主站各位置必须保持同一组件、数据口径和交互语义,头像 / 设置等账号入口继续保留各自语义。
|
||||
|
||||
创作恢复参数只保留 `sessionId`、`profileId`、`draftId`、`workId` 这四个私有 query。它们只允许在同一条创作链路的结果页、生成页、工作台之间保留;切到首页、公开作品详情、runtime 或另一条玩法链路时必须清掉。平台入口刷新直达时,路径到玩法恢复目标、四个 query 归一化、生成页标记、大鱼吃小鱼 workId 兜底、作品 / 草稿身份匹配和跳一跳 / 敲木鱼恢复阶段落点统一由 `platformCreationUrlStateModel.ts` 解析,壳层只执行读取作品、恢复草稿和切换阶段等副作用。生成页等待时间统一以生成状态里的 `startedAtMs` 为准;创建该状态时优先使用后端 session 下发的时间戳,作品摘要里的 `updatedAt` 仍只用于排序与摘要展示,不作为前端自行推导业务状态的真相。
|
||||
|
||||
|
||||
@@ -56,14 +56,15 @@ Genarrative / 陶泥儿是一个 AI 原生互动内容与小游戏平台。当
|
||||
|
||||
## 账户与充值
|
||||
|
||||
1. “我的”页账户充值弹窗包含 `泥点充值` 与 `会员卡充值` 两个页签,入口必须打开独立弹窗,不在当前面板下方展开。
|
||||
2. 泥点默认档位为 `60 / 180 / 300 / 680 / 1280 / 3280`,会员默认档位为月卡、季卡、年卡;实际展示、下单校验和支付确认都以后端返回的充值商品配置为准。
|
||||
3. 首充双倍按泥点商品档位独立计算。用户买过 `points_60` 后,只影响 `points_60` 的首充展示和结算,其它未购买档位仍保留各自首充权益。
|
||||
4. 前端不得用 `hasPointsRecharged` 统一隐藏所有泥点档位首充权益;该字段只表示账号是否发生过任一泥点充值。
|
||||
5. 充值支付渠道只允许由设备平台隔离层解析为 `wechat_mp`、`wechat_mp_virtual`、`wechat_jsapi`、`wechat_h5` 或 `wechat_native`;生产真实支付不得默认落到 `mock`,缺失或未知 `paymentChannel` 必须拒绝。
|
||||
6. 小程序 WebView 充值使用 `wechat_mp_virtual` 调起小程序虚拟支付;微信内浏览器使用 `wechat_jsapi` 调起微信支付 JSAPI;普通 Web 使用 `wechat_native` 二维码支付,避免因移动 UA、触控能力或窄屏误入 `wechat_h5`。只有微信通知或查单确认 `SUCCESS` 后才刷新余额或会员状态。
|
||||
7. 后端必须按 access JWT 中的最小设备快照拦截真实微信充值路径,不能只依赖前端隐藏入口或请求体传入的 `paymentChannel`。
|
||||
8. 后台“充值商品”页维护泥点和会员商品配置,保存后影响新的充值中心快照、下单和支付确认;历史订单保留下单时快照。
|
||||
1. 主站和图片画板统一使用公共泥点资产入口。收起态展示“泥点图标 + 泥点总额 | 充值”;桌面端通过 hover / focus 展开,移动端通过点击展开。展开态只展示不限时泥点、每日免费泥点及“每天重置为 20 泥点”,并提供“使用详情”入口;余额都以后端充值中心 read model 为准,前端不得自行相减推算。
|
||||
2. 账户充值弹窗标题统一为“购买更多泥点”,当前版本只展示泥点商品,不展示会员页签、会员商品、购买会员或升级会员入口。底层会员数据与周期刷新能力继续保留用于存量兼容和结算,会员周期限时泥点不在当前版本前台展示。
|
||||
3. 泥点默认商品固定为四档:`60 泥点 / ¥6`、`180 + 90 泥点 / ¥18`、`300 + 150 泥点 / ¥30`、`680 + 340 泥点 / ¥68`。`60` 档不加赠,后三档首次购买各加赠基础泥点的 `50%`;实际展示、下单校验和支付确认仍以后端返回的充值商品配置为准。
|
||||
4. 首充加赠资格按泥点商品档位独立计算。用户买过 `points_180` 后,只影响 `points_180` 的首充展示和结算,其它未购买档位仍保留各自首充加赠资格。
|
||||
5. 前端不得用 `hasPointsRecharged` 统一隐藏所有泥点档位首充权益;该字段只表示账号是否发生过任一泥点充值。
|
||||
6. 充值支付渠道只允许由设备平台隔离层解析为 `wechat_mp`、`wechat_mp_virtual`、`wechat_jsapi`、`wechat_h5` 或 `wechat_native`;生产真实支付不得默认落到 `mock`,缺失或未知 `paymentChannel` 必须拒绝。
|
||||
7. 小程序 WebView 充值使用 `wechat_mp_virtual` 调起小程序虚拟支付;微信内浏览器使用 `wechat_jsapi` 调起微信支付 JSAPI;普通 Web 使用 `wechat_native` 二维码支付,避免因移动 UA、触控能力或窄屏误入 `wechat_h5`。只有微信通知或查单确认 `SUCCESS` 后才刷新余额或会员状态。
|
||||
8. 后端必须按 access JWT 中的最小设备快照拦截真实微信充值路径,不能只依赖前端隐藏入口或请求体传入的 `paymentChannel`。
|
||||
9. 后台“充值商品”页继续维护泥点和会员商品配置,保存后影响新的充值中心快照、下单和支付确认;历史订单保留下单时快照。会员商品配置保留不表示当前版本开放公开购买或升级入口。
|
||||
|
||||
## 唯一后端路线
|
||||
|
||||
@@ -102,10 +103,10 @@ server-rs + Axum + SpacetimeDB
|
||||
7. 主站入口已锁定移动端页面级缩放;单个游戏页面不要再重复实现整页缩放锁定。
|
||||
8. 图像输入通用 UI 统一走 `src/components/common/CreativeImageInputPanel.tsx`。外层页面持有业务状态,组件只承担上传卡、预览、参考图缩略图、AI 重绘开关、错误展示和提交按钮。
|
||||
9. 发现页 `分类` 子频道的筛选必须打开独立 dialog / drawer / modal,至少支持玩法类型过滤与排序切换;筛选结果为空时显示空状态,不把筛选内容展开在当前列表下方。
|
||||
10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、通用设置入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;当前只展示四项常驻入口时必须按四列铺满整行,不保留五列网格导致左对齐空位。页面不再提供独立存档按钮入口,也不在底部保留旧的填邀请码次级入口;主题设置、账号与安全只作为通用设置弹窗下一级入口,不在“我的”页外层单独占行。填邀请码只由邀请链接 query 或其它明确引导打开独立弹窗,不作为“我的”页常驻按钮。
|
||||
11. “我的”页每日任务卡必须展示后端 `/api/profile/tasks` 返回的当前任务摘要,包括奖励泥点数和进度;外层任务卡不展示“去完成”等左右侧行动按钮,领取 / 去完成 / 已完成状态只在任务中心弹窗内表达。任务领取成功后,卡片摘要必须跟随返回的任务中心数据同步刷新,不能继续硬编码 `0 / 1` 或只更新弹窗内任务列表。用户停留在“我的”页跨过北京时间 0 点时,前端必须非阻断刷新登录态以补齐 `daily_login` 埋点,再重拉任务中心,避免继续展示上一自然日已领取状态。
|
||||
12. “我的”页泥点余额、累计游玩、已玩游戏三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、会员卡、每日任务、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
|
||||
13. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、每日任务、五项常用功能和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
|
||||
10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、三张统计卡、五项常用功能宫格、通用设置入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;当前只展示四项常驻入口时必须按四列铺满整行,不保留五列网格导致左对齐空位。页面不再提供会员购买 / 升级横幅、每日任务卡片或任务中心入口,也不提供独立存档按钮入口,不在底部保留旧的填邀请码次级入口;主题设置、账号与安全只作为通用设置弹窗下一级入口,不在“我的”页外层单独占行。填邀请码只由邀请链接 query 或其它明确引导打开独立弹窗,不作为“我的”页常驻按钮。
|
||||
11. 每日免费泥点由后端独立余额桶承载,基础额度固定为 `20`,按北京时间每日 `00:00` 重置。跨业务日退款时,原消费中的每日免费泥点部分叠加到退款当日每日免费桶,当日余额允许超过 `20`;到下一业务日仍统一失效并重置为 `20`。主站不得把已隐藏的每日任务入口或 `daily_task_reward` 文案继续当作每日免费泥点入口。
|
||||
12. “我的”页泥点余额、累计游玩、已玩游戏三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
|
||||
13. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、五项常用功能和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
|
||||
14. RPG 等运行态的战斗飘字、血量变化和即时反馈必须在暗色、噪声高的场景背景上保持可读:使用高亮文字、深色描边、强阴影或小面积半透明底,不只依赖红/绿文字本身表达伤害或治疗。
|
||||
15. 平台亮色 UI 配色以陶泥儿主视觉为准:暖白 / 米杏底、陶土橙主按钮、深棕正文与浅杏边框;新增界面优先复用 `src/index.css` 的 `--platform-*` 主题变量和 `apps/admin-web/src/styles/admin.css` 的同系色值,不再引入粉红、蓝绿等独立主色方案。
|
||||
|
||||
|
||||
@@ -51,6 +51,15 @@ export type ProfileDashboardSummary = {
|
||||
totalPlayTimeMs: number;
|
||||
playedWorldCount: number;
|
||||
updatedAt: string | null;
|
||||
dailyFreePoints?: ProfileDailyFreePoints;
|
||||
};
|
||||
|
||||
export type ProfileDailyFreePoints = {
|
||||
dayKey: number;
|
||||
grantedPoints: number;
|
||||
remainingPoints: number;
|
||||
resetsAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type ProfileWalletLedgerEntry = {
|
||||
@@ -65,6 +74,8 @@ export type ProfileWalletLedgerEntry = {
|
||||
| 'points_recharge'
|
||||
| 'membership_period_grant'
|
||||
| 'membership_period_reset'
|
||||
| 'daily_free_grant'
|
||||
| 'daily_free_reset'
|
||||
| 'asset_operation_consume'
|
||||
| 'asset_operation_refund'
|
||||
| 'redeem_code_reward'
|
||||
@@ -162,6 +173,16 @@ export type ProfileMembership = {
|
||||
cyclePeriodDays: number;
|
||||
};
|
||||
|
||||
export type ProfileMudPointBalance = {
|
||||
totalPoints: number;
|
||||
permanentPoints: number;
|
||||
limitedPoints: number;
|
||||
limitedExpiresAt: string | null;
|
||||
dailyFreePoints: number;
|
||||
dailyFreeResetPoints: number;
|
||||
dailyFreeResetsAt: string;
|
||||
};
|
||||
|
||||
export type ProfileRechargeOrder = {
|
||||
orderId: string;
|
||||
productId: string;
|
||||
@@ -183,12 +204,14 @@ export type ProfileRechargeOrder = {
|
||||
|
||||
export type ProfileRechargeCenterResponse = {
|
||||
walletBalance: number;
|
||||
mudPointBalance?: ProfileMudPointBalance;
|
||||
membership: ProfileMembership;
|
||||
pointProducts: ProfileRechargeProduct[];
|
||||
membershipProducts: ProfileRechargeProduct[];
|
||||
benefits: ProfileMembershipBenefit[];
|
||||
latestOrder: ProfileRechargeOrder | null;
|
||||
hasPointsRecharged: boolean;
|
||||
dailyFreePoints?: ProfileDailyFreePoints;
|
||||
};
|
||||
|
||||
export type WechatMiniProgramPayParams = {
|
||||
|
||||
@@ -9,22 +9,23 @@ use axum::{
|
||||
};
|
||||
use hmac::{Hmac, Mac};
|
||||
use module_runtime::{
|
||||
AnalyticsGranularity, PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK,
|
||||
AnalyticsGranularity, PROFILE_DAILY_FREE_POINTS_PER_DAY, PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK,
|
||||
PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_H5, PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_JSAPI,
|
||||
PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_MINI_PROGRAM,
|
||||
PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_MINI_PROGRAM_VIRTUAL,
|
||||
PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_NATIVE, RuntimeProfileCodeOperationRecord,
|
||||
RuntimeProfileFeedbackEvidenceRecord, RuntimeProfileFeedbackEvidenceSnapshot,
|
||||
RuntimeProfileFeedbackSubmissionRecord, RuntimeProfileInviteCodeRecord,
|
||||
RuntimeProfileMembershipBenefitRecord, RuntimeProfileMembershipTier,
|
||||
RuntimeProfileRechargeCenterRecord, RuntimeProfileRechargeOrderRecord,
|
||||
RuntimeProfileRechargeOrderStatus, RuntimeProfileRechargeProductConfigRecord,
|
||||
RuntimeProfileRechargeProductKind, RuntimeProfileRechargeProductRecord,
|
||||
RuntimeProfileRedeemCodeMode, RuntimeProfileRedeemCodeRecord,
|
||||
RuntimeProfileRewardCodeRedeemRecord, RuntimeProfileTaskCenterRecord,
|
||||
RuntimeProfileTaskClaimRecord, RuntimeProfileTaskConfigRecord, RuntimeProfileTaskCycle,
|
||||
RuntimeProfileTaskItemRecord, RuntimeProfileTaskStatus, RuntimeProfileWalletLedgerSourceType,
|
||||
RuntimeReferralInviteCenterRecord, RuntimeTrackingScopeKind,
|
||||
RuntimeProfileDailyFreePointsRecord, RuntimeProfileFeedbackEvidenceRecord,
|
||||
RuntimeProfileFeedbackEvidenceSnapshot, RuntimeProfileFeedbackSubmissionRecord,
|
||||
RuntimeProfileInviteCodeRecord, RuntimeProfileMembershipBenefitRecord,
|
||||
RuntimeProfileMembershipTier, RuntimeProfileRechargeCenterRecord,
|
||||
RuntimeProfileRechargeOrderRecord, RuntimeProfileRechargeOrderStatus,
|
||||
RuntimeProfileRechargeProductConfigRecord, RuntimeProfileRechargeProductKind,
|
||||
RuntimeProfileRechargeProductRecord, RuntimeProfileRedeemCodeMode,
|
||||
RuntimeProfileRedeemCodeRecord, RuntimeProfileRewardCodeRedeemRecord,
|
||||
RuntimeProfileTaskCenterRecord, RuntimeProfileTaskClaimRecord, RuntimeProfileTaskConfigRecord,
|
||||
RuntimeProfileTaskCycle, RuntimeProfileTaskItemRecord, RuntimeProfileTaskStatus,
|
||||
RuntimeProfileWalletLedgerSourceType, RuntimeReferralInviteCenterRecord,
|
||||
RuntimeTrackingScopeKind,
|
||||
};
|
||||
use platform_wechat::pay::{WechatPayError, WechatPayNotifyOrder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -47,6 +48,8 @@ use shared_contracts::runtime::{
|
||||
PROFILE_TASK_STATUS_DISABLED, PROFILE_TASK_STATUS_INCOMPLETE,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_CONSUME,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_REFUND,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_GRANT,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_RESET,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_TASK_REWARD,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_INVITE_INVITEE_REWARD,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_INVITE_INVITER_REWARD,
|
||||
@@ -57,9 +60,10 @@ use shared_contracts::runtime::{
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_PUZZLE_AUTHOR_INCENTIVE_CLAIM,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_REDEEM_CODE_REWARD,
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_SNAPSHOT_SYNC, ProfileCodeOperationAdminResponse,
|
||||
ProfileDashboardSummaryResponse, ProfileFeedbackEvidenceItemResponse,
|
||||
ProfileFeedbackSubmissionResponse, ProfileInviteCodeAdminListResponse,
|
||||
ProfileInviteCodeAdminResponse, ProfileMembershipBenefitResponse, ProfileMembershipResponse,
|
||||
ProfileDailyFreePointsResponse, ProfileDashboardSummaryResponse,
|
||||
ProfileFeedbackEvidenceItemResponse, ProfileFeedbackSubmissionResponse,
|
||||
ProfileInviteCodeAdminListResponse, ProfileInviteCodeAdminResponse,
|
||||
ProfileMembershipBenefitResponse, ProfileMembershipResponse, ProfileMudPointBalanceResponse,
|
||||
ProfilePlayStatsResponse, ProfilePlayedWorkSummaryResponse, ProfileRechargeCenterResponse,
|
||||
ProfileRechargeOrderResponse, ProfileRechargeProductConfigAdminListResponse,
|
||||
ProfileRechargeProductConfigAdminResponse, ProfileRechargeProductResponse,
|
||||
@@ -119,6 +123,7 @@ pub async fn get_profile_dashboard(
|
||||
total_play_time_ms: record.total_play_time_ms,
|
||||
played_world_count: record.played_world_count,
|
||||
updated_at: record.updated_at,
|
||||
daily_free_points: build_profile_daily_free_points_response(record.daily_free_points),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -191,6 +196,12 @@ fn format_profile_wallet_ledger_source_type(
|
||||
RuntimeProfileWalletLedgerSourceType::DailyTaskReward => {
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_TASK_REWARD
|
||||
}
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeGrant => {
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_GRANT
|
||||
}
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeReset => {
|
||||
PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_RESET
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1635,8 +1646,10 @@ fn paid_at_micros_from_wechat_order(order: &WechatPayNotifyOrder) -> i64 {
|
||||
fn build_profile_recharge_center_response(
|
||||
record: RuntimeProfileRechargeCenterRecord,
|
||||
) -> ProfileRechargeCenterResponse {
|
||||
let mud_point_balance = build_profile_mud_point_balance_response(&record);
|
||||
ProfileRechargeCenterResponse {
|
||||
wallet_balance: record.wallet_balance,
|
||||
mud_point_balance,
|
||||
membership: ProfileMembershipResponse {
|
||||
status: record.membership.status.as_str().to_string(),
|
||||
tier: record.membership.tier.as_str().to_string(),
|
||||
@@ -1668,6 +1681,49 @@ fn build_profile_recharge_center_response(
|
||||
.latest_order
|
||||
.map(build_profile_recharge_order_response),
|
||||
has_points_recharged: record.has_points_recharged,
|
||||
daily_free_points: build_profile_daily_free_points_response(record.daily_free_points),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_profile_mud_point_balance_response(
|
||||
record: &RuntimeProfileRechargeCenterRecord,
|
||||
) -> ProfileMudPointBalanceResponse {
|
||||
let daily_free_points = record.daily_free_points.remaining_points;
|
||||
let limited_points = record.membership.cycle_remaining_points;
|
||||
let permanent_points = record
|
||||
.wallet_balance
|
||||
.saturating_sub(daily_free_points)
|
||||
.saturating_sub(limited_points);
|
||||
let limited_expires_at = (limited_points > 0)
|
||||
.then(|| {
|
||||
record
|
||||
.membership
|
||||
.cycle_resets_at
|
||||
.clone()
|
||||
.or_else(|| record.membership.expires_at.clone())
|
||||
})
|
||||
.flatten();
|
||||
|
||||
ProfileMudPointBalanceResponse {
|
||||
total_points: record.wallet_balance,
|
||||
permanent_points,
|
||||
limited_points,
|
||||
limited_expires_at,
|
||||
daily_free_points,
|
||||
daily_free_reset_points: PROFILE_DAILY_FREE_POINTS_PER_DAY,
|
||||
daily_free_resets_at: record.daily_free_points.resets_at.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_profile_daily_free_points_response(
|
||||
record: RuntimeProfileDailyFreePointsRecord,
|
||||
) -> ProfileDailyFreePointsResponse {
|
||||
ProfileDailyFreePointsResponse {
|
||||
day_key: record.day_key,
|
||||
granted_points: record.granted_points,
|
||||
remaining_points: record.remaining_points,
|
||||
resets_at: record.resets_at,
|
||||
updated_at: record.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2152,15 +2208,16 @@ mod tests {
|
||||
use module_auth::{ResolveWechatLoginInput, WechatIdentityProfile};
|
||||
use module_runtime::{
|
||||
PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_MINI_PROGRAM_VIRTUAL,
|
||||
RuntimeProfileMembershipRecord, RuntimeProfileMembershipStatus,
|
||||
RuntimeProfileMembershipTier, RuntimeProfileRechargeCenterRecord,
|
||||
RuntimeProfileRechargeOrderRecord, RuntimeProfileRechargeOrderStatus,
|
||||
RuntimeProfileRechargeProductKind, RuntimeProfileRechargeProductRecord,
|
||||
RuntimeProfileWalletLedgerSourceType,
|
||||
RuntimeProfileDailyFreePointsRecord, RuntimeProfileMembershipRecord,
|
||||
RuntimeProfileMembershipStatus, RuntimeProfileMembershipTier,
|
||||
RuntimeProfileRechargeCenterRecord, RuntimeProfileRechargeOrderRecord,
|
||||
RuntimeProfileRechargeOrderStatus, RuntimeProfileRechargeProductKind,
|
||||
RuntimeProfileRechargeProductRecord, RuntimeProfileWalletLedgerSourceType,
|
||||
};
|
||||
|
||||
use super::{
|
||||
build_wechat_virtual_pay_params, calc_wechat_virtual_payment_pay_signature_with_key,
|
||||
build_profile_mud_point_balance_response, build_wechat_virtual_pay_params,
|
||||
calc_wechat_virtual_payment_pay_signature_with_key,
|
||||
calc_wechat_virtual_payment_user_signature_with_key,
|
||||
format_profile_wallet_ledger_source_type,
|
||||
is_wechat_profile_recharge_order_terminal_for_confirmation,
|
||||
@@ -2182,6 +2239,63 @@ mod tests {
|
||||
|
||||
use crate::{app::build_router, config::AppConfig, state::AppState};
|
||||
|
||||
fn daily_free_points_record() -> RuntimeProfileDailyFreePointsRecord {
|
||||
RuntimeProfileDailyFreePointsRecord {
|
||||
day_key: 20_646,
|
||||
granted_points: 20,
|
||||
remaining_points: 20,
|
||||
resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
resets_at_micros: 1_783_872_000_000_000,
|
||||
updated_at: "2026-07-12T08:00:00Z".to_string(),
|
||||
updated_at_micros: 1_783_843_200_000_000,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mud_point_balance_is_split_by_backend_wallet_buckets() {
|
||||
let record = RuntimeProfileRechargeCenterRecord {
|
||||
user_id: "user-1".to_string(),
|
||||
wallet_balance: 200,
|
||||
membership: RuntimeProfileMembershipRecord {
|
||||
user_id: "user-1".to_string(),
|
||||
status: RuntimeProfileMembershipStatus::Active,
|
||||
tier: RuntimeProfileMembershipTier::Starter,
|
||||
started_at: Some("2026-07-01T00:00:00Z".to_string()),
|
||||
started_at_micros: Some(1_783_036_800_000_000),
|
||||
expires_at: Some("2026-08-01T00:00:00Z".to_string()),
|
||||
expires_at_micros: Some(1_785_542_400_000_000),
|
||||
updated_at: Some("2026-07-12T08:00:00Z".to_string()),
|
||||
updated_at_micros: Some(1_783_843_200_000_000),
|
||||
cycle_started_at: Some("2026-07-08T00:00:00Z".to_string()),
|
||||
cycle_started_at_micros: Some(1_783_468_800_000_000),
|
||||
cycle_resets_at: Some("2026-07-15T00:00:00Z".to_string()),
|
||||
cycle_resets_at_micros: Some(1_784_073_600_000_000),
|
||||
cycle_granted_points: 80,
|
||||
cycle_remaining_points: 80,
|
||||
cycle_period_days: 7,
|
||||
},
|
||||
point_products: vec![],
|
||||
membership_products: vec![],
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: daily_free_points_record(),
|
||||
};
|
||||
|
||||
let balance = build_profile_mud_point_balance_response(&record);
|
||||
|
||||
assert_eq!(balance.total_points, 200);
|
||||
assert_eq!(balance.permanent_points, 100);
|
||||
assert_eq!(balance.limited_points, 80);
|
||||
assert_eq!(balance.daily_free_points, 20);
|
||||
assert_eq!(balance.daily_free_reset_points, 20);
|
||||
assert_eq!(
|
||||
balance.limited_expires_at.as_deref(),
|
||||
Some("2026-07-15T00:00:00Z"),
|
||||
);
|
||||
assert_eq!(balance.daily_free_resets_at, "2026-07-12T16:00:00Z");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_wallet_ledger_source_type_formats_backend_values() {
|
||||
assert_eq!(
|
||||
@@ -2214,6 +2328,18 @@ mod tests {
|
||||
),
|
||||
shared_contracts::runtime::PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_TASK_REWARD
|
||||
);
|
||||
assert_eq!(
|
||||
format_profile_wallet_ledger_source_type(
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeGrant
|
||||
),
|
||||
shared_contracts::runtime::PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_GRANT
|
||||
);
|
||||
assert_eq!(
|
||||
format_profile_wallet_ledger_source_type(
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeReset
|
||||
),
|
||||
shared_contracts::runtime::PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_RESET
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -2983,6 +3109,7 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: daily_free_points_record(),
|
||||
};
|
||||
|
||||
let params =
|
||||
@@ -3098,6 +3225,7 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: true,
|
||||
daily_free_points: daily_free_points_record(),
|
||||
};
|
||||
|
||||
let params =
|
||||
@@ -3211,6 +3339,7 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: daily_free_points_record(),
|
||||
};
|
||||
|
||||
let params = build_wechat_virtual_pay_params(&state, ¢er, &order, "openid-user-item01")
|
||||
@@ -3389,6 +3518,7 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: daily_free_points_record(),
|
||||
};
|
||||
|
||||
let error = build_wechat_virtual_pay_params(&state, ¢er, &order, "openid-sandbox-1")
|
||||
|
||||
@@ -981,6 +981,23 @@ pub fn build_runtime_profile_dashboard_record(
|
||||
played_world_count: snapshot.played_world_count,
|
||||
updated_at: snapshot.updated_at_micros.map(format_utc_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
daily_free_points: build_runtime_profile_daily_free_points_record(
|
||||
snapshot.daily_free_points,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_daily_free_points_record(
|
||||
snapshot: RuntimeProfileDailyFreePointsSnapshot,
|
||||
) -> RuntimeProfileDailyFreePointsRecord {
|
||||
RuntimeProfileDailyFreePointsRecord {
|
||||
day_key: snapshot.day_key,
|
||||
granted_points: snapshot.granted_points,
|
||||
remaining_points: snapshot.remaining_points,
|
||||
resets_at: format_utc_micros(snapshot.resets_at_micros),
|
||||
resets_at_micros: snapshot.resets_at_micros,
|
||||
updated_at: format_utc_micros(snapshot.updated_at_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1047,6 +1064,9 @@ pub fn build_runtime_profile_recharge_center_record(
|
||||
.latest_order
|
||||
.map(build_runtime_profile_recharge_order_record),
|
||||
has_points_recharged: snapshot.has_points_recharged,
|
||||
daily_free_points: build_runtime_profile_daily_free_points_record(
|
||||
snapshot.daily_free_points,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ pub const PROFILE_TASK_EVENT_KEY_DAILY_LOGIN: &str = "daily_login";
|
||||
pub const PROFILE_TASK_DEFAULT_TITLE_DAILY_LOGIN: &str = "每日登录";
|
||||
pub const PROFILE_TASK_DEFAULT_REWARD_POINTS: u64 = 10;
|
||||
pub const PROFILE_TASK_DEFAULT_THRESHOLD: u32 = 1;
|
||||
pub const PROFILE_DAILY_FREE_POINTS_PER_DAY: u64 = 20;
|
||||
pub const SAVE_SNAPSHOT_VERSION: u32 = 2;
|
||||
pub const DEFAULT_SAVE_ARCHIVE_SUMMARY_TEXT: &str = "继续推进上一次保存的故事。";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK: &str = "mock";
|
||||
@@ -674,6 +675,17 @@ pub struct RuntimeProfileDashboardSnapshot {
|
||||
pub total_play_time_ms: u64,
|
||||
pub played_world_count: u32,
|
||||
pub updated_at_micros: Option<i64>,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsSnapshot,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RuntimeProfileDailyFreePointsSnapshot {
|
||||
pub day_key: i64,
|
||||
pub granted_points: u64,
|
||||
pub remaining_points: u64,
|
||||
pub resets_at_micros: i64,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
@@ -1077,6 +1089,8 @@ pub enum RuntimeProfileWalletLedgerSourceType {
|
||||
DailyTaskReward,
|
||||
MembershipPeriodGrant,
|
||||
MembershipPeriodReset,
|
||||
DailyFreeGrant,
|
||||
DailyFreeReset,
|
||||
}
|
||||
|
||||
impl RuntimeProfileWalletLedgerSourceType {
|
||||
@@ -1094,6 +1108,8 @@ impl RuntimeProfileWalletLedgerSourceType {
|
||||
Self::RedeemCodeReward => "redeem_code_reward",
|
||||
Self::PuzzleAuthorIncentiveClaim => "puzzle_author_incentive_claim",
|
||||
Self::DailyTaskReward => "daily_task_reward",
|
||||
Self::DailyFreeGrant => "daily_free_grant",
|
||||
Self::DailyFreeReset => "daily_free_reset",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1307,6 +1323,7 @@ pub struct RuntimeProfileRechargeCenterSnapshot {
|
||||
pub benefits: Vec<RuntimeProfileMembershipBenefitSnapshot>,
|
||||
pub latest_order: Option<RuntimeProfileRechargeOrderSnapshot>,
|
||||
pub has_points_recharged: bool,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsSnapshot,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
@@ -1821,6 +1838,18 @@ pub struct RuntimeProfileDashboardRecord {
|
||||
pub played_world_count: u32,
|
||||
pub updated_at: Option<String>,
|
||||
pub updated_at_micros: Option<i64>,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsRecord,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct RuntimeProfileDailyFreePointsRecord {
|
||||
pub day_key: i64,
|
||||
pub granted_points: u64,
|
||||
pub remaining_points: u64,
|
||||
pub resets_at: String,
|
||||
pub resets_at_micros: i64,
|
||||
pub updated_at: String,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -1986,6 +2015,7 @@ pub struct RuntimeProfileRechargeCenterRecord {
|
||||
pub benefits: Vec<RuntimeProfileMembershipBenefitRecord>,
|
||||
pub latest_order: Option<RuntimeProfileRechargeOrderRecord>,
|
||||
pub has_points_recharged: bool,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsRecord,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
||||
@@ -22,59 +22,33 @@ pub fn format_utc_micros(micros: i64) -> String {
|
||||
|
||||
pub fn runtime_profile_recharge_point_products() -> Vec<RuntimeProfileRechargeProductSnapshot> {
|
||||
vec![
|
||||
build_points_recharge_product(
|
||||
"points_60",
|
||||
"60泥点",
|
||||
600,
|
||||
60,
|
||||
60,
|
||||
"首充双倍",
|
||||
"首充送60泥点",
|
||||
),
|
||||
build_points_recharge_product("points_60", "60泥点", 600, 60, 0, "", "60泥点"),
|
||||
build_points_recharge_product(
|
||||
"points_180",
|
||||
"180泥点",
|
||||
1800,
|
||||
180,
|
||||
180,
|
||||
"首充双倍",
|
||||
"首充送180泥点",
|
||||
90,
|
||||
"首充加赠",
|
||||
"首充加赠90泥点",
|
||||
),
|
||||
build_points_recharge_product(
|
||||
"points_300",
|
||||
"300泥点",
|
||||
3000,
|
||||
300,
|
||||
300,
|
||||
"首充双倍",
|
||||
"首充送300泥点",
|
||||
150,
|
||||
"首充加赠",
|
||||
"首充加赠150泥点",
|
||||
),
|
||||
build_points_recharge_product(
|
||||
"points_680",
|
||||
"680泥点",
|
||||
6800,
|
||||
680,
|
||||
680,
|
||||
"首充双倍",
|
||||
"首充送680泥点",
|
||||
),
|
||||
build_points_recharge_product(
|
||||
"points_1280",
|
||||
"1280泥点",
|
||||
12800,
|
||||
1280,
|
||||
1280,
|
||||
"首充双倍",
|
||||
"首充送1280泥点",
|
||||
),
|
||||
build_points_recharge_product(
|
||||
"points_3280",
|
||||
"3280泥点",
|
||||
32800,
|
||||
3280,
|
||||
3280,
|
||||
"首充双倍",
|
||||
"首充送3280泥点",
|
||||
340,
|
||||
"首充加赠",
|
||||
"首充加赠340泥点",
|
||||
),
|
||||
]
|
||||
}
|
||||
@@ -878,6 +852,13 @@ mod tests {
|
||||
total_play_time_ms: 12,
|
||||
played_world_count: 2,
|
||||
updated_at_micros: Some(1_713_680_000_000_000),
|
||||
daily_free_points: RuntimeProfileDailyFreePointsSnapshot {
|
||||
day_key: 19_834,
|
||||
granted_points: PROFILE_DAILY_FREE_POINTS_PER_DAY,
|
||||
remaining_points: 12,
|
||||
resets_at_micros: 1_713_715_200_000_000,
|
||||
updated_at_micros: 1_713_680_000_000_000,
|
||||
},
|
||||
});
|
||||
|
||||
assert_eq!(record.updated_at, Some("2024-04-21T06:13:20Z".to_string()));
|
||||
@@ -917,6 +898,14 @@ mod tests {
|
||||
RuntimeProfileWalletLedgerSourceType::DailyTaskReward.as_str(),
|
||||
"daily_task_reward"
|
||||
);
|
||||
assert_eq!(
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeGrant.as_str(),
|
||||
"daily_free_grant"
|
||||
);
|
||||
assert_eq!(
|
||||
RuntimeProfileWalletLedgerSourceType::DailyFreeReset.as_str(),
|
||||
"daily_free_reset"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1105,16 +1094,20 @@ mod tests {
|
||||
let point_products = runtime_profile_recharge_point_products();
|
||||
let membership_products = runtime_profile_recharge_membership_products();
|
||||
|
||||
assert_eq!(point_products.len(), 6);
|
||||
assert_eq!(point_products.len(), 4);
|
||||
assert_eq!(point_products[0].product_id, "points_60");
|
||||
assert_eq!(point_products[0].title, "60泥点");
|
||||
assert_eq!(point_products[0].price_cents, 600);
|
||||
assert_eq!(point_products[0].bonus_points, 60);
|
||||
assert_eq!(point_products[0].description, "首充送60泥点");
|
||||
assert_eq!(point_products[5].product_id, "points_3280");
|
||||
assert_eq!(point_products[5].price_cents, 32800);
|
||||
assert_eq!(point_products[5].bonus_points, 3280);
|
||||
assert_eq!(point_products[5].description, "首充送3280泥点");
|
||||
assert_eq!(point_products[0].bonus_points, 0);
|
||||
assert_eq!(point_products[0].badge_label, "");
|
||||
assert_eq!(point_products[0].description, "60泥点");
|
||||
assert_eq!(point_products[1].product_id, "points_180");
|
||||
assert_eq!(point_products[1].bonus_points, 90);
|
||||
assert_eq!(point_products[2].bonus_points, 150);
|
||||
assert_eq!(point_products[3].product_id, "points_680");
|
||||
assert_eq!(point_products[3].price_cents, 6800);
|
||||
assert_eq!(point_products[3].bonus_points, 340);
|
||||
assert_eq!(point_products[3].description, "首充加赠340泥点");
|
||||
assert_eq!(membership_products.len(), 4);
|
||||
assert_eq!(membership_products[0].product_id, "member_starter");
|
||||
assert_eq!(membership_products[0].title, "Starter");
|
||||
@@ -1139,17 +1132,19 @@ mod tests {
|
||||
#[test]
|
||||
fn recharge_point_products_do_not_hide_all_first_bonus_by_account_flag() {
|
||||
let first_recharge_products = resolve_runtime_profile_recharge_point_products(false);
|
||||
assert_eq!(first_recharge_products[0].bonus_points, 60);
|
||||
assert_eq!(first_recharge_products[0].badge_label, "首充双倍");
|
||||
assert_eq!(first_recharge_products[0].description, "首充送60泥点");
|
||||
assert_eq!(first_recharge_products[0].bonus_points, 0);
|
||||
assert_eq!(first_recharge_products[0].badge_label, "");
|
||||
assert_eq!(first_recharge_products[0].description, "60泥点");
|
||||
assert_eq!(first_recharge_products[1].bonus_points, 90);
|
||||
assert_eq!(first_recharge_products[1].badge_label, "首充加赠");
|
||||
assert_eq!(first_recharge_products[1].description, "首充加赠90泥点");
|
||||
|
||||
let repeated_recharge_products = resolve_runtime_profile_recharge_point_products(true);
|
||||
assert_eq!(repeated_recharge_products[0].bonus_points, 60);
|
||||
assert_eq!(repeated_recharge_products[0].badge_label, "首充双倍");
|
||||
assert_eq!(repeated_recharge_products[0].description, "首充送60泥点");
|
||||
assert_eq!(repeated_recharge_products[5].bonus_points, 3280);
|
||||
assert_eq!(repeated_recharge_products[5].badge_label, "首充双倍");
|
||||
assert_eq!(repeated_recharge_products[5].description, "首充送3280泥点");
|
||||
assert_eq!(repeated_recharge_products[0].bonus_points, 0);
|
||||
assert_eq!(repeated_recharge_products[1].bonus_points, 90);
|
||||
assert_eq!(repeated_recharge_products[3].bonus_points, 340);
|
||||
assert_eq!(repeated_recharge_products[3].badge_label, "首充加赠");
|
||||
assert_eq!(repeated_recharge_products[3].description, "首充加赠340泥点");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,6 +11,8 @@ pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_MEMBERSHIP_PERIOD_GRANT: &str =
|
||||
"membership_period_grant";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_MEMBERSHIP_PERIOD_RESET: &str =
|
||||
"membership_period_reset";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_GRANT: &str = "daily_free_grant";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_DAILY_FREE_RESET: &str = "daily_free_reset";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_INVITE_INVITER_REWARD: &str = "invite_inviter_reward";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_INVITE_INVITEE_REWARD: &str = "invite_invitee_reward";
|
||||
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_CONSUME: &str =
|
||||
@@ -173,6 +175,29 @@ pub struct ProfileDashboardSummaryResponse {
|
||||
pub total_play_time_ms: u64,
|
||||
pub played_world_count: u32,
|
||||
pub updated_at: Option<String>,
|
||||
pub daily_free_points: ProfileDailyFreePointsResponse,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProfileDailyFreePointsResponse {
|
||||
pub day_key: i64,
|
||||
pub granted_points: u64,
|
||||
pub remaining_points: u64,
|
||||
pub resets_at: String,
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProfileMudPointBalanceResponse {
|
||||
pub total_points: u64,
|
||||
pub permanent_points: u64,
|
||||
pub limited_points: u64,
|
||||
pub limited_expires_at: Option<String>,
|
||||
pub daily_free_points: u64,
|
||||
pub daily_free_reset_points: u64,
|
||||
pub daily_free_resets_at: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
@@ -305,12 +330,14 @@ pub struct WechatNativePaymentResponse {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProfileRechargeCenterResponse {
|
||||
pub wallet_balance: u64,
|
||||
pub mud_point_balance: ProfileMudPointBalanceResponse,
|
||||
pub membership: ProfileMembershipResponse,
|
||||
pub point_products: Vec<ProfileRechargeProductResponse>,
|
||||
pub membership_products: Vec<ProfileRechargeProductResponse>,
|
||||
pub benefits: Vec<ProfileMembershipBenefitResponse>,
|
||||
pub latest_order: Option<ProfileRechargeOrderResponse>,
|
||||
pub has_points_recharged: bool,
|
||||
pub daily_free_points: ProfileDailyFreePointsResponse,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
@@ -1192,6 +1219,18 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
fn empty_mud_point_balance() -> ProfileMudPointBalanceResponse {
|
||||
ProfileMudPointBalanceResponse {
|
||||
total_points: 0,
|
||||
permanent_points: 0,
|
||||
limited_points: 0,
|
||||
limited_expires_at: None,
|
||||
daily_free_points: 0,
|
||||
daily_free_reset_points: 20,
|
||||
daily_free_resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_settings_request_uses_camel_case_fields() {
|
||||
let payload = serde_json::to_value(PutRuntimeSettingsRequest {
|
||||
@@ -1260,6 +1299,13 @@ mod tests {
|
||||
total_play_time_ms: 16,
|
||||
played_world_count: 3,
|
||||
updated_at: Some("2026-04-22T10:00:00Z".to_string()),
|
||||
daily_free_points: ProfileDailyFreePointsResponse {
|
||||
day_key: 20_646,
|
||||
granted_points: 20,
|
||||
remaining_points: 12,
|
||||
resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
updated_at: "2026-07-12T08:00:00Z".to_string(),
|
||||
},
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
@@ -1267,6 +1313,7 @@ mod tests {
|
||||
assert_eq!(payload["totalPlayTimeMs"], json!(16));
|
||||
assert_eq!(payload["playedWorldCount"], json!(3));
|
||||
assert_eq!(payload["updatedAt"], json!("2026-04-22T10:00:00Z"));
|
||||
assert_eq!(payload["dailyFreePoints"]["remainingPoints"], json!(12));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1444,6 +1491,15 @@ mod tests {
|
||||
fn profile_recharge_center_response_uses_camel_case_fields() {
|
||||
let payload = serde_json::to_value(ProfileRechargeCenterResponse {
|
||||
wallet_balance: 29,
|
||||
mud_point_balance: ProfileMudPointBalanceResponse {
|
||||
total_points: 29,
|
||||
permanent_points: 4,
|
||||
limited_points: 5,
|
||||
limited_expires_at: Some("2026-05-25T10:00:00Z".to_string()),
|
||||
daily_free_points: 20,
|
||||
daily_free_reset_points: 20,
|
||||
daily_free_resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
},
|
||||
membership: ProfileMembershipResponse {
|
||||
status: "active".to_string(),
|
||||
tier: "month".to_string(),
|
||||
@@ -1476,10 +1532,20 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: ProfileDailyFreePointsResponse {
|
||||
day_key: 20_646,
|
||||
granted_points: 20,
|
||||
remaining_points: 20,
|
||||
resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
updated_at: "2026-07-12T08:00:00Z".to_string(),
|
||||
},
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
assert_eq!(payload["walletBalance"], json!(29));
|
||||
assert_eq!(payload["mudPointBalance"]["permanentPoints"], json!(4));
|
||||
assert_eq!(payload["mudPointBalance"]["limitedPoints"], json!(5));
|
||||
assert_eq!(payload["mudPointBalance"]["dailyFreePoints"], json!(20));
|
||||
assert_eq!(
|
||||
payload["membership"]["expiresAt"],
|
||||
json!("2026-05-25T10:00:00Z")
|
||||
@@ -1493,6 +1559,7 @@ mod tests {
|
||||
json!("首充送60泥点")
|
||||
);
|
||||
assert_eq!(payload["hasPointsRecharged"], json!(false));
|
||||
assert_eq!(payload["dailyFreePoints"]["grantedPoints"], json!(20));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1528,6 +1595,7 @@ mod tests {
|
||||
};
|
||||
let center = ProfileRechargeCenterResponse {
|
||||
wallet_balance: 0,
|
||||
mud_point_balance: empty_mud_point_balance(),
|
||||
membership: ProfileMembershipResponse {
|
||||
status: "normal".to_string(),
|
||||
tier: "normal".to_string(),
|
||||
@@ -1545,6 +1613,13 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: ProfileDailyFreePointsResponse {
|
||||
day_key: 20_646,
|
||||
granted_points: 20,
|
||||
remaining_points: 20,
|
||||
resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
updated_at: "2026-07-12T08:00:00Z".to_string(),
|
||||
},
|
||||
};
|
||||
let payload = serde_json::to_value(CreateProfileRechargeOrderResponse {
|
||||
order,
|
||||
@@ -1596,6 +1671,7 @@ mod tests {
|
||||
};
|
||||
let center = ProfileRechargeCenterResponse {
|
||||
wallet_balance: 0,
|
||||
mud_point_balance: empty_mud_point_balance(),
|
||||
membership: ProfileMembershipResponse {
|
||||
status: "normal".to_string(),
|
||||
tier: "normal".to_string(),
|
||||
@@ -1613,6 +1689,13 @@ mod tests {
|
||||
benefits: vec![],
|
||||
latest_order: None,
|
||||
has_points_recharged: false,
|
||||
daily_free_points: ProfileDailyFreePointsResponse {
|
||||
day_key: 20_646,
|
||||
granted_points: 20,
|
||||
remaining_points: 20,
|
||||
resets_at: "2026-07-12T16:00:00Z".to_string(),
|
||||
updated_at: "2026-07-12T08:00:00Z".to_string(),
|
||||
},
|
||||
};
|
||||
let payload = serde_json::to_value(CreateProfileRechargeOrderResponse {
|
||||
order,
|
||||
|
||||
@@ -609,6 +609,12 @@ pub(crate) fn map_runtime_profile_wallet_ledger_source_type_back(
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::DailyTaskReward => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::DailyTaskReward
|
||||
}
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::DailyFreeGrant => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::DailyFreeGrant
|
||||
}
|
||||
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::DailyFreeReset => {
|
||||
module_runtime::RuntimeProfileWalletLedgerSourceType::DailyFreeReset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -928,6 +928,21 @@ pub(crate) fn map_runtime_profile_dashboard_snapshot(
|
||||
total_play_time_ms: snapshot.total_play_time_ms,
|
||||
played_world_count: snapshot.played_world_count,
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
daily_free_points: map_runtime_profile_daily_free_points_snapshot(
|
||||
snapshot.daily_free_points,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn map_runtime_profile_daily_free_points_snapshot(
|
||||
snapshot: RuntimeProfileDailyFreePointsSnapshot,
|
||||
) -> module_runtime::RuntimeProfileDailyFreePointsSnapshot {
|
||||
module_runtime::RuntimeProfileDailyFreePointsSnapshot {
|
||||
day_key: snapshot.day_key,
|
||||
granted_points: snapshot.granted_points,
|
||||
remaining_points: snapshot.remaining_points,
|
||||
resets_at_micros: snapshot.resets_at_micros,
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,6 +1010,9 @@ pub(crate) fn map_runtime_profile_recharge_center_snapshot(
|
||||
.latest_order
|
||||
.map(map_runtime_profile_recharge_order_snapshot),
|
||||
has_points_recharged: snapshot.has_points_recharged,
|
||||
daily_free_points: map_runtime_profile_daily_free_points_snapshot(
|
||||
snapshot.daily_free_points,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,9 +1135,7 @@ pub(crate) fn map_runtime_profile_recharge_order_table_row(
|
||||
amount_cents: row.amount_cents,
|
||||
status: map_runtime_profile_recharge_order_status_back(row.status),
|
||||
payment_channel: row.payment_channel,
|
||||
paid_at_micros: row
|
||||
.paid_at
|
||||
.map(|value| value.to_micros_since_unix_epoch()),
|
||||
paid_at_micros: row.paid_at.map(|value| value.to_micros_since_unix_epoch()),
|
||||
provider_transaction_id: row.provider_transaction_id,
|
||||
created_at_micros: row.created_at.to_micros_since_unix_epoch(),
|
||||
points_delta: row.points_delta,
|
||||
|
||||
@@ -737,6 +737,8 @@ pub mod player_progression_table;
|
||||
pub mod player_progression_type;
|
||||
pub mod profile_code_operation_table;
|
||||
pub mod profile_code_operation_type;
|
||||
pub mod profile_daily_free_points_table;
|
||||
pub mod profile_daily_free_points_type;
|
||||
pub mod profile_dashboard_state_table;
|
||||
pub mod profile_dashboard_state_type;
|
||||
pub mod profile_feedback_submission_table;
|
||||
@@ -1011,6 +1013,7 @@ pub mod runtime_item_reward_item_rarity_type;
|
||||
pub mod runtime_item_reward_item_snapshot_type;
|
||||
pub mod runtime_platform_theme_type;
|
||||
pub mod runtime_profile_code_operation_snapshot_type;
|
||||
pub mod runtime_profile_daily_free_points_snapshot_type;
|
||||
pub mod runtime_profile_dashboard_get_input_type;
|
||||
pub mod runtime_profile_dashboard_procedure_result_type;
|
||||
pub mod runtime_profile_dashboard_snapshot_type;
|
||||
@@ -2072,6 +2075,8 @@ pub use player_progression_table::*;
|
||||
pub use player_progression_type::PlayerProgression;
|
||||
pub use profile_code_operation_table::*;
|
||||
pub use profile_code_operation_type::ProfileCodeOperation;
|
||||
pub use profile_daily_free_points_table::*;
|
||||
pub use profile_daily_free_points_type::ProfileDailyFreePoints;
|
||||
pub use profile_dashboard_state_table::*;
|
||||
pub use profile_dashboard_state_type::ProfileDashboardState;
|
||||
pub use profile_feedback_submission_table::*;
|
||||
@@ -2346,6 +2351,7 @@ pub use runtime_item_reward_item_rarity_type::RuntimeItemRewardItemRarity;
|
||||
pub use runtime_item_reward_item_snapshot_type::RuntimeItemRewardItemSnapshot;
|
||||
pub use runtime_platform_theme_type::RuntimePlatformTheme;
|
||||
pub use runtime_profile_code_operation_snapshot_type::RuntimeProfileCodeOperationSnapshot;
|
||||
pub use runtime_profile_daily_free_points_snapshot_type::RuntimeProfileDailyFreePointsSnapshot;
|
||||
pub use runtime_profile_dashboard_get_input_type::RuntimeProfileDashboardGetInput;
|
||||
pub use runtime_profile_dashboard_procedure_result_type::RuntimeProfileDashboardProcedureResult;
|
||||
pub use runtime_profile_dashboard_snapshot_type::RuntimeProfileDashboardSnapshot;
|
||||
@@ -3031,6 +3037,7 @@ pub struct DbUpdate {
|
||||
npc_state: __sdk::TableUpdate<NpcState>,
|
||||
player_progression: __sdk::TableUpdate<PlayerProgression>,
|
||||
profile_code_operation: __sdk::TableUpdate<ProfileCodeOperation>,
|
||||
profile_daily_free_points: __sdk::TableUpdate<ProfileDailyFreePoints>,
|
||||
profile_dashboard_state: __sdk::TableUpdate<ProfileDashboardState>,
|
||||
profile_feedback_submission: __sdk::TableUpdate<ProfileFeedbackSubmission>,
|
||||
profile_invite_code: __sdk::TableUpdate<ProfileInviteCode>,
|
||||
@@ -3341,6 +3348,9 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
|
||||
"profile_code_operation" => db_update.profile_code_operation.append(
|
||||
profile_code_operation_table::parse_table_update(table_update)?,
|
||||
),
|
||||
"profile_daily_free_points" => db_update.profile_daily_free_points.append(
|
||||
profile_daily_free_points_table::parse_table_update(table_update)?,
|
||||
),
|
||||
"profile_dashboard_state" => db_update.profile_dashboard_state.append(
|
||||
profile_dashboard_state_table::parse_table_update(table_update)?,
|
||||
),
|
||||
@@ -3926,6 +3936,12 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
&self.profile_code_operation,
|
||||
)
|
||||
.with_updates_by_pk(|row| &row.operation_id);
|
||||
diff.profile_daily_free_points = cache
|
||||
.apply_diff_to_table::<ProfileDailyFreePoints>(
|
||||
"profile_daily_free_points",
|
||||
&self.profile_daily_free_points,
|
||||
)
|
||||
.with_updates_by_pk(|row| &row.user_id);
|
||||
diff.profile_dashboard_state = cache
|
||||
.apply_diff_to_table::<ProfileDashboardState>(
|
||||
"profile_dashboard_state",
|
||||
@@ -4504,6 +4520,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
"profile_code_operation" => db_update
|
||||
.profile_code_operation
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"profile_daily_free_points" => db_update
|
||||
.profile_daily_free_points
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"profile_dashboard_state" => db_update
|
||||
.profile_dashboard_state
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
@@ -4931,6 +4950,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
"profile_code_operation" => db_update
|
||||
.profile_code_operation
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"profile_daily_free_points" => db_update
|
||||
.profile_daily_free_points
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"profile_dashboard_state" => db_update
|
||||
.profile_dashboard_state
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
@@ -5221,6 +5243,7 @@ pub struct AppliedDiff<'r> {
|
||||
npc_state: __sdk::TableAppliedDiff<'r, NpcState>,
|
||||
player_progression: __sdk::TableAppliedDiff<'r, PlayerProgression>,
|
||||
profile_code_operation: __sdk::TableAppliedDiff<'r, ProfileCodeOperation>,
|
||||
profile_daily_free_points: __sdk::TableAppliedDiff<'r, ProfileDailyFreePoints>,
|
||||
profile_dashboard_state: __sdk::TableAppliedDiff<'r, ProfileDashboardState>,
|
||||
profile_feedback_submission: __sdk::TableAppliedDiff<'r, ProfileFeedbackSubmission>,
|
||||
profile_invite_code: __sdk::TableAppliedDiff<'r, ProfileInviteCode>,
|
||||
@@ -5647,6 +5670,11 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
||||
&self.profile_code_operation,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<ProfileDailyFreePoints>(
|
||||
"profile_daily_free_points",
|
||||
&self.profile_daily_free_points,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<ProfileDashboardState>(
|
||||
"profile_dashboard_state",
|
||||
&self.profile_dashboard_state,
|
||||
@@ -6705,6 +6733,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
||||
npc_state_table::register_table(client_cache);
|
||||
player_progression_table::register_table(client_cache);
|
||||
profile_code_operation_table::register_table(client_cache);
|
||||
profile_daily_free_points_table::register_table(client_cache);
|
||||
profile_dashboard_state_table::register_table(client_cache);
|
||||
profile_feedback_submission_table::register_table(client_cache);
|
||||
profile_invite_code_table::register_table(client_cache);
|
||||
@@ -6845,6 +6874,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
||||
"npc_state",
|
||||
"player_progression",
|
||||
"profile_code_operation",
|
||||
"profile_daily_free_points",
|
||||
"profile_dashboard_state",
|
||||
"profile_feedback_submission",
|
||||
"profile_invite_code",
|
||||
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::profile_daily_free_points_type::ProfileDailyFreePoints;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `profile_daily_free_points`.
|
||||
///
|
||||
/// Obtain a handle from the [`ProfileDailyFreePointsTableAccess::profile_daily_free_points`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.profile_daily_free_points()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.profile_daily_free_points().on_insert(...)`.
|
||||
pub struct ProfileDailyFreePointsTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<ProfileDailyFreePoints>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `profile_daily_free_points`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait ProfileDailyFreePointsTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`ProfileDailyFreePointsTableHandle`], which mediates access to the table `profile_daily_free_points`.
|
||||
fn profile_daily_free_points(&self) -> ProfileDailyFreePointsTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl ProfileDailyFreePointsTableAccess for super::RemoteTables {
|
||||
fn profile_daily_free_points(&self) -> ProfileDailyFreePointsTableHandle<'_> {
|
||||
ProfileDailyFreePointsTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<ProfileDailyFreePoints>("profile_daily_free_points"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ProfileDailyFreePointsInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct ProfileDailyFreePointsDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for ProfileDailyFreePointsTableHandle<'ctx> {
|
||||
type Row = ProfileDailyFreePoints;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = ProfileDailyFreePoints> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = ProfileDailyFreePointsInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> ProfileDailyFreePointsInsertCallbackId {
|
||||
ProfileDailyFreePointsInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: ProfileDailyFreePointsInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = ProfileDailyFreePointsDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> ProfileDailyFreePointsDeleteCallbackId {
|
||||
ProfileDailyFreePointsDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: ProfileDailyFreePointsDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ProfileDailyFreePointsUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for ProfileDailyFreePointsTableHandle<'ctx> {
|
||||
type UpdateCallbackId = ProfileDailyFreePointsUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> ProfileDailyFreePointsUpdateCallbackId {
|
||||
ProfileDailyFreePointsUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: ProfileDailyFreePointsUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `user_id` unique index on the table `profile_daily_free_points`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`ProfileDailyFreePointsUserIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.profile_daily_free_points().user_id().find(...)`.
|
||||
pub struct ProfileDailyFreePointsUserIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<ProfileDailyFreePoints, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> ProfileDailyFreePointsTableHandle<'ctx> {
|
||||
/// Get a handle on the `user_id` unique index on the table `profile_daily_free_points`.
|
||||
pub fn user_id(&self) -> ProfileDailyFreePointsUserIdUnique<'ctx> {
|
||||
ProfileDailyFreePointsUserIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("user_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> ProfileDailyFreePointsUserIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `user_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<ProfileDailyFreePoints> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<ProfileDailyFreePoints>("profile_daily_free_points");
|
||||
_table.add_unique_constraint::<String>("user_id", |row| &row.user_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<ProfileDailyFreePoints>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<ProfileDailyFreePoints>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `ProfileDailyFreePoints`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait profile_daily_free_pointsQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `ProfileDailyFreePoints`.
|
||||
fn profile_daily_free_points(&self) -> __sdk::__query_builder::Table<ProfileDailyFreePoints>;
|
||||
}
|
||||
|
||||
impl profile_daily_free_pointsQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn profile_daily_free_points(&self) -> __sdk::__query_builder::Table<ProfileDailyFreePoints> {
|
||||
__sdk::__query_builder::Table::new("profile_daily_free_points")
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct ProfileDailyFreePoints {
|
||||
pub user_id: String,
|
||||
pub day_key: i64,
|
||||
pub granted_points: u64,
|
||||
pub remaining_points: u64,
|
||||
pub updated_at: __sdk::Timestamp,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ProfileDailyFreePoints {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
/// Column accessor struct for the table `ProfileDailyFreePoints`.
|
||||
///
|
||||
/// Provides typed access to columns for query building.
|
||||
pub struct ProfileDailyFreePointsCols {
|
||||
pub user_id: __sdk::__query_builder::Col<ProfileDailyFreePoints, String>,
|
||||
pub day_key: __sdk::__query_builder::Col<ProfileDailyFreePoints, i64>,
|
||||
pub granted_points: __sdk::__query_builder::Col<ProfileDailyFreePoints, u64>,
|
||||
pub remaining_points: __sdk::__query_builder::Col<ProfileDailyFreePoints, u64>,
|
||||
pub updated_at: __sdk::__query_builder::Col<ProfileDailyFreePoints, __sdk::Timestamp>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasCols for ProfileDailyFreePoints {
|
||||
type Cols = ProfileDailyFreePointsCols;
|
||||
fn cols(table_name: &'static str) -> Self::Cols {
|
||||
ProfileDailyFreePointsCols {
|
||||
user_id: __sdk::__query_builder::Col::new(table_name, "user_id"),
|
||||
day_key: __sdk::__query_builder::Col::new(table_name, "day_key"),
|
||||
granted_points: __sdk::__query_builder::Col::new(table_name, "granted_points"),
|
||||
remaining_points: __sdk::__query_builder::Col::new(table_name, "remaining_points"),
|
||||
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indexed column accessor struct for the table `ProfileDailyFreePoints`.
|
||||
///
|
||||
/// Provides typed access to indexed columns for query building.
|
||||
pub struct ProfileDailyFreePointsIxCols {
|
||||
pub user_id: __sdk::__query_builder::IxCol<ProfileDailyFreePoints, String>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasIxCols for ProfileDailyFreePoints {
|
||||
type IxCols = ProfileDailyFreePointsIxCols;
|
||||
fn ix_cols(table_name: &'static str) -> Self::IxCols {
|
||||
ProfileDailyFreePointsIxCols {
|
||||
user_id: __sdk::__query_builder::IxCol::new(table_name, "user_id"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for ProfileDailyFreePoints {}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct RuntimeProfileDailyFreePointsSnapshot {
|
||||
pub day_key: i64,
|
||||
pub granted_points: u64,
|
||||
pub remaining_points: u64,
|
||||
pub resets_at_micros: i64,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RuntimeProfileDailyFreePointsSnapshot {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
+3
@@ -4,6 +4,8 @@
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::runtime_profile_daily_free_points_snapshot_type::RuntimeProfileDailyFreePointsSnapshot;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct RuntimeProfileDashboardSnapshot {
|
||||
@@ -12,6 +14,7 @@ pub struct RuntimeProfileDashboardSnapshot {
|
||||
pub total_play_time_ms: u64,
|
||||
pub played_world_count: u32,
|
||||
pub updated_at_micros: Option<i64>,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsSnapshot,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RuntimeProfileDashboardSnapshot {
|
||||
|
||||
+2
@@ -4,6 +4,7 @@
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::runtime_profile_daily_free_points_snapshot_type::RuntimeProfileDailyFreePointsSnapshot;
|
||||
use super::runtime_profile_membership_benefit_snapshot_type::RuntimeProfileMembershipBenefitSnapshot;
|
||||
use super::runtime_profile_membership_snapshot_type::RuntimeProfileMembershipSnapshot;
|
||||
use super::runtime_profile_recharge_order_snapshot_type::RuntimeProfileRechargeOrderSnapshot;
|
||||
@@ -20,6 +21,7 @@ pub struct RuntimeProfileRechargeCenterSnapshot {
|
||||
pub benefits: Vec<RuntimeProfileMembershipBenefitSnapshot>,
|
||||
pub latest_order: Option<RuntimeProfileRechargeOrderSnapshot>,
|
||||
pub has_points_recharged: bool,
|
||||
pub daily_free_points: RuntimeProfileDailyFreePointsSnapshot,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RuntimeProfileRechargeCenterSnapshot {
|
||||
|
||||
+4
@@ -31,6 +31,10 @@ pub enum RuntimeProfileWalletLedgerSourceType {
|
||||
MembershipPeriodGrant,
|
||||
|
||||
MembershipPeriodReset,
|
||||
|
||||
DailyFreeGrant,
|
||||
|
||||
DailyFreeReset,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RuntimeProfileWalletLedgerSourceType {
|
||||
|
||||
@@ -194,6 +194,7 @@ macro_rules! migration_tables {
|
||||
feature_gate_config,
|
||||
user_browse_history,
|
||||
profile_dashboard_state,
|
||||
profile_daily_free_points,
|
||||
profile_wallet_ledger,
|
||||
asset_operation_wallet_settlement,
|
||||
profile_wallet_config,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { render, screen, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { expect, test, vi } from 'vitest';
|
||||
|
||||
import { PlatformMudPointWalletEntry } from './PlatformMudPointWalletEntry';
|
||||
import { formatMudPointCount } from './platformMudPointWalletModel';
|
||||
|
||||
const breakdown = {
|
||||
totalPoints: 207,
|
||||
permanentPoints: 100,
|
||||
limitedPoints: 80,
|
||||
limitedExpiresAt: '2026-07-06T16:00:00Z',
|
||||
dailyFreePoints: 27,
|
||||
dailyFreeResetPoints: 20,
|
||||
dailyFreeResetsAt: '2026-07-12T16:00:00Z',
|
||||
};
|
||||
|
||||
test('formats mud point counts consistently', () => {
|
||||
expect(formatMudPointCount(12_345)).toBe('12,345');
|
||||
expect(formatMudPointCount(12_345, true)).toBe('1.2万');
|
||||
});
|
||||
|
||||
test('shows only permanent and daily free points in the shared wallet panel', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onRequestDetails = vi.fn();
|
||||
const onRecharge = vi.fn();
|
||||
const onOpenLedger = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformMudPointWalletEntry
|
||||
balance={999}
|
||||
breakdown={breakdown}
|
||||
onRequestDetails={onRequestDetails}
|
||||
onRecharge={onRecharge}
|
||||
onOpenLedger={onOpenLedger}
|
||||
/>,
|
||||
);
|
||||
|
||||
const balanceButton = screen.getByRole('button', { name: '泥点 207' });
|
||||
await user.hover(balanceButton);
|
||||
|
||||
const details = screen.getByRole('dialog', { name: '泥点账户详情' });
|
||||
expect(details.className).toContain('rounded-[1.12rem]');
|
||||
expect(within(details).getByText('不限时泥点')).toBeTruthy();
|
||||
expect(within(details).getByText('按量充值、兑换码获得')).toBeTruthy();
|
||||
expect(within(details).getByText('100')).toBeTruthy();
|
||||
expect(within(details).queryByText('限时泥点')).toBeNull();
|
||||
expect(within(details).queryByText('2026-07-07 到期')).toBeNull();
|
||||
expect(within(details).getByText('每日免费泥点')).toBeTruthy();
|
||||
expect(within(details).getByText('27')).toBeTruthy();
|
||||
expect(within(details).getByText('每天重置为 20 泥点')).toBeTruthy();
|
||||
expect(onRequestDetails).not.toHaveBeenCalled();
|
||||
|
||||
await user.click(within(details).getByRole('button', { name: '使用详情' }));
|
||||
expect(onOpenLedger).toHaveBeenCalledTimes(1);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: '充值' }));
|
||||
expect(onRecharge).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('requests the balance breakdown when a compact entry opens', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onRequestDetails = vi.fn();
|
||||
|
||||
render(
|
||||
<PlatformMudPointWalletEntry
|
||||
balance={20}
|
||||
breakdown={null}
|
||||
isLoading={false}
|
||||
variant="mobile"
|
||||
onRequestDetails={onRequestDetails}
|
||||
onRecharge={vi.fn()}
|
||||
onOpenLedger={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: '泥点 20' }));
|
||||
expect(onRequestDetails).toHaveBeenCalledTimes(1);
|
||||
expect(screen.getByText('余额明细暂不可用')).toBeTruthy();
|
||||
});
|
||||
@@ -0,0 +1,255 @@
|
||||
import { ChevronRight, ReceiptText } from 'lucide-react';
|
||||
import {
|
||||
type FocusEvent,
|
||||
type MouseEvent,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
import type { ProfileMudPointBalance } from '../../../packages/shared/src/contracts/runtime';
|
||||
import { formatMudPointCount } from './platformMudPointWalletModel';
|
||||
|
||||
const MUD_POINT_ICON_SRC = '/creation-home/topbar-wallet.png';
|
||||
|
||||
export type PlatformMudPointWalletEntryProps = {
|
||||
balance: number | null;
|
||||
breakdown?: ProfileMudPointBalance | null;
|
||||
isLoading?: boolean;
|
||||
error?: string | null;
|
||||
variant?: 'desktop' | 'mobile' | 'editor';
|
||||
className?: string;
|
||||
onRequestDetails: () => void;
|
||||
onRecharge: () => void;
|
||||
onOpenLedger: () => void;
|
||||
};
|
||||
|
||||
function MudPointBalanceRow({
|
||||
label,
|
||||
points,
|
||||
detail,
|
||||
}: {
|
||||
label: string;
|
||||
points: number;
|
||||
detail?: string | null;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-h-[3.25rem] items-center justify-between gap-4 border-t border-[var(--platform-subpanel-border)] px-4 py-2.5">
|
||||
<div className="min-w-0">
|
||||
<div className="text-[13px] font-bold text-[var(--platform-text-strong)]">
|
||||
{label}
|
||||
</div>
|
||||
{detail ? (
|
||||
<div className="mt-0.5 truncate text-[11px] text-[var(--platform-text-soft)]">
|
||||
{detail}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="shrink-0 text-[15px] font-black tabular-nums text-[var(--platform-text-strong)]">
|
||||
{formatMudPointCount(points)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PlatformMudPointWalletEntry({
|
||||
balance,
|
||||
breakdown,
|
||||
isLoading = false,
|
||||
variant = 'desktop',
|
||||
className,
|
||||
onRequestDetails,
|
||||
onRecharge,
|
||||
onOpenLedger,
|
||||
}: PlatformMudPointWalletEntryProps) {
|
||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||
const isOpenRef = useRef(false);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const isCompact = variant === 'mobile';
|
||||
const displayedBalance = breakdown?.totalPoints ?? balance;
|
||||
const balanceLabel =
|
||||
displayedBalance === null
|
||||
? '--'
|
||||
: formatMudPointCount(displayedBalance, true);
|
||||
const exactBalanceLabel =
|
||||
displayedBalance === null ? '--' : formatMudPointCount(displayedBalance);
|
||||
|
||||
const closeDetails = useCallback(() => {
|
||||
isOpenRef.current = false;
|
||||
setIsOpen(false);
|
||||
}, []);
|
||||
|
||||
const requestAndOpen = useCallback(() => {
|
||||
if (isOpenRef.current) {
|
||||
return;
|
||||
}
|
||||
isOpenRef.current = true;
|
||||
setIsOpen(true);
|
||||
if (!breakdown && !isLoading) {
|
||||
onRequestDetails();
|
||||
}
|
||||
}, [breakdown, isLoading, onRequestDetails]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
const handlePointerDown = (event: PointerEvent) => {
|
||||
if (!rootRef.current?.contains(event.target as Node)) {
|
||||
closeDetails();
|
||||
}
|
||||
};
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
closeDetails();
|
||||
}
|
||||
};
|
||||
document.addEventListener('pointerdown', handlePointerDown);
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
return () => {
|
||||
document.removeEventListener('pointerdown', handlePointerDown);
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [closeDetails, isOpen]);
|
||||
|
||||
const closeAfterFocusLeaves = (event: FocusEvent<HTMLDivElement>) => {
|
||||
const nextTarget = event.relatedTarget;
|
||||
if (
|
||||
!(nextTarget instanceof Node) ||
|
||||
!event.currentTarget.contains(nextTarget)
|
||||
) {
|
||||
closeDetails();
|
||||
}
|
||||
};
|
||||
const closeAfterPointerLeaves = (event: MouseEvent<HTMLDivElement>) => {
|
||||
const nextTarget = event.relatedTarget;
|
||||
if (
|
||||
nextTarget instanceof Node &&
|
||||
event.currentTarget.contains(nextTarget)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
window.setTimeout(() => {
|
||||
if (
|
||||
rootRef.current &&
|
||||
!rootRef.current.contains(document.activeElement)
|
||||
) {
|
||||
closeDetails();
|
||||
}
|
||||
}, 120);
|
||||
};
|
||||
return (
|
||||
<div
|
||||
ref={rootRef}
|
||||
className={`platform-mud-point-wallet-entry relative shrink-0 ${className ?? ''}`}
|
||||
onMouseEnter={isCompact ? undefined : requestAndOpen}
|
||||
onMouseLeave={isCompact ? undefined : closeAfterPointerLeaves}
|
||||
onFocusCapture={isCompact ? undefined : requestAndOpen}
|
||||
onBlurCapture={closeAfterFocusLeaves}
|
||||
>
|
||||
<div
|
||||
className={`flex items-stretch overflow-hidden rounded-full border border-[rgba(214,184,159,0.78)] bg-[rgba(255,250,244,0.9)] text-[#6f3d24] shadow-[0_0.18rem_0.55rem_rgba(112,62,32,0.08)] ${
|
||||
isCompact ? 'h-8 text-[11px]' : 'h-9 text-xs'
|
||||
}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-w-0 items-center gap-1.5 px-2 font-black outline-none transition-colors hover:bg-white/70 focus-visible:bg-white/80"
|
||||
aria-label={`泥点 ${exactBalanceLabel}`}
|
||||
aria-expanded={isOpen}
|
||||
aria-haspopup="dialog"
|
||||
aria-busy={isLoading}
|
||||
onClick={() => {
|
||||
if (isOpenRef.current) {
|
||||
closeDetails();
|
||||
return;
|
||||
}
|
||||
requestAndOpen();
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={MUD_POINT_ICON_SRC}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
draggable={false}
|
||||
className={`${isCompact ? 'h-[1.05rem] w-[1.05rem]' : 'h-[1.2rem] w-[1.2rem]'} shrink-0 object-cover mix-blend-multiply`}
|
||||
/>
|
||||
<span className="truncate whitespace-nowrap">
|
||||
泥点 {balanceLabel}
|
||||
</span>
|
||||
</button>
|
||||
<span
|
||||
className="my-1.5 w-px shrink-0 bg-[rgba(196,153,120,0.62)]"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="shrink-0 px-2.5 font-black outline-none transition-colors hover:bg-white/75 focus-visible:bg-white/80"
|
||||
onClick={() => {
|
||||
closeDetails();
|
||||
onRecharge();
|
||||
}}
|
||||
>
|
||||
充值
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{isOpen ? (
|
||||
<div
|
||||
role="dialog"
|
||||
aria-label="泥点账户详情"
|
||||
className="absolute right-0 top-[calc(100%+0.5rem)] z-[95] w-[min(19rem,calc(100vw-1rem))] overflow-hidden rounded-[1.12rem] border border-[var(--platform-subpanel-border)] bg-[#fffaf4] text-left shadow-[0_1rem_2.8rem_rgba(76,44,27,0.2)]"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 px-4 py-3">
|
||||
<div className="text-[15px] font-black text-[var(--platform-text-strong)]">
|
||||
泥点 {exactBalanceLabel}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs font-black text-[var(--platform-accent-strong)] outline-none hover:underline focus-visible:underline"
|
||||
onClick={() => {
|
||||
closeDetails();
|
||||
onRecharge();
|
||||
}}
|
||||
>
|
||||
充值
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{breakdown ? (
|
||||
<>
|
||||
<MudPointBalanceRow
|
||||
label="不限时泥点"
|
||||
points={breakdown.permanentPoints}
|
||||
detail="按量充值、兑换码获得"
|
||||
/>
|
||||
<MudPointBalanceRow
|
||||
label="每日免费泥点"
|
||||
points={breakdown.dailyFreePoints}
|
||||
detail={`每天重置为 ${formatMudPointCount(breakdown.dailyFreeResetPoints)} 泥点`}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<div className="border-t border-[var(--platform-subpanel-border)] px-4 py-6 text-center text-xs font-semibold text-[var(--platform-text-soft)]">
|
||||
{isLoading ? '余额读取中' : '余额明细暂不可用'}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center justify-center gap-2 border-t border-[var(--platform-subpanel-border)] px-4 py-3 text-[13px] font-black text-[var(--platform-text-strong)] outline-none transition-colors hover:bg-white/45 focus-visible:bg-white/55"
|
||||
onClick={() => {
|
||||
closeDetails();
|
||||
onOpenLedger();
|
||||
}}
|
||||
>
|
||||
<ReceiptText className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
使用详情
|
||||
<ChevronRight className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user