From 0adc4c8c264c29a3f7668089db9a5d79a7cd54e8 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 21 Jan 2026 23:37:35 -0800 Subject: [PATCH] =?UTF-8?q?fix(batch-mining):=20=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E6=89=B9=E6=AC=A1preMineDays=3D0=E6=97=B6=E6=94=B9=E4=B8=BA1?= =?UTF-8?q?=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最后一个批次即使 preMineDays=0,也要算1天(所有人一起挖1天生成收益) Co-Authored-By: Claude Opus 4.5 --- .../src/application/services/batch-mining.service.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 5edf8deb..d8bb34e4 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 @@ -392,14 +392,21 @@ export class BatchMiningService { // 阶段1: 只有第一批,分配第一批的 preMineDays 天 // 阶段2: 第一批+第二批,分配第二批的 preMineDays 天 // 阶段3: 第一批+第二批+第三批,分配第三批的 preMineDays 天 - // ...依次类推,总天数 = 所有 preMineDays 之和 + // ...依次类推 + // 最后一个批次即使 preMineDays=0,也要算1天(所有人一起挖1天) for (let i = 0; i < sortedBatches.length; i++) { const currentBatch = sortedBatches[i]; - const currentPreMineDays = batchPreMineDays.get(currentBatch) || 0; + let currentPreMineDays = batchPreMineDays.get(currentBatch) || 0; // 当前批次加入参与列表 participatingBatches.push(currentBatch); + // 最后一个批次如果 preMineDays=0,改为1天 + const isLastBatch = i === sortedBatches.length - 1; + if (isLastBatch && currentPreMineDays === 0) { + currentPreMineDays = 1; + } + // 该阶段持续天数 = 当前批次的 preMineDays if (currentPreMineDays > 0) { // 计算该阶段参与用户的总算力