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

PaidServicePaySuccessInfoEntity $PaidServicePaySuccessInfoEntityFromJson(Map<String, dynamic> json) {
  final PaidServicePaySuccessInfoEntity paidServicePaySuccessInfoEntity = PaidServicePaySuccessInfoEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    paidServicePaySuccessInfoEntity.id = id;
  }
  final String? sn = jsonConvert.convert<String>(json['sn']);
  if (sn != null) {
    paidServicePaySuccessInfoEntity.sn = sn;
  }
  final int? totalAmount = jsonConvert.convert<int>(json['total_amount']);
  if (totalAmount != null) {
    paidServicePaySuccessInfoEntity.totalAmount = totalAmount;
  }
  final String? paidAt = jsonConvert.convert<String>(json['paid_at']);
  if (paidAt != null) {
    paidServicePaySuccessInfoEntity.paidAt = paidAt;
  }
  final String? notes = jsonConvert.convert<String>(json['notes']);
  if (notes != null) {
    paidServicePaySuccessInfoEntity.notes = notes;
  }
  final PaidServicePaySuccessInfoAccount? account = jsonConvert.convert<PaidServicePaySuccessInfoAccount>(json['account']);
  if (account != null) {
    paidServicePaySuccessInfoEntity.account = account;
  }
  final PaidServicePaySuccessInfoOrderService? orderService = jsonConvert.convert<PaidServicePaySuccessInfoOrderService>(json['order_service']);
  if (orderService != null) {
    paidServicePaySuccessInfoEntity.orderService = orderService;
  }
  final PaidServicePaySuccessInfoMerchant? merchant = jsonConvert.convert<PaidServicePaySuccessInfoMerchant>(json['merchant']);
  if (merchant != null) {
    paidServicePaySuccessInfoEntity.merchant = merchant;
  }
  final PaidServicePaySuccessInfoStaff? staff = jsonConvert.convert<PaidServicePaySuccessInfoStaff>(json['staff']);
  if (staff != null) {
    paidServicePaySuccessInfoEntity.staff = staff;
  }
  final List<PaidServicePaySuccessInfoOrderProducts>? orderProducts = (json['order_products'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PaidServicePaySuccessInfoOrderProducts>(e) as PaidServicePaySuccessInfoOrderProducts).toList();
  if (orderProducts != null) {
    paidServicePaySuccessInfoEntity.orderProducts = orderProducts;
  }
  final PaidServicePaySuccessInfoEstate? estate = jsonConvert.convert<PaidServicePaySuccessInfoEstate>(json['estate']);
  if (estate != null) {
    paidServicePaySuccessInfoEntity.estate = estate;
  }
  final PaidServicePaySuccessInfoEstateUnit? estateUnit = jsonConvert.convert<PaidServicePaySuccessInfoEstateUnit>(json['estate_unit']);
  if (estateUnit != null) {
    paidServicePaySuccessInfoEntity.estateUnit = estateUnit;
  }
  final PaidServicePaySuccessInfoOrder? order = jsonConvert.convert<PaidServicePaySuccessInfoOrder>(json['order']);
  if (order != null) {
    paidServicePaySuccessInfoEntity.order = order;
  }
  return paidServicePaySuccessInfoEntity;
}

