package cn.superdesk.uniorder.dubbo.provider.thirdpart.szhtxx.paperInvoice;

import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.InvoiceApply;
import cn.superdesk.uniorder.dao.entity.sys.notify.SysNotify;
import cn.superdesk.uniorder.dto.param.thirdpart.szhtxx.common.becomeInvalid.SzhtxxInvoiceFptxxOpBecomeInvalidForm;
import cn.superdesk.uniorder.dto.param.thirdpart.szhtxx.common.redBitchLlq.SzhtxxInvoiceFptxxOpRedLowerWorkLlqForm;
import cn.superdesk.uniorder.dto.param.thirdpart.szhtxx.common.singleBilling.SzhtxxInvoiceFptxxOpSingleBillingForm;
import cn.superdesk.uniorder.dto.param.thirdpart.szhtxx.common.taxDeviceInfo.SzhtxxPaperInvoiceOpTaxDeviceInfoForm;
import cn.superdesk.uniorder.dto.param.thirdpart.szhtxx.common.taxInfo.SzhtxxPaperInvoiceOpTaxInfoForm;
import cn.superdesk.uniorder.dto.vo.thirdpart.szhtxx.electronicInvoice.SzhtxxElectronicInvoiceFptxxListItemVo;
import cn.superdesk.uniorder.dubbo.facade.thirdpart.szhtxx.paperInvoice.DubboSzhtxxPaperInvoiceFptxxService;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID121TaxInfo.SID121TaxInfoRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID1SingleBilling.SID1SingleBillingRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID20BitchLlq.SID20BitchLlqRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID25TaxDeviceInfo.SID25TaxDeviceInfoRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID4ToInvalid.SID4ToInvalidRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.request.SID5SelectBillInfo.SID5SelectBillInfoRequestBody;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.response.SID25TaxDeviceInfo.SID25TaxDeviceInfoResponseBody;
import cn.superdesk.uniorder.service.invoice.customer.InvoiceApplyCustomerService;
import cn.superdesk.uniorder.service.invoice.customer.state.InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingOffLineService;
import cn.superdesk.uniorder.service.invoice.customer.state.InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxElectronicInvoiceService;
import cn.superdesk.uniorder.service.invoice.customer.state.InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxPaperInvoiceService;
import cn.superdesk.uniorder.service.thirdpart.szhtxx.paperInvoice.SzhtxxPaperInvoiceFptxxService;
import com.alibaba.dubbo.config.annotation.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@Service(version = "1.0.0", retries = -1, timeout = 10000)
public class DubboSzhtxxPaperInvoiceFptxxServiceImpl implements DubboSzhtxxPaperInvoiceFptxxService {


    @Autowired
    private InvoiceApplyCustomerService invoiceApplyCustomerService;

//    @Autowired
//    private SzhtxxElectronicInvoiceFptxxService szhtxxElectronicInvoiceFptxxService;

    @Autowired
    private SzhtxxPaperInvoiceFptxxService szhtxxPaperInvoiceFptxxService;

    @Autowired
    private InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingOffLineService                 invoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingOffLineService;
    @Autowired
    private InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxElectronicInvoiceService invoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxElectronicInvoiceService;
    @Autowired
    private InvoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxPaperInvoiceService      invoiceApplyCustomerFieldMakeInvoiceStatusOpOngoingSzhtxxPaperInvoiceService;


    @Override
    public SID1SingleBillingRequestBody opRedWriteRequest(
            SzhtxxInvoiceFptxxOpSingleBillingForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply invoiceApplyCustomerEntity,
            LoginSysUser loginSysUser) {

//        InvoiceApply invoiceApplyCustomerEntity = invoiceApplyCustomerService.findByInvoiceApplySn(form.getFpqqlsh(), loginSysUser);

        return szhtxxPaperInvoiceFptxxService.opRedWriteRequest(form, fptxxListItemVo, invoiceApplyCustomerEntity, loginSysUser);

    }

    /**
     * TODO
     *
     * @param form
     * @param fptxxListItemVo
     * @param entity
     * @param loginSysUser
     * @return
     */
    @Override
    public SysNotify opRedWriteResponse(
            SzhtxxInvoiceFptxxOpSingleBillingForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser) {


        return szhtxxPaperInvoiceFptxxService.opRedWriteResponse(
                form,
                fptxxListItemVo,
                entity, loginSysUser
        );

    }


    /**************************************** op申请红字信息表编号-op确认申请(纸质专用发票)(深圳航信纸质票) start ****************************************/

    @Override
    public SID20BitchLlqRequestBody opRedBitchLlqRequest(
            SzhtxxInvoiceFptxxOpSingleBillingForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser) {


        return szhtxxPaperInvoiceFptxxService.opRedBitchLlqRequest(form, fptxxListItemVo, entity, loginSysUser);

    }

