package com.xunhong.erp.turbo.biz.infrastructure.convert;

import com.xunhong.erp.turbo.api.biz.dto.cmd.*;
import com.xunhong.erp.turbo.biz.domain.entity.PurchaseOrder;
import com.xunhong.erp.turbo.biz.infrastructure.entity.PurchaseOrderDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;

/**
 * @author shenyifei
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {OrderVehicleConvert.class, OrderSupplierConvert.class, OrderCostConvert.class, OrderPackageConvert.class, OrderDealerConvert.class, OrderRebateConvert.class, OrderCompanyConvert.class})
public interface PurchaseOrderConvert {

	@Mapping(target = "orderRebate", source = "orderRebateDO")
	@Mapping(target = "orderCompany", source = "orderCompanyDO")
	@Mapping(target = "orderDealer", source = "orderDealerDO")
	@Mapping(target = "orderCostList", source = "orderCostDOList")
	@Mapping(target = "orderSupplierList", source = "orderSupplierDOList")
	@Mapping(target = "orderVehicle", source = "orderVehicleDO")
	PurchaseOrder toPurchaseOrder(PurchaseOrderDO purchaseOrderDO);

	@Mapping(target = "totalCost", ignore = true)
	@Mapping(target = "supplierCount", ignore = true)
	@Mapping(target = "saleAmount", ignore = true)
	@Mapping(target = "rebate", ignore = true)
	@Mapping(target = "pricingMethod", ignore = true)
	@Mapping(target = "packageFee", ignore = true)
	@Mapping(target = "orderRebateDO", ignore = true)
	@Mapping(target = "orderCompanyDO", ignore = true)
	@Mapping(target = "netWeight", ignore = true)
	@Mapping(target = "grossWeight", ignore = true)
	@Mapping(target = "freightCharge", ignore = true)
	@Mapping(target = "avgUnitPrice", ignore = true)
	@Mapping(target = "orderDealerDO", ignore = true)
	@Mapping(target = "orderCostDOList", ignore = true)
	@Mapping(target = "orderSn", ignore = true)
	@Mapping(target = "orderVehicleDO", ignore = true)
	@Mapping(target = "orderSupplierDOList", ignore = true)
	@Mapping(target = "state", ignore = true)
	@Mapping(target = "orderId", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	PurchaseOrderDO toPurchaseOrderDO(PurchaseOrderCreateCmd purchaseOrderCreateCmd);

	@Mapping(target = "totalCost", ignore = true)
	@Mapping(target = "supplierCount", ignore = true)
	@Mapping(target = "saleAmount", ignore = true)
	@Mapping(target = "rebate", ignore = true)
	@Mapping(target = "pricingMethod", ignore = true)
	@Mapping(target = "packageFee", ignore = true)
	@Mapping(target = "orderRebateDO", ignore = true)
	@Mapping(target = "orderCompanyDO", ignore = true)
	@Mapping(target = "netWeight", ignore = true)
	@Mapping(target = "grossWeight", ignore = true)
	@Mapping(target = "freightCharge", ignore = true)
	@Mapping(target = "avgUnitPrice", ignore = true)
	@Mapping(target = "orderDealerDO", ignore = true)
	@Mapping(target = "orderCostDOList", ignore = true)
	@Mapping(target = "orderVehicleDO", ignore = true)
	@Mapping(target = "orderSupplierDOList", ignore = true)
	@Mapping(target = "orderSn", ignore = true)
	@Mapping(target = "state", ignore = true)
	@Mapping(target = "createdByName", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toPurchaseOrderDO(@MappingTarget PurchaseOrderDO purchaseOrderDO, PurchaseOrderUpdateCmd purchaseOrderUpdateCmd);

	PurchaseOrderStep1Cmd toPurchaseOrderStep1Cmd(PurchaseOrderCreateCmd purchaseOrderCreateCmd);

	PurchaseOrderStep2Cmd toPurchaseOrderStep2Cmd(PurchaseOrderCreateCmd purchaseOrderCreateCmd);

	PurchaseOrderStep3Cmd toPurchaseOrderStep3Cmd(PurchaseOrderCreateCmd purchaseOrderCreateCmd);

	@Mapping(target = "originPrincipal", source = "createdByName")
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "totalCost", ignore = true)
	@Mapping(target = "supplierCount", ignore = true)
	@Mapping(target = "state", ignore = true)
	@Mapping(target = "saleAmount", ignore = true)
	@Mapping(target = "remark", ignore = true)
	@Mapping(target = "rebate", ignore = true)
	@Mapping(target = "pricingMethod", ignore = true)
	@Mapping(target = "packageFee", ignore = true)
	@Mapping(target = "orderVehicleDO", ignore = true)
	@Mapping(target = "orderSupplierDOList", ignore = true)
	@Mapping(target = "orderSn", ignore = true)
	@Mapping(target = "orderRebateDO", ignore = true)
	@Mapping(target = "orderDealerDO", ignore = true)
	@Mapping(target = "orderCostDOList", ignore = true)
	@Mapping(target = "orderCompanyDO", ignore = true)
	@Mapping(target = "netWeight", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "grossWeight", ignore = true)
	@Mapping(target = "freightCharge", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	@Mapping(target = "avgUnitPrice", ignore = true)
	PurchaseOrderDO toPurchaseOrderDO(PurchaseOrderStep1Cmd purchaseOrderStep1Cmd);
}

