package nc.impl.imag.taxfactory.apply.einvoice;

import nc.dto.imag.boot.RequestInfo;
import nc.dto.imag.invoice.PInvoice;
import nc.dto.imag.invoice.PInvoiceCepz;
import nc.dto.imag.invoice.PInvoiceDetail;
import nc.dto.imag.invoice.PInvoiceSDetail;
import nc.dto.imag.invoice.PInvoiceTspz;
import nc.dto.imag.invoice.tax.apply.InvoiceApplyCommonRequest;
import nc.imag.basefactory.router.Sm4Util;
import nc.imag.common.util.IJsonUtil;
import nc.impl.imag.taxfactory.einvoice.EInvoiceRequest;
import nc.itf.imag.basefactory.IFactoryRequest;
import nc.vo.imag.verify.InvoiceTypeEnum;
import nc.vo.pub.BusinessException;
import nc.vo.pub.BusinessRuntimeException;
import nccloud.commons.collections.MapUtils;
import ssc.mq.util.Logger;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;

class ApplyRequest extends EInvoiceRequest implements IFactoryRequest {

    // 开票申请发票信息，包含发票头、发票明细
    private String requestdatas;

    // 邮件推送配置(可选)
    private String email;

    // 短信推送配置(可选)
    private String sms;

    // ncc友企联回调参数
    private List<CallBackInfo> nc6x_ubl;

    // 是否自动审核(可选)
    private boolean autoAudit;

    @SuppressWarnings("unchecked")
    @Override
    public <E> E buildContent(RequestInfo<?> p) throws BusinessException {

        initRequest(p);

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("requestdatas", this.requestdatas);
        params.put("email", this.email);
        params.put("sms", this.sms);
        params.put("autoAudit", this.autoAudit + "");
        params.put("nc6x-ubl", IJsonUtil.toJson(this.nc6x_ubl));
        return (E) params;
    }

    @Override
    public Map<String, Object> buildHeaderParams(RequestInfo<?> p) throws BusinessException {

        initRequest(p);
        Map<String, Object> header = new HashMap<String, Object>();
        try {
            header.put("requestdatas", getMD5(this.requestdatas));
        } catch (Exception e) {
            throw new BusinessException(e.getMessage(),e);
        }
        return header;
    }

    @Override
    public void checkParamsBeforeDoRequest() throws BusinessException {
        //接口方法，不用实现
    }

    @Override
    public RequestTypeEnum requestType() {

        return RequestTypeEnum.POSTFORM;
    }

    /**
     * initRequest 初始化请求参数
     *
     * @param p
     */
    private void initRequest(RequestInfo<?> p) {

        if (this.requestdatas != null) {
            return;
        }
        InvoiceApplyCommonRequest r = (InvoiceApplyCommonRequest) p.getData();
        this.requestdatas = IJsonUtil.toJson(buildApplyInvoice(r.getInvoices()));
        this.email = IJsonUtil.toJson(buildNotify(r.getEmail()));
        this.sms = IJsonUtil.toJson(buildNotify(r.getSms()));
        this.autoAudit = r.isAutoAudit();
    }

