import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/service_order_detail_entity.dart';

ServiceOrderDetailEntity $ServiceOrderDetailEntityFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailEntity serviceOrderDetailEntity = ServiceOrderDetailEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailEntity.id = id;
  }
  final String? sn = jsonConvert.convert<String>(json['sn']);
  if (sn != null) {
    serviceOrderDetailEntity.sn = sn;
  }
  final int? totalAmount = jsonConvert.convert<int>(json['total_amount']);
  if (totalAmount != null) {
    serviceOrderDetailEntity.totalAmount = totalAmount;
  }
  final int? orderStatus = jsonConvert.convert<int>(json['order_status']);
  if (orderStatus != null) {
    serviceOrderDetailEntity.orderStatus = orderStatus;
  }
  final String? cancelStatus = jsonConvert.convert<String>(json['cancel_status']);
  if (cancelStatus != null) {
    serviceOrderDetailEntity.cancelStatus = cancelStatus;
  }
  final String? paidAt = jsonConvert.convert<String>(json['paid_at']);
  if (paidAt != null) {
    serviceOrderDetailEntity.paidAt = paidAt;
  }
  final String? notes = jsonConvert.convert<String>(json['notes']);
  if (notes != null) {
    serviceOrderDetailEntity.notes = notes;
  }
  final ServiceOrderDetailAccount? account = jsonConvert.convert<ServiceOrderDetailAccount>(json['account']);
  if (account != null) {
    serviceOrderDetailEntity.account = account;
  }
  final ServiceOrderDetailOrderService? orderService = jsonConvert.convert<ServiceOrderDetailOrderService>(json['order_service']);
  if (orderService != null) {
    serviceOrderDetailEntity.orderService = orderService;
  }
  final ServiceOrderDetailMerchant? merchant = jsonConvert.convert<ServiceOrderDetailMerchant>(json['merchant']);
  if (merchant != null) {
    serviceOrderDetailEntity.merchant = merchant;
  }
  final ServiceOrderDetailStaff? staff = jsonConvert.convert<ServiceOrderDetailStaff>(json['staff']);
  if (staff != null) {
    serviceOrderDetailEntity.staff = staff;
  }
  final List<ServiceOrderDetailOrderProducts>? orderProducts = (json['order_products'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ServiceOrderDetailOrderProducts>(e) as ServiceOrderDetailOrderProducts).toList();
  if (orderProducts != null) {
    serviceOrderDetailEntity.orderProducts = orderProducts;
  }
  final ServiceOrderDetailEstate? estate = jsonConvert.convert<ServiceOrderDetailEstate>(json['estate']);
  if (estate != null) {
    serviceOrderDetailEntity.estate = estate;
  }
  final ServiceOrderDetailEstateUnit? estateUnit = jsonConvert.convert<ServiceOrderDetailEstateUnit>(json['estate_unit']);
  if (estateUnit != null) {
    serviceOrderDetailEntity.estateUnit = estateUnit;
  }
  final ServiceOrderDetailOrder? order = jsonConvert.convert<ServiceOrderDetailOrder>(json['order']);
  if (order != null) {
    serviceOrderDetailEntity.order = order;
  }
  return serviceOrderDetailEntity;
}

Map<String, dynamic> $ServiceOrderDetailEntityToJson(ServiceOrderDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sn'] = entity.sn;
  data['total_amount'] = entity.totalAmount;
  data['order_status'] = entity.orderStatus;
  data['cancel_status'] = entity.cancelStatus;
  data['paid_at'] = entity.paidAt;
  data['notes'] = entity.notes;
  data['account'] = entity.account?.toJson();
  data['order_service'] = entity.orderService?.toJson();
  data['merchant'] = entity.merchant?.toJson();
  data['staff'] = entity.staff?.toJson();
  data['order_products'] = entity.orderProducts?.map((v) => v.toJson()).toList();
  data['estate'] = entity.estate?.toJson();
  data['estate_unit'] = entity.estateUnit?.toJson();
  data['order'] = entity.order?.toJson();
  return data;
}

extension ServiceOrderDetailEntityExtension on ServiceOrderDetailEntity {
  ServiceOrderDetailEntity copyWith({
    String? id,
    String? sn,
    int? totalAmount,
    int? orderStatus,
    String? cancelStatus,
    String? paidAt,
    String? notes,
    ServiceOrderDetailAccount? account,
    ServiceOrderDetailOrderService? orderService,
    ServiceOrderDetailMerchant? merchant,
    ServiceOrderDetailStaff? staff,
    List<ServiceOrderDetailOrderProducts>? orderProducts,
    ServiceOrderDetailEstate? estate,
    ServiceOrderDetailEstateUnit? estateUnit,
    ServiceOrderDetailOrder? order,
  }) {
    return ServiceOrderDetailEntity()
      ..id = id ?? this.id
      ..sn = sn ?? this.sn
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderStatus = orderStatus ?? this.orderStatus
      ..cancelStatus = cancelStatus ?? this.cancelStatus
      ..paidAt = paidAt ?? this.paidAt
      ..notes = notes ?? this.notes
      ..account = account ?? this.account
      ..orderService = orderService ?? this.orderService
      ..merchant = merchant ?? this.merchant
      ..staff = staff ?? this.staff
      ..orderProducts = orderProducts ?? this.orderProducts
      ..estate = estate ?? this.estate
      ..estateUnit = estateUnit ?? this.estateUnit
      ..order = order ?? this.order;
  }
}

