Files
platforms/apps/user_app/lib/domain/models/client_models.dart

74 lines
1.9 KiB
Dart
Raw Normal View History

class ClientRecord {
const ClientRecord({
required this.identity,
required this.title,
required this.subtitle,
required this.raw,
this.status,
});
final String identity;
final String title;
final String subtitle;
final int? status;
final Map<String, Object?> raw;
}
class UserProfile {
const UserProfile({
required this.identity,
required this.name,
required this.phone,
required this.avatar,
this.realName = '',
});
final String identity;
final String name;
final String phone;
final String avatar;
final String realName;
factory UserProfile.fromJson(Map<String, Object?> json) => UserProfile(
identity: json['identity'] as String? ?? '',
name: json['name'] as String? ?? '',
phone: json['phone'] as String? ?? '',
avatar: json['avatar'] as String? ?? '',
realName: json['real_name'] as String? ?? '',
);
}
class WalletSummary {
const WalletSummary({
required this.balance,
required this.withdrawalBalance,
this.paymentPasswordSet,
});
final int balance;
final int withdrawalBalance;
// 缺少状态时保持未知,不能误当作未设置支付密码。
final bool? paymentPasswordSet;
factory WalletSummary.fromJson(Map<String, Object?> json) => WalletSummary(
balance: (json['balance'] as num?)?.toInt() ?? 0,
withdrawalBalance: (json['withdrawal_balance'] as num?)?.toInt() ?? 0,
paymentPasswordSet: json['payment_password_set'] as bool?,
);
}
/// 手机验证码申请结果,明确区分请求建立与短信已发送。
class PaymentCodeRequest {
const PaymentCodeRequest({
required this.identity,
required this.delivered,
required this.maskedPhone,
required this.retryAfter,
});
final String identity, maskedPhone;
final bool delivered;
final int retryAfter;
}
String moneyText(int cents) => '¥${(cents / 100).toStringAsFixed(2)}';