    /**
     * buildApplyInvoice 原始参数请求转换
     *
     * @param pInvoices
     * @return
     */
    private ApplyInvoice[] buildApplyInvoice(PInvoice[] pInvoices) {

        ApplyInvoice[] invoices = new ApplyInvoice[pInvoices.length];

        for (int i = 0; i < invoices.length; i++) {
            PInvoice p = pInvoices[i];
            ApplyInvoice a = new ApplyInvoice();
            a.setBZ(p.getBz());
            a.setFPQQLSH(p.getApplyNumber());
            a.setFHR(p.getFhr());
            a.setFPLX(imagToEInvoice(p.getFplx()));
            a.setGMF_DZDH(p.getGmfDzdh());
            a.setGMF_MC(p.getGmfMc());
            a.setGMF_NSRSBH(p.getGmfNsrsbh());
            a.setGMF_YHZH(p.getGmfYhzh());
            a.setHJJE(getUFDoubleValue(p.getHjje()));
            a.setHJSE(getUFDoubleValue(p.getHjse()));
            a.setJSHJ(getUFDoubleValue(p.getJshj()));
            a.setKPR(p.getKpr());
            a.setORGCODE(p.getOrgcode());
            a.setORGTYPE("billingstation");
            a.setSGBZ(p.getSgbz());
            a.setSKR(p.getSkr());
            a.setXSF_DZDH(p.getXsfDzdh());
            a.setXSF_MC(p.getXsfMc());
            a.setXSF_NSRSBH(p.getXsfNsrsbh());
            a.setXSF_YHZH(p.getXsfYhzh());
            a.setLYID(p.getLyid());
            a.setSLSM(p.getSlsm());
            a.setLylx("n");// 税务云约定来源系统传n代表ncc
            a.setALLELCUSERNAME(decode(p.getXsfNsrsbh(),p.getAllelcusername()));
            a.setALLELCPASSWORD(decode(p.getXsfNsrsbh(),p.getAllelcpassword()));
            a.setXSF_DZ(p.getXsf_dz());
            a.setXSF_DH(p.getXsf_dh());
            a.setXSF_YH(p.getXsf_yh());
            a.setXSF_ZH(p.getXsf_zh());
            a.setGMF_DZ(p.getGmf_dz());
            a.setGMF_DH(p.getGmf_dh());
            a.setGMF_YH(p.getGmf_yh());
            a.setGMF_ZH(p.getGmf_zh());

            a.setEINVOICESHOWGXFYHZH(p.getEinvoiceshowgxfyhzh());
            a.setEINVOICESHOWGXFDZDH(p.getEinvoiceshowgxfdzdh());

            a.setSLSM(p.getSlsm());
            a.setTSPZ(p.getTspz());
            a.setZDYBZ(p.getZdybz());
            a.setZSFS(p.getZsfs());
            a.setBDCDZ(p.getBdcdz());
            a.setZLQQ(p.getZlqq());
            a.setZLQZ(p.getZlqz());
            a.setKDSBZ(p.getKdsbz());
            a.setTDZZSXMBH(p.getTdzzsxmbh());
            a.setWQHTBABH(p.getWqhtbabh());
            a.setBDCDWDM(p.getBdcdwdm());
            a.setHDJSJG(getUFDoubleValue(p.getHdjsjg()));
            a.setSJCJHSJE(getUFDoubleValue(p.getSjcjhsje()));
            a.setBXDH(p.getBxdh());
            a.setCPHCBDJH(p.getCphcbdjh());
            a.setSKSSQ(p.getSkssq());
            a.setDSCCSJE(getUFDoubleValue(p.getDsccsje()));
            a.setZNJ(getUFDoubleValue(p.getZnj()));
            a.setJEHJ(getUFDoubleValue(p.getJehj()));
            a.setCJH(p.getCjh());
            a.setKQYSSSXBGGLBM(p.getKqysssxbgglbm());
            //@特殊票种电子凭证@ end
            //机动车专票特殊处理
            if(String.valueOf(InvoiceTypeEnum.JDCZYFP.getTypeCode()).equals(p.getFplx())){
                a.setFPLX(imagToEInvoice(String.valueOf(InvoiceTypeEnum.ZZSZYFP.getTypeCode())));
                a.setTSPZ("12");
            }
            ApplyInvoiceDetail[] details = new ApplyInvoiceDetail[p.getItems().length];
            for (int j = 0; j < details.length; j++) {
                PInvoiceDetail pd = p.getItems()[j];
                ApplyInvoiceDetail ad = new ApplyInvoiceDetail();
                ad.setDW(pd.getDw());
                ad.setGGXH(pd.getGgxh());
                ad.setLSLBS(pd.getLslbs());
                ad.setSE(getUFDoubleValue(pd.getSe()));
                ad.setSL(getUFDoubleValue(pd.getSl()));
                ad.setSPBM(pd.getSpbm());
                ad.setXMDJ(getUFDoubleValue(pd.getXmdj()));
                ad.setXMJE(getUFDoubleValue(pd.getXmje()));
                ad.setXMJSHJ(getUFDoubleValue(pd.getXmjshj()));
                ad.setXMMC(pd.getXmmc());
                ad.setXMBM(pd.getXmbm());
                ad.setXMSL(changeZeroToNull(pd.getXmsl()));// 税务云规范：项目数量字段如果是0则传空
                ad.setFPHXZ(pd.getFphxz());
                ad.setHH(pd.getHh());
                ad.setZKHHH(pd.getZkhhh());
                ad.setZXBM(pd.getZxbm());
                ad.setYHZCBS(pd.getYhzcbs());
                ad.setZZSTSGL(pd.getZzstsgl());
                ad.setKCE(getUFDoubleValue(pd.getKce()));

                PInvoiceSDetail psd = pd.getDetailMotor();
                if(psd != null){
                    ApplyInvoiceMotor motor = new ApplyInvoiceMotor();
                    motor.setCQZSBH(psd.getCqzsbh());
                    motor.setJZFWFSD(psd.getJzfwfsd());
                    motor.setJZXMMC(psd.getJzxmmc());
//					**************************************2024-07-11 新增 （增加数电纸质发票(机动车销售统一发票)）
                    motor.setCD(psd.getCd());
                    motor.setCJHM(psd.getCjhm());
                    motor.setCLLX(psd.getCllx());
                    motor.setCPXH(psd.getCpxh());
                    motor.setSCQYMC(psd.getScqymc());
                    motor.setXCRS(psd.getXcrs());

                    motor.setHGZH(psd.getHgzh());
                    motor.setFDJHM(psd.getFdjhm());
                    motor.setDUNWEI(psd.getDunwei());
//					***********************************************************************
                    ad.setDetailMotor(motor);
                }
                details[j] = ad;
            }
            a.setItems(details);

            if (p.getTspzs() != null && p.getTspzs().length > 0){
                PInvoiceTspz[] ptspzs = p.getTspzs();
                ApplyInvoiceTspz[] tspzs = new ApplyInvoiceTspz[ptspzs.length];
                for (int j = 0;j < ptspzs.length;j++){
                    PInvoiceTspz ptspz = ptspzs[j];
                    ApplyInvoiceTspz tspz = new ApplyInvoiceTspz();
                    tspz.setYSMXXH(ptspz.getYsmxxh());
                    tspz.setYSGJZL(ptspz.getYsgjzl());
                    tspz.setYSGJPH(ptspz.getYsgjph());
                    tspz.setQYD(ptspz.getQyd());
                    tspz.setDDD(ptspz.getDdd());
                    tspz.setYSHWMC(ptspz.getYshwmc());
                    tspz.setCXRXH(ptspz.getCxrxh());
                    tspz.setCXR(ptspz.getCxr());
                    tspz.setCHUXRQ(ptspz.getChuxrq());
                    tspz.setCXRZJLXDM(ptspz.getCxrzjlxDm());
                    tspz.setSFZJHM(ptspz.getSfzjhm());
                    tspz.setCFD(ptspz.getCfd());
                    tspz.setLKDDD(ptspz.getLkddd());
                    tspz.setZWDJ(ptspz.getZwdj());
                    tspz.setJTGJLXDM(ptspz.getJtgjlxDm());
                    tspzs[j] = tspz;
                }
                a.setTspzs(tspzs);
            }

            if (p.getCepzs() != null && p.getCepzs().length > 0){
                PInvoiceCepz[] pcepzs = p.getCepzs();
                ApplyInvoiceCepz[] cepzs = new ApplyInvoiceCepz[pcepzs.length];
                for (int j = 0;j < pcepzs.length;j++){
                    PInvoiceCepz pcepz = pcepzs[j];
                    ApplyInvoiceCepz cepz = new ApplyInvoiceCepz();
                    cepz.setXH(pcepz.getXh());
                    cepz.setPZLX(pcepz.getPzlx());
                    cepz.setFPHM(pcepz.getFphm());
                    cepz.setFPDM(pcepz.getFpdm());
                    cepz.setZZFPHM(pcepz.getZzfphm());
                    cepz.setPZHM(pcepz.getPzhm());
                    cepz.setKJRQ(pcepz.getKjrq());
                    cepz.setHJJE(getUFDoubleValue(pcepz.getHjje()));
                    cepz.setKCE(getUFDoubleValue(pcepz.getKce()));
                    cepz.setBZ(pcepz.getBz());
                    cepz.setLY(pcepz.getLy());
                    cepz.setBCKCJE(getUFDoubleValue(pcepz.getBckcje()));
                    cepz.setPZHJJE(getUFDoubleValue(pcepz.getPzhjje()));
                    cepzs[j] = cepz;
                }
                a.setCepzs(cepzs);
            }

            invoices[i] = a;
            // 添加回调信息
            addCallBackInfo(p.getApplyNumber());
        }

        return invoices;
    }

