From 702fa937e87cffd78ee641328e55406d294e9d9b Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 21 Jan 2026 21:29:34 -0800 Subject: [PATCH] =?UTF-8?q?fix(batch-mining):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E5=88=92=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - preMineDays 是该批次加入后挖矿的天数,不是差值 - 批次1的preMineDays=3 → 批次1先独挖3天 - 批次2的preMineDays=2 → 批次1+2一起挖2天 - 批次3的preMineDays=1 → 批次1+2+3一起挖1天 - 最后所有批次一起挖剩余天数 Co-Authored-By: Claude Opus 4.5 --- .../services/batch-mining.service.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 50697f45..69a3ddf6 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 @@ -307,14 +307,16 @@ export class BatchMiningService { * 根据批次的"提前天数"构建各挖矿阶段: * - preMineDays 表示该批次比下一批次提前开始的天数 * - 批次1的 preMineDays=3 意味着批次1比批次2提前3天 - * - 批次2的 preMineDays=2 意味着批次2比批次3提前2天 - * - 批次3的 preMineDays=1 意味着批次3比批次4提前1天 + * - 批次1的 preMineDays=3 意味着批次1先独挖3天 + * - 批次2的 preMineDays=2 意味着批次1+2一起挖2天 + * - 批次3的 preMineDays=1 意味着批次1+2+3一起挖1天 * * 阶段划分: - * - 阶段1: 只有批次1,持续 (批次1的preMineDays - 批次2的preMineDays) 天 - * - 阶段2: 批次1+2,持续 (批次2的preMineDays - 批次3的preMineDays) 天 + * - 阶段1: 只有批次1,持续 preMineDays 天 + * - 阶段2: 批次1+2,持续 preMineDays 天 + * - 阶段3: 批次1+2+3,持续 preMineDays 天 * - ... - * - 最后阶段: 所有批次一起挖 (totalMiningDays - 提前天数的总和) + * - 最后阶段: 所有批次一起挖 (totalMiningDays - 所有提前天数之和) */ private buildMiningPhases( items: BatchMiningItem[], @@ -343,8 +345,6 @@ export class BatchMiningService { this.logger.log(`[buildMiningPhases] 各批次提前天数: ${JSON.stringify(Object.fromEntries(batchPreMineDays))}`); this.logger.log(`[buildMiningPhases] 最大总挖矿天数: ${maxTotalMiningDays}`); - // 获取第一批次的提前天数 - const firstBatchPreMineDays = batchPreMineDays.get(sortedBatches[0]) || 0; if (maxTotalMiningDays <= 0) { this.logger.warn('[buildMiningPhases] 总挖矿天数<=0,无法计算'); return phases; @@ -355,17 +355,16 @@ export class BatchMiningService { let usedDays = 0; // 已分配的天数 // 按批次顺序添加阶段(提前挖矿阶段) + // 每个批次加入后,挖该批次的 preMineDays 天 for (let i = 0; i < sortedBatches.length; i++) { const currentBatch = sortedBatches[i]; const currentPreMineDays = batchPreMineDays.get(currentBatch) || 0; - const nextBatch = sortedBatches[i + 1]; - const nextPreMineDays = nextBatch !== undefined ? (batchPreMineDays.get(nextBatch) || 0) : 0; // 当前批次加入挖矿 participatingBatches.push(currentBatch); - // 计算当前阶段持续的天数 = 当前批次提前天数 - 下一批次提前天数 - const phaseDays = currentPreMineDays - nextPreMineDays; + // 该阶段持续天数 = 当前批次的提前天数 + const phaseDays = currentPreMineDays; if (phaseDays > 0) { // 计算该阶段参与用户的算力