fix(trading): 修复卖出预估计算,加入销毁倍数

卖出预估计算现在使用与后端一致的公式:
- 有效积分股 = 卖出量 × (1 + burnMultiplier)
- 卖出交易额 = 有效积分股 × 价格 × 0.9

修复的位置:
1. _calculateEstimate() 方法 - 预计获得显示
2. _handleTrade() 确认弹窗 - 显示销毁倍数和有效积分股明细

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-19 04:10:32 -08:00
parent 6109bf4584
commit 7df57b9de5
1 changed files with 36 additions and 10 deletions

View File

@ -810,21 +810,32 @@ class _TradingPageState extends ConsumerState<TradingPage> {
);
}
/// /
/// = ( + ) × × 0.9
/// = × (1 + burnMultiplier) × × 0.9
String _calculateEstimate() {
final price = double.tryParse(_priceController.text) ?? 0;
final quantity = double.tryParse(_quantityController.text) ?? 0;
final total = price * quantity;
if (total == 0) {
if (price == 0 || quantity == 0) {
return '0.00 积分值';
}
if (_selectedTab == 1) {
// 10%
final afterBurn = total * 0.9;
return '${formatAmount(afterBurn.toString())} 积分值';
// = × (1 + burnMultiplier)
// = × × 0.910%
final marketAsync = ref.read(marketOverviewProvider);
final burnMultiplier = double.tryParse(
marketAsync.valueOrNull?.burnMultiplier ?? '0',
) ?? 0;
final effectiveQuantity = quantity * (1 + burnMultiplier);
final grossAmount = effectiveQuantity * price;
final netAmount = grossAmount * 0.9; // 10%
return '${formatAmount(netAmount.toString())} 积分值';
}
// = ×
final total = price * quantity;
return '${formatAmount(total.toString())} 积分值';
}
@ -1036,9 +1047,20 @@ class _TradingPageState extends ConsumerState<TradingPage> {
//
if (!isBuy) {
final total = price * quantity;
final burned = total * 0.1;
final received = total * 0.9;
// 使
final marketAsync = ref.read(marketOverviewProvider);
final burnMultiplier = double.tryParse(
marketAsync.valueOrNull?.burnMultiplier ?? '0',
) ?? 0;
// = × (1 + burnMultiplier)
final effectiveQuantity = quantity * (1 + burnMultiplier);
// = ×
final grossAmount = effectiveQuantity * price;
// = × 10%
final tradeFee = grossAmount * 0.1;
// = × 90%
final received = grossAmount * 0.9;
final confirmed = await showDialog<bool>(
context: context,
@ -1052,10 +1074,14 @@ class _TradingPageState extends ConsumerState<TradingPage> {
const SizedBox(height: 8),
Text('卖出价格: ${formatPrice(price.toString())} 积分值'),
const SizedBox(height: 8),
Text('交易总额: ${formatAmount(total.toString())} 积分值'),
Text('销毁倍数: ${burnMultiplier.toStringAsFixed(4)}'),
const SizedBox(height: 8),
Text('有效积分股: ${formatAmount(effectiveQuantity.toString())}'),
const SizedBox(height: 8),
Text('交易总额: ${formatAmount(grossAmount.toString())} 积分值'),
const SizedBox(height: 8),
Text(
'进入积分股池: ${formatAmount(burned.toString())} 积分值 (10%)',
'进入积分股池: ${formatAmount(tradeFee.toString())} 积分值 (10%)',
style: const TextStyle(color: _green),
),
const SizedBox(height: 8),