    /**
     * 用户名秘密加密
     * @param xsfnsrsbh 销售方纳税人识别号
     * @param usernameOrPassword 用户名或密码
     * @return
     */
    private String decode(String xsfnsrsbh, String usernameOrPassword){
        if (xsfnsrsbh == null){
            throw new BusinessRuntimeException("销售方纳税人识别号不能为空");
        }
        if (usernameOrPassword == null){
            return null;
        }
        String key = UUID.nameUUIDFromBytes(xsfnsrsbh.getBytes()).toString().replaceAll("-","");
        //国密四加密用户名
        try {
            return Sm4Util.encryptEcb(key,usernameOrPassword);//sm4加密
        } catch (Exception e) {
            Logger.error(e.getMessage());
            throw new BusinessRuntimeException(e.getMessage(),e);
        }
    }

    /**
     * 设置税务云回调信息
     *
     * @param applyNumber
     */
    private void addCallBackInfo(String applyNumber) {

        if (this.nc6x_ubl == null) {
            this.nc6x_ubl = new ArrayList<CallBackInfo>();
        }
        this.nc6x_ubl.add(
                new CallBackInfo(applyNumber, "nccloud.itf.imag.invoice.IBlueInvoiceApplyCallBack", "callBack"));
    }

    private Double getUFDoubleValue(BigDecimal d) {

        return d == null ? null : d.doubleValue();
    }

    private Double changeZeroToNull(BigDecimal d) {

        return (d == null || d.doubleValue() == 0) ? null : d.doubleValue();
    }

    /**
     * buildNotify
     *
     * @param notifys
     * @return
     */
    private List<Notify> buildNotify(Map<String, InvoiceApplyCommonRequest.Notify> notifys) {

        if (MapUtils.isEmpty(notifys)) {
            return null;
        }

        List<Notify> notify = new ArrayList<Notify>();

        for (Entry<String, InvoiceApplyCommonRequest.Notify> entry : notifys.entrySet()) {

            if (entry.getValue().isEmpty()) {
                continue;
            }

            Notify n = new Notify();
            n.setFpqqlsh(entry.getKey());
            Set<String> values = entry.getValue().address;
            StringBuilder address = new StringBuilder();

            for (String value : values) {
                address.append(value + ",");
            }
            n.setAddress(address.deleteCharAt(address.length() - 1).toString());
            n.setTitle(entry.getValue().title);
            n.setContent(entry.getValue().content);
            notify.add(n);
        }

        return notify;
    }

    class ApplyInvoice {

        // 发票申请流水号
        private String FPQQLSH;

        // 来源类型
        private String LYLX;

        // 请求来源唯一标识
        private String LYID;

        // 备注
        private String BZ;

        // 复核人
        private String FHR;

        // 发票类型
        private String FPLX;

        // 购买方地址电话
        private String GMF_DZDH;