ServiceOrderDetailAccount $ServiceOrderDetailAccountFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailAccount serviceOrderDetailAccount = ServiceOrderDetailAccount();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailAccount.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceOrderDetailAccount.name = name;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    serviceOrderDetailAccount.avatar = avatar;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    serviceOrderDetailAccount.phone = phone;
  }
  return serviceOrderDetailAccount;
}

Map<String, dynamic> $ServiceOrderDetailAccountToJson(ServiceOrderDetailAccount entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['avatar'] = entity.avatar;
  data['phone'] = entity.phone;
  return data;
}

extension ServiceOrderDetailAccountExtension on ServiceOrderDetailAccount {
  ServiceOrderDetailAccount copyWith({
    String? id,
    String? name,
    String? avatar,
    String? phone,
  }) {
    return ServiceOrderDetailAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..phone = phone ?? this.phone;
  }
}

ServiceOrderDetailOrderService $ServiceOrderDetailOrderServiceFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailOrderService serviceOrderDetailOrderService = ServiceOrderDetailOrderService();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailOrderService.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceOrderDetailOrderService.name = name;
  }
  final int? evaluationsAvgScore = jsonConvert.convert<int>(json['evaluations_avg_score']);
  if (evaluationsAvgScore != null) {
    serviceOrderDetailOrderService.evaluationsAvgScore = evaluationsAvgScore;
  }
  return serviceOrderDetailOrderService;
}

Map<String, dynamic> $ServiceOrderDetailOrderServiceToJson(ServiceOrderDetailOrderService entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['evaluations_avg_score'] = entity.evaluationsAvgScore;
  return data;
}

extension ServiceOrderDetailOrderServiceExtension on ServiceOrderDetailOrderService {
  ServiceOrderDetailOrderService copyWith({
    String? id,
    String? name,
    int? evaluationsAvgScore,
  }) {
    return ServiceOrderDetailOrderService()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..evaluationsAvgScore = evaluationsAvgScore ?? this.evaluationsAvgScore;
  }
}

ServiceOrderDetailMerchant $ServiceOrderDetailMerchantFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailMerchant serviceOrderDetailMerchant = ServiceOrderDetailMerchant();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailMerchant.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceOrderDetailMerchant.name = name;
  }
  final String? contactPhone = jsonConvert.convert<String>(json['contact_phone']);
  if (contactPhone != null) {
    serviceOrderDetailMerchant.contactPhone = contactPhone;
  }
  return serviceOrderDetailMerchant;
}

Map<String, dynamic> $ServiceOrderDetailMerchantToJson(ServiceOrderDetailMerchant entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['contact_phone'] = entity.contactPhone;
  return data;
}

extension ServiceOrderDetailMerchantExtension on ServiceOrderDetailMerchant {
  ServiceOrderDetailMerchant copyWith({
    String? id,
    String? name,
    String? contactPhone,
  }) {
    return ServiceOrderDetailMerchant()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..contactPhone = contactPhone ?? this.contactPhone;
  }
}

ServiceOrderDetailStaff $ServiceOrderDetailStaffFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailStaff serviceOrderDetailStaff = ServiceOrderDetailStaff();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailStaff.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceOrderDetailStaff.name = name;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    serviceOrderDetailStaff.phone = phone;
  }
  return serviceOrderDetailStaff;
}

Map<String, dynamic> $ServiceOrderDetailStaffToJson(ServiceOrderDetailStaff entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['phone'] = entity.phone;
  return data;
}

extension ServiceOrderDetailStaffExtension on ServiceOrderDetailStaff {
  ServiceOrderDetailStaff copyWith({
    String? id,
    String? name,
    String? phone,
  }) {
    return ServiceOrderDetailStaff()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..phone = phone ?? this.phone;
  }
}

ServiceOrderDetailOrderProducts $ServiceOrderDetailOrderProductsFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailOrderProducts serviceOrderDetailOrderProducts = ServiceOrderDetailOrderProducts();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailOrderProducts.id = id;
  }
  final String? productName = jsonConvert.convert<String>(json['product_name']);
  if (productName != null) {
    serviceOrderDetailOrderProducts.productName = productName;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    serviceOrderDetailOrderProducts.quantity = quantity;
  }
  final int? totalAmount = jsonConvert.convert<int>(json['total_amount']);
  if (totalAmount != null) {
    serviceOrderDetailOrderProducts.totalAmount = totalAmount;
  }
  final String? plannedServiceAt = jsonConvert.convert<String>(json['planned_service_at']);
  if (plannedServiceAt != null) {
    serviceOrderDetailOrderProducts.plannedServiceAt = plannedServiceAt;
  }
  return serviceOrderDetailOrderProducts;
}

