part of models;

/// 已完成订单
class OrderCompletedModel {
  OrderCompletedModel(
      {required this.value, required this.name, this.link, this.other});

  String value;
  String name;
  String? link;
  String? other;
}

/// 已完成订单详细信息模型
class OrderCompletedInfoModel {
  OrderCompletedInfoModel({
    this.id,
    this.price,
    this.totalPay,
    this.favorable,
    this.orderId,
    this.payWay,
    this.payTime,
    this.orderTime,
  });

  OrderCompletedInfoModel.fromJson(dynamic json) {
    id = json['id'];
    price = json['price'];
    totalPay = json['totalPay'];
    favorable = json['favorable'];
    orderId = json['orderId'];
    payWay = json['payWay'];
    payTime = json['payTime'];
    orderTime = json['orderTime'];
  }

  num? id;
  String? price; // 价格
  String? totalPay;
  String? favorable; // 优惠
  String? orderId; // 订单编号
  String? payWay; // 支付方式
  String? payTime; // 支付时间
  String? orderTime; // 下单时间

  OrderCompletedInfoModel copyWith({
    num? id,
    String? price,
    String? totalPay,
    String? favorable,
    String? orderId,
    String? payWay,
    String? payTime,
    String? orderTime,
  }) =>
      OrderCompletedInfoModel(
        id: id ?? this.id,
        price: price ?? this.price,
        totalPay: totalPay ?? this.totalPay,
        favorable: favorable ?? this.favorable,
        orderId: orderId ?? this.orderId,
        payWay: payWay ?? this.payWay,
        payTime: payTime ?? this.payTime,
        orderTime: orderTime ?? this.orderTime,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['price'] = price;
    map['totalPay'] = totalPay;
    map['favorable'] = favorable;
    map['orderId'] = orderId;
    map['payWay'] = payWay;
    map['payTime'] = payTime;
    map['orderTime'] = orderTime;
    return map;
  }
}

/// 订单列表模型
class OrderListModel {
  OrderListModel({
    this.id,
    this.ordersnum,
    this.totalPrice,
    this.finalTotalPrice,
    this.num_,
    this.status,
    this.payType,
    this.types,
    this.createTime,
    this.cartList,
  });

  OrderListModel.fromJson(dynamic json) {
    id = json['id'];
    ordersnum = json['ordersnum'];
    totalPrice = json['total_price'];
    finalTotalPrice = json['final_total_price'];
    num_ = json['num'];
    status = json['status'];
    payType = json['pay_type'];
    types = json['types'];
    createTime = json['create_time'];
    if (json['cart_list'] != null) {
      cartList = [];
      json['cart_list'].forEach((v) {
        cartList?.add(CartListModel.fromJson(v));
      });
    }
  }

  num? id;  //订单id
  String? ordersnum; //订单编号
  String? totalPrice; // 原价总价
  String? finalTotalPrice; //最终总价
  num? num_; //商品数量
  num? status; //订单状态 1：待支付，2取消支付，3：已支付 4:已退款
  num? payType; //支付方式 1：微信 2：支付宝,3：紫荆币
  num? types; //1是书籍订单  2是充值订单
  String? createTime; //创建时间
  List<CartListModel>? cartList = [];

