From 2d3891740c2615423384c0c751870b89437bef1d Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 23 Dec 2025 00:20:35 -0800 Subject: [PATCH] =?UTF-8?q?feat(authorization):=20=E7=81=AB=E6=9F=B4?= =?UTF-8?q?=E4=BA=BA=E6=8E=92=E5=90=8D=E6=94=B9=E4=B8=BA=E5=85=A8=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=8E=92=E5=90=8D=EF=BC=8C=E4=B8=8D=E6=8C=89=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端新增 findRankingsByMonthAndRoleType 方法查询全系统排名 - 修改 getStickmanRanking 不再按 regionCode 过滤 - 前端简化加载条件,只要有授权就加载排名 - 添加详细调试日志帮助排查问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .claude/settings.local.json | 40 ++++++++++++++- .../authorization-application.service.ts | 26 +++++++++- .../monthly-assessment.repository.ts | 4 ++ .../monthly-assessment.repository.impl.ts | 14 ++++++ .../presentation/pages/profile_page.dart | 49 +++++++++++++------ .../presentation/pages/trading_page.dart | 21 ++++---- 6 files changed, 127 insertions(+), 27 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index a1983ff1..e4939a9b 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -287,7 +287,45 @@ "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x5b25ae3ac4ad6291ef67aceaf657b62a200d8bf8'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n const amount = BigInt\\(1000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 1,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0xe9f7dafeb225bd3c88bcad2cce35c6512c9b2987'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 100,000,000 USDT = 100000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(100000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 100,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x631c1c09c5d481d6d2c4a75461a8b46af54eb846'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n const amount = BigInt\\(1000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 1,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", - "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0xa00ac1347f045676F8fc9791595e603810994d67'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 100,000,000 USDT = 100000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(100000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 100,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")" + "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0xa00ac1347f045676F8fc9791595e603810994d67'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 100,000,000 USDT = 100000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(100000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 100,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", + "Bash(npx tsc --noEmit)", + "Bash(backend/services/authorization-service/src/api/dto/request/self-apply-authorization.dto.ts )", + "Bash(backend/services/authorization-service/src/application/services/authorization-application.service.ts )", + "Bash(backend/services/identity-service/src/api/controllers/user-account.controller.ts )", + "Bash(backend/services/identity-service/src/api/dto/index.ts )", + "Bash(backend/services/identity-service/src/api/dto/request/verify-sms-code.dto.ts )", + "Bash(backend/services/identity-service/src/application/commands/index.ts )", + "Bash(backend/services/identity-service/src/application/services/user-application.service.ts )", + "Bash(backend/services/wallet-service/prisma/schema.prisma )", + "Bash(backend/services/wallet-service/prisma/migrations/20241222000000_add_withdrawal_fee_config/ )", + "Bash(backend/services/wallet-service/src/api/controllers/wallet.controller.ts )", + "Bash(backend/services/wallet-service/src/api/dto/response/index.ts )", + "Bash(backend/services/wallet-service/src/api/dto/response/fee-config.dto.ts )", + "Bash(backend/services/wallet-service/src/application/services/wallet-application.service.ts )", + "Bash(backend/services/wallet-service/src/domain/aggregates/withdrawal-order.aggregate.ts )", + "Bash(backend/services/wallet-service/src/infrastructure/infrastructure.module.ts )", + "Bash(backend/services/wallet-service/src/infrastructure/persistence/repositories/index.ts )", + "Bash(backend/services/wallet-service/src/infrastructure/persistence/repositories/fee-config.repository.impl.ts )", + "Bash(frontend/mobile-app/lib/core/services/account_service.dart )", + "Bash(frontend/mobile-app/lib/core/services/authorization_service.dart )", + "Bash(frontend/mobile-app/lib/core/services/wallet_service.dart )", + "Bash(frontend/mobile-app/lib/features/auth/presentation/pages/guide_page.dart )", + "Bash(frontend/mobile-app/lib/features/auth/presentation/pages/phone_login_page.dart )", + "Bash(frontend/mobile-app/lib/features/auth/presentation/pages/forgot_password_page.dart )", + "Bash(frontend/mobile-app/lib/features/authorization/presentation/pages/authorization_apply_page.dart )", + "Bash(frontend/mobile-app/lib/features/mining/presentation/pages/mining_page.dart )", + "Bash(frontend/mobile-app/lib/features/withdraw/presentation/pages/withdraw_confirm_page.dart )", + "Bash(frontend/mobile-app/lib/features/withdraw/presentation/pages/withdraw_usdt_page.dart )", + "Bash(frontend/mobile-app/lib/routes/app_router.dart )", + "Bash(frontend/mobile-app/lib/routes/route_names.dart )", + "Bash(frontend/mobile-app/lib/routes/route_paths.dart)", + "Bash(git commit -m \"$\\(cat <<''EOF''\nfeat: 多项业务功能增强\n\n- 动态提取手续费配置:支持固定/百分比两种费率类型,默认2绿积分/笔\n- 找回密码功能:新增手机号+短信验证码重置密码流程\n- 授权申请优化:自助申请时验证团队链授权状态\n- UI文案调整:登录账号、监控页待开启等\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")", + "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x323AA5bd8101Ad97B724dc1584479219c7660628'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 200,000,000 USDT = 200000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(200000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 200,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", + "Bash(git commit -m \"$\\(cat <<''EOF''\nfix\\(admin-service\\): 修复用户事件消费时 payload 嵌套层级错误\n\nidentity-service 发布的消息结构为 { eventId, eventType, payload: {...} },\n但 admin-service 消费时直接使用 eventData 而不是 eventData.payload,\n导致 payload.userId 为 undefined,BigInt\\(undefined\\) 抛出异常被静默吞掉,\n用户数据无法同步到 UserQueryView。\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")", + "Bash(git commit -m \"$\\(cat <<''EOF''\nfix\\(mobile-app\\): 修复提款页面 _feeRate 未定义错误\n\n将 _feeRate 改为 _feeConfig?.feeValue ?? 0.02,\n使用 FeeConfig 对象中的 feeValue 字段。\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")", + "Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x0ec001ed6233b7959d7a251e2792621e4707c35f'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 100,000,000 USDT = 100000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(100000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 100,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")", + "Bash(git commit -m \"$\\(cat <<''EOF''\nfix\\(mobile-app\\): 调整账本明细流水类型筛选顺序和标签\n\n- REWARD_SETTLED 标签从\"提取\"改为\"结算\"\n- 调整筛选选项顺序:转入/转出放到全部后面,充值绿积分放到最后\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")", + "Bash(git commit -m \"$\\(cat <<''EOF''\nfix\\(blockchain-service\\): 过滤热钱包发出的转账避免内部转账重复入账\n\n内部转账时,wallet-service 已经处理了接收方入账,\n需要过滤掉 blockchain-service 扫描到的热钱包转出交易,\n避免将其当作充值重复处理导致双倍入账\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 \nEOF\n\\)\")" ], "deny": [], "ask": [] diff --git a/backend/services/authorization-service/src/application/services/authorization-application.service.ts b/backend/services/authorization-service/src/application/services/authorization-application.service.ts index 9ed4ddf6..c4bd83ae 100644 --- a/backend/services/authorization-service/src/application/services/authorization-application.service.ts +++ b/backend/services/authorization-service/src/application/services/authorization-application.service.ts @@ -572,6 +572,9 @@ export class AuthorizationApplicationService { /** * 查询火柴人排名数据 + * + * 业务规则:查询全系统该角色类型的所有排名数据(不按区域过滤) + * 只要有任何一个用户达标,所有申请了该角色类型授权的用户都能看到排名 */ async getStickmanRanking( month: string, @@ -579,13 +582,24 @@ export class AuthorizationApplicationService { regionCode: string, currentUserId?: string, ): Promise { - const assessments = await this.assessmentRepository.findRankingsByMonthAndRegion( + this.logger.log( + `[getStickmanRanking] 查询火柴人排名: month=${month}, roleType=${roleType}, regionCode=${regionCode}, currentUserId=${currentUserId}`, + ) + + // 查询全系统该角色类型的所有评估记录(不按区域过滤) + const assessments = await this.assessmentRepository.findRankingsByMonthAndRoleType( Month.create(month), roleType, - RegionCode.create(regionCode), + ) + + this.logger.log( + `[getStickmanRanking] 查询到 ${assessments.length} 条评估记录`, ) if (assessments.length === 0) { + this.logger.warn( + `[getStickmanRanking] 没有找到任何评估记录,month=${month}, roleType=${roleType}`, + ) return [] } @@ -598,6 +612,10 @@ export class AuthorizationApplicationService { for (const assessment of assessments) { const userInfo = userInfoMap.get(assessment.userId.value) + this.logger.debug( + `[getStickmanRanking] 处理评估记录: userId=${assessment.userId.value}, ` + + `regionCode=${assessment.regionCode.value}, cumulativeCompleted=${assessment.cumulativeCompleted}`, + ) rankings.push({ id: assessment.authorizationId.value, userId: assessment.userId.value, @@ -624,6 +642,10 @@ export class AuthorizationApplicationService { // 按完成数量降序排序 rankings.sort((a, b) => b.completedCount - a.completedCount) + this.logger.log( + `[getStickmanRanking] 返回 ${rankings.length} 条排名数据`, + ) + return rankings } diff --git a/backend/services/authorization-service/src/domain/repositories/monthly-assessment.repository.ts b/backend/services/authorization-service/src/domain/repositories/monthly-assessment.repository.ts index 9c0f2cfd..5d5a0f26 100644 --- a/backend/services/authorization-service/src/domain/repositories/monthly-assessment.repository.ts +++ b/backend/services/authorization-service/src/domain/repositories/monthly-assessment.repository.ts @@ -24,6 +24,10 @@ export interface IMonthlyAssessmentRepository { roleType: RoleType, regionCode: RegionCode, ): Promise + findRankingsByMonthAndRoleType( + month: Month, + roleType: RoleType, + ): Promise findByAuthorization(authorizationId: AuthorizationId): Promise delete(assessmentId: AssessmentId): Promise } diff --git a/backend/services/authorization-service/src/infrastructure/persistence/repositories/monthly-assessment.repository.impl.ts b/backend/services/authorization-service/src/infrastructure/persistence/repositories/monthly-assessment.repository.impl.ts index c5b0ead4..62a7e21d 100644 --- a/backend/services/authorization-service/src/infrastructure/persistence/repositories/monthly-assessment.repository.impl.ts +++ b/backend/services/authorization-service/src/infrastructure/persistence/repositories/monthly-assessment.repository.impl.ts @@ -196,6 +196,20 @@ export class MonthlyAssessmentRepositoryImpl implements IMonthlyAssessmentReposi return records.map((record) => this.toDomain(record)) } + async findRankingsByMonthAndRoleType( + month: Month, + roleType: RoleType, + ): Promise { + const records = await this.prisma.monthlyAssessment.findMany({ + where: { + assessmentMonth: month.value, + roleType: roleType, + }, + orderBy: [{ exceedRatio: 'desc' }, { completedAt: 'asc' }], + }) + return records.map((record) => this.toDomain(record)) + } + async findByAuthorization(authorizationId: AuthorizationId): Promise { const records = await this.prisma.monthlyAssessment.findMany({ where: { authorizationId: authorizationId.value }, diff --git a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart index 5ddd1c97..852c2043 100644 --- a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart +++ b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart @@ -81,6 +81,7 @@ class _ProfilePageState extends ConsumerState { int _authCityCompanyInitialTarget = 100; int _authCityCompanyMonthlyTarget = 100; int _authCityCompanyMonthIndex = 0; + String _authCityCompanyRegionCode = ''; // 市团队区域代码 // 省团队考核数据 bool _hasAuthProvinceCompanyAuth = false; @@ -89,6 +90,7 @@ class _ProfilePageState extends ConsumerState { int _authProvinceCompanyInitialTarget = 500; int _authProvinceCompanyMonthlyTarget = 500; int _authProvinceCompanyMonthIndex = 0; + String _authProvinceCompanyRegionCode = ''; // 省团队区域代码 // 市区域考核数据 bool _hasCityCompanyAuth = false; @@ -487,8 +489,15 @@ class _ProfilePageState extends ConsumerState { _authCityCompanyInitialTarget = summary.authCityCompany!.initialTargetTreeCount; _authCityCompanyMonthlyTarget = summary.authCityCompany!.monthlyTargetTreeCount; _authCityCompanyMonthIndex = summary.authCityCompany!.currentMonthIndex; + _authCityCompanyRegionCode = summary.authCityCompany!.regionCode; + debugPrint('[ProfilePage] 市团队授权数据:'); + debugPrint('[ProfilePage] regionCode: $_authCityCompanyRegionCode'); + debugPrint('[ProfilePage] benefitActive: $_authCityCompanyBenefitActive'); + debugPrint('[ProfilePage] currentTreeCount: $_authCityCompanyCurrentTreeCount'); + debugPrint('[ProfilePage] monthIndex: $_authCityCompanyMonthIndex'); } else { _hasAuthCityCompanyAuth = false; + _authCityCompanyRegionCode = ''; } // 更新省团队考核数据 @@ -499,8 +508,15 @@ class _ProfilePageState extends ConsumerState { _authProvinceCompanyInitialTarget = summary.authProvinceCompany!.initialTargetTreeCount; _authProvinceCompanyMonthlyTarget = summary.authProvinceCompany!.monthlyTargetTreeCount; _authProvinceCompanyMonthIndex = summary.authProvinceCompany!.currentMonthIndex; + _authProvinceCompanyRegionCode = summary.authProvinceCompany!.regionCode; + debugPrint('[ProfilePage] 省团队授权数据:'); + debugPrint('[ProfilePage] regionCode: $_authProvinceCompanyRegionCode'); + debugPrint('[ProfilePage] benefitActive: $_authProvinceCompanyBenefitActive'); + debugPrint('[ProfilePage] currentTreeCount: $_authProvinceCompanyCurrentTreeCount'); + debugPrint('[ProfilePage] monthIndex: $_authProvinceCompanyMonthIndex'); } else { _hasAuthProvinceCompanyAuth = false; + _authProvinceCompanyRegionCode = ''; } // 更新市区域考核数据 @@ -571,19 +587,20 @@ class _ProfilePageState extends ConsumerState { final now = DateTime.now(); final month = '${now.year}-${now.month.toString().padLeft(2, '0')}'; - // 如果有省公司授权,加载省排名 - if (_hasAuthProvinceCompanyAuth && _authProvinceCompany != '--') { + // 如果有省团队授权,加载省排名(全系统所有省团队的排名) + if (_hasAuthProvinceCompanyAuth) { try { - // 从省公司名称中提取省代码(假设格式为 "XX省" 或直接省名) - final provinceName = _authProvinceCompany; - _provinceRegionName = provinceName; + _provinceRegionName = _authProvinceCompany; + debugPrint('[ProfilePage] 开始加载省团队排名: month=$month, regionCode=$_authProvinceCompanyRegionCode'); final rankings = await authorizationService.getStickmanRanking( month: month, roleType: 'AUTH_PROVINCE_COMPANY', - regionCode: provinceName, + regionCode: _authProvinceCompanyRegionCode, ); + debugPrint('[ProfilePage] 省团队排名API返回: ${rankings.length}条'); + if (mounted) { setState(() { _provinceRankings = rankings.map((r) => StickmanRankingData( @@ -597,24 +614,26 @@ class _ProfilePageState extends ConsumerState { )).toList(); }); } - debugPrint('[ProfilePage] 省公司排名加载成功: ${_provinceRankings.length}条'); + debugPrint('[ProfilePage] 省团队排名加载成功: ${_provinceRankings.length}条'); } catch (e) { - debugPrint('[ProfilePage] 加载省公司排名失败: $e'); + debugPrint('[ProfilePage] 加载省团队排名失败: $e'); } } - // 如果有市公司授权,加载市排名 - if (_hasAuthCityCompanyAuth && _authCityCompany != '--') { + // 如果有市团队授权,加载市排名(全系统所有市团队的排名) + if (_hasAuthCityCompanyAuth) { try { - final cityName = _authCityCompany; - _cityRegionName = cityName; + _cityRegionName = _authCityCompany; + debugPrint('[ProfilePage] 开始加载市团队排名: month=$month, regionCode=$_authCityCompanyRegionCode'); final rankings = await authorizationService.getStickmanRanking( month: month, roleType: 'AUTH_CITY_COMPANY', - regionCode: cityName, + regionCode: _authCityCompanyRegionCode, ); + debugPrint('[ProfilePage] 市团队排名API返回: ${rankings.length}条'); + if (mounted) { setState(() { _cityRankings = rankings.map((r) => StickmanRankingData( @@ -628,9 +647,9 @@ class _ProfilePageState extends ConsumerState { )).toList(); }); } - debugPrint('[ProfilePage] 市公司排名加载成功: ${_cityRankings.length}条'); + debugPrint('[ProfilePage] 市团队排名加载成功: ${_cityRankings.length}条'); } catch (e) { - debugPrint('[ProfilePage] 加载市公司排名失败: $e'); + debugPrint('[ProfilePage] 加载市团队排名失败: $e'); } } diff --git a/frontend/mobile-app/lib/features/trading/presentation/pages/trading_page.dart b/frontend/mobile-app/lib/features/trading/presentation/pages/trading_page.dart index 4047c8a1..bdade5ec 100644 --- a/frontend/mobile-app/lib/features/trading/presentation/pages/trading_page.dart +++ b/frontend/mobile-app/lib/features/trading/presentation/pages/trading_page.dart @@ -350,15 +350,18 @@ class _TradingPageState extends ConsumerState { valueColor: AlwaysStoppedAnimation(Color(0xFFD4AF37)), ), ) - : Text( - '${_formatNumber(_settleableAmount)} 绿积分', - style: const TextStyle( - fontSize: 32, - fontFamily: 'Inter', - fontWeight: FontWeight.w700, - height: 1.25, - letterSpacing: -0.8, - color: Color(0xFF5D4037), + : FittedBox( + fit: BoxFit.scaleDown, + child: Text( + '${_formatNumber(_settleableAmount)} 绿积分', + style: const TextStyle( + fontSize: 32, + fontFamily: 'Inter', + fontWeight: FontWeight.w700, + height: 1.25, + letterSpacing: -0.8, + color: Color(0xFF5D4037), + ), ), ), ],