Skip to content

fix: preserve negative balances in account displays - #531

Merged
chenyme merged 1 commit into
devfrom
billing
Jul 28, 2026
Merged

fix: preserve negative balances in account displays#531
chenyme merged 1 commit into
devfrom
billing

Conversation

@chenyme

@chenyme chenyme commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

修复负余额在订阅页面和后台账户管理中错误显示为 0 的问题。

后端账户余额响应现在保留负数;前端使用独立的余额格式化逻辑展示正负余额,并在后台账户列表中遵循管理员配置的 USD/CNY 展示货币。管理员仍不能主动设置负余额,但可以正常编辑已有负余额用户的其他资料。

同时精简账户页的计费配置请求,避免无关的模型或定价接口失败影响余额币种展示。

Fixes #518

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd frontend && pnpm lint
  • cd frontend && pnpm typecheck
  • cd backend && go test ./internal/transport/http/billing
  • pnpm api:check
  • git diff --check
  • Not run; reason: pnpm build 未运行,本次已完成聚焦静态检查与后端测试。

Screenshots, API examples, or logs

负余额现在会按照配置的展示货币正确呈现,例如:

-$1.250000
-¥9.000000

Configuration, migration, and compatibility notes

  • 无数据库迁移或配置项变更。
  • API 字段结构保持不变,仅修正 balanceUSD 将负余额错误归零的响应语义。
  • 管理员余额写入接口仍以 USD 为单位,并继续拒绝设置负余额。
  • 编辑和批量余额输入已明确标注为 USD,避免与 CNY 只读展示混淆。
  • Swagger 与生成的 TypeScript API 契约无需更新。

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including billing balance reads and admin balance updates.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Jul 28, 2026
@chenyme
chenyme merged commit d5f5742 into dev Jul 28, 2026
11 checks passed
@chenyme
chenyme deleted the billing branch July 28, 2026 07:10
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.

[Bug]: 余额为负数时订阅界面与后台账户管理列表的余额显示为 0

1 participant