recharge_list_model.dart 6.46 KB
import 'dart:convert' as convert;

import 'package:common_utils/common_utils.dart';
import 'package:one_key/models/filter_btn_model.dart';

import 'coupon_model.dart';

class RechargeListModel {
  int ret;
  List<RechargeListSunModel> data;
  String msg;

  RechargeListModel({this.ret, this.data, this.msg});

  RechargeListModel.fromJson(Map<String, dynamic> json) {
    ret = json['ret'];
    if (json['data'] != null) {
      data = [];
      json['data'].forEach((v) {
        if (v['status'] != '1') {
          data.add(new RechargeListSunModel.fromJson(v));
        }
      });
    }
    msg = json['msg'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ret'] = this.ret;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    data['msg'] = this.msg;
    return data;
  }
}

class RechargeListSunModel {
  String id;
  String uid;
  String sellerid;
  String rname;
  String rechargeMoney;
  RechargeListDataModel rechargeList;
  RechargeDateModel expDate;
  String explain;
  String isOpen;
  String status;
  String qrcode;
  String isExamine;
  String cdate;
  bool isCheck = false;
  String stime;
  String etime;

  String get cdateStr {
    if (cdate.toString() == '0') {
      return '';
    }
    DateTime dateTime =
        DateTime.fromMillisecondsSinceEpoch(int.parse(cdate.toString()) * 1000);
    return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
  }

  String get stimeStr {
    if (stime == null || stime.toString() == '0') {
      return '';
    }
    DateTime dateTime =
        DateTime.fromMillisecondsSinceEpoch(int.parse(stime.toString()) * 1000);
    return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
  }

  String get etimeStr {
    if (etime == null || etime.toString() == '0') {
      return '';
    }
    DateTime dateTime =
        DateTime.fromMillisecondsSinceEpoch(int.parse(etime.toString()) * 1000);
    return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
  }

  RechargeListSunModel(
      {this.id,
      this.uid,
      this.sellerid,
      this.rname,
      this.rechargeMoney,
      this.rechargeList,
      this.expDate,
      this.explain,
      this.isOpen,
      this.status,
      this.qrcode,
      this.isExamine,
      this.cdate,
      this.stime,
      this.etime});

  RechargeListSunModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    uid = json['uid'];
    sellerid = json['sellerid'];
    rname = json['rname'];
    rechargeMoney = json['recharge_money'];
    rechargeList = json['recharge_list'] == null
        ? null
        : json['recharge_list'] is Map
            ? RechargeListDataModel.fromJson(json['recharge_list'])
            : RechargeListDataModel.fromJson(convert
                .jsonDecode(json['recharge_list']) as Map<String, dynamic>);

    expDate = json['exp_date'] == null
        ? null
        : json['exp_date'] is Map
            ? RechargeDateModel.fromJson(json['exp_date'])
            : RechargeDateModel.fromJson(
                convert.jsonDecode(json['exp_date']) as Map<String, dynamic>);
    explain = json['explain'];
    isOpen = json['is_open'];
    status = json['status'];
    qrcode = json['qrcode'];
    isExamine = json['is_examine'];
    cdate = json['cdate'];
    stime = json['stime'];
    etime = json['etime'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['uid'] = this.uid;
    data['sellerid'] = this.sellerid;
    data['rname'] = this.rname;
    data['recharge_money'] = this.rechargeMoney;
    data['recharge_list'] = this.rechargeList;
    data['exp_date'] = this.expDate;
    data['explain'] = this.explain;
    data['is_open'] = this.isOpen;
    data['status'] = this.status;
    data['qrcode'] = this.qrcode;
    data['is_examine'] = this.isExamine;
    data['cdate'] = this.cdate;
    data['stime'] = this.stime;
    data['etime'] = this.etime;
    return data;
  }
}

class RechargeListDataModel {
  String isPrice;
  String isScore;
  String isCoupons;
  String price;
  String score;
  List<CouponSunModel> coupons;
  List<dynamic> couponsIds;
  List<dynamic> couponsNames;

  RechargeListDataModel({
    this.isPrice,
    this.isCoupons,
    this.isScore,
    this.price,
    this.score,
    this.coupons,
    this.couponsIds,
    this.couponsNames,
  });

  RechargeListDataModel.fromJson(Map<String, dynamic> json) {
    isPrice = json['is_price'];
    isScore = json['is_score'];
    isCoupons = json['is_coupons'];
    price = json['price'];
    score = json['score'];
    coupons = <CouponSunModel>[];
    if (json['coupons'] != null) {
      json['coupons'].forEach((v) {
        coupons.add(new CouponSunModel.fromJson(v));
      });
    }

    couponsIds = json['coupons_ids'];
    couponsNames = json['coupons_names'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['is_price'] = this.isPrice;
    data['is_score'] = this.isScore;
    data['is_coupons'] = this.isCoupons;
    data['price'] = this.price;
    data['score'] = this.score;
    data['coupons'] = this.coupons;
    data['coupons_ids'] = this.couponsIds;
    data['coupons_names'] = this.couponsNames;

    return data;
  }
}

class RechargeDateModel {
  String isFix;
  String isWeek;
  String isBirthday;
  String fixSdate;
  String fixEdate;
  String weekDateShow;
  List<FilterBtnModel> weekDateData;

  RechargeDateModel({
    this.isFix,
    this.isWeek,
    this.isBirthday,
    this.fixSdate,
    this.fixEdate,
    this.weekDateShow,
    this.weekDateData,
  });

  RechargeDateModel.fromJson(Map<String, dynamic> json) {
    isFix = json['is_fix'];
    isWeek = json['is_week'];
    isBirthday = json['is_birthday'];
    fixSdate = json['fix_sdate'];
    fixEdate = json['fix_edate'];
    weekDateShow = json['week_date_show'];

    weekDateData = <FilterBtnModel>[];
    if (json['week_date_data'] != null && json['week_date_data'] != '') {
      json['week_date_data'].forEach((v) {
        weekDateData.add(new FilterBtnModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['is_fix'] = this.isFix;
    data['is_week'] = this.isWeek;
    data['is_birthday'] = this.isBirthday;
    data['fix_sdate'] = this.fixSdate;
    data['fix_edate'] = this.fixEdate;
    data['week_date_show'] = this.weekDateShow;
    data['week_date_data'] = this.weekDateData;

    return data;
  }
}