Map<String, dynamic> $ServiceOrderDetailOrderProductsToJson(ServiceOrderDetailOrderProducts entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['product_name'] = entity.productName;
  data['quantity'] = entity.quantity;
  data['total_amount'] = entity.totalAmount;
  data['planned_service_at'] = entity.plannedServiceAt;
  return data;
}

extension ServiceOrderDetailOrderProductsExtension on ServiceOrderDetailOrderProducts {
  ServiceOrderDetailOrderProducts copyWith({
    String? id,
    String? productName,
    int? quantity,
    int? totalAmount,
    String? plannedServiceAt,
  }) {
    return ServiceOrderDetailOrderProducts()
      ..id = id ?? this.id
      ..productName = productName ?? this.productName
      ..quantity = quantity ?? this.quantity
      ..totalAmount = totalAmount ?? this.totalAmount
      ..plannedServiceAt = plannedServiceAt ?? this.plannedServiceAt;
  }
}

ServiceOrderDetailEstate $ServiceOrderDetailEstateFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailEstate serviceOrderDetailEstate = ServiceOrderDetailEstate();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailEstate.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceOrderDetailEstate.name = name;
  }
  return serviceOrderDetailEstate;
}

Map<String, dynamic> $ServiceOrderDetailEstateToJson(ServiceOrderDetailEstate entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  return data;
}

extension ServiceOrderDetailEstateExtension on ServiceOrderDetailEstate {
  ServiceOrderDetailEstate copyWith({
    String? id,
    String? name,
  }) {
    return ServiceOrderDetailEstate()
      ..id = id ?? this.id
      ..name = name ?? this.name;
  }
}

ServiceOrderDetailEstateUnit $ServiceOrderDetailEstateUnitFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailEstateUnit serviceOrderDetailEstateUnit = ServiceOrderDetailEstateUnit();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    serviceOrderDetailEstateUnit.id = id;
  }
  final String? unit = jsonConvert.convert<String>(json['unit']);
  if (unit != null) {
    serviceOrderDetailEstateUnit.unit = unit;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    serviceOrderDetailEstateUnit.address = address;
  }
  return serviceOrderDetailEstateUnit;
}

Map<String, dynamic> $ServiceOrderDetailEstateUnitToJson(ServiceOrderDetailEstateUnit entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['unit'] = entity.unit;
  data['address'] = entity.address;
  return data;
}

extension ServiceOrderDetailEstateUnitExtension on ServiceOrderDetailEstateUnit {
  ServiceOrderDetailEstateUnit copyWith({
    String? id,
    String? unit,
    String? address,
  }) {
    return ServiceOrderDetailEstateUnit()
      ..id = id ?? this.id
      ..unit = unit ?? this.unit
      ..address = address ?? this.address;
  }
}

ServiceOrderDetailOrder $ServiceOrderDetailOrderFromJson(Map<String, dynamic> json) {
  final ServiceOrderDetailOrder serviceOrderDetailOrder = ServiceOrderDetailOrder();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    serviceOrderDetailOrder.id = id;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['total_amount']);
  if (totalAmount != null) {
    serviceOrderDetailOrder.totalAmount = totalAmount;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['order_amount']);
  if (orderAmount != null) {
    serviceOrderDetailOrder.orderAmount = orderAmount;
  }
  final String? depositAmount = jsonConvert.convert<String>(json['deposit_amount']);
  if (depositAmount != null) {
    serviceOrderDetailOrder.depositAmount = depositAmount;
  }
  final int? paymentStatus = jsonConvert.convert<int>(json['payment_status']);
  if (paymentStatus != null) {
    serviceOrderDetailOrder.paymentStatus = paymentStatus;
  }
  final String? paidAt = jsonConvert.convert<String>(json['paid_at']);
  if (paidAt != null) {
    serviceOrderDetailOrder.paidAt = paidAt;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    serviceOrderDetailOrder.refundStatus = refundStatus;
  }
  final String? refundedAt = jsonConvert.convert<String>(json['refunded_at']);
  if (refundedAt != null) {
    serviceOrderDetailOrder.refundedAt = refundedAt;
  }
  return serviceOrderDetailOrder;
}

Map<String, dynamic> $ServiceOrderDetailOrderToJson(ServiceOrderDetailOrder entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['total_amount'] = entity.totalAmount;
  data['order_amount'] = entity.orderAmount;
  data['deposit_amount'] = entity.depositAmount;
  data['payment_status'] = entity.paymentStatus;
  data['paid_at'] = entity.paidAt;
  data['refund_status'] = entity.refundStatus;
  data['refunded_at'] = entity.refundedAt;
  return data;
}

extension ServiceOrderDetailOrderExtension on ServiceOrderDetailOrder {
  ServiceOrderDetailOrder copyWith({
    int? id,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    int? paymentStatus,
    String? paidAt,
    int? refundStatus,
    String? refundedAt,
  }) {
    return ServiceOrderDetailOrder()
      ..id = id ?? this.id
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..paidAt = paidAt ?? this.paidAt
      ..refundStatus = refundStatus ?? this.refundStatus
      ..refundedAt = refundedAt ?? this.refundedAt;
  }
}