feat(mining-app): P2P转出记录显示手续费及合计扣除

- P2pTransferModel 新增 fee 字段解析
- 转出卡片聚合显示:转账金额 + 手续费 + 合计扣除
- 转入卡片保持只显示转账金额

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-30 20:45:37 -08:00
parent 7180e2ac27
commit 7c416adecd
2 changed files with 84 additions and 15 deletions

View File

@ -5,6 +5,7 @@ class P2pTransferModel {
final String toAccountSequence; final String toAccountSequence;
final String toPhone; final String toPhone;
final String amount; final String amount;
final String fee;
final String? memo; final String? memo;
final String status; final String status;
final DateTime createdAt; final DateTime createdAt;
@ -15,6 +16,7 @@ class P2pTransferModel {
required this.toAccountSequence, required this.toAccountSequence,
required this.toPhone, required this.toPhone,
required this.amount, required this.amount,
required this.fee,
this.memo, this.memo,
required this.status, required this.status,
required this.createdAt, required this.createdAt,
@ -27,6 +29,7 @@ class P2pTransferModel {
toAccountSequence: json['toAccountSequence'] ?? '', toAccountSequence: json['toAccountSequence'] ?? '',
toPhone: json['toPhone'] ?? '', toPhone: json['toPhone'] ?? '',
amount: json['amount']?.toString() ?? '0', amount: json['amount']?.toString() ?? '0',
fee: json['fee']?.toString() ?? '0',
memo: json['memo'], memo: json['memo'],
status: json['status'] ?? 'PENDING', status: json['status'] ?? 'PENDING',
createdAt: json['createdAt'] != null createdAt: json['createdAt'] != null

View File

@ -214,24 +214,84 @@ class P2pTransferRecordsPage extends ConsumerWidget {
const SizedBox(height: 12), const SizedBox(height: 12),
const Divider(height: 1), const Divider(height: 1),
const SizedBox(height: 12), const SizedBox(height: 12),
// // + +
Row( //
mainAxisAlignment: MainAxisAlignment.spaceBetween, if (isSend) ...[
children: [ //
const Text( Row(
'转账金额', mainAxisAlignment: MainAxisAlignment.spaceBetween,
style: TextStyle(fontSize: 13, color: _grayText), children: [
), const Text(
Text( '转账金额',
'${isSend ? '-' : '+'}${formatAmount(record.amount)} 积分值', style: TextStyle(fontSize: 13, color: _grayText),
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: isSend ? _orange : _green,
), ),
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), const SizedBox(height: 8),
// //
Row( 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) { String _maskPhone(String phone) {
if (phone.length != 11) return phone; if (phone.length != 11) return phone;
return '${phone.substring(0, 3)}****${phone.substring(7)}'; return '${phone.substring(0, 3)}****${phone.substring(7)}';