feat(mining-app): P2P转出记录显示手续费及合计扣除
- P2pTransferModel 新增 fee 字段解析 - 转出卡片聚合显示:转账金额 + 手续费 + 合计扣除 - 转入卡片保持只显示转账金额 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7180e2ac27
commit
7c416adecd
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)}';
|
||||
|
|
|
|||
Loading…
Reference in New Issue