        // 购买方名称
        private String GMF_MC;

        // 购买方纳税人识别号
        private String GMF_NSRSBH;

        // 购买方银行账号
        private String GMF_YHZH;

        // 合计金额
        private Double HJJE;

        // 合计税额
        private Double HJSE;

        // 价税合计
        private Double JSHJ;

        // 开票人
        private String KPR;

        // 收款人
        private String SKR;

        // 销售方地址电话
        private String XSF_DZDH;

        // 销售方名称
        private String XSF_MC;

        // 销售方纳税人识别号
        private String XSF_NSRSBH;

        // 销售方银行账号
        private String XSF_YHZH;

        // 开票点编码
        private String ORGCODE;

        // 开票来源组织类型  会计主体（财务组织）：financeorg；销售组织：salesorg；采购组织：purchaseorg；库存组织：inventoryorg；工厂组织：factoryorg；资产组织：assetsorg
        private String ORGTYPE;

        // 收购标志
        private String SGBZ;

        //机动车专票特殊参数
        private String TSPZ;

        //电子税局用户名
        private String ALLELCUSERNAME;

        //电子税局密码
        private String ALLELCPASSWORD;

        //销售方地址
        private String XSF_DZ;

        //销售方电话
        private String XSF_DH;

        //销售方银行
        private String XSF_YH;

        //销售方账号
        private String XSF_ZH;

        //购买方地址
        private String GMF_DZ;

        //购买方电话
        private String GMF_DH;

        //购买方银行
        private String GMF_YH;

        //购买方账号
        private String GMF_ZH;

        // 数电发票是否显示购销方地址电话
        private String EINVOICESHOWGXFDZDH;

        // 数电发票是否显示购销方银行、账号
        private String EINVOICESHOWGXFYHZH;

        //税率说明
        private String SLSM;

        //自定义备注
        private String ZDYBZ;

        //征税方式
        private String ZSFS;

        //不动产租赁地址
        private String BDCDZ;

        //租赁日期起
        private String ZLQQ;

        //租赁日期止
        private String ZLQZ;

        //是否跨地址标志
        private String KDSBZ;

        //土地增值税项目编号
        private String TDZZSXMBH;

        //网签合同备案编号
        private String WQHTBABH;

        //不动产单元代码
        private String BDCDWDM;

        //核定计税价格
        private Double HDJSJG;

        //实际成交含税金额
        private Double SJCJHSJE;

        //保险单号
        private String BXDH;

        //车牌号/船舶登记号
        private String CPHCBDJH;

        //税款所属期yyyy-MM+空格+yyyy-MM
        private String SKSSQ;

        //代收车船税金额
        private Double DSCCSJE;

        //滞纳金
        private Double ZNJ;

        //金额合计
        private Double JEHJ;

        //车辆识别代码/车架号码
        private String CJH;

        //跨区域涉税事项报验管理编号
        private String KQYSSSXBGGLBM;

        //货物运输
        private ApplyInvoiceTspz[] tspzs;

        //差额开票
        private ApplyInvoiceCepz[] cepzs;

        public String getZSFS() {
            return ZSFS;
        }

        public void setZSFS(String zSFS) {
            ZSFS = zSFS;
        }

        public String getLYID() {

            return LYID;
        }

        public void setLYID(String lYID) {

            LYID = lYID;
        }

        private ApplyInvoiceDetail[] items;

        public String getFPQQLSH() {

            return FPQQLSH;
        }

        public void setFPQQLSH(String fPQQLSH) {

            FPQQLSH = fPQQLSH;
        }

        public String getLylx() {
            return LYLX;
        }

        public void setLylx(String lylx) {
            this.LYLX = lylx;
        }

        public String getBZ() {

            return BZ;
        }

        public void setBZ(String bZ) {

            BZ = bZ;
        }

        public String getFHR() {

            return FHR;
        }

        public void setFHR(String fHR) {

            FHR = fHR;
        }

        public String getFPLX() {

            return FPLX;
        }

        public void setFPLX(String fPLX) {

            FPLX = fPLX;
        }

        public String getGMF_DZDH() {

            return GMF_DZDH;
        }

        public void setGMF_DZDH(String gMF_DZDH) {

            GMF_DZDH = gMF_DZDH;
        }

        public String getGMF_MC() {

            return GMF_MC;
        }

        public void setGMF_MC(String gMF_MC) {

            GMF_MC = gMF_MC;
        }

        public String getGMF_NSRSBH() {

            return GMF_NSRSBH;
        }

        public void setGMF_NSRSBH(String gMF_NSRSBH) {

            GMF_NSRSBH = gMF_NSRSBH;
        }

        public String getGMF_YHZH() {

            return GMF_YHZH;
        }

        public void setGMF_YHZH(String gMF_YHZH) {

            GMF_YHZH = gMF_YHZH;
        }

        public Double getHJJE() {

            return HJJE;
        }

        public void setHJJE(Double hJJE) {

            HJJE = hJJE;
        }

        public Double getHJSE() {

            return HJSE;
        }

        public void setHJSE(Double hJSE) {

            HJSE = hJSE;
        }

        public Double getJSHJ() {

            return JSHJ;
        }

        public void setJSHJ(Double jSHJ) {

            JSHJ = jSHJ;
        }

        public String getKPR() {

            return KPR;
        }

