diff --git a/backend/services/trading-service/src/application/services/asset.service.ts b/backend/services/trading-service/src/application/services/asset.service.ts index fb17ae4b..ea9e5283 100644 --- a/backend/services/trading-service/src/application/services/asset.service.ts +++ b/backend/services/trading-service/src/application/services/asset.service.ts @@ -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), diff --git a/backend/services/trading-service/src/infrastructure/persistence/repositories/black-hole.repository.ts b/backend/services/trading-service/src/infrastructure/persistence/repositories/black-hole.repository.ts index 32e25ab3..c315a93a 100644 --- a/backend/services/trading-service/src/infrastructure/persistence/repositories/black-hole.repository.ts +++ b/backend/services/trading-service/src/infrastructure/persistence/repositories/black-hole.repository.ts @@ -149,6 +149,17 @@ export class BlackHoleRepository { }; } + /** + * 获取全网卖出销毁总量 + */ + async getTotalSellBurned(): Promise { + const result = await this.prisma.burnRecord.aggregate({ + where: { sourceType: 'SELL_BURN' }, + _sum: { burnAmount: true }, + }); + return new Money(result._sum.burnAmount || 0); + } + async getTodayBurnAmount(): Promise { const today = new Date(); today.setHours(0, 0, 0, 0); diff --git a/frontend/mining-app/lib/data/models/market_overview_model.dart b/frontend/mining-app/lib/data/models/market_overview_model.dart index 117538b6..4e30b0ce 100644 --- a/frontend/mining-app/lib/data/models/market_overview_model.dart +++ b/frontend/mining-app/lib/data/models/market_overview_model.dart @@ -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', diff --git a/frontend/mining-app/lib/domain/entities/market_overview.dart b/frontend/mining-app/lib/domain/entities/market_overview.dart index 0cc9b8f4..609b8e77 100644 --- a/frontend/mining-app/lib/domain/entities/market_overview.dart +++ b/frontend/mining-app/lib/domain/entities/market_overview.dart @@ -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, diff --git a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart index affa49c5..db984f1f 100644 --- a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart +++ b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart @@ -459,7 +459,7 @@ class _TradingPageState extends ConsumerState { children: [ _buildBurnDetailRow('系统总销毁量', formatIntWithCommas(market.blackHoleAmount), darkText, grayText), const SizedBox(height: 16), - _buildBurnDetailRow('全网兑换销毁量', formatIntWithCommas(market.circulationPool), darkText, grayText), + _buildBurnDetailRow('全网兑换销毁量', formatIntWithCommas(market.totalSellBurned), darkText, grayText), ], ), actions: [