recharge_order.dart 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /// 链上充值父币种 — GET uc/coin-network/recharge-parents
  2. class RechargeParentCoin {
  3. final String name;
  4. final String nameCn;
  5. final String unit;
  6. final int status;
  7. final int canRecharge;
  8. final int sort;
  9. const RechargeParentCoin({
  10. required this.name,
  11. required this.nameCn,
  12. required this.unit,
  13. this.status = 0,
  14. this.canRecharge = 0,
  15. this.sort = 0,
  16. });
  17. factory RechargeParentCoin.fromJson(Map<String, dynamic> json) {
  18. return RechargeParentCoin(
  19. name: json['name']?.toString() ?? '',
  20. nameCn: json['nameCn']?.toString() ?? '',
  21. unit: json['unit']?.toString() ?? '',
  22. status: int.tryParse(json['status']?.toString() ?? '') ?? 0,
  23. canRecharge: int.tryParse(json['canRecharge']?.toString() ?? '') ?? 0,
  24. sort: int.tryParse(json['sort']?.toString() ?? '') ?? 0,
  25. );
  26. }
  27. }
  28. /// 扁平化后的充值网络选项(与 Web `RechargeFlatNetworkOption` 一致)
  29. class RechargeFlatNetworkOption {
  30. final String coinName;
  31. final String coinNameCn;
  32. final int networkConfigId;
  33. final String networkName;
  34. final String protocol;
  35. final String contractAddress;
  36. final String rechargeAddress;
  37. const RechargeFlatNetworkOption({
  38. required this.coinName,
  39. required this.coinNameCn,
  40. required this.networkConfigId,
  41. required this.networkName,
  42. required this.protocol,
  43. required this.contractAddress,
  44. required this.rechargeAddress,
  45. });
  46. bool get hasTokenContract => contractAddress.trim().isNotEmpty;
  47. }
  48. /// 充值订单详情
  49. class RechargeOrderDetail {
  50. final int id;
  51. final String orderNo;
  52. final String coinName;
  53. final String networkName;
  54. final String rechargeAddress;
  55. final String amount;
  56. final String? txHash;
  57. final int status;
  58. final String createTime;
  59. const RechargeOrderDetail({
  60. this.id = 0,
  61. this.orderNo = '',
  62. this.coinName = '',
  63. this.networkName = '',
  64. this.rechargeAddress = '',
  65. this.amount = '0',
  66. this.txHash,
  67. this.status = 0,
  68. this.createTime = '',
  69. });
  70. factory RechargeOrderDetail.fromJson(Map<String, dynamic> json) {
  71. final th = json['txHash'];
  72. return RechargeOrderDetail(
  73. id: int.tryParse(json['id']?.toString() ?? '') ?? 0,
  74. orderNo: json['orderNo']?.toString() ?? '',
  75. coinName: json['coinName']?.toString() ?? '',
  76. networkName: json['networkName']?.toString() ?? '',
  77. rechargeAddress: json['rechargeAddress']?.toString() ?? '',
  78. amount: json['amount']?.toString() ?? '0',
  79. txHash: th != null && th.toString().isNotEmpty ? th.toString() : null,
  80. status: int.tryParse(json['status']?.toString() ?? '') ?? 0,
  81. createTime: json['createTime']?.toString() ?? '',
  82. );
  83. }
  84. bool get isPendingPayment => status == 0;
  85. }