        public void setKPR(String kPR) {

            KPR = kPR;
        }

        public String getSKR() {

            return SKR;
        }

        public void setSKR(String sKR) {

            SKR = sKR;
        }

        public String getXSF_DZDH() {

            return XSF_DZDH;
        }

        public void setXSF_DZDH(String xSF_DZDH) {

            XSF_DZDH = xSF_DZDH;
        }

        public String getXSF_MC() {

            return XSF_MC;
        }

        public void setXSF_MC(String xSF_MC) {

            XSF_MC = xSF_MC;
        }

        public String getXSF_NSRSBH() {

            return XSF_NSRSBH;
        }

        public void setXSF_NSRSBH(String xSF_NSRSBH) {

            XSF_NSRSBH = xSF_NSRSBH;
        }

        public String getORGTYPE() {

            return ORGTYPE;
        }

        public void setORGTYPE(String oRGTYPE) {

            ORGTYPE = oRGTYPE;
        }

        public String getXSF_YHZH() {

            return XSF_YHZH;
        }

        public void setXSF_YHZH(String xSF_YHZH) {

            XSF_YHZH = xSF_YHZH;
        }

        public String getORGCODE() {

            return ORGCODE;
        }

        public void setORGCODE(String oRGCODE) {

            ORGCODE = oRGCODE;
        }

        public String getSGBZ() {

            return SGBZ;
        }

        public void setSGBZ(String sGBZ) {

            SGBZ = sGBZ;
        }

        public String getBDCDZ() {
            return BDCDZ;
        }

        public void setBDCDZ(String BDCDZ) {
            this.BDCDZ = BDCDZ;
        }

        public String getZLQQ() {
            return ZLQQ;
        }

        public void setZLQQ(String ZLQQ) {
            this.ZLQQ = ZLQQ;
        }

        public String getZLQZ() {
            return ZLQZ;
        }

        public void setZLQZ(String ZLQZ) {
            this.ZLQZ = ZLQZ;
        }

        public String getKDSBZ() {
            return KDSBZ;
        }

        public void setKDSBZ(String KDSBZ) {
            this.KDSBZ = KDSBZ;
        }

        public ApplyInvoiceDetail[] getItems() {

            return items;
        }

        public void setItems(ApplyInvoiceDetail[] items) {

            this.items = items;
        }

        public String getTSPZ() {
            return TSPZ;
        }

        public void setTSPZ(String tSPZ) {
            TSPZ = tSPZ;
        }

        public String getALLELCPASSWORD() {
            return ALLELCPASSWORD;
        }

        public void setALLELCPASSWORD(String aLLELCPASSWORD) {
            ALLELCPASSWORD = aLLELCPASSWORD;
        }

        public String getXSF_DZ() {
            return XSF_DZ;
        }

        public void setXSF_DZ(String xSF_DZ) {
            XSF_DZ = xSF_DZ;
        }

        public String getXSF_DH() {
            return XSF_DH;
        }

        public void setXSF_DH(String xSF_DH) {
            XSF_DH = xSF_DH;
        }

        public String getXSF_YH() {
            return XSF_YH;
        }

        public void setXSF_YH(String xSF_YH) {
            XSF_YH = xSF_YH;
        }

        public String getXSF_ZH() {
            return XSF_ZH;
        }

        public void setXSF_ZH(String xSF_ZH) {
            XSF_ZH = xSF_ZH;
        }

        public String getGMF_DZ() {
            return GMF_DZ;
        }

        public void setGMF_DZ(String gMF_DZ) {
            GMF_DZ = gMF_DZ;
        }

        public String getGMF_DH() {
            return GMF_DH;
        }

        public void setGMF_DH(String gMF_DH) {
            GMF_DH = gMF_DH;
        }

        public String getGMF_YH() {
            return GMF_YH;
        }

        public void setGMF_YH(String gMF_YH) {
            GMF_YH = gMF_YH;
        }

        public String getGMF_ZH() {
            return GMF_ZH;
        }

        public void setGMF_ZH(String gMF_ZH) {
            GMF_ZH = gMF_ZH;
        }

        public String getEINVOICESHOWGXFDZDH() {
            return EINVOICESHOWGXFDZDH;
        }

        public void setEINVOICESHOWGXFDZDH(String EINVOICESHOWGXFDZDH) {
            this.EINVOICESHOWGXFDZDH = EINVOICESHOWGXFDZDH;
        }

        public String getEINVOICESHOWGXFYHZH() {
            return EINVOICESHOWGXFYHZH;
        }

        public void setEINVOICESHOWGXFYHZH(String EINVOICESHOWGXFYHZH) {
            this.EINVOICESHOWGXFYHZH = EINVOICESHOWGXFYHZH;
        }

        public String getALLELCUSERNAME() {
            return ALLELCUSERNAME;
        }

        public void setALLELCUSERNAME(String aLLELCUSERNAME) {
            ALLELCUSERNAME = aLLELCUSERNAME;
        }

        public String getLYLX() {
            return LYLX;
        }

        public void setLYLX(String lYLX) {
            LYLX = lYLX;
        }

        public String getSLSM() {
            return SLSM;
        }

        public void setSLSM(String sLSM) {
            SLSM = sLSM;
        }

        public String getZDYBZ() {
            return ZDYBZ;
        }