Map<String, dynamic> $PaidServicePaySuccessInfoEntityToJson(PaidServicePaySuccessInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sn'] = entity.sn;
  data['total_amount'] = entity.totalAmount;
  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 PaidServicePaySuccessInfoEntityExtension on PaidServicePaySuccessInfoEntity {
  PaidServicePaySuccessInfoEntity copyWith({
    String? id,
    String? sn,
    int? totalAmount,
    String? paidAt,
    String? notes,
    PaidServicePaySuccessInfoAccount? account,
    PaidServicePaySuccessInfoOrderService? orderService,
    PaidServicePaySuccessInfoMerchant? merchant,
    PaidServicePaySuccessInfoStaff? staff,
    List<PaidServicePaySuccessInfoOrderProducts>? orderProducts,
    PaidServicePaySuccessInfoEstate? estate,
    PaidServicePaySuccessInfoEstateUnit? estateUnit,
    PaidServicePaySuccessInfoOrder? order,
  }) {
    return PaidServicePaySuccessInfoEntity()
      ..id = id ?? this.id
      ..sn = sn ?? this.sn
      ..totalAmount = totalAmount ?? this.totalAmount
      ..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;
  }
}

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

Map<String, dynamic> $PaidServicePaySuccessInfoAccountToJson(PaidServicePaySuccessInfoAccount 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 PaidServicePaySuccessInfoAccountExtension on PaidServicePaySuccessInfoAccount {
  PaidServicePaySuccessInfoAccount copyWith({
    String? id,
    String? name,
    String? avatar,
    String? phone,
  }) {
    return PaidServicePaySuccessInfoAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..phone = phone ?? this.phone;
  }
}

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

Map<String, dynamic> $PaidServicePaySuccessInfoOrderServiceToJson(PaidServicePaySuccessInfoOrderService 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 PaidServicePaySuccessInfoOrderServiceExtension on PaidServicePaySuccessInfoOrderService {
  PaidServicePaySuccessInfoOrderService copyWith({
    String? id,
    String? name,
    int? evaluationsAvgScore,
  }) {
    return PaidServicePaySuccessInfoOrderService()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..evaluationsAvgScore = evaluationsAvgScore ?? this.evaluationsAvgScore;
  }
}

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

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

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

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

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

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

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

Map<String, dynamic> $PaidServicePaySuccessInfoOrderProductsToJson(PaidServicePaySuccessInfoOrderProducts 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 PaidServicePaySuccessInfoOrderProductsExtension on PaidServicePaySuccessInfoOrderProducts {
  PaidServicePaySuccessInfoOrderProducts copyWith({
    String? id,
    String? productName,
    int? quantity,
    int? totalAmount,
    String? plannedServiceAt,
  }) {
    return PaidServicePaySuccessInfoOrderProducts()
      ..id = id ?? this.id
      ..productName = productName ?? this.productName
      ..quantity = quantity ?? this.quantity
      ..totalAmount = totalAmount ?? this.totalAmount
      ..plannedServiceAt = plannedServiceAt ?? this.plannedServiceAt;
  }
}

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

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

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

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

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

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

PaidServicePaySuccessInfoOrder $PaidServicePaySuccessInfoOrderFromJson(Map<String, dynamic> json) {
  final PaidServicePaySuccessInfoOrder paidServicePaySuccessInfoOrder = PaidServicePaySuccessInfoOrder();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServicePaySuccessInfoOrder.id = id;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['total_amount']);
  if (totalAmount != null) {
    paidServicePaySuccessInfoOrder.totalAmount = totalAmount;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['order_amount']);
  if (orderAmount != null) {
    paidServicePaySuccessInfoOrder.orderAmount = orderAmount;
  }
  final String? depositAmount = jsonConvert.convert<String>(json['deposit_amount']);
  if (depositAmount != null) {
    paidServicePaySuccessInfoOrder.depositAmount = depositAmount;
  }
  final int? paymentStatus = jsonConvert.convert<int>(json['payment_status']);
  if (paymentStatus != null) {
    paidServicePaySuccessInfoOrder.paymentStatus = paymentStatus;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    paidServicePaySuccessInfoOrder.refundStatus = refundStatus;
  }
  return paidServicePaySuccessInfoOrder;
}

Map<String, dynamic> $PaidServicePaySuccessInfoOrderToJson(PaidServicePaySuccessInfoOrder 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['refund_status'] = entity.refundStatus;
  return data;
}

extension PaidServicePaySuccessInfoOrderExtension on PaidServicePaySuccessInfoOrder {
  PaidServicePaySuccessInfoOrder copyWith({
    int? id,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    int? paymentStatus,
    int? refundStatus,
  }) {
    return PaidServicePaySuccessInfoOrder()
      ..id = id ?? this.id
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus;
  }
}