Repository navigation
Conversation
…mount Consolidate top-up quota calculation into (*TopUp).creditedQuota() shared by ManualCompleteTopUp and provider callbacks so Creem orders credit raw Amount without multiplying by QuotaPerUnit again, fail closed on ambiguous legacy ref_ orders, preserve legacy USR epay semantics, and reject non-finite or non-positive inputs before decimal conversion. Closes #8489
|
No actionable comments were generated in the recent review. WalkthroughTop-up quota conversion now uses a shared helper across provider settlement paths and manual completion. The helper validates provider-specific inputs and converted quota values. Tests cover legacy provider inference, invalid inputs, unchanged state on failures, and matching Creem callback and manual credits. ChangesTop-up quota handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: High Suggested reviewers: Merge Risk:
|
🔗 关联任务 / Related Issue
🚀 变更类型 / Type of change
📝 变更描述 / Description
修复管理员补单
ManualCompleteTopUp对 Creem 订单重复乘以common.QuotaPerUnit导致入账额度放大 500,000 倍的问题:model/topup.go:将所有充值渠道的应入账额度换算收敛到(*TopUp).creditedQuota() (int, error),由ManualCompleteTopUp与 5 个Recharge*回调共用,统一经common.WalletQuotaFromDecimalStrict转换并校验> 0。creem直接使用Amount(下单时已存最终额度);stripe使用Money * quotaPerUnit;epay/waffo/waffo_pancake使用Amount * quotaPerUnit。PaymentProvider == ""订单仅在TradeNo以ref_开头时按PaymentMethod区分 Creem/Stripe;ref_且PaymentMethod也为空的歧义旧单拒绝自动换算(返回ErrInvalidTopUpQuota并保持 pending);非ref_的历史 Epay(USR...)即便带有自定义stripe/creemmethod 仍保持Amount * quotaPerUnit。decimal.NewFromFloat前校验局部变量quotaPerUnit与Money为有限正数,避免NaN/Infpanic 或负负得正。📸 运行证明 / Proof of Work
在
model/payment_method_guard_test.go新增TestManualCompleteTopUpCreditsProviderQuota(16 组用例)、TestTopUpCreditedQuotaRejectsNonFiniteStripeMoney与TestRechargeCreemAndManualCompletionCreditSameQuota,覆盖 Creem 补单与回调一致(500000 仅入账 500000)、Stripe/Epay/Waffo 正常换算、历史ref_歧义单拒绝、USR...Epay 冲突兼容、超上限与非有限/负数拦截。注:本次未修改表结构、SQL 或行锁,仅在默认 SQLite 测试库运行单测,未在 MySQL/PostgreSQL 实例上重跑。
✅ 提交前检查项 / Checklist
go build通过或测试通过,不视为有效证明。Summary by CodeRabbit