        public void setZDYBZ(String zDYBZ) {
            ZDYBZ = zDYBZ;
        }

        public String getTDZZSXMBH() {
            return TDZZSXMBH;
        }

        public void setTDZZSXMBH(String TDZZSXMBH) {
            this.TDZZSXMBH = TDZZSXMBH;
        }

        public ApplyInvoiceTspz[] getTspzs() {
            return tspzs;
        }

        public void setTspzs(ApplyInvoiceTspz[] tspzs) {
            this.tspzs = tspzs;
        }

        public String getWQHTBABH() {
            return WQHTBABH;
        }

        public void setWQHTBABH(String WQHTBABH) {
            this.WQHTBABH = WQHTBABH;
        }

        public String getBDCDWDM() {
            return BDCDWDM;
        }

        public void setBDCDWDM(String BDCDWDM) {
            this.BDCDWDM = BDCDWDM;
        }

        public Double getHDJSJG() {
            return HDJSJG;
        }

        public void setHDJSJG(Double HDJSJG) {
            this.HDJSJG = HDJSJG;
        }

        public Double getSJCJHSJE() {
            return SJCJHSJE;
        }

        public void setSJCJHSJE(Double SJCJHSJE) {
            this.SJCJHSJE = SJCJHSJE;
        }

        public String getBXDH() {
            return BXDH;
        }

        public void setBXDH(String BXDH) {
            this.BXDH = BXDH;
        }

        public String getCPHCBDJH() {
            return CPHCBDJH;
        }

        public void setCPHCBDJH(String CPHCBDJH) {
            this.CPHCBDJH = CPHCBDJH;
        }

        public String getSKSSQ() {
            return SKSSQ;
        }

        public void setSKSSQ(String SKSSQ) {
            this.SKSSQ = SKSSQ;
        }

        public Double getDSCCSJE() {
            return DSCCSJE;
        }

        public void setDSCCSJE(Double DSCCSJE) {
            this.DSCCSJE = DSCCSJE;
        }

        public Double getZNJ() {
            return ZNJ;
        }

        public void setZNJ(Double ZNJ) {
            this.ZNJ = ZNJ;
        }

        public Double getJEHJ() {
            return JEHJ;
        }

        public void setJEHJ(Double JEHJ) {
            this.JEHJ = JEHJ;
        }

        public String getCJH() {
            return CJH;
        }

        public void setCJH(String CJH) {
            this.CJH = CJH;
        }

        public ApplyInvoiceCepz[] getCepzs() {
            return cepzs;
        }

        public void setCepzs(ApplyInvoiceCepz[] cepzs) {
            this.cepzs = cepzs;
        }

        public String getKQYSSSXBGGLBM() {
            return KQYSSSXBGGLBM;
        }

        public void setKQYSSSXBGGLBM(String KQYSSSXBGGLBM) {
            this.KQYSSSXBGGLBM = KQYSSSXBGGLBM;
        }
    }

    class ApplyInvoiceDetail {

        // 单位
        private int FPHXZ;

        // 单位
        private String DW;

        // 项目名称
        private String XMMC;

        // 项目名称
        private String XMBM;

        // 规格型号
        private String GGXH;

        // 项目数量
        private Double XMSL;

        // 项目单价
        private Double XMDJ;

        // 项目金额
        private Double XMJE;

        // 税率
        private Double SL;

        // 税额
        private Double SE;

        // 项目价税合计
        private Double XMJSHJ;

        // 商品编码
        private String SPBM;

        // 零税率标识
        private String LSLBS;

        // 行号
        private String HH;

        // 折扣行行号
        private String ZKHHH;

        // 商品自行编码
        private String ZXBM;

        // 销售优惠标识
        private int YHZCBS;

        // 优惠政策说明
        private String ZZSTSGL;

        // 扣除额
        private Double KCE;

        private ApplyInvoiceMotor detailMotor;

        public String getDW() {

            return DW;
        }

        public void setDW(String dW) {

            DW = dW;
        }

        public String getXMMC() {

            return XMMC;
        }

        public void setXMMC(String xMMC) {

            XMMC = xMMC;
        }

        public String getGGXH() {

            return GGXH;
        }

        public void setGGXH(String gGXH) {

            GGXH = gGXH;
        }

        public int getFPHXZ() {

            return FPHXZ;
        }

        public void setFPHXZ(int fPHXZ) {

            FPHXZ = fPHXZ;
        }

        public Double getXMSL() {

            return XMSL;
        }

        public void setXMSL(Double xMSL) {

            XMSL = xMSL;
        }

        public Double getXMDJ() {

            return XMDJ;
        }

        public void setXMDJ(Double xMDJ) {

            XMDJ = xMDJ;
        }

        public Double getXMJE() {

            return XMJE;
        }

        public void setXMJE(Double xMJE) {

            XMJE = xMJE;
        }

        public Double getSL() {

            return SL;
        }

        public void setSL(Double sL) {

            SL = sL;
        }

        public Double getSE() {

            return SE;
        }

        public void setSE(Double sE) {

            SE = sE;
        }

        public Double getXMJSHJ() {

            return XMJSHJ;
        }

        public void setXMJSHJ(Double xMJSHJ) {

            XMJSHJ = xMJSHJ;
        }

