Skip to content

fix: model pricing use correct display type - #4426

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/86489c09a85b2b3c6e4c27f3fdeda866258c19f4
Apr 24, 2026
Merged

fix: model pricing use correct display type#4426
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/86489c09a85b2b3c6e4c27f3fdeda866258c19f4

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Apr 24, 2026

Copy link
Copy Markdown
Member

提交说明 / PR Notice

修复模型广场 动态计费未按设置的展示单位显示的问题

变更描述 / Description

获取后台设置的展示单位进行正确的显示

运行证明 / Proof of Work

修改前:
image

修改后:
image

image

Summary by CodeRabbit

  • New Features
    • Pricing displays now support multiple currencies with dynamic exchange rate conversion based on configuration.
    • Pricing values are properly formatted and converted according to the selected currency and exchange rate settings.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update currency formatting logic across two components to dynamically derive display configurations from a centralized source instead of using fixed values. The tier price column header and price values now reflect configured currency symbols and exchange rates read from localStorage, with values appropriately scaled before display.

Changes

Cohort / File(s) Summary
Dynamic Currency Configuration
web/src/components/table/model-pricing/modal/components/DynamicPricingBreakdown.jsx, web/src/helpers/utils.jsx
Both files updated to source currency formatting from configuration instead of fixed values. Tier prices are now scaled by configured exchange rates and formatted with configured currency symbols. Helper function reads quota_display_type from localStorage to determine symbol and rate for CNY, CUSTOM, or default currency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • seefs001

Poem

🐰 Hop, hop—the symbols dance and sway,
Exchange rates now guide the way,
No more locked to dollars' song,
Currency config rights the wrong,
From localStorage we take our cue,
Dynamic prices, fresh and true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: model pricing use correct display type' directly aligns with the PR's objective to fix an issue where model marketplace dynamic pricing was not displayed using the configured display unit.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
web/src/helpers/utils.jsx (1)

903-915: Replace the inlined currency config with getCurrencyConfig().

This block duplicates getCurrencyConfig() defined in web/src/helpers/render.jsx (lines 1102-1128), which is already exported from the helpers barrel and consumed elsewhere (e.g., DynamicPricingBreakdown.jsx after this PR). Reusing the helper avoids drift if fallback rules (e.g., CNY default rate of 7, custom symbol ¤) change later.

♻️ Proposed refactor
-  const quotaDisplayType = localStorage.getItem('quota_display_type') || 'USD';
-  let symbol = '$';
-  let rate = 1;
-  try {
-    const s = JSON.parse(localStorage.getItem('status') || '{}');
-    if (quotaDisplayType === 'CNY') {
-      symbol = '¥';
-      rate = s?.usd_exchange_rate || 7;
-    } else if (quotaDisplayType === 'CUSTOM') {
-      symbol = s?.custom_currency_symbol || '¤';
-      rate = s?.custom_currency_exchange_rate || 1;
-    }
-  } catch (e) {}
+  const { symbol, rate } = getCurrencyConfig();

Add the import at the top of the file:

-import { Toast, Pagination } from '@douyinfe/semi-ui';
+import { Toast, Pagination } from '@douyinfe/semi-ui';
+import { getCurrencyConfig } from './render';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/helpers/utils.jsx` around lines 903 - 915, Replace the inlined
currency config block that computes quotaDisplayType, symbol and rate with a
call to the shared helper getCurrencyConfig(): remove the
JSON.parse/localStorage logic and use getCurrencyConfig(quotaDisplayType) to
obtain symbol and rate (preserving the existing quotaDisplayType retrieval), and
add the import for getCurrencyConfig from the helpers barrel (the function is
defined in render.jsx as getCurrencyConfig); ensure variables quotaDisplayType,
symbol and rate are set from the helper's return so fallback rules (CNY default
rate 7, custom symbol ¤, etc.) come from the centralized implementation.
web/src/components/table/model-pricing/modal/components/DynamicPricingBreakdown.jsx (1)

134-136: Optional: reuse convertUSDToCurrency helper for the cell render.

The render expression ${symbol}${(v * rate).toFixed(4)} on Line 136 is exactly what convertUSDToCurrency(v, 4) returns (see web/src/helpers/render.jsx:1136-1140). The column title still needs the raw symbol, so keeping getCurrencyConfig() above is fine — but the cell renderer could delegate for consistency with the rest of the codebase.

♻️ Proposed refactor
-import { parseTiersFromExpr, getCurrencyConfig } from '../../../../../helpers';
+import { parseTiersFromExpr, getCurrencyConfig, convertUSDToCurrency } from '../../../../../helpers';
@@
-  const { symbol, rate } = getCurrencyConfig();
+  const { symbol } = getCurrencyConfig();
@@
         title: `${t(label)} (${symbol}/1M tokens)`,
         dataIndex: field,
-        render: (v) => v > 0 ? <Text strong>{`${symbol}${(v * rate).toFixed(4)}`}</Text> : '-',
+        render: (v) => v > 0 ? <Text strong>{convertUSDToCurrency(v, 4)}</Text> : '-',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/components/table/model-pricing/modal/components/DynamicPricingBreakdown.jsx`
around lines 134 - 136, The cell renderer is duplicating currency formatting;
replace the inline template `${symbol}${(v * rate).toFixed(4)}` with the
existing helper convertUSDToCurrency so formatting is consistent with the app.
In the DynamicPricingBreakdown column definition (where getCurrencyConfig()
supplies symbol and rate), call convertUSDToCurrency(v, 4) inside the render
function (keeping the title using symbol unchanged) and return '-' when v <= 0
to preserve existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@web/src/components/table/model-pricing/modal/components/DynamicPricingBreakdown.jsx`:
- Around line 134-136: The cell renderer is duplicating currency formatting;
replace the inline template `${symbol}${(v * rate).toFixed(4)}` with the
existing helper convertUSDToCurrency so formatting is consistent with the app.
In the DynamicPricingBreakdown column definition (where getCurrencyConfig()
supplies symbol and rate), call convertUSDToCurrency(v, 4) inside the render
function (keeping the title using symbol unchanged) and return '-' when v <= 0
to preserve existing behavior.

In `@web/src/helpers/utils.jsx`:
- Around line 903-915: Replace the inlined currency config block that computes
quotaDisplayType, symbol and rate with a call to the shared helper
getCurrencyConfig(): remove the JSON.parse/localStorage logic and use
getCurrencyConfig(quotaDisplayType) to obtain symbol and rate (preserving the
existing quotaDisplayType retrieval), and add the import for getCurrencyConfig
from the helpers barrel (the function is defined in render.jsx as
getCurrencyConfig); ensure variables quotaDisplayType, symbol and rate are set
from the helper's return so fallback rules (CNY default rate 7, custom symbol ¤,
etc.) come from the centralized implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4c44840-89c9-44f1-90d6-d5f14ab5eadb

📥 Commits

Reviewing files that changed from the base of the PR and between 65b1654 and 63ce2db.

📒 Files selected for processing (2)
  • web/src/components/table/model-pricing/modal/components/DynamicPricingBreakdown.jsx
  • web/src/helpers/utils.jsx

@Calcium-Ion
Calcium-Ion merged commit 2e610e5 into QuantumNous:main Apr 24, 2026
2 checks passed
Jinxuans referenced this pull request in TokFlux-Org/TokFlux May 9, 2026
…fdeda866258c19f4

fix: model pricing use correct display type
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.

2 participants