120 lines
3.4 KiB
Dart
120 lines
3.4 KiB
Dart
/// 微信支付(对应 Android WxPayEntity)
|
||
class WxPay {
|
||
final String appId;
|
||
final String partnerId;
|
||
final String prepayId;
|
||
final String packageValue;
|
||
final String nonceStr;
|
||
final String timeStamp;
|
||
final String sign;
|
||
|
||
const WxPay({
|
||
required this.appId,
|
||
required this.partnerId,
|
||
required this.prepayId,
|
||
required this.packageValue,
|
||
required this.nonceStr,
|
||
required this.timeStamp,
|
||
required this.sign,
|
||
});
|
||
|
||
factory WxPay.fromJson(Map<String, dynamic> json) => WxPay(
|
||
appId: json['appid'] as String? ?? '',
|
||
partnerId: json['partnerid'] as String? ?? '',
|
||
prepayId: json['prepayid'] as String? ?? '',
|
||
packageValue: json['package'] as String? ?? 'Sign=WXPay',
|
||
nonceStr: json['noncestr'] as String? ?? '',
|
||
timeStamp: json['timestamp'] as String? ?? '',
|
||
sign: json['sign'] as String? ?? '',
|
||
);
|
||
}
|
||
|
||
/// 提现记录(对应 Android TiXianListEntity)
|
||
class WithdrawalRecord {
|
||
final int id;
|
||
final double amount;
|
||
final String status; // pending / success / failed
|
||
final DateTime createdAt;
|
||
final String? bankAccount;
|
||
final String? failureReason;
|
||
|
||
const WithdrawalRecord({
|
||
required this.id,
|
||
required this.amount,
|
||
required this.status,
|
||
required this.createdAt,
|
||
this.bankAccount,
|
||
this.failureReason,
|
||
});
|
||
|
||
factory WithdrawalRecord.fromJson(Map<String, dynamic> json) =>
|
||
WithdrawalRecord(
|
||
id: json['id'] as int? ?? 0,
|
||
amount: (json['amount'] as num?)?.toDouble() ?? 0,
|
||
status: json['status'] as String? ?? 'pending',
|
||
createdAt: DateTime.tryParse(json['created_at'] as String? ?? '') ??
|
||
DateTime.now(),
|
||
bankAccount: json['bank_account'] as String?,
|
||
failureReason: json['failure_reason'] as String?,
|
||
);
|
||
}
|
||
|
||
/// 金额明细(对应 Android AmountListItemViewModel)
|
||
class AmountItem {
|
||
final int id;
|
||
final String title;
|
||
final double amount;
|
||
final String type; // income / expense
|
||
final DateTime createdAt;
|
||
final String? orderNo;
|
||
|
||
const AmountItem({
|
||
required this.id,
|
||
required this.title,
|
||
required this.amount,
|
||
required this.type,
|
||
required this.createdAt,
|
||
this.orderNo,
|
||
});
|
||
|
||
factory AmountItem.fromJson(Map<String, dynamic> json) => AmountItem(
|
||
id: json['id'] as int? ?? 0,
|
||
title: json['title'] as String? ?? '',
|
||
amount: (json['amount'] as num?)?.toDouble() ?? 0,
|
||
type: json['type'] as String? ?? 'income',
|
||
createdAt: DateTime.tryParse(json['created_at'] as String? ?? '') ??
|
||
DateTime.now(),
|
||
orderNo: json['order_no'] as String?,
|
||
);
|
||
|
||
Map<String, dynamic> toJson() => {
|
||
'id': id,
|
||
'title': title,
|
||
'amount': amount,
|
||
'type': type,
|
||
'created_at': createdAt.toIso8601String(),
|
||
'order_no': orderNo,
|
||
};
|
||
}
|
||
|
||
/// 充值(对应 Android Recharge)
|
||
class Recharge {
|
||
final String id;
|
||
final double amount;
|
||
final String payMethod;
|
||
final String? qrCodeUrl;
|
||
|
||
const Recharge({
|
||
required this.id,
|
||
required this.amount,
|
||
required this.payMethod,
|
||
this.qrCodeUrl,
|
||
});
|
||
|
||
factory Recharge.fromJson(Map<String, dynamic> json) => Recharge(
|
||
id: json['id'] as String? ?? '',
|
||
amount: (json['amount'] as num?)?.toDouble() ?? 0,
|
||
payMethod: json['pay_method'] as String? ?? '',
|
||
qrCodeUrl: json['qr_code_url'] as String?,
|
||
);
|
||
} |