        public String getSPBM() {

            return SPBM;
        }

        public void setSPBM(String sPBM) {

            SPBM = sPBM;
        }

        public String getLSLBS() {

            return LSLBS;
        }

        public void setLSLBS(String lSLBS) {

            LSLBS = lSLBS;
        }

        public String getHH() {

            return HH;
        }

        public void setHH(String hH) {

            HH = hH;
        }

        public String getZKHHH() {

            return ZKHHH;
        }

        public void setZKHHH(String zKHHH) {

            ZKHHH = zKHHH;
        }

        public String getZXBM() {

            return ZXBM;
        }

        public void setZXBM(String zXBM) {

            ZXBM = zXBM;
        }

        public int getYHZCBS() {

            return YHZCBS;
        }

        public void setYHZCBS(int yHZCBS) {

            YHZCBS = yHZCBS;
        }

        public String getZZSTSGL() {

            return ZZSTSGL;
        }

        public void setZZSTSGL(String zZSTSGL) {

            ZZSTSGL = zZSTSGL;
        }

        public Double getKCE() {

            return KCE;
        }

        public void setKCE(Double kCE) {

            KCE = kCE;
        }

        public String getXMBM() {

            return XMBM;
        }

        public void setXMBM(String xMBM) {

            XMBM = xMBM;
        }

        public ApplyInvoiceMotor getDetailMotor() {
            return detailMotor;
        }

        public void setDetailMotor(ApplyInvoiceMotor detailMotor) {
            this.detailMotor = detailMotor;
        }
    }

    class Notify {

        private String fpqqlsh;
        private String address;
        private String title;
        private String content;

        public String getFpqqlsh() {

            return fpqqlsh;
        }

        public void setFpqqlsh(String fpqqlsh) {

            this.fpqqlsh = fpqqlsh;
        }

        public String getAddress() {

            return address;
        }

        public void setAddress(String address) {

            this.address = address;
        }

        public String getTitle() {

            return title;
        }

        public void setTitle(String title) {

            this.title = title;
        }

        public String getContent() {

            return content;
        }

        public void setContent(String content) {

            this.content = content;
        }
    }

    class ApplyInvoiceMotor{

        //产权证书编号
        private String CQZSBH;

        //建筑项目名称
        private String JZXMMC;

        //建筑服务发生地
        private String JZFWFSD;
        // 产地
        private String CD;

        // 车架号码
        private String CJHM;

        // 车辆类型
        private String CLLX;

        // 产牌型号
        private String CPXH;

        // 生产企业名称
        private String SCQYMC;

        // 限乘人数
        private String XCRS;

        //合格证号
        private String HGZH;


        //发动机号码
        private String FDJHM;


        //吨位
        private String DUNWEI;

        public String getHGZH() {
            return HGZH;
        }

        public void setHGZH(String HGZH) {
            this.HGZH = HGZH;
        }

        public String getFDJHM() {
            return FDJHM;
        }

        public void setFDJHM(String FDJHM) {
            this.FDJHM = FDJHM;
        }

        public String getDUNWEI() {
            return DUNWEI;
        }

        public void setDUNWEI(String DUNWEI) {
            this.DUNWEI = DUNWEI;
        }



        public String getCD() {
            return CD;
        }

        public void setCD(String CD) {
            this.CD = CD;
        }

        public String getCJHM() {
            return CJHM;
        }

        public void setCJHM(String CJHM) {
            this.CJHM = CJHM;
        }

        public String getCLLX() {
            return CLLX;
        }

        public void setCLLX(String CLLX) {
            this.CLLX = CLLX;
        }

        public String getCPXH() {
            return CPXH;
        }

        public void setCPXH(String CPXH) {
            this.CPXH = CPXH;
        }


        public String getSCQYMC() {
            return SCQYMC;
        }

        public void setSCQYMC(String SCQYMC) {
            this.SCQYMC = SCQYMC;
        }

        public String getXCRS() {
            return XCRS;
        }

        public void setXCRS(String XCRS) {
            this.XCRS = XCRS;
        }

        public String getCQZSBH() {
            return CQZSBH;
        }

        public void setCQZSBH(String CQZSBH) {
            this.CQZSBH = CQZSBH;
        }

        public String getJZXMMC() {
            return JZXMMC;
        }

        public void setJZXMMC(String JZXMMC) {
            this.JZXMMC = JZXMMC;
        }

        public String getJZFWFSD() {
            return JZFWFSD;
        }

        public void setJZFWFSD(String JZFWFSD) {
            this.JZFWFSD = JZFWFSD;
        }
    }

    class ApplyInvoiceTspz{

        //运输明细序号
        private String YSMXXH;

        //运输工具种类
        private String YSGJZL;

        //运输工具牌号
        private String YSGJPH;

        //起运地
        private String QYD;

        //到达地
        private String DDD;

        //货物运输名称
        private String YSHWMC;

        //出行人序号
        private String CXRXH;

        //出行人
        private String CXR;

        //出行日期
        private String CHUXRQ;

        //出行人证件类型代码
        private String CXRZJLXDM;

        //身份证件号码
        private String SFZJHM;

        //出发地
        private String CFD;

        //到达地
        private String LKDDD;

