package cn.superdesk.uniorder.dubbo.consumer.invoice.customer;

import cn.hutool.core.collection.CollUtil;
import cn.superdesk.uniorder.common.enums.accounting.AccountingOrderTypeDimEnum;
import cn.superdesk.uniorder.common.exception.UnifiedOrderRuntimeException;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.rest.response.ResponseResultOuterUtils;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.InvoiceApply;
import cn.superdesk.uniorder.dao.entity.order.ExpressCompany;
import cn.superdesk.uniorder.dto.param.invoice.customer.*;
import cn.superdesk.uniorder.dto.vo.invoice.customer.*;
import cn.superdesk.uniorder.dto.vo.thirdpart.szhtxx.electronicInvoice.SzhtxxElectronicInvoiceFptxxListItemVo;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.customer.DubboInvoiceApplyCustomerService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
public class InvoiceApplyCustomerDubboConsumerService {

    @Reference(version = "1.0.0", timeout = 300000, retries = -1)
    private DubboInvoiceApplyCustomerService dubboInvoiceApplyCustomerService;

    @Resource
    private PermissionDubboCustomerService permissionDubboCustomerService;

    public InvoiceApply findById(Long invoiceApplyId) {
        return dubboInvoiceApplyCustomerService.findById(invoiceApplyId);
    }

    public List<InvoiceApply> findByIds(List<Long> invoiceApplyIds) {
        return dubboInvoiceApplyCustomerService.findByIds(invoiceApplyIds);
    }

    public List<InvoiceApply> findByAccountingOrderSn(String accountingOrderSn, AccountingOrderTypeDimEnum accountingOrderTypeDimEnum) {
        return dubboInvoiceApplyCustomerService.findByAccountingOrderSn(accountingOrderSn, accountingOrderTypeDimEnum);
    }

    public InvoiceApply findByInvoiceApplySn(String invoiceApplySn, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboInvoiceApplyCustomerService.findByInvoiceApplySn(invoiceApplySn, loginSysUser);
    }

    public int updateInvoiceApplyByPrimaryKeySelective(InvoiceApply invoiceApply) {
        return dubboInvoiceApplyCustomerService.updateInvoiceApplyByPrimaryKeySelective(invoiceApply);
    }

