fix(qoder): 额度按套餐+加量包+资源包求和,修复签到后额度不显示 - #231
Open
BrianBoyCN wants to merge 1 commit into
Open
BrianBoyCN wants to merge 1 commit into
BrianBoyCN wants to merge 1 commit into
Conversation
Qoder reports credits in up to three buckets: the plan's monthly user quota, the add-on pack, and an organization resource package. The account card read only the plan quota, so a plan-only account never moved after a daily check-in — the reward lands in the add-on bucket (issue caigee-cmd#229, "一直显示 300 积分,未增加过"), and a balance-only account with no plan quota showed a flat 0%. Sum the available buckets for the headline Used/Total/Remaining/Percentage, matching how the Qoder client itself totals them (its remaining is userQuota + addOnQuota + orgResourcePackage) and the upstream totalUsagePercentage, which is the same aggregate ratio. Per-bucket detail fields (has_add_on / add_on_* / has_resource_package / resource_package_*) are unchanged, and Exceeded keeps its meaning: an available add-on or package still keeps an exhausted plan routable. Refs caigee-cmd#229
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #229
概述
修复 Qoder(国内版/国际版)签到后额度不显示 / 一直停在 300 的问题(#229)。
根因
Qoder 上游把额度拆在最多三个桶里:套餐额度
userQuota、加量包addOnQuota、组织资源包orgResourcePackage。addOnQuota;internal/providers/qoder/quota.go的snapshot()只取userQuota作为卡片主数值。所以:套餐额度为 300 的账号签到后,主数字仍是 300(奖励在加量包里没被算进去)→ 就是 #229 说的「一直显示 300 积分,未增加过」;纯余额档(
personal_standard,上游userQuota全 0)则永远显示 0%。上游口径(本机实测,非猜测)
用一个真实 CN 账号核对,上游自己返回的百分比就是三桶合计:
并且 Qoder 客户端自身的合计逻辑也是三桶相加:
改动
snapshot()的 headline(Used/Total/Remaining/Percentage)改为可用桶之和,对齐上游口径:available === false的桶);has_add_on/add_on_*/has_resource_package/resource_package_*)保持不变,控制台 tooltip 照旧;Exceeded语义不变:套餐耗尽但加量包/资源包仍有可用额度时,账号仍可路由;nil(未知),不编造 0。纯后端改动,无前端/接口字段变更。
Test plan
go test ./...go vet ./...cd worker && npm testcd frontend && npm run build && npm run lintchangelog/unreleased/qoder-quota-sum-buckets.md另附:新增/更新单测覆盖「套餐+加量包求和」「纯余额档」「套餐耗尽但加量包可用」「资源包参与合计 / 不可用资源包被忽略」「无任何桶 → nil」;
go test -race ./...与gitleaks本地通过。