fix(contribution-service): 预种算力除数从 5 改为 10,冻结阈值同步更新

- PRE_PLANTING_PORTION_DIVISOR: 5 → 10(每份算力 = 1棵树的 1/10)
- 冻结条件:totalPortions < 5 → < 10
- 解冻条件:totalPortions >= 5 → >= 10
- 同步更新所有相关注释和日志文案

注:2026-03-02 前已分配的份额算力记录(按 1/5 计算)不追溯修正。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-04 08:04:42 -08:00
parent 2b07219046
commit 94792f56ea
6 changed files with 27 additions and 22 deletions

View File

@ -26,7 +26,7 @@ import { PrePlantingCdcModule } from './pre-planting/pre-planting-cdc.module';
InfrastructureModule,
ApplicationModule,
ApiModule,
PrePlantingCdcModule, // 预种计划:独立 CDC consumer、独立 Prisma schema、1/5 算力、冻结调度
PrePlantingCdcModule, // 预种计划:独立 CDC consumer、独立 Prisma schema、1/10 算力、冻结调度
],
providers: [
{

View File

@ -25,7 +25,7 @@ export interface PrePlantingOrderSyncResult {
* 1. pre_planting_synced_orders
* 2. PAID
* 3. synced_adoptions marker getDirectReferralAdoptedCount
* 4. 1/5 PostCommitCallback
* 4. 1/10 PostCommitCallback
*
* === ===
* -

View File

@ -15,11 +15,11 @@ import {
* [2026-02-17] /
*
* === ===
* - firstPurchaseAt + 1 5 totalPortions < 5
* - firstPurchaseAt + 1 10 totalPortions < 10
* - expiredis_expired=true
*
* === ===
* - 5 totalPortions >= 5
* - 10 totalPortions >= 10
* - = + 2
*
* === ===
@ -77,7 +77,7 @@ export class PrePlantingFreezeScheduler {
}
/**
* firstPurchaseAt + 1 5
* firstPurchaseAt + 1 10
*/
private async processFreezes(now: Date): Promise<number> {
const freezeDeadline = new Date(now);
@ -86,7 +86,7 @@ export class PrePlantingFreezeScheduler {
const candidates = await this.prePlantingPrisma.prePlantingFreezeState.findMany({
where: {
firstPurchaseAt: { lte: freezeDeadline },
totalPortions: { lt: 5 },
totalPortions: { lt: 10 },
isFrozen: false,
},
take: 100,
@ -122,13 +122,13 @@ export class PrePlantingFreezeScheduler {
}
/**
* 5
* 10
*/
private async processUnfreezes(now: Date): Promise<number> {
const candidates = await this.prePlantingPrisma.prePlantingFreezeState.findMany({
where: {
isFrozen: true,
totalPortions: { gte: 5 },
totalPortions: { gte: 10 },
},
take: 100,
});

View File

@ -40,10 +40,11 @@ export interface PrePlantingMergeSyncResult {
/**
*
*
* [2026-02-17] 1/5
* [2026-02-17] 1/10
* [2026-03-04] 51101 rate/5 rate/10
*
* === ===
* - SyncedAdoption treeCount=portionCount, contributionPerTree=rate/5
* - SyncedAdoption treeCount=portionCount, contributionPerTree=rate/10
* - ContributionCalculatorService
* - contribution_accounts/contribution_records
* - 使 PRE_PLANTING_SOURCE_ID_OFFSET (10B) ID
@ -103,7 +104,7 @@ export class PrePlantingContributionService {
return;
}
// 获取当日每棵树贡献值(预种份额 = 1/5
// 获取当日每棵树贡献值(预种份额 = 1/1010份合1棵树
const adoptionDate = order.paidAt || order.createdAt;
let contributionPerTree = new Decimal('22617');
try {
@ -123,7 +124,7 @@ export class PrePlantingContributionService {
status: 'MINING_ENABLED',
selectedProvince: order.provinceCode,
selectedCity: order.cityCode,
contributionPerTree: contributionPerPortion, // 1/5 贡献值
contributionPerTree: contributionPerPortion, // 1/10 贡献值
sourceSequenceNum: BigInt(0),
syncedAt: new Date(),
contributionDistributed: false,
@ -557,10 +558,11 @@ export class PrePlantingContributionService {
/**
*
*
* [2026-02-28] 51mining_enabled_at
* [2026-02-28] 1mining_enabled_at
* [2026-03-04] 5 10
*
* === ===
* 1. 5is_expired=trueremark
* 1. is_expired=trueremark
* 2.
* 3. 1remark
* 4. saveDistributionResult 0=
@ -574,7 +576,7 @@ export class PrePlantingContributionService {
const { mergeNo, mergeId, accountSequence, sourceOrderNos, miningEnabledAt } = result;
const mergeSourceAdoptionId = PRE_PLANTING_MERGE_SOURCE_ID_OFFSET + mergeId;
// Step 1: 查找5份源订单的追踪记录
// Step 1: 查找源订单的追踪记录
const sourceOrders = await this.prePlantingPrisma.prePlantingSyncedOrder.findMany({
where: { orderNo: { in: sourceOrderNos } },
});
@ -671,7 +673,7 @@ export class PrePlantingContributionService {
const expireRemark =
`预种合成本份额已合并为1棵树${mergeNo}),算力转为树级计算,已挖积分不受影响`;
const mergeRemark =
`预种合成树:由5份份额合并(${mergeNo})算力升级为整棵树,` +
`预种合成树:由${sourceOrderNos.length}份份额合并(${mergeNo})算力升级为整棵树,` +
`源订单:${sourceOrderNos.join('、')}`;
await this.unitOfWork.executeInTransaction(async () => {

View File

@ -17,22 +17,25 @@ export const PRE_PLANTING_SOURCE_ID_OFFSET = 10_000_000_000n;
/**
*
*
* = 1 1/5
* = 1 1/10101
* contributionPerPortion = contributionPerTree / PRE_PLANTING_PORTION_DIVISOR
*
* [2026-03-04] 5 1051(3566USDT/)101(1887USDT/)
* 2026-03-01 3566USDT/1/5
*/
export const PRE_PLANTING_PORTION_DIVISOR = 5;
export const PRE_PLANTING_PORTION_DIVISOR = 10;
/**
*
*
* + 1 5
* + 1 10
*/
export const PRE_PLANTING_FREEZE_PERIOD_YEARS = 1;
/**
*
*
* 5 2
* 10 2
*/
export const PRE_PLANTING_POST_UNFREEZE_VALIDITY_YEARS = 2;

View File

@ -35,9 +35,9 @@ import { BonusClaimService } from '../application/services/bonus-claim.service';
* === ===
* 1. CDC consumer cdc.pre-planting.public.*
* 2. /PrePlantingPrismaService
* 3. 1/5
* 3. 1/10 101
* 4. synced_adoptions marker unlock
* 5. /1 5 5 + 2
* 5. /1 10 10 + 2
*
* === ===
* - Kafka consumer groupcontribution-pre-planting-cdc contribution-service-cdc-group