asset_statement.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /// 资产流水记录 - POST uc/asset/transaction/all
  2. class AssetStatement {
  3. final String id;
  4. final String fee;
  5. final String flag;
  6. final String type;
  7. final String amount;
  8. final String symbol;
  9. final String realFee;
  10. /// 返佣ID(JSON: address)
  11. final String rebateId;
  12. /// 用户ID(JSON: memberId)
  13. final String accountId;
  14. final String createTime;
  15. /// "0"=开仓 "1"=平仓
  16. final String direction;
  17. final String discountFee;
  18. const AssetStatement({
  19. this.id = '',
  20. this.fee = '0',
  21. this.flag = '0',
  22. this.type = '',
  23. this.amount = '0',
  24. this.symbol = '',
  25. this.realFee = '0',
  26. this.rebateId = '',
  27. this.accountId = '',
  28. this.createTime = '',
  29. this.direction = '',
  30. this.discountFee = '0',
  31. });
  32. /// type=1,19,25 时显示额外字段
  33. bool get showExtraField => ['1', '19', '25'].contains(type);
  34. String get displaySymbol => symbol;
  35. factory AssetStatement.fromJson(Map<String, dynamic> json) {
  36. return AssetStatement(
  37. id: json['id']?.toString() ?? '',
  38. fee: json['fee']?.toString() ?? '0',
  39. flag: json['flag']?.toString() ?? '0',
  40. type: json['type']?.toString() ?? '',
  41. amount: json['amount']?.toString() ?? '0',
  42. symbol: json['symbol']?.toString() ?? '',
  43. realFee: json['realFee']?.toString() ?? '0',
  44. rebateId: json['address']?.toString() ?? '',
  45. accountId: json['memberId']?.toString() ?? '',
  46. createTime: json['createTime']?.toString() ?? '',
  47. direction: json['direction']?.toString() ?? '',
  48. discountFee: json['discountFee']?.toString() ?? '0',
  49. );
  50. }
  51. }
  52. /// 流水类型 - GET uc/asset/transaction/type
  53. class StatementType {
  54. final int index;
  55. /// 类型ID(JSON: typeName)
  56. final String typeId;
  57. final String name;
  58. const StatementType({
  59. this.index = 0,
  60. this.typeId = '',
  61. this.name = '',
  62. });
  63. factory StatementType.fromJson(Map<String, dynamic> json) {
  64. return StatementType(
  65. index: json['index'] as int? ?? 0,
  66. typeId: json['index']?.toString() ?? '', // 后台用 ordinal 整数过滤,不是枚举名
  67. name: json['name']?.toString() ?? '',
  68. );
  69. }
  70. }
  71. /// 流水币种筛选项 - GET uc/asset/transaction/coin
  72. class StatementCoin {
  73. final String fullName;
  74. final String code;
  75. final String name;
  76. final int sort;
  77. const StatementCoin({
  78. this.fullName = '',
  79. this.code = '',
  80. this.name = '',
  81. this.sort = 0,
  82. });
  83. factory StatementCoin.fromJson(Map<String, dynamic> json) {
  84. return StatementCoin(
  85. fullName: json['name']?.toString() ?? '',
  86. code: json['unit']?.toString() ?? '',
  87. name: json['nameCn']?.toString() ?? '',
  88. sort: int.tryParse(json['sort']?.toString() ?? '0') ?? 0,
  89. );
  90. }
  91. }