import 'package:kaer_with_panels/app/utils/kr_log_util.dart';

class KRPaymentMethods {
  /// 支付方式列表
  final List<KRPaymentMethod> list;

  KRPaymentMethods({required this.list});

  factory KRPaymentMethods.fromJson(Map<String, dynamic> json) {
    final List<dynamic> rawList = json['list'] ?? [];
    return KRPaymentMethods(
      list: rawList.map((item) => KRPaymentMethod.fromJson(item)).toList(),
    );
  }
}

class KRPaymentMethod {
  final int id;
  final String name;
  final String platform;
  final String icon;
  final int feeMode;
  final int feePercent;
  final int feeAmount;

  KRPaymentMethod({
    required this.id,
    required this.name,
    required this.platform,
    required this.icon,
    required this.feeMode,
    required this.feePercent,
    required this.feeAmount,
  });

  factory KRPaymentMethod.fromJson(Map<String, dynamic> json) {
    KRLogUtil.kr_i(json.toString());
    return KRPaymentMethod(
      id: (json['id'] ?? 0),
      name: json['name'] ?? '',
      platform: json['platform'] ?? '',
      icon: json['icon'] ?? '',
      feeMode: json['fee_mode'] ?? 0,
      feePercent: json['fee_percent'] ?? 0,
      feeAmount: json['fee_amount'] ?? 0,
    );
  }
}
