fix(mobile): 预种可结算列表以wallet实际金额为准,避免已结算条目残留

planting-service 的分配记录不跟踪 wallet 端的结算状态,
原来的反向排除法(排除PENDING+EXPIRED)无法处理:
1. 已结算到余额(SETTLED→余额)的条目
2. hasPlanted=true 后直接进可结算、不经 pending_rewards 的条目

改为以 walletInfo.rewards.settleableUsdt 为权威来源:
- settleableUsdt=0 时直接跳过(已全部结算到余额)
- settleableUsdt>0 时按金额截断,确保展示总额不超过实际可结算

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-01 10:19:31 -08:00
parent eba125901c
commit 31e6f9e15a
1 changed files with 45 additions and 32 deletions

View File

@ -801,8 +801,16 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
// [2026-03-01]
// pre-planting/my-rewards
// PENDING
// PENDING EXPIRED
// PENDINGEXPIRED
//
// wallet settleableUsdt
// settleableUsdt=0
// settleableUsdt>0 PENDING + EXPIRED
// wallet
final walletSettleableUsdt = walletInfo.rewards.settleableUsdt;
List<SettleableRewardItem> prePlantingSettleable = [];
if (walletSettleableUsdt > 0) {
final pendingPplOrderIds = walletPendingRewards
.where((r) => r.isPrePlanting)
.map((r) => r.sourceOrderId)
@ -812,14 +820,18 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
.map((r) => r.sourceOrderId)
.toSet();
final excludedPplOrderIds = {...pendingPplOrderIds, ...expiredPplOrderIds};
final prePlantingSettleable = prePlantingRewards.settleableRewards
.where((r) => !excludedPplOrderIds.contains(r.sourceOrderNo))
.map((r) {
double accumulatedUsdt = 0;
for (final r in prePlantingRewards.settleableRewards) {
if (excludedPplOrderIds.contains(r.sourceOrderNo)) continue;
if (accumulatedUsdt + r.usdtAmount > walletSettleableUsdt + 0.01) break;
accumulatedUsdt += r.usdtAmount;
final srcAcct = r.sourceAccountSequence;
final memoSuffix = (srcAcct != null && srcAcct.isNotEmpty)
? ':来自${srcAcct}的预种'
: '';
return SettleableRewardItem(
prePlantingSettleable.add(SettleableRewardItem(
id: r.id,
rightType: r.rightType,
usdtAmount: r.usdtAmount,
@ -829,11 +841,12 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
sourceOrderNo: r.sourceOrderNo,
sourceAccountSequence: r.sourceAccountSequence,
memo: '[预种] ${r.memo}$memoSuffix',
);
})
.toList();
));
}
}
settleableRewards = [...settleableRewards, ...prePlantingSettleable];
debugPrint('[ProfilePage] 预种可结算奖励: ${prePlantingSettleable.length} 条 (排除 ${pendingPplOrderIds.length} 条 PENDING, ${expiredPplOrderIds.length} 条 EXPIRED)');
debugPrint('[ProfilePage] 预种可结算奖励: ${prePlantingSettleable.length} 条 (walletSettleableUsdt=$walletSettleableUsdt)');
// [2026-03-01]
// wallet-service pending_rewards +