    public List<InvoiceApplyCustomerSelectScoreVo> invoiceApplySelectFocusUnifiedDimOrder(Map<String, Object> params) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.invoiceApplySelectFocusUnifiedDimOrder(params);
    }

    public List<InvoiceApplyCustomerSelectScoreVo> invoiceApplySelectFocusUnifiedDimGoods(Map<String, Object> params) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.invoiceApplySelectFocusUnifiedDimGoods(params);
    }

    public List<InvoiceApplyCustomerSelectScoreVo> invoiceApplySelectFocusScoreDimCredit(InvoiceApplyCustomerQueryCriteria criteria) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.invoiceApplySelectFocusScoreDimCredit(criteria);
    }

    public InvoiceApplyCustomerSelectScoreStruct invoiceApplySelectFocusScoreDimCreditV2_1(InvoiceApplyCustomerQueryCriteria criteria, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.invoiceApplySelectFocusScoreDimCreditV2_1(criteria, loginSysUser);
    }

    /**
     * 客户结算 > 发票申请管理 > opt 申请开票 -> 编辑页面 opt 提交
     *
     * @param token
     * @param form
     * @throws UnifiedOrderRuntimeException
     */
    public R opInvoiceApplyCustomerFocusUnified(String token, InvoiceApplyCustomerFocusUnifiedOpApplyForm form) throws UnifiedOrderRuntimeException {

        // InvoiceApplyFocusUnifiedParams 转 InvoiceApplyCommonParams

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        Integer accountingOrderTypeDim = form.getAccountingOrderTypeDim();
        Integer dimCreateBy            = form.getDimCreateBy();

        InvoiceApplyCommonOpApplyForm invoiceApplyCommonOpApplyForm = new InvoiceApplyCommonOpApplyForm();

        invoiceApplyCommonOpApplyForm.setGoodsSelected(form.getOrderGoodsObj());

        invoiceApplyCommonOpApplyForm.setDimCreateBy(dimCreateBy);
        invoiceApplyCommonOpApplyForm.setAccountingOrderTypeDim(accountingOrderTypeDim);

        invoiceApplyCommonOpApplyForm.setInvoiceTitle(form.getInvoiceCompanyName());
//		invoiceApplyCommonOpApplyForm.setSysEnterpriseExtInvoiceId(form.getSysEnterpriseExtInvoiceId());
        invoiceApplyCommonOpApplyForm.setInvoiceTypeId(form.getInvoiceType());

        // 这里还有疑问点
        invoiceApplyCommonOpApplyForm.setTaxRate(form.getTaxRate());

        invoiceApplyCommonOpApplyForm.setInvoiceApplyAmount(form.getInvoiceApplyAmount());
        invoiceApplyCommonOpApplyForm.setFreeAmount(form.getFreeAmount());
        invoiceApplyCommonOpApplyForm.setRealAmount(form.getRealAmount());
        invoiceApplyCommonOpApplyForm.setNoCheckCount(form.getRealAmount());

        invoiceApplyCommonOpApplyForm.setRemark(form.getRemark());

        dubboInvoiceApplyCustomerService.opInvoiceApply(invoiceApplyCommonOpApplyForm, loginSysUser);

        return new R();
    }

    /**
     * 积分结算2.0
     *
     * @param form
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public R opInvoiceApplyCustomerFocusScore(InvoiceApplyFocusScoreOpApplyForm form, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        if (CollUtil.isEmpty(form.getApplyOrderGoodsCreditParamsList())) {
            return ResponseResultOuterUtils.createErrorResult("500", "商品错误码");
        }

        InvoiceApplyCommonOpApplyForm invoiceApplyCommonOpApplyForm = new InvoiceApplyCommonOpApplyForm();

        invoiceApplyCommonOpApplyForm.setCreditSelected(form.getApplyOrderGoodsCreditParamsList());

        // 发票申请维度 1-一般订单 2-积分订单
        invoiceApplyCommonOpApplyForm.setAccountingOrderTypeDim(form.getAccountingOrderTypeDim());
        invoiceApplyCommonOpApplyForm.setDimCreateBy(form.getDimCreateBy());

        invoiceApplyCommonOpApplyForm.setInvoiceTitle(form.getInvoiceTitle());
        invoiceApplyCommonOpApplyForm.setSysEnterpriseExtInvoiceId(form.getSysEnterpriseExtInvoiceId());
        invoiceApplyCommonOpApplyForm.setInvoiceTypeId(form.getInvoiceType());

        invoiceApplyCommonOpApplyForm.setTaxRate(form.getTaxRate());

        invoiceApplyCommonOpApplyForm.setInvoiceApplyAmount(form.getInvoiceApplyAmount());
        invoiceApplyCommonOpApplyForm.setFreeAmount(form.getFreeAmount());
        invoiceApplyCommonOpApplyForm.setRealAmount(form.getRealAmount());
        invoiceApplyCommonOpApplyForm.setNoCheckCount(form.getNoCheckCount());

        invoiceApplyCommonOpApplyForm.setRemark(form.getRemark());
        invoiceApplyCommonOpApplyForm.setRemark2(form.getRemark());

        dubboInvoiceApplyCustomerService.opInvoiceApply(invoiceApplyCommonOpApplyForm, loginSysUser);

        return new R();
    }

    public R<InvoiceApplyFocusScoreOpApplyReportV2_1> opInvoiceApplyCustomerFocusScoreV2_1(InvoiceApplyFocusScoreOpApplyFormV2_1 form, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.opInvoiceApplyV2_1(form, loginSysUser);
    }


    public R<List<InvoiceApplyCustomerPageVo>> findViewByPageFocusUnified(String token, Map<String, Object> params, int pageNum, int pageSize) throws UnifiedOrderRuntimeException {

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, params);
        if (isPass.equals(false)) {
            return ResponseResultOuterUtils.createErrorResult("500", "您没有企业数据权限！");
        }

        return dubboInvoiceApplyCustomerService.findViewByPageFocusUnified(params, pageNum, pageSize);

    }
//	public ResponseResult<List<InvoiceApplyPage>> findInvoiceByPage(String token, Map<String, Object> params, int pageNum, int pageSize) throws SuperdeskUniOrderException {
//
//		// 20191205 add 数据权限
//		Map<String, Object> tv = JwtUtil.GetTokenVo(token);
//
//		if (tv.get("outLogin").toString().equals("1")) {
//
//			String[] virtIds = tv.get("virtIds").toString().split(",");
//
//			if (virtIds.length > 0) {
//
//				params.put("outVirtIds", virtIds);
//				String[] services = {"LNSS"};
//				params.put("outServices", services);
//
//			} else {
//
//				ResponseResult<List<InvoiceApplyPage>> responseResult = new ResponseResult<>();
//				responseResult.setMessage("您没有企业数据权限！");
//				responseResult.setSuccess(false);
//
//				return responseResult;
//			}
//		}
//
//		return dubboInvoiceApplyService.findViewByPageFocusUnified(params, pageNum, pageSize);
//	}

    public InvoiceApplyCustomerHeadDataVo findViewHeadDataFocusUnified(String token, Map<String, Object> params) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, params);
        if (isPass.equals(false)) {
            return null;
        }
        return dubboInvoiceApplyCustomerService.findViewHeadDataFocusUnified(params);
    }


    public R<List<InvoiceApplyCustomerPageVo>> findViewByPageFocusScore(InvoiceApplyCustomerQueryCriteria queryCriteria, int pageNum, int pageSize, String token) throws UnifiedOrderRuntimeException {

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
        if (isPass.equals(false)) {
            return ResponseResultOuterUtils.createErrorResult("500", "您没有企业数据权限！");
        }

        return dubboInvoiceApplyCustomerService.findViewByPageFocusScore(queryCriteria, pageNum, pageSize);

    }

    public InvoiceApplyCustomerHeadDataVo findViewHeadDataFocusScore(InvoiceApplyCustomerQueryCriteria queryCriteria, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
        if (isPass.equals(false)) {
            return null;
        }
        return dubboInvoiceApplyCustomerService.findViewHeadDataFocusScore(queryCriteria);
    }

    public R<List<InvoiceApplyCustomerPageVo>> findViewByPageFocusScoreV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteria, String token) throws UnifiedOrderRuntimeException {

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);

        if (isPass.equals(false)) {
            return ResponseResultOuterUtils.createErrorResult("500", "您没有企业数据权限！");
        }

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.findViewByPageFocusScoreV2_1(queryCriteria, loginSysUser);

    }

    /**
     * 积分结算-发票申请管理-op导出列表
     * 积分结算v2.1
     *
     * @param queryCriteria
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public String exportInvoiceApplyListExcelV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteria, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
        if (isPass.equals(false)) {
            return null;
        }

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.exportInvoiceApplyListExcelV2_1(queryCriteria, loginSysUser);

    }

    public InvoiceApplyCustomerHeadDataVoV2_1 findViewHeadDataFocusScoreV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteria, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
        if (isPass.equals(false)) {
            return null;
        }
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboInvoiceApplyCustomerService.findViewHeadDataFocusScoreV2_1(queryCriteria, loginSysUser);
    }


    public R<List<InvoiceApplyCustomerPageVo>> findInvoiceListByPageFocusScoreV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteria, String token) throws UnifiedOrderRuntimeException {

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);

        if (isPass.equals(false)) {
            return ResponseResultOuterUtils.createErrorResult("500", "您没有企业数据权限！");
        }

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.findInvoiceListByPageFocusScoreV2_1(queryCriteria, loginSysUser);

    }

    public List<InvoiceApplyCustomerPageVo> findInvoiceListFocusScoreV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteriaV2_1, String token) {

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteriaV2_1);

        if (isPass.equals(false)) {
//            R<List<InvoiceApplyCustomerPageVo>> responseResult = new R<>();
//            responseResult.setMessage("您没有企业数据权限！");
//            responseResult.setSuccess(false);
            return null;
        }

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.findInvoiceListFocusScoreV2_1(queryCriteriaV2_1, loginSysUser);
    }

    public InvoiceApplyCustomerHeadDataVoV2_1 findInvoiceHeadDataFocusScoreV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 queryCriteria, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
        if (isPass.equals(false)) {
            return null;
        }
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboInvoiceApplyCustomerService.findInvoiceHeadDataFocusScoreV2_1(queryCriteria, loginSysUser);
    }


    /****************************************** 客户结算 开票申请 列表导出 Excel数据 start ******************************************/

    public List<ExportExcelInvoiceApplyForceUnifiedDimGoodsVo> findInvoiceApplyFocusUnifiedDimGoods(Map<String, Object> params, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, params);
        if (isPass.equals(false)) {
            return null;
        }

        return dubboInvoiceApplyCustomerService.findInvoiceApplyFocusUnifiedDimGoods(params);
    }

    /**
     * 积分结算-发票申请管理-opt 导出报表
     *
     * @param criteria
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public List<ExportExcelInvoiceApplyCustomerForceScoreDimCreditVo> findInvoiceApplyFocusScoreDimCredit(InvoiceApplyCustomerQueryCriteria criteria, String token) throws UnifiedOrderRuntimeException {

        // 20191205 add 数据权限
        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, criteria);
        if (isPass.equals(false)) {
            return null;
        }
        return dubboInvoiceApplyCustomerService.findInvoiceApplyFocusScoreDimCredit(criteria);
    }

    /**
     * TODO 未实现 目前还是 controller 里实现的
     *
     * @param params
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public String exportExcelInvoiceApplyFocusUnifiedDimGoods(Map<String, Object> params, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, params);
        if (isPass.equals(false)) {
            return null;
        }

        return dubboInvoiceApplyCustomerService.exportExcelInvoiceApplyCustomerFocusUnifiedDimGoods(params, loginSysUser);
    }

    public String exportExcelInvoiceApplyCustomerFocusScoreDimCredit(InvoiceApplyCustomerQueryCriteria criteria, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        Boolean isPass = permissionDubboCustomerService.addOnPerm(token, criteria);
        if (isPass.equals(false)) {
            return null;
        }

        return dubboInvoiceApplyCustomerService.exportExcelInvoiceApplyCustomerFocusScoreDimCredit(criteria, loginSysUser);
    }

    /****************************************** 客户结算 开票申请 列表导出 Excel数据   end ******************************************/


    /****************************************** 发票申请管理 查看详情 start ******************************************/

    /**
     * 开票申请 一般订单 查看详情
     *
     * @param params
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public InvoiceApplyCustomerDetailDimGoodsVo getUnifiedCustomerInvoice2GoodsDetail(Map<String, Object> params) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.getUnifiedCustomerInvoice2GoodsDetail(params);
    }

    /**
     * 客户结算-申请开票-查看详情-opt 导出详情
     * 客户结算-发票管理-查看详情-opt 导出明细
     *
     * @param params
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public String exportUnifiedCustomerInvoice2GoodsDetail(Map<String, Object> params, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.exportExcelUnifiedCustomerInvoice2GoodsDetail(params, loginSysUser);
    }

    public InvoiceApplyCustomerDetailDimCreditVo getInvoiceApplyCustomerDetailDimCredit(InvoiceApplyCustomerQueryCriteria criteria, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboInvoiceApplyCustomerService.getInvoiceApplyCustomerDetailDimCredit(criteria, loginSysUser);
    }

    public InvoiceApplyCustomerDetailDimCreditVoV2_1 getInvoiceApplyCustomerDetailDimCreditV2_1(InvoiceApplyCustomerQueryCriteriaV2_1 criteria, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboInvoiceApplyCustomerService.getInvoiceApplyCustomerDetailDimCreditV2_1(criteria, loginSysUser);
    }

    /**
     * 客户结算-申请开票-查看详情-opt 导出详情
     * 客户结算-发票管理-查看详情-opt 导出明细
     *
     * @param criteria
     * @param token
     * @return
     * @throws UnifiedOrderRuntimeException
     */
    public String exportUnifiedCustomerInvoice2CreditDetail(InvoiceApplyCustomerQueryCriteria criteria, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.exportExcelUnifiedCustomerInvoice2CreditDetail(criteria, loginSysUser);
    }

    /****************************************** 发票申请管理 查看详情   end ******************************************/


    /****************************************** 第三方软件导出类 start ******************************************/


    public String exportExcelDimUnifiedInvoiceRegister4E6(Long invoiceApplyId, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.exportExcelDimUnifiedInvoiceRegister4E6(invoiceApplyId, loginSysUser);
    }

    /****************************************** 第三方软件导出类   end ******************************************/


    public String importInvoiceExcel(List<Map<String, Object>> list, String token) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.importInvoiceExcel(token, list);
    }

    public String importSendInvoiceExcel(List<Map<String, Object>> list, String token) throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.importSendInvoiceExcel(token, list);
    }


    public List<ExpressCompany> findExpressCompany() throws UnifiedOrderRuntimeException {
        return dubboInvoiceApplyCustomerService.findExpressCompany();
    }

    public R<List<InvoiceApply>> findInvoiceByPageNew(Map<String, Object> params, int pageNum, int pageSize, String token) {
        return dubboInvoiceApplyCustomerService.findInvoiceByPageNew(params, pageNum, pageSize);
    }

    public List<InvoiceApply> findInvoiceByOrderSn(Map<String, Object> invQuery) {
        return dubboInvoiceApplyCustomerService.findByOrderSn(invQuery);
    }


    public Map<String, InvoiceApply> findInvoiceByOrderSnList(List<String> orderSnList) {
        return dubboInvoiceApplyCustomerService.findByOrderSnList(orderSnList);
    }


    /****************************************** 验证程序 start ******************************************/

    public void validatedInvoiceApplyRelationTable() {
        dubboInvoiceApplyCustomerService.validatedInvoiceApplyRelationTable();
    }

    /****************************************** 验证程序   end ******************************************/


    public void opAudit(Map<String, Object> params, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        dubboInvoiceApplyCustomerService.opAudit(params, loginSysUser);
    }


    public void opRegister(Map<String, Object> params, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        dubboInvoiceApplyCustomerService.opRegister(params, loginSysUser);
    }

    public int opModifyInvoiceTitle(InvoiceApplyCustomerOpModifyInvoiceTitleForm form, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.opModifyInvoiceTitle(form, loginSysUser);
    }

    public int opDelete(Long invoiceApplyId, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.opDelete(invoiceApplyId, loginSysUser);
    }

    /**
     * 操作 opt 积分结算-发票管理-重新开票 (过 20200730 1711)
     *
     * @param form
     * @param invoiceApplyEntity
     * @param fptxxListItemVo
     * @param token
     * @throws UnifiedOrderRuntimeException
     */
    public int opAgainSzhtxxElectronicInvoice(
            InvoiceApplyCustomerOpAgainInvoiceApplyForm form,
            InvoiceApply invoiceApplyEntity,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.opAgainSzhtxxElectronicInvoice(form, invoiceApplyEntity, fptxxListItemVo, loginSysUser);
    }

    public int opAgainSzhtxxPaperInvoice(
            InvoiceApplyCustomerOpAgainInvoiceApplyForm form,
            InvoiceApply invoiceApplyEntity,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboInvoiceApplyCustomerService.opAgainSzhtxxPaperInvoice(form, invoiceApplyEntity, fptxxListItemVo, loginSysUser);
    }

    /**
     * 寄票登记
     *
     * @param sendInvoiceRegisterList
     * @param token
     * @throws UnifiedOrderRuntimeException
     */
    public void sendInvoiceRegister(List<Map> sendInvoiceRegisterList, String token) throws UnifiedOrderRuntimeException {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboInvoiceApplyCustomerService.sendInvoiceRegister(sendInvoiceRegisterList, loginSysUser);
    }


    /****************************************** 补丁程序 start ******************************************/

    public void patchInvoiceApplyCustomerFixV2_1() {
        dubboInvoiceApplyCustomerService.patchInvoiceApplyCustomerFixV2_1();
    }

}
