| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import 'package:json_annotation/json_annotation.dart';
- import 'package:keyboard/utils/common_expand.dart';
- part 'goods_info.g.dart';
- @JsonSerializable()
- class GoodsInfo {
- @JsonKey(name: "id")
- late int id;
- @JsonKey(name: "sort")
- late int sort;
- @JsonKey(name: "name")
- late String name;
- @JsonKey(name: "subscribable")
- late int subscribable;
- @JsonKey(name: "amount")
- late int amount;
- @JsonKey(name: "originalAmount")
- late int originalAmount;
- @JsonKey(name: "auth")
- late String auth;
- @JsonKey(name: "subscriptionMillis")
- late int subscriptionMillis;
- @JsonKey(name: "priceDesc")
- late String priceDesc;
- @JsonKey(name: 'payOptionIds')
- List<int>? payOptionIds;
- @JsonKey(name: 'description')
- String? description;
- @JsonKey(name: 'discountDesc')
- String? discountDesc;
- @JsonKey(name: 'mostDesc')
- String? mostDesc;
- @JsonKey(name: 'selectDesc')
- String? selectDesc;
- GoodsInfo({
- required this.id,
- required this.sort,
- required this.name,
- required this.subscribable,
- required this.amount,
- required this.originalAmount,
- required this.auth,
- required this.subscriptionMillis,
- required this.priceDesc,
- this.payOptionIds,
- this.description,
- this.discountDesc,
- this.mostDesc,
- this.selectDesc,
- });
- get amountText => (amount / 100).toFormattedString(2);
- get originalAmountText => "${(originalAmount / 100).toFormattedString(2)}元";
- get priceDescNumber => priceDesc.extractAmount();
- get priceDescUnit => priceDesc.extractUnit();
- factory GoodsInfo.fromJson(Map<String, dynamic> json) =>
- _$GoodsInfoFromJson(json);
- Map<String, dynamic> toJson() => _$GoodsInfoToJson(this);
- GoodsInfo copyWith() {
- return GoodsInfo(
- id: id,
- sort: sort,
- name: name,
- subscribable: subscribable,
- amount: amount,
- originalAmount: originalAmount,
- auth: auth,
- subscriptionMillis: subscriptionMillis,
- priceDesc: priceDesc,
- payOptionIds: payOptionIds,
- description: description,
- discountDesc: discountDesc,
- mostDesc: mostDesc,
- selectDesc: selectDesc,
- );
- }
- }
|