package cn.superdesk.uniorder.dao.convert;

import cn.hutool.core.util.StrUtil;
import cn.superdesk.uniorder.common.numerical.AnBigDecimalUtils;
import cn.superdesk.uniorder.common.numerical.AnDateUtils;
import cn.superdesk.uniorder.dto.vo.accounting.score.customer.AccountingOrderScoreCustomerListItemVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.supplier.AccountingOrderUnifiedSuplierHeadVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.supplier.AccountingOrderUnifiedSupplierListItemVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.supplier.notyet.UnifiedOrderJoinGoodsOfSupplierStatementOfAccountVo;
import cn.superdesk.uniorder.dto.vo.invoice.supplier.InvoiceApplySupplierPageVo;
import cn.superdesk.uniorder.dto.vo.invoice.supplier.InvoiceApplySupplierSelectGoodsVo;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Description: 粉饰太平
 * @Author: linjinyu
 * @CreateDate: 2022/1/10 上午9:27
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/1/10 上午9:27
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
public class DtoSugarUpUtils {

    /****************************************** 积分结算 对账单 start ******************************************/

    // 列表
    public static void sugarUpAccountingOrderScoreCustomerVoList(List<AccountingOrderScoreCustomerListItemVo> resultList) {

        resultList.forEach(item -> {
            sugarUpAccountingOrderScoreCustomerVo(item);
        });

    }

    public static void sugarUpAccountingOrderScoreCustomerVo(AccountingOrderScoreCustomerListItemVo accountingOrderScoreCustomerVo) {

        /****************************************** 时间 start ******************************************/

        accountingOrderScoreCustomerVo.setStartTimeStr(AnDateUtils.format(accountingOrderScoreCustomerVo.getStartTime(), "yyyy年MM月dd日"));
        accountingOrderScoreCustomerVo.setEndTimeStr(AnDateUtils.format(accountingOrderScoreCustomerVo.getEndTime(), "yyyy年MM月dd日"));
        accountingOrderScoreCustomerVo.setCreateTimeStr(AnDateUtils.format(accountingOrderScoreCustomerVo.getCreateTime(), "yyyy年MM月dd日 HH:mm:ss"));

        accountingOrderScoreCustomerVo.setCycleTimeStr(StrUtil.format("{}-{}", accountingOrderScoreCustomerVo.getStartTimeStr(), accountingOrderScoreCustomerVo.getEndTimeStr()));

        /****************************************** 时间   end ******************************************/

        /****************************************** 金额 start ******************************************/

        accountingOrderScoreCustomerVo.setStatisticsTotalAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(accountingOrderScoreCustomerVo.getStatisticsTotalAmount()));
        accountingOrderScoreCustomerVo.setAccountingAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(accountingOrderScoreCustomerVo.getAccountingAmount()));
        accountingOrderScoreCustomerVo.setUnAccountingAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(accountingOrderScoreCustomerVo.getUnAccountingAmount()));

        /****************************************** 金额   end ******************************************/
    }

    /****************************************** 积分结算 对账单   end ******************************************/

    /****************************************** 供应商结算 对账单 start ******************************************/

    // 列表
    public static void sugarUpUnifiedSupplierStatementOfAccountVo(List<AccountingOrderUnifiedSupplierListItemVo> resultList) {

        resultList.forEach(item -> {
            item.setStartTimeStr(AnDateUtils.format(item.getStartTime(), "yyyy年MM月dd日"));
            item.setEndTimeStr(AnDateUtils.format(item.getEndTime(), "yyyy年MM月dd日"));
            item.setCreateTimeStr(AnDateUtils.format(item.getCreateTime(), "yyyy年MM月dd日 HH:mm:ss"));
            item.setCycleTimeStr(StrUtil.format("{}-{}", item.getStartTimeStr(), item.getEndTimeStr()));

            item.setAccountingOrderAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getAccountingOrderAmount()));
            item.setAccountingOrderAmountWithFreightFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getAccountingOrderAmountWithFreight()));

            item.setAccountingOrderCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getAccountingOrderCostAmount()));
            item.setAccountingOrderCostAmountWithFreightFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getAccountingOrderCostAmountWithFreight()));

            item.setOrderAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderAmount()));
            item.setOrderCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderCostAmount()));

            item.setOrderTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderTransportAmount()));

            item.setRefundOrderAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundOrderAmount()));
            item.setRefundOrderCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundOrderCostAmount()));

            item.setGoodsAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsAmount()));


            item.setRefundGoodsAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundGoodsAmount()));

            /****************************************  start ****************************************/

            item.setGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsCostAmount()));
            item.setRefundGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundGoodsCostAmount()));

            item.setGoodsTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsTransportAmount()));
            item.setRefundGoodsTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundGoodsTransportAmount()));

            /****************************************  start ****************************************/


        });

    }

    // 页头
    public static void sugarUpAccountingUnifiedSuplierHeadVo(AccountingOrderUnifiedSuplierHeadVo item) {

        item.setGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsCostAmount()));
        item.setRefundGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundGoodsCostAmount()));

        item.setGoodsTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsTransportAmount()));
        item.setRefundGoodsTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getRefundGoodsTransportAmount()));

    }

    // 详情
    public static void sugarUpUnifiedOrderJoinGoodsOfSupplierStatementOfAccountVo(
            List<UnifiedOrderJoinGoodsOfSupplierStatementOfAccountVo> resultList) {

        resultList.forEach(item -> {

            item.setOrderAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderAmount()));
            item.setOrderCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderCostAmount()));
            item.setOrderTransportAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderTransportAmount()));

            item.setPriceFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getPrice()));
            item.setCostPriceFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getCostPrice()));

            item.setGoodsAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsAmount()));
            item.setGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsCostAmount()));
        });
    }

    /****************************************** 供应商结算 对账单   end ******************************************/

    /****************************************** 供应商结算 发票登记 start ******************************************/

    // 列表
    public static void sugarUpInvoiceApplySupplierPageVo(List<InvoiceApplySupplierPageVo> resultList) {

        resultList.forEach(item -> {

            item.setInvoiceApplyAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getInvoiceApplyAmount()));

            item.setOrderAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getOrderAmount()));
            item.setGoodsAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsAmount()));
            item.setGoodsCostAmountFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getGoodsCostAmount()));
        });
    }

    // 创建前
    public static void sugarUpInvoiceApplySupplierSelectGoodsVo(List<InvoiceApplySupplierSelectGoodsVo> resultList) {

        resultList.forEach(item -> {

            item.setPriceFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getPrice()));
            item.setCostPriceFormat(AnBigDecimalUtils.getBigDecimalFormat(item.getCostPrice()));
        });
    }

    /****************************************** 供应商结算 发票登记   end ******************************************/

}
