Skip to content

refactor(billing): 将旧支付配置隔离到整数额度报价边界 - #776

Closed
LIghtJUNction wants to merge 1 commit into
wip/rust-core-go-extensionsfrom
refactor/credit-settlement-boundary
Closed

LIghtJUNction wants to merge 1 commit into
wip/rust-core-go-extensionsfrom
refactor/credit-settlement-boundary

Conversation

@LIghtJUNction

@LIghtJUNction LIghtJUNction commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

开发主线交接(2026-10-12)

开发默认主线现为 wip/rust-core-go-extensions;旧单体 main 与 traditional 冻结于 3948a0a1ee1cefdd016a7aa45a11851545bb4b85。分支交接不是发布、部署或验收通过。原问题、源码基线、测试与未完成项保留;旧单体路径仅作历史证据,后续先在微服务源码重新确认并按职责移植,不回灌旧数据库/权限/资金实现。

主线/S11 跟踪:#895。Extore 商品同步:#894,未验收,禁止部署,尤其禁止合并/推送 Extore main。

本 PR 原目标为旧单体 main,现转向微服务主线。只修改审查目标,尚未完成移植或验收,不可直接合并;须解决跨架构差异/冲突并完成本地验证,保留其他任务的改动。

LMM API Pull Request

变更说明 / Summary

资金单位技术债清理的第一项,不是整站资金验收完成声明。

基线:76ba342ce2af858d4c582f943f1b436edd00f790。
提交:3067ec13e0ea9808c0e4e8127bc2e284a525404d。

  • 将固定法币、旧直接报价和旧成对报价统一转换为精确的「结算单位 / 整数钱包额度」。旧单位只在配置适配函数中参与换算,计算部分不读取旧请求单位、展示设置或优惠设置。
  • 报价与向上取整共用同一个只读价格对象,避免提前舍入循环小数。输入和返回值不能反向修改已构造的价格。
  • 保留原有网关配置校验、非 1 兼容比例、96 位小数报价接口、金额取整规则和合法优惠。没有引入 Fix FX conversion for platform-credit top-ups #754 的固定为 1 修改。
  • 现有 settlement_test.go 保持不变。没有修改账本、数据库、充值记录、退款或发布工作流。

与上游的关系 / Upstream relationship

  • LMM API 独有变更 / LMM API-specific change

关联 Issue / Related issue

关联 #754 的单位清理审查,不关闭 #754,也不声称本 PR 解决 #703、#748 或 #753。

变更类型 / Type of change

  • 重构或性能优化 / Refactor or performance

验证 / Verification

实际执行环境:Go 1.23.2,隔离目录,直接编译下列两个生产/测试文件;没有第三方替代实现或业务桩。它不是仓库要求的 Go 1.25.1 全量构建。

在 apps/api-go/pkg/paymentpricing 的对应源码目录执行:

GOTOOLCHAIN=local GO111MODULE=off go test -race -count=1 -v credit_rate.go credit_rate_test.go
GOTOOLCHAIN=local GO111MODULE=off GOMAXPROCS=2 go test -parallel 2 -fuzz '^FuzzCreditRateExactMinor$' -fuzztime=5s credit_rate.go credit_rate_test.go
GOTOOLCHAIN=local GO111MODULE=off go vet credit_rate.go credit_rate_test.go

以上三项退出码均为 0。覆盖金额边界、微小余数、不可变性、并发读取、溢出和无效输入。Fuzz 是算术检查,不是支付、数据库或业务流程覆盖率。

合成基础报价对账(不含优惠,不是实际到账)

场景 整数额度 结算额 向上取整后的百分之一结算单位
USD 500000 1 USD 100
CNY,测试汇率 6.8 500000 6.8 CNY 680
CNY,测试汇率 7.25 500000 7.25 CNY 725
自定义直接 LDC 报价 750000 15 LDC 1500
非 1 历史比例算术样本 3400000 1 结算单位 100
单个额度 1 0.000002 USD 1

历史比例样本不表示当前生产启动允许该配置。

未完成的合并门槛

  • 在 Go 1.25.1 完整仓库执行 paymentpricing 全包测试,包括配置适配函数和原有回归。
  • 完整 controller/model 回归及隔离 PostgreSQL/SQLite 对账。
  • 模拟付款回调、退款、迟到/重复回调与并发验收。
  • 全量 go test / go vet 和来源匹配的发布测试证据。

本地不能解析 GitHub,无法取得完整仓库和依赖。仓库已明确要求所有工作流只允许手动触发;本 PR 没有绕过该规则来开启自动 CI。保持 Draft,不合并、不部署、不发版。

截图或日志 / Screenshots or logs

无 UI 变更。测试文件已经在提交中;本地日志与源码摘要另行记录。已核对远端 credit_rate.go 与 credit_rate_test.go 的 blob SHA,和本地实际测试文件一致。

提交检查 / Checklist

  • 已检索相关开放 PR,并核对 Fix FX conversion for platform-credit top-ups #754。
  • 只包含当前金额计算边界及其测试,无无关格式化。
  • 保留原有兼容配置、优惠政策和测试。
  • 明确区分实际通过的独立计算测试和未执行的整站验收。
  • 不包含密钥、生产数据或未脱敏日志。
  • 完整兼容性与资金验收通过后才能转为可合并状态。

… calculation

Keep legacy provider configuration at one adapter boundary. Quote and exact
minor-unit rounding share an immutable rational rate over wallet credits.
Preserve configured custom rates, promotions and the 96-place quote API.

Standalone production calculator race, fuzz and vet checks passed. Full Go,
controller, isolated database and callback regressions are still required.
No workflow, production, balance migration or release changes.
@LIghtJUNction
LIghtJUNction marked this pull request as ready for review October 11, 2026 12:24
Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-11T12:35:42.772744Z 3067ec1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LIghtJUNction

Copy link
Copy Markdown
Member Author

本轮只读去重核对,基准 main de2c439f26446792d4a605b2b91fa2b84777e284;不因标题相似就关闭财务 PR,也不将已有定向验证当成完整资格。

目前未确认可直接去重整个财务 PR 的候选。完整相关 Go / relaykit 资格,#774 的独立 PostgreSQL 并发与失败回滚,以及各替代方案的实际集成仍应分别记录。主分支的 #756 / #757 也没有因此解除。

本轮没有资金操作、生产库访问、合并、发布或部署;没有触发/重跑日常 CI。部分 PR 的 Draft/Ready 状态在核对期间由其他工作更新,后续动作须再次读回其确切 head,不能沿用第一次列表。

@LIghtJUNction

Copy link
Copy Markdown
Member Author

根据开发主线交接策略,旧单体 main / traditional 已冻结,相关财务/计费/测试/工具逻辑已由 wip/rust-core-go-extensions 对应微服务组件承接。关闭旧单体历史 PR,避免堆积。

@LIghtJUNction
LIghtJUNction deleted the refactor/credit-settlement-boundary branch November 5, 2026 07:31
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.

2 participants