package cn.superdesk.uniorder.service.invoice.customer.impl;

import cn.superdesk.uniorder.common.enums.accounting.AccountingOrderDimCreateByEnum;
import cn.superdesk.uniorder.dto.vo.invoice.customer.InvoiceApplyDetailDimOrderItemVo;
import cn.superdesk.uniorder.dto.vo.invoice.customer.ExportExcelDimUnifiedInvoiceRegister4E6Vo;
import cn.superdesk.uniorder.dto.vo.invoice.customer.InvoiceApplyDetailDimGoodsItemV3Vo;
import cn.superdesk.uniorder.dto.vo.invoice.customer.InvoiceApplyCustomerDetailDimGoodsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2021/3/31 下午4:16
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/3/31 下午4:16
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service
public class TransformExportExcelDimUnifiedInvoiceRegister4E6Tools {


	public List<ExportExcelDimUnifiedInvoiceRegister4E6Vo> transform(InvoiceApplyCustomerDetailDimGoodsVo invoiceApplyDetailDimGoodsVo, AccountingOrderDimCreateByEnum dim) {


		List<ExportExcelDimUnifiedInvoiceRegister4E6Vo> result = new ArrayList<>();

		switch (dim) {
			case 订单:

				List<InvoiceApplyDetailDimOrderItemVo> dzOrders = invoiceApplyDetailDimGoodsVo.getDzOrders();

				dzOrders.forEach(item1 -> {
					result.add(ViewDzOrder2ExportExcelDimUnifiedInvoiceRegister4E6Vo(invoiceApplyDetailDimGoodsVo, item1));
				});

				break;
			case 商品:

				List<InvoiceApplyDetailDimGoodsItemV3Vo> innerOrderJoinGoodsList = invoiceApplyDetailDimGoodsVo.getInnerOrderJoinGoodsList();

				innerOrderJoinGoodsList.forEach(item2 -> {
					result.add(InvoiceApplyDetailDimGoodsV3Vo2ExportExcelDimUnifiedInvoiceRegister4E6Vo(invoiceApplyDetailDimGoodsVo, item2));
				});

				break;
			case 流水:
				break;
			default:
				break;

		}

		return result;
	}

	public ExportExcelDimUnifiedInvoiceRegister4E6Vo ViewDzOrder2ExportExcelDimUnifiedInvoiceRegister4E6Vo(InvoiceApplyCustomerDetailDimGoodsVo mainItem, InvoiceApplyDetailDimOrderItemVo listItem) {

		ExportExcelDimUnifiedInvoiceRegister4E6Vo exportExcelDimUnifiedInvoiceRegister4E6Vo = new ExportExcelDimUnifiedInvoiceRegister4E6Vo();

		exportExcelDimUnifiedInvoiceRegister4E6Vo.setOrderSn(listItem.getOrderSn());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceApplySn(mainItem.getInvoiceApplySn());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setGoodsName(listItem.getOptionname());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceCompanyName(listItem.getInvoiceCompanyName());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setQuantity(listItem.getTotal());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setPriceXQuantity(listItem.getTotalPrice());
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setSelfOption(viewDzOrder.g);
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setUnit(listItem.getUnit());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setRemark(listItem.getRemarks());
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setTaxRate(viewDzOrder.gett);
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceTypeName(listItem.getInvoiceTypeName());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setTaxCode(listItem.getTaxCode());
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setPurchaseUserName(viewDzOrder.getp);
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setRecUserName();


		return exportExcelDimUnifiedInvoiceRegister4E6Vo;

	}

	public ExportExcelDimUnifiedInvoiceRegister4E6Vo InvoiceApplyDetailDimGoodsV3Vo2ExportExcelDimUnifiedInvoiceRegister4E6Vo(InvoiceApplyCustomerDetailDimGoodsVo mainItem, InvoiceApplyDetailDimGoodsItemV3Vo listItem) {

		ExportExcelDimUnifiedInvoiceRegister4E6Vo exportExcelDimUnifiedInvoiceRegister4E6Vo = new ExportExcelDimUnifiedInvoiceRegister4E6Vo();

		exportExcelDimUnifiedInvoiceRegister4E6Vo.setOrderSn(listItem.getOrderSn());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceApplySn(mainItem.getInvoiceApplySn());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setGoodsName(listItem.getGoodsName());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceCompanyName(mainItem.getInvoiceTitle());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setQuantity(listItem.getQuantity());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setPriceXQuantity(listItem.getPrice().multiply(new BigDecimal(listItem.getQuantity())));
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setSelfOption(listItem.getSelfOption());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setUnit(listItem.getUnit());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setRemark(mainItem.getRemark());
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setTaxRate(listItem.getTaxRate());
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setInvoiceTypeName(mainItem.);
		exportExcelDimUnifiedInvoiceRegister4E6Vo.setTaxCode(listItem.getTaxCode());
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setPurchaseUserName();
//		exportExcelDimUnifiedInvoiceRegister4E6Vo.setRecUserName();

		return exportExcelDimUnifiedInvoiceRegister4E6Vo;
	}
}
