|
|
|
@ -0,0 +1,53 @@ |
|
|
|
/// 聊天音频产品模型 |
|
|
|
class ChatAudioProductModel { |
|
|
|
final String isFree; // "true" 或 "false" |
|
|
|
final String productId; |
|
|
|
final String productSpecId; |
|
|
|
final int mainCategory; |
|
|
|
final int subCategory; |
|
|
|
final String productTitle; |
|
|
|
final double unitSellingPrice; |
|
|
|
|
|
|
|
ChatAudioProductModel({ |
|
|
|
required this.isFree, |
|
|
|
required this.productId, |
|
|
|
required this.productSpecId, |
|
|
|
required this.mainCategory, |
|
|
|
required this.subCategory, |
|
|
|
required this.productTitle, |
|
|
|
required this.unitSellingPrice, |
|
|
|
}); |
|
|
|
|
|
|
|
factory ChatAudioProductModel.fromJson(Map<String, dynamic> json) { |
|
|
|
return ChatAudioProductModel( |
|
|
|
isFree: json['isFree']?.toString() ?? 'false', |
|
|
|
productId: json['productId']?.toString() ?? '', |
|
|
|
productSpecId: json['productSpecId']?.toString() ?? '', |
|
|
|
mainCategory: json['mainCategory'] as int? ?? 0, |
|
|
|
subCategory: json['subCategory'] as int? ?? 0, |
|
|
|
productTitle: json['productTitle']?.toString() ?? '', |
|
|
|
unitSellingPrice: (json['unitSellingPrice'] as num?)?.toDouble() ?? 0.0, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, dynamic> toJson() { |
|
|
|
return { |
|
|
|
'isFree': isFree, |
|
|
|
'productId': productId, |
|
|
|
'productSpecId': productSpecId, |
|
|
|
'mainCategory': mainCategory, |
|
|
|
'subCategory': subCategory, |
|
|
|
'productTitle': productTitle, |
|
|
|
'unitSellingPrice': unitSellingPrice, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/// 判断是否为免费产品 |
|
|
|
bool get isFreeProduct => isFree.toLowerCase() == 'true'; |
|
|
|
|
|
|
|
@override |
|
|
|
String toString() { |
|
|
|
return 'ChatAudioProductModel(productId: $productId, productTitle: $productTitle, unitSellingPrice: $unitSellingPrice, isFree: $isFree)'; |
|
|
|
} |
|
|
|
} |
|
|
|
|