Search in sources :

Example 16 with BusinessLicense

use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.

the class BaiWangServiceImpl method query.

/**
 * 查询百旺发票通平台的状态
 * @param extraBill
 */
public ExtraBill query(ExtraBill extraBill) {
    synchronized (baiWangTask.BaiWangTaskLock) {
        if (!baiWangTask.isConnection() || !baiWangTask.isBaiWangDanJiConnection()) {
            baiWangTask.initBaiWang();
        }
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = null;
        try {
            // 筛选是该产品,并且订单状态是服务商审核中
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("productId", extraBill.getExtraProduct());
            paramMap.put("isquery", 1);
            paramMap.put("id", extraBill.getId());
            paramMap.put("desc", 1);
            // 2.查找是该产品的订单,并且订单状态是已支付,待服务商审核的订单.然后遍历订单信息
            List<Map<String, Object>> Extrabills = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition_BAIWANG", paramMap);
            if (null == Extrabills || Extrabills.isEmpty()) {
                return null;
            }
            for (Map<String, Object> bill : Extrabills) {
                Long id = (Long) bill.get("id");
                Boolean is_sendfpt = (Boolean) bill.get("is_sendfpt");
                Boolean is_passfpt = (Boolean) bill.get("is_passfpt");
                Boolean is_senddj = (Boolean) bill.get("is_senddj");
                Boolean is_passdj = (Boolean) bill.get("is_passdj");
                // 其他附加信息
                // 营业执照
                BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
                // 企业信息
                Enterprise enterprise = enterpriseService.getEnterpriseById((Long) bill.get("enterprise"));
                // 开户行信息
                OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
                // 税务登记
                TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
                // 0:税号 1:信用代码号
                Integer credentialsType = null;
                if (null != businessLicense && businessLicense.getBusinessType().equals(1)) {
                    credentialsType = 1;
                } else if (null != taxRegisterCert) {
                    credentialsType = 0;
                }
                String TAX_REGISTER_NO = credentialsType == 1 ? businessLicense.getLicenseNo() : taxRegisterCert.getCertNo();
                if (null != is_sendfpt && is_sendfpt.equals(true) && ((null == is_passfpt || is_passfpt.equals(false)))) {
                    String param2 = "<REQUEST><HEAD>" + "<client_id>" + BaiWangTask.client_id + "</client_id>" + "<access_token>" + BaiWangTask.access_token + "</access_token>" + "<openID>" + BaiWangTask.openID + "</openID>" + "</HEAD>" + "<BODY>" + "<SQM>" + BaiWangTask.SQM + "</SQM>" + "<TAX_REGISTER_NO>" + TAX_REGISTER_NO + "</TAX_REGISTER_NO>" + "</BODY>" + "</REQUEST>";
                    String param = URLEncoder.encode(new String(Base64.encode(param2.getBytes())), "UTF-8");
                    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
                    String urlAccessToken = BaiWangTask.baseUrl + "thirdInvoiceService";
                    URI uri;
                    uri = new URI(urlAccessToken);
                    map.add("sign", "caResult");
                    map.add("xml", param);
                    Map<String, String> resultMap = new HashMap<>();
                    String xml = restTemplate.postForObject(uri, map, String.class);
                    resultMap = BaiWangTask.parseXml(xml);
                    String recode = resultMap.get("REPLYCODE");
                    if (StringUtils.isNotBlank(recode) && recode.equals("0000")) {
                        // 当单机的已经审核通过之后,才能修改订单状态
                        if (null != extraBill.getIsPassdj() && extraBill.getIsPassdj().equals(true)) {
                            if (null != extraBill.geteInvoice()) {
                                // 订单需要开票.判断是否开票了.
                                Boolean isinvoiced = extraBill.getIsInvoiced();
                                if (null == isinvoiced || isinvoiced.equals(false)) {
                                    extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_6);
                                } else {
                                    extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
                                    extraBill.setFinishTime(new Date());
                                }
                            } else {
                                // 订单不需要开票,直接完成
                                extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
                                extraBill.setFinishTime(new Date());
                            }
                            extraBill.setCheckTime(new Date());
                        }
                        extraBill.setIsPassfpt(true);
                        is_passfpt = true;
                        status = transactionManager.getTransaction(def);
                        extraBillService.updateByPrimaryKeySelective(extraBill);
                        transactionManager.commit(status);
                        LogUtil.adminlog(sqlSession, "审核通过_百旺发票通", "订单号:" + bill.get("bill_id").toString());
                    } else if (StringUtils.isNotBlank(recode) && recode.equals("0003")) {
                        extraBill.setRefuseReason(resultMap.get("REPLYMSG").toString());
                        extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_5);
                        extraBill.setIsRefuse(true);
                        extraBill.setIsPassfpt(false);
                        extraBill.setIsSendfpt(false);
                        status = transactionManager.getTransaction(def);
                        extraBillService.updateByPrimaryKeySelective(extraBill);
                        transactionManager.commit(status);
                        log.error("审核拒绝_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("REPLYCODE") + "拒绝信息:" + resultMap.get("REPLYMSG") + ", 参数:" + param2);
                        LogUtil.adminlog(sqlSession, "审核拒绝_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("REPLYCODE") + "拒绝信息:" + resultMap.get("REPLYMSG"));
                    }
                }
                // 查询单机
                if (null != is_senddj && is_senddj.equals(true) && (null == is_passdj || is_passdj.equals(false))) {
                    StringBuffer stringBuffer = new StringBuffer();
                    String url = baiWangTask.dan_ji_url + "/fpfw/api/kpbusiness";
                    /**
                     *							<?xml version="1.0" encoding="utf-8"?>
                     *							<business comment="查询申请结果" id="CXSQJG">
                     *							<head>
                     *							    <login_name><![CDATA[itruschina]]></login_name>
                     *							    <passwd><![CDATA[12345678]]></passwd>
                     *							    <skpbh><![CDATA[ceshi2017071311222333]]></skpbh>
                     *							    <nsrsbh><![CDATA[911101088020176222333]]></nsrsbh>
                     *							</head>
                     *							</business>
                     */
                    stringBuffer.append("<?xml version='1.0' encoding='utf-8'?>");
                    stringBuffer.append("<business comment='查询申请结果' id='CXSQJG'>");
                    stringBuffer.append("head>");
                    stringBuffer.append("<login_name><![CDATA[" + baiWangTask.dan_ji_userName + "]]></login_name>");
                    stringBuffer.append("<passwd><![CDATA[" + baiWangTask.dan_ji_passWord + "]]></passwd>");
                    stringBuffer.append("<skpbh><![CDATA[" + openBankInfo.getTaxNumber() + "]]></skpbh>");
                    stringBuffer.append("<nsrsbh><![CDATA[" + enterprise.getNsrsbh() + "]]></nsrsbh>");
                    stringBuffer.append("</head>");
                    stringBuffer.append("</business>");
                    try {
                        Map resultMap = new HashMap<>();
                        HttpClient client = new HttpClient();
                        client.getHostConfiguration().setHost(baiWangTask.dan_ji_url, baiWangTask.dan_ji_port, baiWangTask.dan_ji_protocol);
                        HttpMethod method = null;
                        PostMethod post = new PostMethod("/fpfw/api/kpbusiness");
                        NameValuePair bw = new NameValuePair("bw", stringBuffer.toString());
                        NameValuePair[] nameValuePairs = { bw };
                        post.setRequestBody(nameValuePairs);
                        method = post;
                        client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
                        method.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                        client.executeMethod(method);
                        String xml = new String(method.getResponseBodyAsString().getBytes("UTF-8"));
                        resultMap = baiWangTask.parseXml(xml);
                        /**
                         *							 返回报文:
                         *							<?xml version="1.0" encoding="utf-8"?>
                         *							<business id="CXSQJG" version='1.0'>
                         *							<head>
                         *							</head>
                         *							<body>
                         *							<sq_date>申请日期</sq_date>
                         *							<yxqq>有效期起</yxqq>
                         *							<yxqz>有效期止</yxqz>
                         *							<kt_date>开通日期</kt_date>
                         *							<downloadurl>下载地址</downloadurl>
                         *							<returncode>返回</returncode>
                         *							<returnmsg>返回信息</returnmsg>
                         *							</body>
                         *							</business>
                         */
                        String returncode = resultMap.get("returncode").toString();
                        extraBill = extraBillService.selectByPrimaryKey(id);
                        if (StringUtils.isNotBlank(returncode) && returncode.equals("0")) {
                            // 当发票通的已经审核通过之后,才能修改订单状态
                            if (null != extraBill.getIsPassfpt() && extraBill.getIsPassfpt().equals(true)) {
                                if (null != extraBill.geteInvoice()) {
                                    // 订单需要开票.判断是否开票了.
                                    Boolean isinvoiced = extraBill.getIsInvoiced();
                                    if (null == isinvoiced || isinvoiced.equals(false)) {
                                        extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_6);
                                    } else {
                                        extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
                                        extraBill.setFinishTime(new Date());
                                    }
                                } else {
                                    // 订单不需要开票,直接完成
                                    extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
                                    extraBill.setFinishTime(new Date());
                                }
                                extraBill.setCheckTime(new Date());
                            }
                            extraBill.setIsPassdj(true);
                            is_passdj = true;
                            bwdjRecordService.insertOneRecored(resultMap, extraBill.getId());
                            status = transactionManager.getTransaction(def);
                            extraBillService.updateByPrimaryKeySelective(extraBill);
                            transactionManager.commit(status);
                            LogUtil.adminlog(sqlSession, "审核通过_百旺单机", "订单号:" + bill.get("bill_id").toString());
                        } else if (StringUtils.isNotBlank(returncode) && returncode.equals(baiWangTask.BW_DANJI_SHEN_HE_JU_JUE)) {
                            status = transactionManager.getTransaction(def);
                            String refuseReason = (String) resultMap.get("returnmsg");
                            extraBill.setRefuseReason(refuseReason);
                            baiWangTask.refuseDanJi(extraBill);
                            transactionManager.commit(status);
                            log.error("审核拒绝_百旺发票通", "审核拒绝_百旺单机", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("returncode") + "错误信息:" + resultMap.get("returnmsg") + ", 参数:" + stringBuffer.toString());
                            LogUtil.adminlog(sqlSession, "审核拒绝_百旺单机", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("returncode") + "错误信息:" + resultMap.get("returnmsg"));
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        log.error("查询订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + "异常信息:" + e.getMessage() + ", 参数:" + stringBuffer.toString());
                        LogUtil.adminlog(sqlSession, "查询订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + "异常信息:" + e.getMessage());
                    }
                }
            }
        } catch (Exception e) {
            LogUtil.adminlog(sqlSession, "查询订单失败_百旺", "错误信息:" + e.getMessage());
            e.printStackTrace();
        } finally {
            if (status != null && !status.isCompleted()) {
                transactionManager.rollback(status);
            }
        }
        extraBill = extraBillService.selectByPrimaryKey(extraBill.getId());
        return extraBill;
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PostMethod(org.apache.commons.httpclient.methods.PostMethod) TransactionStatus(org.springframework.transaction.TransactionStatus) URI(java.net.URI) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) NameValuePair(org.apache.commons.httpclient.NameValuePair) Date(java.util.Date) BusinessLicense(com.itrus.portal.db.BusinessLicense) HttpClient(org.apache.commons.httpclient.HttpClient) Enterprise(com.itrus.portal.db.Enterprise) HashMap(java.util.HashMap) Map(java.util.Map) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 17 with BusinessLicense

use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.

the class BaiWangServiceImpl method submitOrder.

/**
 * 1.订单资料推送到第三方平台
 * @param extraBill
 * @return
 */
public boolean submitOrder(ExtraBill extraBill) {
    synchronized (baiWangTask.BaiWangTaskLock) {
        if (!baiWangTask.isConnection() || !baiWangTask.isBaiWangDanJiConnection()) {
            baiWangTask.initBaiWang();
        }
        boolean fpt_flag = false;
        boolean danji_flag = false;
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = null;
        try {
            // 筛选是该产品,并且订单状态是3:已支付,待服务商审核,5:服务商审核拒绝 :这两种状态的订单
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("productId", extraBill.getExtraProduct());
            paramMap.put("issubmit", 1);
            paramMap.put("id", extraBill.getId());
            paramMap.put("desc", 1);
            // 2.查找是该产品的订单,并且订单状态是已支付,待服务商审核的订单.然后遍历订单信息
            List<Map<String, Object>> Extrabills = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition_BAIWANG", paramMap);
            if (null == Extrabills || Extrabills.isEmpty()) {
                return false;
            }
            Integer count = 0;
            for (Map<String, Object> bill : Extrabills) {
                Long id = (Long) bill.get("id");
                Boolean is_sendfpt = (Boolean) bill.get("is_sendfpt");
                Boolean is_passfpt = (Boolean) bill.get("is_passfpt");
                Boolean is_senddj = (Boolean) bill.get("is_senddj");
                Boolean is_passdj = (Boolean) bill.get("is_passdj");
                Long userinfoId = (Long) bill.get("unique_id");
                // 企业信息
                Enterprise enterprise = enterpriseService.getEnterpriseById((Long) bill.get("enterprise"));
                // 其他附加信息
                // 营业执照
                BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
                // 税务登记
                TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
                // 组织机构代码
                // OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
                // 代理人
                // Agent agent = agentService.getAgentByExtraBillId(id, null);
                UserInfo userInfo = userInfoService.getUserInfoById(userinfoId);
                // 开户行信息
                OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
                // 法人信息
                IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
                Integer type = 0;
                Boolean isRefuse = (Boolean) bill.get("is_refuse");
                if (null != isRefuse && isRefuse.equals(true)) {
                    type = 1;
                }
                // 0:税号 1:信用代码号
                Integer credentialsType = null;
                if (null != businessLicense && businessLicense.getBusinessType().equals(1)) {
                    credentialsType = 1;
                } else if (null != taxRegisterCert) {
                    credentialsType = 0;
                }
                String TAX_REGISTER_NO = credentialsType == 1 ? businessLicense.getLicenseNo() : taxRegisterCert.getCertNo();
                // 省份,当省份是几个直辖的或者特区的时候,省和市是一样的
                // 北京市110000,天津市120000,上海市310000,重庆市500000,
                // 香港,澳门,台湾先不做处理
                String province = enterprise.getProvince();
                boolean iscity = false;
                if (province.equals("110000") || province.equals("120000") || province.equals("310000") || province.equals("500000")) {
                    iscity = true;
                }
                province = sysRegionService.getProvince(province);
                // 城市
                String city = "";
                if (iscity) {
                    city = province;
                } else {
                    city = sysRegionService.getCity(enterprise.getCity());
                }
                String param2 = "";
                try {
                    // 当没发送过到百旺发票通的时候,则进行发送
                    if (null == is_sendfpt || is_sendfpt.equals(false)) {
                        File file = new File(systemConfigService.getTrustDir().getPath() + File.separator + enterprise.getEnterpriseSn());
                        if (!file.exists()) {
                            file.mkdir();
                        }
                        File imgFile = new File(file, businessLicense.getImgFile());
                        FileInputStream fis = null;
                        fis = new FileInputStream(imgFile);
                        // 三证合一/营业执照
                        String A_BIZ_LIC = ImageToBase64Utils.GetFileBase64(fis);
                        if (A_BIZ_LIC.length() > baiWangTask.BAI_WANG_MAX_IMG) {
                            A_BIZ_LIC = baiWangTask.compressImage(A_BIZ_LIC);
                        }
                        fis.close();
                        // +"<A_ID_FRONT>"+"企业联系人身份证(正面)"+"</A_ID_FRONT>"
                        imgFile = new File(file, identityCard.getFrontImg());
                        fis = new FileInputStream(imgFile);
                        String A_ID_FRONT = ImageToBase64Utils.GetFileBase64(fis);
                        if (A_ID_FRONT.length() > baiWangTask.BAI_WANG_MAX_IMG) {
                            A_ID_FRONT = baiWangTask.compressImage(A_ID_FRONT);
                        }
                        fis.close();
                        // 若法人是合并上传的,则传递两张一样的照片过去
                        String A_ID_BACK = "";
                        if (StringUtils.isBlank(identityCard.getBackImg())) {
                            A_ID_BACK = A_ID_FRONT;
                        } else {
                            // +"<A_ID_BACK>"+"企业联系人身份证(反面)"+"</A_ID_BACK>"
                            imgFile = new File(file, identityCard.getBackImg());
                            fis = new FileInputStream(imgFile);
                            A_ID_BACK = ImageToBase64Utils.GetFileBase64(fis);
                            if (A_ID_BACK.length() > baiWangTask.BAI_WANG_MAX_IMG) {
                                A_ID_BACK = baiWangTask.compressImage(A_ID_BACK);
                            }
                            fis.close();
                        }
                        fis.close();
                        // +"<TAXPAYER_ID>"+"申请 CA 企业对应唯一编号/当 type=1 时必传"+"</TAXPAYER_ID>"
                        String TAXPAYER_ID = "";
                        if (type == 1) {
                            TAXPAYER_ID = bill.get("taxpayer_id").toString();
                        }
                        param2 = "<REQUEST><HEAD>" + "<client_id>" + BaiWangTask.client_id + "</client_id>" + "<access_token>" + BaiWangTask.access_token + "</access_token>" + "<openID>" + BaiWangTask.openID + "</openID>" + "</HEAD>" + "<BODY>" + "<SQM>" + BaiWangTask.SQM + "</SQM>" + "<TAXPAYER_NAME>" + enterprise.getEnterpriseName() + "</TAXPAYER_NAME>" + "<SHORT_NAME>" + enterprise.getShortName() + "</SHORT_NAME>" + // 0:税号 1:信用代码号
                        "<IS_SZHY>" + credentialsType + "</IS_SZHY>" + // 企业税号或者企业三证合一之后的社会信用代码
                        "<TAX_REGISTER_NO>" + TAX_REGISTER_NO + "</TAX_REGISTER_NO>" + "<ENT_PROVINCE>" + province + "</ENT_PROVINCE>" + "<ENT_CITY>" + city + "</ENT_CITY>" + "<LEGAL_PERSON>" + identityCard.getName() + "</LEGAL_PERSON>" + "<ADDRESS>" + businessLicense.getBusinessPlace() + "</ADDRESS>" + "<ENT_EMAIL>" + bill.get("email").toString() + "</ENT_EMAIL>" + "<A_NAME>" + userInfo.getRealName() + "</A_NAME>" + "<A_MOBILE>" + bill.get("m_phone").toString() + "</A_MOBILE>" + "<A_ID_NO>" + identityCard.getIdCode() + "</A_ID_NO>" + "<A_EINVOICE_DEL></A_EINVOICE_DEL>" + "<A_BIZ_LIC>" + A_BIZ_LIC + "</A_BIZ_LIC>" + "<A_ID_FRONT>" + A_ID_FRONT + "</A_ID_FRONT>" + "<A_ID_BACK>" + A_ID_BACK + "</A_ID_BACK>" + "<TAXPAYER_ID>" + TAXPAYER_ID + "</TAXPAYER_ID>" + "</BODY>" + "</REQUEST>";
                        String param = URLEncoder.encode(new String(Base64.encode(param2.getBytes())), "UTF-8");
                        LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
                        String urlAccessToken = BaiWangTask.baseUrl + "thirdInvoiceService";
                        URI uri;
                        uri = new URI(urlAccessToken);
                        map.add("sign", "caApply");
                        map.add("type", type);
                        map.add("xml", param);
                        Map<String, String> resultMap = new HashMap<>();
                        String xml = restTemplate.postForObject(uri, map, String.class);
                        resultMap = BaiWangTask.parseXml(xml);
                        String recode = resultMap.get("REPLYCODE");
                        if (StringUtils.isNotBlank(recode) && recode.equals("0000")) {
                            extraBill.setIsSendfpt(true);
                            // 两个平台都成功送审之后,订单状态改为服务商审核中
                            if (null != extraBill.getIsSenddj() && extraBill.getIsSenddj().equals(true)) {
                                extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_4);
                            }
                            extraBill.setTaxpayerId(resultMap.get("TAXPAYER_ID").toString());
                            if (type == 1) {
                                // 曾经拒绝过的订单,再次推送成功
                                extraBill.setIsRefuse(false);
                            }
                            status = transactionManager.getTransaction(def);
                            extraBillService.updateByPrimaryKeySelective(extraBill);
                            transactionManager.commit(status);
                            LogUtil.adminlog(sqlSession, "推送订单_百旺发票通", "手动推送,总共:" + Extrabills.size() + "条,成功:" + count + "条");
                            fpt_flag = true;
                        } else {
                            log.error("推送订单失败_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("REPLYCODE") + "错误信息:" + resultMap.get("REPLYMSG") + ", 参数:" + param2);
                            LogUtil.adminlog(sqlSession, "推送订单失败_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "错误码:" + resultMap.get("REPLYCODE") + "错误信息:" + resultMap.get("REPLYMSG"));
                        }
                    }
                } catch (Exception e) {
                    log.error("推送订单异常_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "异常信息:" + e.getMessage() + ", 参数:" + param2);
                    LogUtil.adminlog(sqlSession, "推送订单异常_百旺发票通", "订单号:" + bill.get("bill_id").toString() + "异常信息:" + e.getMessage());
                }
                // 当没发送到百旺单机的时候,重新发送
                try {
                    if (null == is_senddj || is_senddj.equals(false)) {
                        StringBuffer stringBuffer = new StringBuffer();
                        /**
                         *								<?xml version="1.0" encoding="utf-8"?>
                         *								<business comment="注册申请" id="ZCSQ">
                         *								<body>
                         *								    <login_name><![CDATA[itruschina]]></login_name>
                         *								    <passwd><![CDATA[12345678]]></passwd>
                         *								    <skpbh><![CDATA[ceshi2017071311222333]]></skpbh>
                         *								    <nsrsbh><![CDATA[911101088020176222333]]></nsrsbh>
                         *								    <nsrmc><![CDATA[北京天威诚信电子商务服务有限公司测试070333]]></nsrmc>
                         *								    <city><![CDATA[北京市]]></city>
                         *								    <kh_usr_name><![CDATA[张三]]></kh_usr_name>
                         *								    <kh_lxdh><![CDATA[18878996333]]></kh_lxdh>
                         *								    <sfsy><![CDATA[1]]></sfsy>
                         *								    <bz><![CDATA[123]]></bz>
                         *								    <sqr_usr_name><![CDATA[何冠宏]]></sqr_usr_name>
                         *								    <sqr_lxdh><![CDATA[18878991333]]></sqr_lxdh>
                         *								    <sqr_ssgs><![CDATA[北京天威诚信电子商务服务有限公司]]></sqr_ssgs>
                         *								    <sfsf><![CDATA[1]]></sfsf>
                         *								    <sfje><![CDATA[0]]></sfje>
                         *								</body>
                         *								</business>
                         */
                        stringBuffer.append("<?xml version='1.0' encoding='utf-8'?>");
                        stringBuffer.append("<business comment='注册申请' id='ZCSQ'>");
                        stringBuffer.append("<body>");
                        stringBuffer.append("<login_name><![CDATA[" + baiWangTask.dan_ji_userName + "]]></login_name>");
                        stringBuffer.append("<passwd><![CDATA[" + baiWangTask.dan_ji_passWord + "]]></passwd>");
                        stringBuffer.append("<skpbh><![CDATA[" + openBankInfo.getTaxNumber() + "]]></skpbh>");
                        stringBuffer.append("<nsrsbh><![CDATA[" + enterprise.getNsrsbh() + "]]></nsrsbh>");
                        stringBuffer.append("<nsrmc><![CDATA[" + enterprise.getEnterpriseName() + "]]></nsrmc>");
                        stringBuffer.append("<city><![CDATA[" + city + "]]></city>");
                        stringBuffer.append("<kh_usr_name><![CDATA[" + userInfo.getRealName() + "]]></kh_usr_name>");
                        stringBuffer.append("<kh_lxdh><![CDATA[" + bill.get("m_phone").toString() + "]]></kh_lxdh>");
                        // 试用就是1 ,正式就用0.这个是针对客户端是否试用的
                        stringBuffer.append("<sfsy><![CDATA[0]]></sfsy>");
                        stringBuffer.append("<bz><![CDATA[" + bill.get("bill_id").toString() + "]]></bz>");
                        stringBuffer.append("<sqr_usr_name><![CDATA[" + "王晓雪" + "]]></sqr_usr_name>");
                        stringBuffer.append("<sqr_lxdh><![CDATA[" + "13120460901" + "]]></sqr_lxdh>");
                        stringBuffer.append("<sqr_ssgs><![CDATA[" + "北京天威诚信电子商务服务有限公司" + "]]></sqr_ssgs>");
                        stringBuffer.append("<sfsf><![CDATA[1]]></sfsf>");
                        stringBuffer.append("<sfje><![CDATA[0]]></sfje>");
                        stringBuffer.append("</body>");
                        stringBuffer.append("</business>");
                        HttpClient client = new HttpClient();
                        client.getHostConfiguration().setHost(baiWangTask.dan_ji_url, baiWangTask.dan_ji_port, baiWangTask.dan_ji_protocol);
                        HttpMethod method = null;
                        PostMethod post = new PostMethod("/fpfw/api/kpbusiness");
                        NameValuePair bw = new NameValuePair("bw", stringBuffer.toString());
                        NameValuePair[] nameValuePairs = { bw };
                        post.setRequestBody(nameValuePairs);
                        method = post;
                        client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
                        method.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                        client.executeMethod(method);
                        String xml = new String(method.getResponseBodyAsString().getBytes("UTF-8"));
                        Map<String, String> resultMap = new HashMap<>();
                        resultMap = baiWangTask.parseXml(xml);
                        String returncode = resultMap.get("returncode");
                        if (StringUtils.isNotBlank(returncode) && returncode.equals("0")) {
                            extraBill = extraBillService.selectByPrimaryKey(id);
                            extraBill.setIsSenddj(true);
                            // 两个平台都成功送审之后,订单状态改为服务商审核中
                            if (null != extraBill.getIsSendfpt() && extraBill.getIsSendfpt().equals(true)) {
                                extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_4);
                            }
                            status = transactionManager.getTransaction(def);
                            extraBillService.updateByPrimaryKeySelective(extraBill);
                            transactionManager.commit(status);
                            danji_flag = true;
                        } else {
                            /**
                             * 现在是<?xml version='1.0' encoding='utf-8'?><business version='1.0'><head></head><body><returncode>3</returncode><returnmsg>xml解析错误</returnmsg></body></business>
                             */
                            log.error("推送订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + ", 错误码:" + resultMap.get("returncode") + ", 错误信息:" + resultMap.get("returnmsg") + ",参数:" + stringBuffer.toString());
                            LogUtil.adminlog(sqlSession, "推送订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + ", 错误码:" + resultMap.get("returncode") + ", 错误信息:" + resultMap.get("returnmsg"));
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    log.error("推送订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + "错误信息:" + e.getMessage());
                    LogUtil.adminlog(sqlSession, "推送订单失败_百旺单机", "订单号:" + bill.get("bill_id").toString() + "错误信息:" + e.getMessage());
                    continue;
                }
            }
        } catch (Exception e) {
            LogUtil.syslog(sqlSession, "推送订单失败_百旺", "错误信息:" + e.getMessage());
            e.printStackTrace();
            return false;
        } finally {
            if (status != null && !status.isCompleted()) {
                transactionManager.rollback(status);
            }
        }
        return (danji_flag && fpt_flag);
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PostMethod(org.apache.commons.httpclient.methods.PostMethod) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) URI(java.net.URI) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) IdentityCard(com.itrus.portal.db.IdentityCard) NameValuePair(org.apache.commons.httpclient.NameValuePair) FileInputStream(java.io.FileInputStream) BusinessLicense(com.itrus.portal.db.BusinessLicense) HttpClient(org.apache.commons.httpclient.HttpClient) Enterprise(com.itrus.portal.db.Enterprise) HashMap(java.util.HashMap) Map(java.util.Map) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) File(java.io.File) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 18 with BusinessLicense

use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.

the class BusinessServiceImpl method getBusinessLicensesNews2.

/**
 * 查询数据库中是否存在该用户,该企业,未关联订单和增值订单.并且认证通过的信息,按生成时间降序排序
 *
 * @param enterpriseId
 * @return
 */
public BusinessLicense getBusinessLicensesNews2(Long enterpriseId, Long userinfoId) {
    List<BusinessLicense> bus = new ArrayList<BusinessLicense>();
    BusinessLicenseExample example = new BusinessLicenseExample();
    example.setOrderByClause("create_time DESC");
    BusinessLicenseExample.Criteria criteria = example.or();
    criteria.andEnterpriseEqualTo(enterpriseId);
    criteria.andUserInfoEqualTo(userinfoId);
    criteria.andBillIsNull();
    criteria.andExtraBillIsNull();
    bus = sqlSession.selectList("com.itrus.portal.db.BusinessLicenseMapper.selectByExample", example);
    if (null == bus || bus.isEmpty()) {
        return null;
    }
    return bus.get(0);
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) ArrayList(java.util.ArrayList) BusinessLicenseExample(com.itrus.portal.db.BusinessLicenseExample)

Example 19 with BusinessLicense

use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.

the class BusinessServiceImpl method saveBusinessExtraBill.

/**
 * 增值订单存储营业执照
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param businessLicense
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public BusinessLicense saveBusinessExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, BusinessLicense businessLicense, Integer itemStatus, BusinessLicense old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断营业执照图片是否重新上传了,没有重新上传,则会提交营业执照的id,重新上传,还是按照下面的方法处理
    if (null != businessLicense.getId()) {
        BusinessLicense bu0 = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", businessLicense.getId());
        BusinessLicense newBu = new BusinessLicense();
        newBu.setEnterpriseName(businessLicense.getEnterpriseName());
        newBu.setBusinessType(businessLicense.getBusinessType());
        newBu.setLicenseNo(businessLicense.getLicenseNo());
        newBu.setAbode(businessLicense.getAbode());
        newBu.setBusinessScope(businessLicense.getBusinessScope());
        newBu.setBusinessPlace(businessLicense.getBusinessPlace());
        newBu.setRegFund(businessLicense.getRegFund());
        newBu.setOperationStart(businessLicense.getOperationStart());
        newBu.setOperationEnd(businessLicense.getOperationEnd());
        newBu.setOperator(businessLicense.getOperator());
        newBu.setLegalPerson(businessLicense.getLegalPerson());
        newBu.setEnterprise(enterpriseId);
        newBu.setExtraBill(billId);
        newBu.setUserInfo(userInfoId);
        newBu.setIsDateless(true);
        newBu.setCreateTime(new Date());
        newBu.setLastModify(new Date());
        // 审核状态:1未审核,2已审核,3已拒绝
        newBu.setItemStatus(bu0.getItemStatus());
        if (StringUtils.isNotBlank(businessLicense.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
            if (liceImg != null && liceImg.isFile()) {
                newBu.setImgFile(liceImg.getName());
                newBu.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newBu.setImgFile(bu0.getImgFile());
            newBu.setImgFileHash(bu0.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", newBu);
        sqlSession.flushStatements();
        return newBu;
    }
    if (null == businessLicense || StringUtils.isBlank(businessLicense.getImgFile()) || StringUtils.isBlank(businessLicense.getEnterpriseName()) || StringUtils.isBlank(businessLicense.getLicenseNo())) {
        throw new UserInfoServiceException("请提交完整的营业执照信息");
    }
    businessLicense.setEnterprise(enterpriseId);
    businessLicense.setExtraBill(billId);
    businessLicense.setUserInfo(userInfoId);
    businessLicense.setIsDateless(true);
    businessLicense.setCreateTime(new Date());
    businessLicense.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    businessLicense.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(businessLicense.getImgFile()) && !businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
        File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
        if (liceImg != null && liceImg.isFile()) {
            businessLicense.setImgFile(liceImg.getName());
            businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", businessLicense);
    } else {
        businessLicense.setId(old.getId());
        sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKeySelective", businessLicense);
    }
    sqlSession.flushStatements();
    return businessLicense;
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 20 with BusinessLicense

use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.

the class BusinessServiceImpl method saveBusiness1.

public BusinessLicense saveBusiness1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, BusinessLicense businessLicense, Integer itemStatus, BusinessLicense old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断营业执照图片是否重新上传了,没有重新上传,则会提交营业执照的id,重新上传,还是按照下面的方法处理
    if (null != businessLicense.getId()) {
        BusinessLicense bu0 = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", businessLicense.getId());
        BusinessLicense newBu = new BusinessLicense();
        newBu.setEnterpriseName(businessLicense.getEnterpriseName());
        newBu.setBusinessType(businessLicense.getBusinessType());
        newBu.setLicenseNo(businessLicense.getLicenseNo());
        newBu.setEnterprise(enterpriseId);
        newBu.setBill(billId);
        newBu.setUserInfo(userInfoId);
        newBu.setIsDateless(true);
        newBu.setCreateTime(new Date());
        newBu.setLastModify(new Date());
        // 审核状态:1未审核,2已审核,3已拒绝
        newBu.setItemStatus(bu0.getItemStatus());
        if (StringUtils.isNotBlank(businessLicense.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
            if (liceImg != null && liceImg.isFile()) {
                newBu.setImgFile(liceImg.getName());
                newBu.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newBu.setImgFile(bu0.getImgFile());
            newBu.setImgFileHash(bu0.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", newBu);
        sqlSession.flushStatements();
        return newBu;
    }
    if (null == businessLicense || StringUtils.isBlank(businessLicense.getImgFile()) || StringUtils.isBlank(businessLicense.getEnterpriseName()) || StringUtils.isBlank(businessLicense.getLicenseNo())) {
        throw new UserInfoServiceException("请提交完整的营业执照信息");
    }
    businessLicense.setEnterprise(enterpriseId);
    businessLicense.setBill(billId);
    businessLicense.setUserInfo(userInfoId);
    businessLicense.setIsDateless(true);
    businessLicense.setCreateTime(new Date());
    businessLicense.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    businessLicense.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(businessLicense.getImgFile()) && !businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
        File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
        if (liceImg != null && liceImg.isFile()) {
            businessLicense.setImgFile(liceImg.getName());
            businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", businessLicense);
    } else {
        businessLicense.setId(old.getId());
        ;
        sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
    }
    sqlSession.flushStatements();
    return businessLicense;
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Aggregations

BusinessLicense (com.itrus.portal.db.BusinessLicense)43 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)30 Enterprise (com.itrus.portal.db.Enterprise)26 OrgCode (com.itrus.portal.db.OrgCode)25 IdentityCard (com.itrus.portal.db.IdentityCard)24 UserInfo (com.itrus.portal.db.UserInfo)21 Agent (com.itrus.portal.db.Agent)20 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)16 HashMap (java.util.HashMap)14 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ExtraProduct (com.itrus.portal.db.ExtraProduct)12 Proxy (com.itrus.portal.db.Proxy)11 ExtraBill (com.itrus.portal.db.ExtraBill)10 File (java.io.File)10 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 TransactionStatus (org.springframework.transaction.TransactionStatus)9 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)9 Product (com.itrus.portal.db.Product)8