withdraw_record.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /// 提现/转账记录 - GET uc/withdraw/record | uc/withdraw/transfer/record
  2. class WithdrawRecord {
  3. final String id;
  4. /// "0"审核中 "1"放币中 "2"失败 "3"成功 "4"用户取消
  5. final String status;
  6. final String address;
  7. /// 总金额(JSON: totalAmount)—— 链上提币使用
  8. final String amount;
  9. /// 到账/转账金额(JSON: amount)—— 内部转账使用
  10. final String transferAmount;
  11. final String createTime;
  12. final String dealTime;
  13. /// 交易哈希(JSON: transactionNumber)
  14. final String transactionHashId;
  15. final WithdrawRecordCoin? coin;
  16. final String memberId;
  17. /// 是否为内部转账(本地标记,非后端字段)
  18. final bool isTransfer;
  19. const WithdrawRecord({
  20. this.id = '',
  21. this.status = '0',
  22. this.address = '',
  23. this.amount = '0',
  24. this.transferAmount = '0',
  25. this.createTime = '',
  26. this.dealTime = '',
  27. this.transactionHashId = '',
  28. this.coin,
  29. this.memberId = '',
  30. this.isTransfer = false,
  31. });
  32. WithdrawRecord copyWith({bool? isTransfer}) => WithdrawRecord(
  33. id: id,
  34. status: status,
  35. address: address,
  36. amount: amount,
  37. transferAmount: transferAmount,
  38. createTime: createTime,
  39. dealTime: dealTime,
  40. transactionHashId: transactionHashId,
  41. coin: coin,
  42. memberId: memberId,
  43. isTransfer: isTransfer ?? this.isTransfer,
  44. );
  45. bool get canCancel => status == '0';
  46. bool get isSuccess => status == '3';
  47. String get statusText {
  48. switch (status) {
  49. case '0': return '审核中';
  50. case '1': return '放币中';
  51. case '2': return '失败';
  52. case '3': return '成功';
  53. case '4': return '取消提现';
  54. default: return '未知';
  55. }
  56. }
  57. factory WithdrawRecord.fromJson(Map<String, dynamic> json) {
  58. return WithdrawRecord(
  59. id: json['id']?.toString() ?? '',
  60. status: json['status']?.toString() ?? '0',
  61. address: json['address']?.toString() ?? '',
  62. amount: json['totalAmount']?.toString() ?? '0',
  63. transferAmount: json['amount']?.toString() ?? '0',
  64. createTime: json['createTime']?.toString() ?? '',
  65. dealTime: json['dealTime']?.toString() ?? '',
  66. transactionHashId: json['transactionNumber']?.toString() ?? '',
  67. coin: json['coin'] != null
  68. ? WithdrawRecordCoin.fromJson(json['coin'] as Map<String, dynamic>)
  69. : null,
  70. memberId: json['memberId']?.toString() ?? '',
  71. );
  72. }
  73. }
  74. /// 提现记录币种信息
  75. class WithdrawRecordCoin {
  76. /// 币种代号(JSON: unit)如 TUSDT / EUSDT / USDT
  77. final String coinName;
  78. /// 中文别名(JSON: nameCn)如 USDT-TRC20
  79. final String aliasName;
  80. /// 手续费(JSON: withdrawFeeValue)
  81. final String fee;
  82. const WithdrawRecordCoin({
  83. this.coinName = '',
  84. this.aliasName = '',
  85. this.fee = '0',
  86. });
  87. /// 网络名称:TUSDT→TRC20, EUSDT→ERC20, BEP20→BEP20
  88. String get networkName {
  89. if (coinName == 'TUSDT') return 'TRC20';
  90. if (coinName == 'EUSDT') return 'ERC20';
  91. if (coinName.contains('BEP20')) return 'BEP20';
  92. // 从 aliasName 中提取,如 "USDT-TRC20" → "TRC20"
  93. if (aliasName.contains('-')) return aliasName.split('-').last;
  94. return '';
  95. }
  96. /// 基础币种显示名:TUSDT→USDT,或从 aliasName 取 "-" 前缀
  97. String get baseCoinDisplay {
  98. if (aliasName.contains('-')) return aliasName.split('-').first;
  99. // 从 unit 中提取基础名:TUSDT/EUSDT → USDT
  100. if (coinName.length > 4 && coinName.endsWith('USDT')) return 'USDT';
  101. return coinName;
  102. }
  103. factory WithdrawRecordCoin.fromJson(Map<String, dynamic> json) {
  104. return WithdrawRecordCoin(
  105. coinName: json['unit']?.toString() ?? '',
  106. aliasName: json['nameCn']?.toString() ?? '',
  107. fee: json['withdrawFeeValue']?.toString() ?? '0',
  108. );
  109. }
  110. }