makecindy / makecindy/cindy

[Feature] 在用量和计费中展示点数购买记录

Open
#1,152 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 使用场景 / Use case

用户在「设置 > 用量和计费」完成点数购买后,需要回查每一笔购买的时间、获得的点数和实际支付金额,用于核对支付结果、额度变动和后续报销。

## 当前问题 / Current limitation

当前页面只展示套餐、可用额度及额度来源/使用情况,没有购买记录入口。

客户端实际上已具备订单列表接口:`/api/billing/orders?limit=...`,订单数据已包含 `amount`、`currency`、`status`、`createdAt`、`updatedAt`、商品和 offer 标识;但 Billing 设置页未调用该接口,也没有对应 UI,因此用户无法在客户端查看历史购买明细。

## 期望方案 / Proposed solution

在「用量和计费」中增加“购买记录”区域:

- 默认展示最近的点数购买订单,按创建时间倒序;
- 每条至少展示:购买时间、购买点数、实付金额和币种、支付状态;
- 支付状态需区分处理中、成功、失败、已取消和已过期;
- 空记录展示明确空态;
- 加载或请求失败应有明确反馈,并支持重试;
- 购买成功后自动刷新购买记录与余额;
- 订单分页能力由现有 `nextCursor` 契约承接,首期至少支持查看默认最近 20 条。

展示金额必须直接采用服务端订单的 `amount` 与 `currency`;点数应以订单对应 offer 的 `creditAmount` 为准。若历史订单无法可靠关联到已下线/变更的 offer,不应猜测点数,需降级为“点数信息暂不可用”。

## 验收标准

- [ ] 有已成功购买订单时,可看到购买时间、点数、支付金额、币种和成功状态;
- [ ] 可正确展示处理中、失败、取消、过期订单;
- [ ] 没有订单时展示空态,不误报加载失败;
- [ ] 接口失败时展示错误反馈并可重试;
- [ ] 完成购买后无需重启客户端即可看到新订单;
- [ ] 展示口径不会把套餐额度、赠送额度或使用消耗误当作购买记录;
- [ ] Light / Dark 模式均有语义 token 实现。

## 相关 Issue

- #648:订阅与充值页面整体升级;本需求补充其中缺失的“点数购买明细”能力。

## 已考虑的替代方案 / Alternatives considered

仅展示当前余额或额度来源,不能支持用户核对单笔支付、购买时间与支付状态,无法满足购买记录回查需求。

Contributor guide

Open the contributing guide

Research direction

Start at the Billing settings page and inspect the existing `/api/billing/orders?limit=...` contract, including `nextCursor` and the offer `creditAmount`. Trace how a completed purchase refreshes the balance, then implement the listed order states, empty/error/retry behavior, pagination, and theme tokens. Done means the acceptance criteria are met without confusing purchases with other credit changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend, payments
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.