From c7c793f1286000c4af3d72e674559c0b22164bfd Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 7 Jan 2026 06:41:28 -0800 Subject: [PATCH] =?UTF-8?q?fix(reporting-service):=20=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E4=BD=99=E9=A2=9D=E6=94=B9=E4=B8=BA=20=E7=B4=AF=E8=AE=A1?= =?UTF-8?q?=E6=94=B6=E5=85=A5=20-=20=E7=B4=AF=E8=AE=A1=E8=BD=AC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 所有固定账户:账户余额 = 累计收入 - 累计转出 - 总部储蓄(HQ_COMMUNITY):累计收入 = ledger收入 + 过期收益 - 统一计算公式,确保数据一致性 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- ...stem-account-report-application.service.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/services/reporting-service/src/application/services/system-account-report-application.service.ts b/backend/services/reporting-service/src/application/services/system-account-report-application.service.ts index 6fdcd971..6bb272c0 100644 --- a/backend/services/reporting-service/src/application/services/system-account-report-application.service.ts +++ b/backend/services/reporting-service/src/application/services/system-account-report-application.service.ts @@ -302,8 +302,8 @@ export class SystemAccountReportApplicationService { /** * 组装固定账户数据 - * [2026-01-07] 更新:将过期收益累加到总部储蓄账户 (HQ_COMMUNITY / S0000000001) 的累计收入和账户余额中 - * 过期的分享权益会进入 S0000000001,所以余额和收入都需要包含过期收益 + * [2026-01-07] 更新:账户余额 = 累计收入 - 累计转出 + * 对于总部储蓄账户 (HQ_COMMUNITY / S0000000001),累计收入需要加上过期收益 */ private assembleFixedAccounts( fixedAccounts: AllSystemAccountsResponse['fixedAccounts'], @@ -320,25 +320,32 @@ export class SystemAccountReportApplicationService { for (const account of fixedAccounts) { const fieldName = FIXED_ACCOUNT_TYPES[account.accountType]; if (fieldName && fieldName in result) { - // 如果是总部储蓄账户 (HQ_COMMUNITY),累加过期收益到余额和累计收入 + const currentReceived = parseFloat(account.totalReceived) || 0; + const currentTransferred = parseFloat(account.totalTransferred) || 0; + + // 如果是总部储蓄账户 (HQ_COMMUNITY),累计收入需要加上过期收益 if (account.accountType === 'HQ_COMMUNITY' && expiredRewardsTotal > 0) { - const currentBalance = parseFloat(account.usdtBalance) || 0; - const currentReceived = parseFloat(account.totalReceived) || 0; - const newBalance = currentBalance + expiredRewardsTotal; const newTotalReceived = currentReceived + expiredRewardsTotal; + // 账户余额 = 累计收入 - 累计转出 + const newBalance = newTotalReceived - currentTransferred; (result as any)[fieldName] = { ...account, usdtBalance: newBalance.toFixed(8), totalReceived: newTotalReceived.toFixed(8), }; - this.logger.log( - `[assembleFixedAccounts] HQ_COMMUNITY 余额: ${currentBalance} + 过期收益 ${expiredRewardsTotal} = ${newBalance}`, - ); this.logger.log( `[assembleFixedAccounts] HQ_COMMUNITY 累计收入: ${currentReceived} + 过期收益 ${expiredRewardsTotal} = ${newTotalReceived}`, ); + this.logger.log( + `[assembleFixedAccounts] HQ_COMMUNITY 余额: ${newTotalReceived} - ${currentTransferred} = ${newBalance}`, + ); } else { - (result as any)[fieldName] = account; + // 其他账户:账户余额 = 累计收入 - 累计转出 + const newBalance = currentReceived - currentTransferred; + (result as any)[fieldName] = { + ...account, + usdtBalance: newBalance.toFixed(8), + }; } } }