import 'package:intl/intl.dart';
import 'package:location/resource/string.gen.dart';

class MemberStatusInfo {
  final String? userId;
  final bool? trialed;
  final int level;
  final int endTimestamp;
  final bool expired;
  final bool permanent;
  final int? startTimestamp;
  final int? serverTimestamp;
  final String? subscriptionGroup;
  final int? autoRenewStatus;
  final bool? subscriptionExpired;
  final String? avatar;
  final int? trialEndTimestamp;

  MemberStatusInfo({
    required this.level,
    required this.endTimestamp,
    required this.expired,
    required this.permanent,
    this.userId,
    this.trialed,
    this.startTimestamp,
    this.serverTimestamp,
    this.subscriptionGroup,
    this.autoRenewStatus,
    this.subscriptionExpired,
    this.avatar,
    this.trialEndTimestamp
  });

  /// 获取会员等级描述
  static String getLevelDesc(MemberStatusInfo? info) {
    if (info == null || info.expired == true) {
      return "";//'未开通';
    }
    if (info.level > 0 && info.level < 100) {
      return '试用会员';
    }
    // 根据等级返回描述
    switch (info.level) {
      case 0:
        return "";//'未开通';
      case 100:
        return '日卡会员';
      case 700:
        return '周卡会员';
      case 3100:
        return '月度会员';
      case 9200:
        return '季度会员';
      case 36600:
        return '年度会员';
      case 3660000:
        return '终身会员';
      default:
        return "";//'未知会员等级';
    }
  }
}