  OrderListModel copyWith({
    num? id,
    String? ordersnum,
    String? totalPrice,
    String? finalTotalPrice,
    num? num,
    num? status,
    num? payType,
    num? types,
    String? createTime,
    List<CartListModel>? cartList,
  }) =>
      OrderListModel(
        id: id ?? this.id,
        ordersnum: ordersnum ?? this.ordersnum,
        totalPrice: totalPrice ?? this.totalPrice,
        finalTotalPrice: finalTotalPrice ?? this.finalTotalPrice,
        status: status ?? this.status,
        num_: num_ ?? this.num_,
        payType: payType ?? this.payType,
        types: types ?? this.types,
        createTime: createTime ?? this.createTime,
        cartList: cartList ?? this.cartList,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['ordersnum'] = ordersnum;
    map['total_price'] = totalPrice;
    map['final_total_price'] = finalTotalPrice;
    map['num'] = num_;
    map['status'] = status;
    map['pay_type'] = payType;
    map['types'] = types;
    map['create_time'] = createTime;
    if (cartList != null) {
      map['cart_list'] = cartList?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

/// 书籍列表
class CartListModel {
  CartListModel({
    this.recordId,
    this.orderId,
    this.price,
    this.num_,
    this.bookId,
    this.name,
    this.img,
    this.introduction,
    this.rating,
    this.comments,
    this.commentId,
  });

  CartListModel.fromJson(dynamic json) {
    recordId = json['record_id'];
    orderId = json['order_id'];
    price = json['price'];
    num_ = json['num'];
    bookId = json['book_id'];
    name = json['name'];
    img = json['img'];
    introduction = json['introduction'];
    rating = json['rating'];
    comments = json['comments'];
    commentId = json['comment_id'];
  }

  num? recordId; //书籍记录id
  num? orderId; //对应订单id
  String? price; // 书籍价格
  num? num_; // 书籍价格
  num? bookId; //书籍id，为0则是充值的没有书籍
  String? name; // 书籍名
  String? img; // 图片
  String? introduction; // 简介
  num? rating; // 评价星级
  String? comments; // 评价内容
  String? commentId; // 评价id

  CartListModel copyWith({
    num? recordId, //书籍记录id
    num? orderId, //对应订单id
    String? price, // 书籍价格
    num? num_, // 书籍价格
    num? bookId, //书籍id，为0则是充值的没有书籍
    String? name, // 书籍名
    String? img, // 图片
    String? introduction, // 简介
    num? rating, // 评价星级
    String? comments, // 评价内容
    String? commentId, // 评价id
  }) =>
      CartListModel(
        recordId: recordId ?? this.recordId,
        orderId: orderId ?? this.orderId,
        price: price ?? this.price,
        num_: num_ ?? this.num_,
        bookId: bookId ?? this.bookId,
        name: name ?? this.name,
        img: img ?? this.img,
        introduction: introduction ?? this.introduction,
        rating: rating ?? this.rating,
        comments: comments ?? this.comments,
        commentId: commentId ?? this.commentId,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['record_id'] = recordId;
    map['order_id'] = orderId;
    map['num'] = num_;
    map['price'] = price;
    map['book_id'] = bookId;
    map['name'] = name;
    map['img'] = img;
    map['introduction'] = introduction;
    map['rating'] = rating;
    map['comments'] = comments;
    map['comment_id'] = commentId;
    return map;
  }
}


/// id : 740
/// ordersnum : "VN240126111215511309"
/// total_price : "45.00"
/// final_total_price : "45.00"
/// nums : 1
/// status : 3
/// create_time : "2024-01-26 11:12:15"
/// coupon_price : "0.00"
/// integral_price : "0.00"
/// pay_type : 3
/// pay_time : "2024-01-26 11:12:15"
/// types : 1
/// bean : 0
/// book_list : [{"book_id":110,"name":"ASASDASD","img":"img","introduction":"introduction","price":"45.00","rating":0,"comments":0,"create_time":0}]

class OrderInfoModel {
  OrderInfoModel({
    this.id,
    this.ordersnum,
    this.totalPrice,
    this.finalTotalPrice,
    this.nums,
    this.status,
    this.createTime,
    this.couponPrice,
    this.integralPrice,
    this.payType,
    this.payTime,
    this.types,
    this.bean,
    this.bookList,});

  OrderInfoModel.fromJson(dynamic json) {
    id = json['id'];
    ordersnum = json['ordersnum'];
    totalPrice = json['total_price'];
    finalTotalPrice = json['final_total_price'];
    nums = json['num'];
    status = json['status'];
    createTime = json['create_time'];
    couponPrice = json['coupon_price'];
    integralPrice = json['integral_price'];
    payType = json['pay_type'];
    payTime = json['pay_time'];
    types = json['types'];
    bean = json['bean'];
    if (json['list'] != null) {
      bookList = [];
      json['list'].forEach((v) {
        bookList?.add(BookListModel.fromJson(v));
      });
    }
  }
  num? id;
  String? ordersnum;
  String? totalPrice;
  String? finalTotalPrice;
  num? nums;
  num? status;
  String? createTime;
  String? couponPrice;
  String? integralPrice;
  num? payType;
  String? payTime;
  num? types;
  num? bean;
  List<BookListModel>? bookList;
  OrderInfoModel copyWith({  num? id,
    String? ordersnum,
    String? totalPrice,
    String? finalTotalPrice,
    num? nums,
    num? status,
    String? createTime,
    String? couponPrice,
    String? integralPrice,
    num? payType,
    String? payTime,
    num? types,
    num? bean,
    List<BookListModel>? bookList,
  }) => OrderInfoModel(  id: id ?? this.id,
    ordersnum: ordersnum ?? this.ordersnum,
    totalPrice: totalPrice ?? this.totalPrice,
    finalTotalPrice: finalTotalPrice ?? this.finalTotalPrice,
    nums: nums ?? this.nums,
    status: status ?? this.status,
    createTime: createTime ?? this.createTime,
    couponPrice: couponPrice ?? this.couponPrice,
    integralPrice: integralPrice ?? this.integralPrice,
    payType: payType ?? this.payType,
    payTime: payTime ?? this.payTime,
    types: types ?? this.types,
    bean: bean ?? this.bean,
    bookList: bookList ?? this.bookList,
  );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['ordersnum'] = ordersnum;
    map['total_price'] = totalPrice;
    map['final_total_price'] = finalTotalPrice;
    map['num'] = nums;
    map['status'] = status;
    map['create_time'] = createTime;
    map['coupon_price'] = couponPrice;
    map['integral_price'] = integralPrice;
    map['pay_type'] = payType;
    map['pay_time'] = payTime;
    map['types'] = types;
    map['bean'] = bean;
    if (bookList != null) {
      map['list'] = bookList?.map((v) => v.toJson()).toList();
    }
    return map;
  }

}

/// book_id : 110
/// name : "ASASDASD"
/// img : "img"
/// introduction : "introduction"
/// price : "45.00"
/// rating : 0
/// comments : 0
/// create_time : 0

class BookListModel {
  BookListModel({
    this.bookId,
    this.name,
    this.img,
    this.introduction,
    this.price,
    this.rating,
    this.comments,
    this.createTime,});

  BookListModel.fromJson(dynamic json) {
    bookId = json['book_id'];
    name = json['name'];
    img = json['img'];
    introduction = json['introduction'];
    price = json['price'];
    rating = json['rating'];
    comments = json['comments'];
    createTime = json['create_time'];
  }
  num? bookId;
  String? name;
  String? img;
  String? introduction;
  String? price;
  num? rating;
  num? comments;
  num? createTime;
  BookListModel copyWith({  num? bookId,
    String? name,
    String? img,
    String? introduction,
    String? price,
    num? rating,
    num? comments,
    num? createTime,
  }) => BookListModel(  bookId: bookId ?? this.bookId,
    name: name ?? this.name,
    img: img ?? this.img,
    introduction: introduction ?? this.introduction,
    price: price ?? this.price,
    rating: rating ?? this.rating,
    comments: comments ?? this.comments,
    createTime: createTime ?? this.createTime,
  );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['book_id'] = bookId;
    map['name'] = name;
    map['img'] = img;
    map['introduction'] = introduction;
    map['price'] = price;
    map['rating'] = rating;
    map['comments'] = comments;
    map['create_time'] = createTime;
    return map;
  }

}
