fix: keep subscription pre-consume refund atomic (#5556)#6089
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughSubscription refunds now reverse quota usage through the existing database transaction. The shared delta helper handles locking and validation, while tests verify one-time reversal, record status updates, and test-table cleanup. ChangesSubscription refund consistency
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@Calcium-Ion @t0ng7u 麻烦有空时 review 一下这个 PR。 范围:仅 #5556 — 订阅预扣退款在同一事务内回退 |
Important
📝 变更描述 / Description
将订阅预扣退款改为在同一数据库事务内回退 user_subscriptions.amount_used,并标记 subscription_pre_consume_records 为 refunded。原先在事务中调用 PostConsumeUserSubscriptionDelta 会新开事务,可能出现额度已退回但记录状态未更新,导致重试重复退款。
This PR was AI-assisted and manually reviewed before submission.
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit
Bug Fixes
Tests