diff --git a/backend/services/mining-service/src/application/services/batch-mining.service.ts b/backend/services/mining-service/src/application/services/batch-mining.service.ts index 803fdbdc..b13d1297 100644 --- a/backend/services/mining-service/src/application/services/batch-mining.service.ts +++ b/backend/services/mining-service/src/application/services/batch-mining.service.ts @@ -273,7 +273,6 @@ export class BatchMiningService { } // 构建返回结果 - let grandTotalAmount = new Decimal(0); const batchResults: BatchMiningPreviewResult['batches'] = []; // 计算用户总算力(用于显示) @@ -283,6 +282,17 @@ export class BatchMiningService { } this.logger.log(`[preview] 用户总算力: ${totalUserContribution.toFixed(2)}`); + // 计算 grandTotalAmount:所有用户的收益总和(去重) + let grandTotalAmount = new Decimal(0); + const processedUsers = new Set(); + for (const [accountSequence, amount] of userAmounts) { + if (!processedUsers.has(accountSequence)) { + processedUsers.add(accountSequence); + grandTotalAmount = grandTotalAmount.plus(amount); + } + } + this.logger.log(`[preview] 计算的总金额: ${grandTotalAmount.toFixed(8)} (${processedUsers.size}个用户)`); + for (const batchNum of sortedBatches) { const batchItems = batchGroups.get(batchNum)!; const batchContribution = batchContributions.get(batchNum)!; @@ -330,8 +340,6 @@ export class BatchMiningService { cumulativeNetworkContribution: cumulativeContribution.toFixed(10), batchTotalAmount: batchTotalAmount.toFixed(8), }); - - grandTotalAmount = grandTotalAmount.plus(batchTotalAmount); } const result = {