        //座位等级若交通工具为火车、飞机、船舶，则该要素为必填，其他选项选填；
        //---交通工具为火车：一等座、二等座、软席（软座、软卧）、硬席（硬座、硬卧）
        //		---交通工作为飞机： 经济舱、头等舱、公务舱
        //---交通工具为船舶： 一等舱、二等舱 、三等舱
        private String ZWDJ;

        //交通工具类型代码
        private String JTGJLXDM;

        public String getYSMXXH() {
            return YSMXXH;
        }

        public void setYSMXXH(String YSMXXH) {
            this.YSMXXH = YSMXXH;
        }

        public String getYSGJZL() {
            return YSGJZL;
        }

        public void setYSGJZL(String YSGJZL) {
            this.YSGJZL = YSGJZL;
        }

        public String getYSGJPH() {
            return YSGJPH;
        }

        public void setYSGJPH(String YSGJPH) {
            this.YSGJPH = YSGJPH;
        }

        public String getQYD() {
            return QYD;
        }

        public void setQYD(String QYD) {
            this.QYD = QYD;
        }

        public String getDDD() {
            return DDD;
        }

        public void setDDD(String DDD) {
            this.DDD = DDD;
        }

        public String getYSHWMC() {
            return YSHWMC;
        }

        public void setYSHWMC(String YSHWMC) {
            this.YSHWMC = YSHWMC;
        }

        public String getCXRXH() {
            return CXRXH;
        }

        public void setCXRXH(String CXRXH) {
            this.CXRXH = CXRXH;
        }

        public String getCXR() {
            return CXR;
        }

        public void setCXR(String CXR) {
            this.CXR = CXR;
        }

        public String getCHUXRQ() {
            return CHUXRQ;
        }

        public void setCHUXRQ(String CHUXRQ) {
            this.CHUXRQ = CHUXRQ;
        }

        public String getCXRZJLXDM() {
            return CXRZJLXDM;
        }

        public void setCXRZJLXDM(String CXRZJLXDM) {
            this.CXRZJLXDM = CXRZJLXDM;
        }

        public String getSFZJHM() {
            return SFZJHM;
        }

        public void setSFZJHM(String SFZJHM) {
            this.SFZJHM = SFZJHM;
        }

        public String getCFD() {
            return CFD;
        }

        public void setCFD(String CFD) {
            this.CFD = CFD;
        }

        public String getLKDDD() {
            return LKDDD;
        }

        public void setLKDDD(String LKDDD) {
            this.LKDDD = LKDDD;
        }

        public String getZWDJ() {
            return ZWDJ;
        }

        public void setZWDJ(String ZWDJ) {
            this.ZWDJ = ZWDJ;
        }

        public String getJTGJLXDM() {
            return JTGJLXDM;
        }

        public void setJTGJLXDM(String JTGJLXDM) {
            this.JTGJLXDM = JTGJLXDM;
        }
    }

    class ApplyInvoiceCepz{

        //序号
        private String XH;

        //凭证类型
        private String PZLX;

        //全电发票号码
        private String FPHM;

        //非全电发票代码
        private String FPDM;

        //非全电发票号码
        private String ZZFPHM;

        //凭证号码
        private String PZHM;

        //开票日期
        private String KJRQ;

        //合计金额
        private Double HJJE;

        //扣除额
        private Double KCE;

        //备注
        private String BZ;

        //录入方式
        private String LY;

        //本次扣除金额
        private Double BCKCJE;

        //凭证合计金额
        private Double PZHJJE;

        public String getXH() {
            return XH;
        }

        public void setXH(String XH) {
            this.XH = XH;
        }

        public String getPZLX() {
            return PZLX;
        }

        public void setPZLX(String PZLX) {
            this.PZLX = PZLX;
        }

        public String getFPHM() {
            return FPHM;
        }

        public void setFPHM(String FPHM) {
            this.FPHM = FPHM;
        }

        public String getFPDM() {
            return FPDM;
        }

        public void setFPDM(String FPDM) {
            this.FPDM = FPDM;
        }

        public String getZZFPHM() {
            return ZZFPHM;
        }

        public void setZZFPHM(String ZZFPHM) {
            this.ZZFPHM = ZZFPHM;
        }

        public String getPZHM() {
            return PZHM;
        }

        public void setPZHM(String PZHM) {
            this.PZHM = PZHM;
        }

        public String getKJRQ() {
            return KJRQ;
        }

        public void setKJRQ(String KJRQ) {
            this.KJRQ = KJRQ;
        }

        public Double getHJJE() {
            return HJJE;
        }

        public void setHJJE(Double HJJE) {
            this.HJJE = HJJE;
        }

        public Double getKCE() {
            return KCE;
        }

        public void setKCE(Double KCE) {
            this.KCE = KCE;
        }

        public String getBZ() {
            return BZ;
        }

        public void setBZ(String BZ) {
            this.BZ = BZ;
        }

        public String getLY() {
            return LY;
        }

        public void setLY(String LY) {
            this.LY = LY;
        }

        public Double getBCKCJE() {
            return BCKCJE;
        }

        public void setBCKCJE(Double BCKCJE) {
            this.BCKCJE = BCKCJE;
        }

        public Double getPZHJJE() {
            return PZHJJE;
        }

        public void setPZHJJE(Double PZHJJE) {
            this.PZHJJE = PZHJJE;
        }
    }

}
