From e9b9896317cf8438ad34f0236908731d6aa2eeb6 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 1 Mar 2026 08:24:03 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile):=20=E4=BF=AE=E5=A4=8D=E9=A2=84?= =?UTF-8?q?=E7=A7=8D=E5=8F=AF=E7=BB=93=E7=AE=97=E5=88=97=E8=A1=A8=E4=B8=8E?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:pre-planting/my-rewards 返回所有分配记录不区分状态, 导致 PENDING 状态的预种奖励也被错误地显示在可结算列表中, 而可结算金额(从 wallet-service 取值)正确为 0,造成列表和金额不一致。 修复:在合并预种可结算列表时,排除正在 PENDING 和 EXPIRED 状态的条目。 通过 wallet/pending-rewards 和 wallet/expired-rewards 获取实际状态, 用 sourceOrderId 交叉比对,只保留真正可结算的预种条目。 Co-Authored-By: Claude Opus 4.6 --- .../presentation/pages/profile_page.dart | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) 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 7137bdd8..7573a58b 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 @@ -799,23 +799,35 @@ class _ProfilePageState extends ConsumerState { final walletInfo = results[6] as WalletResponse; final walletPendingRewards = results[7] as List; - // 合并预种可结算奖励到列表中 - // 预种奖励转为 SettleableRewardItem 格式,与正常认种统一展示 - final prePlantingSettleable = prePlantingRewards.settleableRewards.map((r) => - SettleableRewardItem( - id: r.id, - rightType: r.rightType, - usdtAmount: r.usdtAmount, - hashpowerAmount: r.hashpowerAmount, - createdAt: r.createdAt, - claimedAt: null, - sourceOrderNo: r.sourceOrderNo, - sourceAccountSequence: r.sourceAccountSequence, - memo: '[预种] ${r.memo}', - ), - ).toList(); + // [2026-03-01] 合并预种可结算奖励到列表中 + // pre-planting/my-rewards 返回所有分配记录(不区分状态), + // 但部分条目可能实际处于 PENDING 状态(用户未认种时)。 + // 需要排除 PENDING 和 EXPIRED 状态的条目,只保留真正可结算的。 + final pendingPplOrderIds = walletPendingRewards + .where((r) => r.isPrePlanting) + .map((r) => r.sourceOrderId) + .toSet(); + final expiredPplOrderIds = expiredRewards + .where((r) => r.sourceOrderId.startsWith('PPL')) + .map((r) => r.sourceOrderId) + .toSet(); + final excludedPplOrderIds = {...pendingPplOrderIds, ...expiredPplOrderIds}; + final prePlantingSettleable = prePlantingRewards.settleableRewards + .where((r) => !excludedPplOrderIds.contains(r.sourceOrderNo)) + .map((r) => SettleableRewardItem( + id: r.id, + rightType: r.rightType, + usdtAmount: r.usdtAmount, + hashpowerAmount: r.hashpowerAmount, + createdAt: r.createdAt, + claimedAt: null, + sourceOrderNo: r.sourceOrderNo, + sourceAccountSequence: r.sourceAccountSequence, + memo: '[预种] ${r.memo}', + )) + .toList(); settleableRewards = [...settleableRewards, ...prePlantingSettleable]; - debugPrint('[ProfilePage] 预种可结算奖励: ${prePlantingSettleable.length} 条, 金额: ${prePlantingRewards.settleableUsdt}'); + debugPrint('[ProfilePage] 预种可结算奖励: ${prePlantingSettleable.length} 条 (排除 ${pendingPplOrderIds.length} 条 PENDING, ${expiredPplOrderIds.length} 条 EXPIRED)'); // [2026-03-01] 合并预种待领取奖励到列表中 // wallet-service 的 pending_rewards 表包含正常认种 + 预种的待领取记录,