fix billing refund consistency - #6066
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
WalkthroughThe changes add subscription plan group matching, make subscription refunds transaction-scoped, support clamped used-quota decrements for users and channels, correct task refund accounting, widen channel group storage, and skip estimated usage for abnormal streams without usage data. ChangesSubscription billing
Quota accounting
Text quota settlement
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant TaskBilling
participant UserModel
participant ChannelModel
participant Database
TaskBilling->>UserModel: DecreaseUserUsedQuota(refund)
UserModel->>Database: decrement used_quota with zero floor
TaskBilling->>ChannelModel: DecreaseChannelUsedQuota(refund)
ChannelModel->>Database: decrement used_quota with zero floor
sequenceDiagram
participant Relay
participant TextQuota
participant Billing
Relay->>TextQuota: provide stream status and missing usage
TextQuota->>TextQuota: detect abnormal stream ending
TextQuota->>Billing: settle without estimated usage
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Closing this combined PR in favor of smaller one-issue PRs, as requested. I will reopen the changes as separate PRs for each linked issue. |
|
Hi @cat0825, thanks for working on these fixes and for splitting the combined PR into focused changes. The |
Important
📝 变更描述 / Description
修复几处计费、退款和订阅隔离问题:
user_subscriptions.amount_used并标记subscription_pre_consume_records为 refunded,避免额度已回退但记录状态更新失败后重试导致重复退款。upgrade_group的订阅计划只覆盖同分组请求,避免跨分组模型错误扣订阅额度。used_quota,避免退款后“剩余额度 + 已用额度”虚增。channels.group扩到varchar(1024),避免多分组渠道保存失败或升级时被迁移回 64 字符。This PR was AI-assisted and manually reviewed before submission.
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Additional check:
Summary by CodeRabbit
New Features
Bug Fixes
Tests