Skip to content

feat(invoice): 統一發票對獎 (stage C item 1)#74

Merged
TTigger merged 1 commit into
masterfrom
feat/invoice-lottery
Jul 12, 2026
Merged

feat(invoice): 統一發票對獎 (stage C item 1)#74
TTigger merged 1 commit into
masterfrom
feat/invoice-lottery

Conversation

@TTigger

@TTigger TTigger commented Jul 12, 2026

Copy link
Copy Markdown
Owner

摘要

階段 C 第 1 項(HANDOFF 待辦,回訪黏性最高):發票對獎 —— 自動抓財政部最新
開獎號碼,輸入末 3 碼立刻知道有沒有中,補到 8 碼確認獎級。全站第二支 serverless function。

資料源

財政部公開 RSS https://invoice.etax.nat.gov.tw/invoice.xml(免金鑰、含近六期號碼)。
固定網址、無使用者輸入 → 無 SSRF 面,不需要走 ssrfGuard。
開獎兩個月一次,CDN 快取 s-maxage=3600, stale-while-revalidate=86400

對獎規則(src/lib/invoice.ts,TDD 17 tests)

  • 特別獎 1,000 萬/特獎 200 萬:8 碼全中才算,末碼相同不算(有測試釘住)
  • 頭獎系列:與任一組頭獎共同末碼 8~3 碼 → 20 萬/4 萬/1 萬/4 千/1 千/200
  • 增開六獎:末 3 碼相同 200 元(近期沒開,解析做成可選)
  • 漸進式對獎 UX:末 3 碼沒對中 → 可以直接確定沒獎(所有獎都要求至少末 3 碼吻合);
    對中頭獎末碼 → 當下獎級已確定、提示續輸可能升級;只對中特別獎/特獎末碼 → 提示補完 8 碼確認
  • 號碼全程字串,前導零不掉(例:特獎 00507588

驗證

  • typecheck:api ✓ / 530 unit ✓(+17)/ 57 e2e ✓(+3,stub API:載入、快篩沒中、
    增開六獎、8 碼頭獎、期別切換、API 掛掉重試)
  • OG 卡已產出(68 張,og.test.ts 守門)並依教訓 feat(bingo): bring bingo game into master #3 目測過兩張新卡
  • 工具頁中獎/沒中兩種狀態已截圖目測
  • ⚠️ 依 HANDOFF 規則:本 PR 動到 api/,preview 部署在 Vercel SSO 後面,
    合併後須立即實打 production /api/invoice-numbers 驗證
    (回傳期別數、號碼格式、快取標頭)

🤖 Generated with Claude Code

新工具「發票對獎」+全站第二支 serverless function。

- src/lib/invoice.ts:財政部 invoice.xml 解析與對獎規則(TDD,17 tests)。
  漸進式對獎:末 3 碼即可確判「沒中」或六獎/增開六獎,
  頭獎末碼系列逐碼升級,特別獎/特獎需 8 碼全中才確認。
  號碼全程字串處理,前導零不掉。
- api/invoice-numbers.ts:代抓財政部公開 RSS(固定網址、免金鑰、
  無使用者輸入故無 SSRF 面),CDN 快取 s-maxage=3600 + SWR 一天。
- src/tools/InvoiceLottery.tsx:期別切換、開獎號碼卡、即時對獎、
  錯誤重試;中英雙語頁面,tools.ts 註冊(實用工具 🧧)。
- OG 卡:npm run og 產出 zh/en 兩張(68 張,og.test 守門),已目測。
- e2e:stub /api/invoice-numbers,涵蓋載入、快篩沒中、增開六獎、
  8 碼頭獎、期別切換、API 掛掉重試(+3)。

測試:typecheck:api ✓ / 530 unit ✓(+17)/ 57 e2e ✓(+3)
合併後需立即驗 production /api/invoice-numbers(preview 在 SSO 後面)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tiglet Ready Ready Preview, Comment Jul 12, 2026 3:58pm

@TTigger TTigger merged commit cb963b9 into master Jul 12, 2026
3 checks passed
@TTigger TTigger deleted the feat/invoice-lottery branch July 12, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant