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:
parent
74f061cfeb
commit
edc81cc55d
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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: [
|
||||
|
|
|
|||
Loading…
Reference in New Issue