/// 充值套餐(来自后端 GET /api/v1/plans,价格以服务端 config.yml 为准) class Plan { final String id; final int days; final int priceYuan; const Plan({ required this.id, required this.days, required this.priceYuan, }); /// 展示名由天数派生(接口无 label 字段) String get label => '$days天'; factory Plan.fromJson(Map json) => Plan( id: json['planId'] as String, days: json['days'] as int, priceYuan: (json['priceCents'] as num) ~/ 100, ); } /// 支付渠道 enum PayChannel { wechat, alipay } /// 订单(由后端创建) class Order { final String orderId; /// 微信支付参数(prepay_id / partner_id / nonce_str / time_stamp / sign 等) final Map wechatParams; /// 支付宝订单串(orderStr) final String? alipayOrderStr; const Order({ required this.orderId, this.wechatParams = const {}, this.alipayOrderStr, }); } /// 授权状态(服务端为准) class LicenseStatus { final bool active; final DateTime? expiresAt; const LicenseStatus({required this.active, this.expiresAt}); bool get isActive => active && (expiresAt?.isAfter(DateTime.now()) ?? false); factory LicenseStatus.fromJson(Map json) => LicenseStatus( active: json['active'] == true, expiresAt: json['expiresAt'] != null ? DateTime.tryParse(json['expiresAt'] as String) : null, ); } /// 支付结果 class PayResult { final bool success; final String? message; final String? orderId; const PayResult({required this.success, this.message, this.orderId}); }