fix(trading+mining-app): 修复"全网兑换销毁量"显示为0的问题

根因:前端"全网兑换销毁量"读取的是circulationPool(流通池积分股),
但实际应该显示burn_records中source_type=SELL_BURN的销毁总量。
这是两个不同的概念:circulationPool是卖出交易进入流通的积分股,
而兑换销毁量是卖出时被销毁(进入黑洞)的积分股。

修复:
- 后端: BlackHoleRepository添加getTotalSellBurned()聚合查询
- 后端: asset.service.ts市场概览API新增totalSellBurned字段
- 前端: MarketOverview实体/Model新增totalSellBurned字段
- 前端: trading_page销毁明细弹窗改用totalSellBurned显示

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-26 09:52:10 -08:00
parent 74f061cfeb
commit edc81cc55d
5 changed files with 25 additions and 8 deletions

View File

@ -278,11 +278,8 @@ export class AssetService {
*
*
* - circulationPool: 价格公式中的流通池/
* - totalMined: 全网已挖矿产出的积分股总量+"流通池"
*
* "流通池" totalMined circulationPool
* circulationPool 0
* "流通池" totalMined
* - totalMined: 全网已挖矿产出的积分股总量+"已分配积分股"
* - totalSellBurned: 全网卖出交易产生的销毁总量burn_records中SELL_BURN的sum"全网兑换销毁量"
*/
async getMarketOverview(): Promise<{
price: string;
@ -290,17 +287,19 @@ export class AssetService {
blackHoleAmount: string;
circulationPool: string;
totalMined: string;
totalSellBurned: string;
effectiveDenominator: string;
burnMultiplier: string;
totalShares: string;
burnTarget: string;
burnProgress: string;
}> {
const [greenPoints, blackHole, circulationPool, totalMined] = await Promise.all([
const [greenPoints, blackHole, circulationPool, totalMined, totalSellBurned] = await Promise.all([
this.getGreenPoints(),
this.blackHoleRepository.getBlackHole(),
this.circulationPoolRepository.getPool(),
this.getTotalMinedFromMiningService(),
this.blackHoleRepository.getTotalSellBurned(),
]);
const blackHoleAmount = blackHole?.totalBurned || Money.zero();
const circulationPoolAmount = circulationPool?.totalShares || Money.zero();
@ -330,6 +329,7 @@ export class AssetService {
blackHoleAmount: blackHoleAmount.toFixed(8),
circulationPool: circulationPoolAmount.toFixed(8),
totalMined: totalMined.toFixed(8),
totalSellBurned: totalSellBurned.toFixed(8),
effectiveDenominator: effectiveDenominator.toFixed(8),
burnMultiplier: burnMultiplier.toFixed(18),
totalShares: TradingCalculatorService.TOTAL_SHARES.toFixed(8),

View File

@ -149,6 +149,17 @@ export class BlackHoleRepository {
};
}
/**
*
*/
async getTotalSellBurned(): Promise<Money> {
const result = await this.prisma.burnRecord.aggregate({
where: { sourceType: 'SELL_BURN' },
_sum: { burnAmount: true },
});
return new Money(result._sum.burnAmount || 0);
}
async getTodayBurnAmount(): Promise<Money> {
const today = new Date();
today.setHours(0, 0, 0, 0);

View File

@ -7,6 +7,7 @@ class MarketOverviewModel extends MarketOverview {
required super.blackHoleAmount,
required super.circulationPool,
required super.totalMined,
required super.totalSellBurned,
required super.effectiveDenominator,
required super.burnMultiplier,
required super.totalShares,
@ -21,6 +22,7 @@ class MarketOverviewModel extends MarketOverview {
blackHoleAmount: json['blackHoleAmount']?.toString() ?? '0',
circulationPool: json['circulationPool']?.toString() ?? '0',
totalMined: json['totalMined']?.toString() ?? '0',
totalSellBurned: json['totalSellBurned']?.toString() ?? '0',
effectiveDenominator: json['effectiveDenominator']?.toString() ?? '0',
burnMultiplier: json['burnMultiplier']?.toString() ?? '0',
totalShares: json['totalShares']?.toString() ?? '0',

View File

@ -10,8 +10,10 @@ class MarketOverview extends Equatable {
final String blackHoleAmount;
///
final String circulationPool;
/// +"流通池"
/// +"已分配积分股"
final String totalMined;
///
final String totalSellBurned;
///
final String effectiveDenominator;
///
@ -29,6 +31,7 @@ class MarketOverview extends Equatable {
required this.blackHoleAmount,
required this.circulationPool,
required this.totalMined,
required this.totalSellBurned,
required this.effectiveDenominator,
required this.burnMultiplier,
required this.totalShares,
@ -43,6 +46,7 @@ class MarketOverview extends Equatable {
blackHoleAmount,
circulationPool,
totalMined,
totalSellBurned,
effectiveDenominator,
burnMultiplier,
totalShares,

View File

@ -459,7 +459,7 @@ class _TradingPageState extends ConsumerState<TradingPage> {
children: [
_buildBurnDetailRow('系统总销毁量', formatIntWithCommas(market.blackHoleAmount), darkText, grayText),
const SizedBox(height: 16),
_buildBurnDetailRow('全网兑换销毁量', formatIntWithCommas(market.circulationPool), darkText, grayText),
_buildBurnDetailRow('全网兑换销毁量', formatIntWithCommas(market.totalSellBurned), darkText, grayText),
],
),
actions: [