feat(server/pay): 订单列表端点 + 分币种展示价 + 富字段详情

- GET /v1/pay/orders 订单列表(Store.ListByUser,本地台账倒序)
- catalog 增 PriceUsdtMicro(USDT 一口价展示) + SettlementCurrency/DisplayAmountMinor
- 下单按支付方式落展示金额/结算币种(crypto→USDT / 法币→CNY),webhook 覆盖实际
- GetOrder 详情回带 sku/plan/method/amount/currency/created_at/paid_at
- 新增 List 越权/倒序/富字段 + 分币种展示金额 + 详情富字段测试
- 修 3 个 pre-existing 迁移测试(renumber 后 21→23 遗留)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
wangjia
2026-07-11 23:45:21 +08:00
parent 43c76fb978
commit a5adbf347b
8 changed files with 273 additions and 52 deletions
+4 -4
View File
@@ -60,7 +60,7 @@ func succeededPayload(orderNo, sku string) map[string]any {
func TestWebhook_HappyPath(t *testing.T) {
h, db, st := newWebhookRig(t)
ctx := context.Background()
if err := st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto"); err != nil {
if err := st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto", 4990000, "USDT"); err != nil {
t.Fatal(err)
}
w := deliver(t, h, succeededPayload("pay001", "pro_month"))
@@ -92,7 +92,7 @@ func TestWebhook_HappyPath(t *testing.T) {
func TestWebhook_RedeliveryIdempotent(t *testing.T) {
h, db, st := newWebhookRig(t)
ctx := context.Background()
_ = st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto")
_ = st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto", 4990000, "USDT")
deliver(t, h, succeededPayload("pay001", "pro_month"))
var exp1 time.Time
_ = db.QueryRow(`SELECT expires_at FROM subscriptions WHERE user_id = 1`).Scan(&exp1)
@@ -117,8 +117,8 @@ func TestWebhook_RedeliveryIdempotent(t *testing.T) {
func TestWebhook_TwoOrdersStack(t *testing.T) {
h, db, st := newWebhookRig(t)
ctx := context.Background()
_ = st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto")
_ = st.Insert(ctx, 1, "uuid-1", "pro_quarter", "pay002", "crypto")
_ = st.Insert(ctx, 1, "uuid-1", "pro_month", "pay001", "crypto", 4990000, "USDT")
_ = st.Insert(ctx, 1, "uuid-1", "pro_quarter", "pay002", "crypto", 12990000, "USDT")
deliver(t, h, succeededPayload("pay001", "pro_month"))
deliver(t, h, succeededPayload("pay002", "pro_quarter"))
var n int