package com.engine.htsc.branchpayment.service.impl;

import cn.hutool.core.lang.Assert;
import com.engine.htsc.branchpayment.enums.BranchPay;
import com.engine.htsc.branchpayment.utils.BranchBizUtil;
import com.engine.htsc.payment.pojo.CostAccountDto;
import com.engine.htsc.payment.service.impl.SettlePaymentCommand;
import com.engine.htsc.payment.util.BizUtils;
import com.engine.htsc.subpayment.enums.SubPay;
import com.engine.htsc.subpayment.utils.SubBizUtil;
import org.apache.commons.logging.LogFactory;

/**
 * 创建核算明细
 */
public class BranchCostDTOFactory {

  private BranchCostDTOFactory() {
  }

  // 分支
  public static CostAccountDto getCostDTOByType(String requestId, String lx) throws Exception {
    Assert.notBlank(requestId, "未指定流程id");
    Assert.notBlank(lx, "未指定类型");
    BizUtils bu = new BizUtils();
    BranchBizUtil bizUtil = new BranchBizUtil();
    SettlePaymentCommand settlePaymentCommand = new SettlePaymentCommand();

    if (BranchPay.GE_PAY.getType().equalsIgnoreCase(lx)
            || BranchPay.SETTLE_PAY.getType().equalsIgnoreCase(lx)) {
      return bizUtil.generateCommonPayData(requestId, BranchPay.getLbByType(lx));
    }

    if (BranchPay.GE_REI.getType().equalsIgnoreCase(lx)) {
      return bu.generateCommonReimbData(requestId, BranchPay.getLbByType(lx));
    }

    if (BranchPay.TRA_REI.getType().equalsIgnoreCase(lx)) {
      return bizUtil.generateTravelReimbData(requestId, BranchPay.getLbByType(lx));
    }
    if (BranchPay.CGSC_TRAVEL.getType().equalsIgnoreCase(lx)) {
      return settlePaymentCommand.generateCommonReimbData(requestId, BranchPay.getLbByType(lx));
    }
    return null;
  }

  // 子公司
  public static CostAccountDto getCostDTOByType4Sub(String requestId, String lx) throws Exception {
    Assert.notBlank(requestId, "未指定流程id");
    Assert.notBlank(lx, "未指定类型");
    SubBizUtil subBizUtil = new SubBizUtil();
    BizUtils bizUtils = new BizUtils();

    if (SubPay.ZJ_REI.getType().equalsIgnoreCase(lx)) {
      return bizUtils.ZjCommonReimbData(requestId, SubPay.getLbByType(lx));
    }

    if (SubPay.ZG_REI.getType().equalsIgnoreCase(lx)) {
      return subBizUtil.generateCommonReimbData(requestId, SubPay.getLbByType(lx));
    }

    if (SubPay.ZGS_REI.getType().equalsIgnoreCase(lx)) {
      return subBizUtil.generateCommonReimbData(requestId, SubPay.getLbByType(lx));
    }

    if (SubPay.ZG_TRAVEL.getType().equalsIgnoreCase(lx)) {
      return subBizUtil.generateTravelReimbData(requestId, SubPay.getLbByType(lx));
    }
    if (SubPay.ZGTY_PAY.getType().equalsIgnoreCase(lx)) {
      return bizUtils.generateCommonPayData(requestId, SubPay.getLbByType(lx));
    }
    if (SubPay.ZJTY_PAY.getType().equalsIgnoreCase(lx)) {
      return bizUtils.generateCommonPayData(requestId, SubPay.getLbByType(lx));
    }

    if (SubPay.ZGS_TRAVEL.getType().equalsIgnoreCase(lx)) {
      return subBizUtil.generateTravelReimbData(requestId, SubPay.getLbByType(lx));
    }

    if (SubPay.ZJ_TRAVEL.getType().equalsIgnoreCase(lx)) {
      return subBizUtil.generateTravelReimbData(requestId, SubPay.getLbByType(lx));
    }

    return null;
  }

  public static CostAccountDto getSettlePaymentCostDTO(String requestId, String lx) throws Exception {
    Assert.notBlank(requestId, "未指定流程id");
    Assert.notBlank(lx, "未指定类型");
    SettlePaymentCommand settlePaymentCommand = new SettlePaymentCommand();
    if (BranchPay.CGSC_TRAVEL.getType().equalsIgnoreCase(lx)) {
      return settlePaymentCommand.generateCommonReimbData(requestId, BranchPay.getLbByType(lx));
    }
    return null;
  }
}
