Skip to content

[codex] Align shop billing and CLIProxy sync#34

Merged
cnYui merged 1 commit into
mainfrom
codex/shop-billing-pricing-sync-20260614
Jun 14, 2026
Merged

[codex] Align shop billing and CLIProxy sync#34
cnYui merged 1 commit into
mainfrom
codex/shop-billing-pricing-sync-20260614

Conversation

@cnYui

@cnYui cnYui commented Jun 14, 2026

Copy link
Copy Markdown
Owner

背景

  • 修正 Shop Admin / Account 消费统计口径,按 usage 实际发生时间归属今日、本月和周消费。
  • 让历史补账按 usage 发生时间选择当时价格版本,避免补账时套用当前价。
  • 新兑换 API key 自动同步到 CLIProxyAPI 顶层 api-keys,失败时回滚兑换事务。
  • 更新 2026-06-14 GPT 缓存命中输入和输出半价规则,以及前端价格展示。

主要改动

  • 新增 lib/cliproxy-api-key-sync.js 和单元测试。
  • 调整 server.js 的账务查询、usage summary 日期边界和兑换同步。
  • 统一 lib/shop-pricing.js 的历史价格回放和当前 GPT 价格。
  • Admin 最近扣费记录支持全部展示并加滚动容器;Account 模型价格支持三位小数。
  • 补充账务、兑换事务回滚、前端渲染和补账回归测试。

验证

  • npm run build:css 通过。
  • npm test 通过,171 个测试全部 pass。
  • git diff --checkgit diff --cached --check 均无输出。
  • 敏感信息扫描未发现真实完整 API key 或 secret,只命中测试假 key。

风险与注意

  • CLIProxyAPI config 同步是文件系统写入,不可能和 SQLite 做真正分布式事务;当前实现优先避免“Shop 已兑换但代理未放行”的半成功状态。
  • CLIPROXY_CONFIG_PATH 未配置时同步会禁用,生产需要显式配置真实 config.yaml 路径。
  • Admin 收银仍按真实账本 price_version 回放历史,不按最新价格重算历史扣费。

@cnYui

cnYui commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

客观 review 结论:无阻塞问题,可以合并。

检查项:

  • 范围聚焦在 Shop 账务时间口径、历史价格回放、CLIProxyAPI 兑换同步、Admin/Account 前端展示和配套测试。
  • 本地 npm test 通过:171/171。
  • 本地 npm run build:css 通过。
  • GitHub Actions validate 通过;PR 上 deploy 跳过属于预期。
  • git diff --check / git diff --cached --check 无输出。
  • 敏感信息扫描未发现真实完整 API key 或 secret,只命中测试假 key。

残余风险:CLIProxyAPI config 是文件系统写入,无法和 SQLite 做真正分布式事务;当前实现优先避免「Shop 已兑换但代理入口未同步」的半成功状态。

@cnYui cnYui merged commit 2f68b85 into main Jun 14, 2026
2 checks passed
@cnYui cnYui deleted the codex/shop-billing-pricing-sync-20260614 branch June 14, 2026 04:17
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