
enum ProductItemType { goods, service }

class ShoppingCart {
  List<ServiceProviderItem>? serviceProviderItemList = []; // 服务商列表
  ShoppingCart({this.serviceProviderItemList});

  ShoppingCart copyWith({
    List<ServiceProviderItem>? serviceProviderItemList,
  }) {
    return ShoppingCart(
      serviceProviderItemList:
          serviceProviderItemList ?? this.serviceProviderItemList,
    );
  }
}

// 卖家
class ServiceProviderItem {
  String? serviceProviderId;  // 服务商Id
  String? serviceProviderName; // 服务商名称
  String? serviceProviderImg;  // 服务商图片
  List<ProductItem>? productItemList = []; // 商品/服务列表
  ServiceProviderItem({
    this.serviceProviderId,
    this.serviceProviderName,
    this.serviceProviderImg,
    this.productItemList
  });

  ServiceProviderItem copyWith({
    String? serviceProviderId,
    String? serviceProviderName,
    String? serviceProviderImg,
    List<ProductItem>? productItemList,
  }) {
    return ServiceProviderItem(
      serviceProviderId: serviceProviderId ?? this.serviceProviderId,
      serviceProviderName: serviceProviderName ?? this.serviceProviderName,
      serviceProviderImg: serviceProviderImg ?? this.serviceProviderImg,
      productItemList: productItemList ?? this.productItemList,
    );
  }
}

// 商品或者服务
class ProductItem {
  ProductItemType type; // 标识是商品还是服务
  String? productId;  // 商品id
  String? productName; // 商品名称
  String? productPrice; // 商品价格
  String? productNum; // 商品数量
  String? productImg; // 商品图片
  double? productScore;  // 商品/服务 评分
  String? serviceDate;  // 服务的日期
  String? serviceTime;  // 服务的时间

  ProductItem({
    required this.type,
    this.productId,
    this.productName,
    this.productPrice,
    this.productNum,
    this.productImg,
    this.productScore,
    this.serviceDate,
    this.serviceTime,
  });

  ProductItem copyWith({
    ProductItemType? type,
    String? productId,
    String? productName,
    String? productPrice,
    String? productNum,
    String? productImg,
    double? productScore,
    String? serviceDate,
    String? serviceTime,
  }) {
    return ProductItem(
      type: type ?? this.type,
      productId: productId ?? this.productId,
      productName: productName ?? this.productName,
      productPrice: productPrice ?? this.productPrice,
      productNum: productNum ?? this.productNum,
      productImg: productImg ?? this.productImg,
      productScore: productScore ?? this.productScore,
      serviceDate: serviceDate ?? this.serviceDate,
      serviceTime: serviceTime ?? this.serviceTime,
    );
  }
}
