fix(batch-mining): 修正阶段划分逻辑

- 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 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-21 21:29:34 -08:00
parent 8b8d1f7d16
commit 702fa937e8
1 changed files with 10 additions and 11 deletions

View File

@ -307,14 +307,16 @@ export class BatchMiningService {
* "提前天数"
* - preMineDays
* - 1 preMineDays=3 123
* - 2 preMineDays=2 232
* - 3 preMineDays=1 341
* - 1 preMineDays=3 13
* - 2 preMineDays=2 1+22
* - 3 preMineDays=1 1+2+31
*
*
* - 阶段1: 只有批次1 (1preMineDays - 2preMineDays)
* - 阶段2: 批次1+2 (2preMineDays - 3preMineDays)
* - 阶段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) {
// 计算该阶段参与用户的算力