From 7c416adecd7c362184e356c239b08359b6930526 Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 30 Jan 2026 20:45:37 -0800 Subject: [PATCH] =?UTF-8?q?feat(mining-app):=20P2P=E8=BD=AC=E5=87=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E6=89=8B=E7=BB=AD=E8=B4=B9?= =?UTF-8?q?=E5=8F=8A=E5=90=88=E8=AE=A1=E6=89=A3=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - P2pTransferModel 新增 fee 字段解析 - 转出卡片聚合显示:转账金额 + 手续费 + 合计扣除 - 转入卡片保持只显示转账金额 Co-Authored-By: Claude Opus 4.5 --- .../lib/data/models/p2p_transfer_model.dart | 3 + .../asset/p2p_transfer_records_page.dart | 96 ++++++++++++++++--- 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/frontend/mining-app/lib/data/models/p2p_transfer_model.dart b/frontend/mining-app/lib/data/models/p2p_transfer_model.dart index d3d933d9..79fd48a0 100644 --- a/frontend/mining-app/lib/data/models/p2p_transfer_model.dart +++ b/frontend/mining-app/lib/data/models/p2p_transfer_model.dart @@ -5,6 +5,7 @@ class P2pTransferModel { final String toAccountSequence; final String toPhone; final String amount; + final String fee; final String? memo; final String status; final DateTime createdAt; @@ -15,6 +16,7 @@ class P2pTransferModel { required this.toAccountSequence, required this.toPhone, required this.amount, + required this.fee, this.memo, required this.status, required this.createdAt, @@ -27,6 +29,7 @@ class P2pTransferModel { toAccountSequence: json['toAccountSequence'] ?? '', toPhone: json['toPhone'] ?? '', amount: json['amount']?.toString() ?? '0', + fee: json['fee']?.toString() ?? '0', memo: json['memo'], status: json['status'] ?? 'PENDING', createdAt: json['createdAt'] != null diff --git a/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart b/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart index 83f42072..6d0cbba8 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart @@ -214,24 +214,84 @@ class P2pTransferRecordsPage extends ConsumerWidget { const SizedBox(height: 12), const Divider(height: 1), const SizedBox(height: 12), - // 金额 - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Text( - '转账金额', - style: TextStyle(fontSize: 13, color: _grayText), - ), - Text( - '${isSend ? '-' : '+'}${formatAmount(record.amount)} 积分值', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - color: isSend ? _orange : _green, + // 转出:显示流水明细(转账金额 + 手续费 + 合计扣除) + // 转入:只显示转账金额 + if (isSend) ...[ + // 转账金额 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + '转账金额', + style: TextStyle(fontSize: 13, color: _grayText), ), + Text( + '-${formatAmount(record.amount)} 积分值', + style: const TextStyle(fontSize: 13, color: _darkText), + ), + ], + ), + // 手续费 + if (double.tryParse(record.fee) != null && double.parse(record.fee) > 0) ...[ + const SizedBox(height: 6), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + '手续费', + style: TextStyle(fontSize: 13, color: _grayText), + ), + Text( + '-${formatAmount(record.fee)} 积分值', + style: const TextStyle(fontSize: 13, color: _darkText), + ), + ], ), + const SizedBox(height: 8), + const Divider(height: 1), + const SizedBox(height: 8), + // 合计扣除 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + '合计扣除', + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: _darkText), + ), + Text( + '-${formatAmount(_addAmounts(record.amount, record.fee))} 积分值', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: _orange, + ), + ), + ], + ), + ] else ...[ + // 无手续费时,转账金额用醒目样式 + // (已在上面显示,无需重复) ], - ), + ] else ...[ + // 转入:只显示金额 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + '转账金额', + style: TextStyle(fontSize: 13, color: _grayText), + ), + Text( + '+${formatAmount(record.amount)} 积分值', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: _green, + ), + ), + ], + ), + ], const SizedBox(height: 8), // 对方账号 Row( @@ -298,6 +358,12 @@ class P2pTransferRecordsPage extends ConsumerWidget { ); } + String _addAmounts(String a, String b) { + final va = double.tryParse(a) ?? 0; + final vb = double.tryParse(b) ?? 0; + return (va + vb).toStringAsFixed(8); + } + String _maskPhone(String phone) { if (phone.length != 11) return phone; return '${phone.substring(0, 3)}****${phone.substring(7)}';