    @Override
    public SysNotify opRedBitchLlqResponse(
            SzhtxxInvoiceFptxxOpSingleBillingForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser) {

        return szhtxxPaperInvoiceFptxxService.opRedBitchLlqResponse(form, fptxxListItemVo, entity, loginSysUser);

    }

    /**************************************** op申请红字信息表编号-op确认申请(纸质专用发票)(深圳航信纸质票)   end ****************************************/

    /**************************************** op下载红字信息表编号-op确认下载(纸质专用发票)(深圳航信纸质票) start ****************************************/

    @Override
    public SID20BitchLlqRequestBody opRedLowerWorkLlqRequest(SzhtxxInvoiceFptxxOpRedLowerWorkLlqForm form, LoginSysUser loginSysUser) {
        return szhtxxPaperInvoiceFptxxService.opRedLowerWorkLlqRequest(form, loginSysUser);
    }

    @Override
    public SysNotify opRedLowerWorkLlqResponse(SzhtxxInvoiceFptxxOpRedLowerWorkLlqForm form, LoginSysUser loginSysUser) {

        return szhtxxPaperInvoiceFptxxService.opRedLowerWorkLlqResponse(form, loginSysUser);
    }

    /**************************************** op下载红字信息表编号-op确认下载(纸质专用发票)(深圳航信纸质票)   end ****************************************/


    /**************************************** op作废发票 start ****************************************/

    @Override
    public SID4ToInvalidRequestBody opBecomeInvalidRequest(
            SzhtxxInvoiceFptxxOpBecomeInvalidForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser) {

        SID4ToInvalidRequestBody sid4Toinvalidrequestbody = szhtxxPaperInvoiceFptxxService.opBecomeInvalidRequest(form, fptxxListItemVo, entity, loginSysUser);

        return sid4Toinvalidrequestbody;

    }

    @Override
    public SysNotify opBecomeInvalidResponse(
            SzhtxxInvoiceFptxxOpBecomeInvalidForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser) {


        return szhtxxPaperInvoiceFptxxService.opBecomeInvalidResponse(form, fptxxListItemVo, entity, loginSysUser);
    }

    /**************************************** op作废发票   end ****************************************/




    /**************************************** 金税盘页面-发起-op发票作废状态修复(纸质专用发票)(深圳航信纸质票) start ****************************************/

    @Override
    public SID5SelectBillInfoRequestBody opBecomeInvalidFakeRequest(
            SzhtxxInvoiceFptxxOpBecomeInvalidForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser){


        return szhtxxPaperInvoiceFptxxService.opBecomeInvalidFakeRequest(form, fptxxListItemVo, entity, loginSysUser);
    }

    @Override
    public SysNotify opBecomeInvalidFakeResponse(
            SzhtxxInvoiceFptxxOpBecomeInvalidForm form,
            SzhtxxElectronicInvoiceFptxxListItemVo fptxxListItemVo,
            InvoiceApply entity,
            LoginSysUser loginSysUser){


        return szhtxxPaperInvoiceFptxxService.opBecomeInvalidFakeResponse(form, fptxxListItemVo, entity, loginSysUser);
    }

    /**************************************** 金税盘页面-发起-op发票作废状态修复(纸质专用发票)(深圳航信纸质票)   end ****************************************/





    /**************************************** 10. 获取金税盘状态接口 SID=121 start ****************************************/

    @Override
    public SID121TaxInfoRequestBody opCallTaxInfoApiRequest(SzhtxxPaperInvoiceOpTaxInfoForm form, LoginSysUser loginSysUser) {
        return szhtxxPaperInvoiceFptxxService.opCallTaxInfoApiRequest(form, loginSysUser);
    }

    @Override
    public SysNotify opCallTaxInfoApiResponse(SzhtxxPaperInvoiceOpTaxInfoForm form, LoginSysUser loginSysUser) {
        return szhtxxPaperInvoiceFptxxService.opCallTaxInfoApiResponse(form, loginSysUser);
    }

    /**************************************** 10. 获取金税盘状态接口 SID=121   end ****************************************/

    /**************************************** 17. 金税设备查询 SID=25 start ****************************************/

    @Override
    public SID25TaxDeviceInfoRequestBody opCallTaxDeviceInfoApiRequest(SzhtxxPaperInvoiceOpTaxDeviceInfoForm form, LoginSysUser loginSysUser) {
        return szhtxxPaperInvoiceFptxxService.opCallTaxDeviceInfoApiRequest(form, loginSysUser);
    }

    @Override
    public SID25TaxDeviceInfoResponseBody opCallTaxDeviceInfoApiResponse(SzhtxxPaperInvoiceOpTaxDeviceInfoForm form, LoginSysUser loginSysUser) {
        return szhtxxPaperInvoiceFptxxService.opCallTaxDeviceInfoApiResponse(form, loginSysUser);
    }

    /**************************************** 17. 金税设备查询 SID=25   end ****************************************/
}
