feat(app): 接入金币充值与会员商品下单

This commit is contained in:
Zhou Weidong committed 2026-10-20 04:32:03 +08:00
1 parent ec2db6842e
commit 730e38622f
21 files changed
+1325 -1

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
// Author: fruit.com.cn
import 'json_numbers.dart';
/// 充值订单:`POST /app/orders` 创建的 `CREATED` 订单,等待支付。
class AppOrder {
const AppOrder({
required this.id,
required this.orderNo,
required this.productName,
required this.coinAmount,
required this.status,
this.productId = '',
this.type = '',
this.amount = '',
this.currency = '',
this.createdAt,
});
static const String created = 'CREATED';
final String id;
final String orderNo;
final String productId;
final String productName;
final String type;
final int coinAmount;
final String amount;
final String currency;
final String status;
final DateTime? createdAt;
bool get isCreated => status == created;
factory AppOrder.fromJson(Map<String, dynamic> json) {
return AppOrder(
id: (json['id'] ?? '').toString(),
orderNo: json['orderNo'] as String? ?? '',
productId: (json['productId'] ?? '').toString(),
productName: json['productName'] as String? ?? '',
type: json['type'] as String? ?? '',
coinAmount: jsonToInt(json['coinAmount']),
amount: (json['amount'] ?? '').toString(),
currency: json['currency'] as String? ?? '',
status: json['status'] as String? ?? '',
createdAt: DateTime.tryParse(json['createdAt'] as String? ?? ''),
);
}
}
+54
View File
@@ -0,0 +1,54 @@
// Author: fruit.com.cn
import 'json_numbers.dart';
/// 充值商品:`GET /app/products` 的 `COIN_PACK` / `VIP` 条目。
class AppProduct {
const AppProduct({
required this.id,
required this.code,
required this.name,
required this.type,
this.coinAmount = 0,
this.bonusCoin = 0,
this.totalCoin = 0,
this.displayPrice = '',
this.currency = '',
this.vipDays = 0,
});
static const String coinPackType = 'COIN_PACK';
static const String vipType = 'VIP';
final String id;
final String code;
final String name;
final String type;
final int coinAmount;
final int bonusCoin;
final int totalCoin;
final String displayPrice;
final String currency;
final int vipDays;
bool get isVip => type == vipType;
factory AppProduct.fromJson(Map<String, dynamic> json) {
final coinAmount = jsonToInt(json['coinAmount']);
final bonusCoin = jsonToInt(json['bonusCoin']);
return AppProduct(
id: (json['id'] ?? '').toString(),
code: json['code'] as String? ?? '',
name: json['name'] as String? ?? '',
type: json['type'] as String? ?? '',
coinAmount: coinAmount,
bonusCoin: bonusCoin,
totalCoin: json['totalCoin'] == null
? coinAmount + bonusCoin
: jsonToInt(json['totalCoin']),
displayPrice: json['displayPrice'] as String? ?? '',
currency: json['currency'] as String? ?? '',
vipDays: jsonToInt(json['vipDays']),
);
}
}