From d9d46065e07f43e949e75c315b5286308173f597 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 19 Jan 2026 04:26:21 -0800 Subject: [PATCH] =?UTF-8?q?fix(asset):=20=E6=80=BB=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E4=BC=B0=E5=80=BC=E5=8C=85=E5=90=AB=E7=A7=AF=E5=88=86=E5=80=BC?= =?UTF-8?q?=E4=BD=99=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 总资产估值 = 积分股价值 + 积分值余额 - 积分股价值 = 积分股 × (1 + burnMultiplier) × 价格 - 积分值余额 = 可用积分值 + 冻结积分值 之前只计算了积分股价值,现在加上了积分值(现金)余额。 Co-Authored-By: Claude Opus 4.5 --- .../presentation/pages/asset/asset_page.dart | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart b/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart index 5bbbafa2..d0d42d0c 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart @@ -117,15 +117,25 @@ class _AssetPageState extends ConsumerState { _timerStarted = false; } - /// 计算当前实时资产显示值 - /// 使用 WebSocket 推送的实时价格 - /// 资产显示值 = 当前积分股余额 × (1 + burnMultiplier) × price - double get _currentDisplayValue { + /// 计算当前实时总资产显示值 + /// 总资产 = 积分股价值 + 积分值余额 + /// 积分股价值 = 当前积分股余额 × (1 + burnMultiplier) × price + /// 积分值余额 = 可用积分值 + 冻结积分值 + double _calculateTotalAssetValue(AssetDisplay? asset) { // 优先使用 WebSocket 推送的价格,否则使用 API 返回的价格 final price = double.tryParse(_currentPrice) ?? 0; final burnMultiplier = double.tryParse(_currentBurnMultiplier) ?? 0; final multiplierFactor = 1 + burnMultiplier; - return _currentShareBalance * multiplierFactor * price; + + // 积分股价值 + final shareValue = _currentShareBalance * multiplierFactor * price; + + // 积分值余额(现金 = 可用 + 冻结) + final availableCash = double.tryParse(asset?.availableCash ?? '0') ?? 0; + final frozenCash = double.tryParse(asset?.frozenCash ?? '0') ?? 0; + final totalCash = availableCash + frozenCash; + + return shareValue + totalCash; } /// 计算当前实时积分股余额 @@ -210,7 +220,7 @@ class _AssetPageState extends ConsumerState { children: [ const SizedBox(height: 8), // 总资产卡片 - 始终显示,数字部分闪烁,实时刷新 - _buildTotalAssetCard(asset, isLoading, _currentDisplayValue, _currentShareBalance, perSecondEarning), + _buildTotalAssetCard(asset, isLoading, _calculateTotalAssetValue(asset), _currentShareBalance, perSecondEarning), const SizedBox(height: 24), // 快捷操作按钮 _buildQuickActions(context), @@ -255,13 +265,13 @@ class _AssetPageState extends ConsumerState { ); } - Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double currentDisplayValue, double currentShareBalance, String perSecondEarning) { + Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double totalAssetValue, double currentShareBalance, String perSecondEarning) { // 使用传入的每秒增长值(来自 mining-service) final growthPerSecond = double.tryParse(perSecondEarning) ?? 0.0; - // 使用实时计算的资产值(含倍数) - final displayValue = asset != null && currentDisplayValue > 0 - ? currentDisplayValue.toString() + // 使用实时计算的总资产值(积分股价值 + 积分值余额) + final displayValue = asset != null && totalAssetValue > 0 + ? totalAssetValue.toString() : asset?.displayAssetValue; // 计算有效积分股(含倍数)= 实时积分股余额 × (1 + burnMultiplier)