Search in sources :

Example 1 with Proxy

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

the class APIService method upload.

/**
 * 证件图片上传
 *
 * @param authHmac
 *            hmac签名值,采用HmacSHA1算法
 * @param appId
 *            应用标识
 * @param orderNumber
 *            申请流水号
 * @param image1
 *            证件图片, base64形式
 * @param image2
 *            证件图片反面, base64形式(法定代表人和代理人证件类型为身份证时,必填)
 * @param type
 *            图片类型 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
 * @return
 */
@PostMapping(value = "/auth/upload")
@ResponseBody
public Map<String, Object> upload(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "orderNumber", required = false) String orderNumber, @RequestParam(value = "image1", required = false) String image1, @RequestParam(value = "image2", required = false) String image2, @RequestParam(value = "type", required = false) String type, HttpServletRequest request) {
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", 0);
    // 验证参数是否完整
    if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(type) || StringUtils.isEmpty(orderNumber) || StringUtils.isEmpty(image1)) {
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    try {
        Bill bill = billService.getBillByOrderNumber(orderNumber);
        if (bill == null) {
            result.put("message", "申请流水号不存在");
            return result;
        }
        UserInfo userInfo = userInfoService.getUserInfoByBillId(bill.getId());
        // 得到应用信息 改成service
        Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
        ApplicationInfo applicationInfo = appInfoMap.get(appId);
        if (applicationInfo == null) {
            ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
            ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
            appInfoExampleCriteria.andAppIdEqualTo(appId);
            applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
        }
        if (applicationInfo == null) {
            result.put("message", "应用标识不存在");
            return result;
        }
        if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
            result.put("status", -1);
            result.put("message", "没有此服务权限");
            log.error("APIService_AccsessIp : " + request.getRemoteAddr());
            return result;
        }
        // 验证hmac有效性
        try {
            String macVal = CertService.hmacSha1(applicationInfo.getSecretKey().getBytes(), (appId + orderNumber + image1 + image2 + type).getBytes("utf-8"));
            // sc.getAddressKey()), false);
            if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
                result.put("status", -2);
                result.put("message", "服务密钥错误");
                return result;
            }
        } catch (Exception e) {
            result.put("status", -3);
            result.put("message", "Hmac验证错误");
            e.printStackTrace();
            return result;
        }
        Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
        // 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
        List<Integer> modifiedStatus = new ArrayList<Integer>();
        modifiedStatus.add(ComNames.BILL_STATUS_3);
        modifiedStatus.add(ComNames.BILL_STATUS_4);
        modifiedStatus.add(ComNames.BILL_STATUS_10);
        // 不在以上状态中
        if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
            result.put("message", "该订单不能上传图片");
            return result;
        }
        // 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
        if (type.equals("1")) {
            BusinessLicense lc = businessService.getBusinessByBillId(bill.getId(), null);
            if (lc == null) {
                result.put("message", "不需要上传营业执照或(事业单位)法人证书图片");
                return result;
            }
            BusinessLicense business = businessService.portUpdateBusiness(bill.getId(), enterprise.getEnterpriseSn(), image1);
            if (business == null) {
                result.put("message", "营业执照或(事业单位)法人证书图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "营业执照或(事业单位)法人证书图片图片上传成功");
            return result;
        } else if (type.equals("2")) {
            OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
            if (oc == null) {
                result.put("message", "不需要上传组织机构代码证书图片");
                return result;
            }
            OrgCode orgCode = orgCodeService.portUpdateOrgCode(bill.getId(), enterprise.getEnterpriseSn(), image1);
            if (orgCode == null) {
                result.put("message", "组织机构代码证书图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "组织机构代码证书图片上传成功");
            return result;
        } else if (type.equals("3")) {
            TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
            if (tc == null) {
                result.put("message", "不需要上传税务登记证图片");
                return result;
            }
            TaxRegisterCert taxRegisterCert = taxCertService.portUpdateTaxCert(bill.getId(), enterprise.getEnterpriseSn(), image1);
            if (taxRegisterCert == null) {
                result.put("message", "税务登记证图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "税务登记证图片上传成功");
            return result;
        } else if (type.equals("4")) {
            IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
            if (ic == null) {
                result.put("message", "不需要上传法定代表人证件图片");
                return result;
            }
            if (ic.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
                result.put("message", "提交的参数信息不完整");
                return result;
            }
            IdentityCard identityCard = identityCardService.portUpdateIdentityCard(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
            if (identityCard == null) {
                result.put("message", "法定代表人证件图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "法定代表人证件图片上传成功");
            return result;
        } else if (type.equals("5")) {
            Agent at = agentService.getAgentByBillId(bill.getId(), null);
            if (at == null) {
                result.put("message", "不需要上传代理人证件图片");
                return result;
            }
            if (at.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
                result.put("message", "提交的参数信息不完整");
                return result;
            }
            Agent agent = agentService.portUpdateAgent(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
            if (agent == null) {
                result.put("message", "代理人证件图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "代理人证件图片上传成功");
            return result;
        } else if (type.equals("6")) {
            Proxy py = proxyService.getProxyByBillId(bill.getId());
            if (py == null) {
                result.put("message", "不需要上传授权书图片");
                return result;
            }
            Proxy proxy = proxyService.portUpdateProxy(bill.getId(), userInfo.getUniqueId(), image1);
            if (proxy == null) {
                result.put("message", "授权书图片上传失败");
                return result;
            }
            result.put("status", 1);
            result.put("message", "授权书图片上传成功");
            return result;
        } else {
            result.put("message", "图片类型参数输入有误");
            return result;
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (e.getMessage().contains("图片大小不能")) {
            result.put("status", 0);
            result.put("message", e.getMessage());
            return result;
        }
        // TODO Auto-generated catch block
        result.put("status", 0);
        result.put("message", "服务端出现未知错误,请联系管理员");
        return result;
    }
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) Agent(com.itrus.portal.db.Agent) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) UserInfo(com.itrus.portal.db.UserInfo) JSONException(org.json.JSONException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Proxy

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

the class DoUnlockKeyController method toDoUnlockPage.

/**
 * 执行证书解锁的页面
 *
 * @param billId
 * @param uiModel
 * @return
 */
@RequestMapping("/toDoUnlockPage")
public String toDoUnlockPage(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确!");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    // if (null == userCert.getUserinfo() || null == userCert.getEnterprise()) {
    // uiModel.addAttribute("errorMsg", "该证书尚未绑定用户或企业");
    // return ComNames.CLIENTFW_ERRORPAGE;
    // }
    Bill bill = billService.getBill(billId);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "不存在解锁订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    Product product = productService.getProduct(bill.getProduct());
    UserInfo userInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    uiModel.addAttribute("mPhone", userInfo.getmPhone());
    uiModel.addAttribute("userCert", userCert);
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("bill", bill);
    if (null != proxy) {
        // 授权书不一定有
        uiModel.addAttribute("proxy", proxy);
    }
    // TODO 解锁订单信息页面
    return "clientFW/zhengshujiesuo";
}
Also used : Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Proxy

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

the class DoUnlockKeyController method toUnlockKeyPage.

/**
 * key已经申请了解锁订单,跳转解锁页面
 * 1.订单处于未支付,则跳转支付页面
 * 2.订单处于已支付,待解锁审批,则跳转查询页面
 * 3.订单为审批拒绝,跳转审核拒绝重新提交页面
 * 4.订单为审批通过,待解锁,跳转解锁页面
 * 5.订单为解锁异常,则跳转解锁异常页面
 * 6.订单为解锁完成,则跳转解锁完成页面
 * @param certSn
 * @param keySn
 * @param enterpriseName
 * @param uiModel
 * @return
 */
@RequestMapping("/toUnlockKeyPage")
public String toUnlockKeyPage(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel, HttpSession session) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确!");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    // if (null== userCert.getUserinfo() || null == userCert.getEnterprise()) {
    // uiModel.addAttribute("errorMsg", "该证书尚未绑定用户或企业");
    // return ComNames.CLIENTFW_ERRORPAGE;
    // }
    Bill bill = billService.getBill(billId);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "不存在解锁订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    Product product = productService.getProduct(bill.getProduct());
    UserInfo userInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    OnPayInfo onPayInfo = onPayInfoService.selectByPrimaryKey(bill.getOnPayInfo());
    Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
    // UserInfo webUserInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
    if (null == session.getAttribute(ComNames.WEB_USER_INFO)) {
        session.setAttribute(ComNames.WEB_USER_INFO, userInfo);
    }
    uiModel.addAttribute("mPhone", userInfo.getmPhone());
    uiModel.addAttribute("userCert", userCert);
    uiModel.addAttribute("keySn", userCert.getKeySn());
    uiModel.addAttribute("certSn", userCert.getCertSn());
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("bill", bill);
    uiModel.addAttribute("onPayInfo", onPayInfo);
    uiModel.addAttribute("enterprise", enterprise);
    uiModel.addAttribute("enterpriseName", enterprise != null ? enterprise.getEnterpriseName() : "");
    if (null != proxy) {
        // 授权书不一定有
        uiModel.addAttribute("proxy", proxy);
    }
    if (bill.getBillStatus().equals(ComNames.BILL_STATUS_1)) {
        // * 1.订单处于未支付,则跳转支付页面 OK
        return "redirect:/unlockKeyBill/zhifu/" + billId;
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_14)) {
        // * 2.订单处于已支付,待解锁审批,则跳转查询页面,
        return "clientFW/dengdaishenhe_unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
        // * 3.订单为审批拒绝,跳转审核拒绝重新提交页面
        return "clientFW/dengdaishenhe_unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_16)) {
        // * 4.订单为审批通过,待解锁,跳转解锁页面
        return "clientFW/unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_17)) {
        // * 5.订单为解锁异常,则跳转解锁异常页面
        return "redirect:/doUnlockKey/toUnlockFailPage/" + billId;
    } else {
        uiModel.addAttribute("errorMsg", "订单不处于解锁状态");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
}
Also used : Proxy(com.itrus.portal.db.Proxy) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Proxy

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

the class ImageByBase64 method getImg.

/**
 * 获取图片文件File
 *
 * @param type
 *            类型:0营业执照图片,1组织机构代码图片,2税务登记图片,3授权书图片,4法人图片
 * @param id
 *            营业执照、组织机构代码、税务登记、授权书、法人中的某一项的id
 * @param num
 *            0表示正面,1标识反面图片
 * @return
 */
public File getImg(Long type, Long id, Long num) {
    File imgFile = null;
    String img = null;
    Long enterpriseId = null;
    Long userInfoId = null;
    try {
        if (type == ComNames.BUSINESS_ITEM) {
            BusinessLicense license = sqlsession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", id);
            if (license == null) {
                return null;
            }
            img = license.getImgFile();
            enterpriseId = license.getEnterprise();
        } else if (type == ComNames.ORG_CODE_ITEM) {
            OrgCode code = sqlsession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", id);
            if (code == null) {
                return null;
            }
            img = code.getImgFile();
            enterpriseId = code.getEnterprise();
        } else if (type == ComNames.TAX_CERT_ITEM) {
            TaxRegisterCert cert = sqlsession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByPrimaryKey", id);
            if (cert == null) {
                return null;
            }
            img = cert.getImgFile();
            enterpriseId = cert.getEnterprise();
        } else if (type == ComNames.IDENTITY_CARD_ITEM) {
            IdentityCard card = sqlsession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", id);
            if (card == null) {
                return null;
            }
            if (num == 0) {
                img = card.getFrontImg();
            } else {
                img = card.getBackImg();
            }
            enterpriseId = card.getEnterprise();
        } else if (type == ComNames.PROXY_ITEM) {
            Proxy proxy = sqlsession.selectOne("com.itrus.portal.db.ProxyMapper.selectByPrimaryKey", id);
            if (proxy == null) {
                return null;
            }
            img = proxy.getImgFile();
            // 授权书图片存放在用户唯一标识目录下
            userInfoId = proxy.getUserInfo();
        } else if (type == ComNames.AGENT_ITEM) {
            Agent agent = sqlsession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", id);
            if (agent == null) {
                return null;
            }
            if (num == 0) {
                img = agent.getFrontImg();
            } else {
                img = agent.getBackImg();
            }
            enterpriseId = agent.getEnterprise();
        }
        if (img == null) {
            return null;
        }
        File file = null;
        if (null != enterpriseId) {
            Enterprise enterprise = sqlsession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", enterpriseId);
            file = filePathUtils.getEnterpriseFile(enterprise.getEnterpriseSn());
        } else if (null != userInfoId) {
            // 授权书图片存放在用户唯一标识目录下
            UserInfo userInfo = sqlsession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", userInfoId);
            file = filePathUtils.getUserInfoFIle(userInfo.getUniqueId());
        } else {
            return null;
        }
        if (!file.exists()) {
            file.mkdirs();
        }
        imgFile = new File(file, img);
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return imgFile;
}
Also used : Agent(com.itrus.portal.db.Agent) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) File(java.io.File) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 5 with Proxy

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

the class ReviewServiceImpl method queryAudit.

/**
 * 查询送审结果
 *
 * @param appsecret
 * @param appId
 * @param dataid
 * @return
 */
public boolean queryAudit(String appsecret, Long appId, String dataid, Bill bill) throws Exception {
    AuditSystemConfig auditSystemConfig = auditSystemConfigService.getAuditSystemConfig(new AuditSystemConfigExample());
    if (null == auditSystemConfig) {
        // 未配置第三方鉴证信息
        return false;
    }
    Map<String, Object> jsonMap = new HashMap<String, Object>();
    jsonMap.put("appId", appId);
    jsonMap.put("appsecret", appsecret);
    // 待查询的记录id
    jsonMap.put("dataid", dataid);
    String jsonString = jsonTool.writeValueAsString(jsonMap);
    String result = RequestUtils.post(auditSystemConfig.getAuditSystemUrl() + ComNames.QUERYAPIS, jsonString, appsecret);
    JsonNode respNode = jsonTool.readTree(result);
    if (200 == respNode.get("status").asInt()) {
        // 查询成功
        JsonNode statusNode = respNode.get("result");
        // 0是未通过,1是通过,2是审核中
        int auditstatus = statusNode.get("auditstatus").asInt();
        BusinessLicense bl = businessService.getBusinessByBillId(bill.getId(), null);
        OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
        TaxRegisterCert trc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
        IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
        Agent at = agentService.getAgentByBillId(bill.getId(), null);
        Proxy p = proxyService.getProxyByBillId(bill.getId());
        // 默认未审核
        Integer itemStatus = 1;
        String reason = null;
        Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
        if (0 == auditstatus) {
            // 未通过(审核拒绝)
            // 记录未通过原因
            reason = statusNode.get("auditresult").getTextValue();
            // 更新订单状态
            bill.setBillStatus(ComNames.BILL_STATUS_4);
            bill.setCancelReason(reason);
            bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
            // 发送短信
            if (sendSmsBySHJJ(bill.getId())) {
                bill.setIsSms(true);
                bill.setSendTime(new Date());
            }
            // 更新认证项状态
            itemStatus = 3;
            // 添加系统日志
            LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核拒绝");
        } else if (1 == auditstatus) {
            // 通过
            Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
            Product product1 = null;
            Product product2 = null;
            Product product3 = null;
            DigitalCert cert1 = null;
            DigitalCert cert2 = null;
            DigitalCert cert3 = null;
            if (null != bill.getProduct1()) {
                product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
                if (null != product1.getCert()) {
                    cert1 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product1.getCert());
                }
            }
            if (null != bill.getProduct2()) {
                product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct2());
                if (null != product2.getCert()) {
                    cert2 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product2.getCert());
                }
            }
            if (null != bill.getProduct3()) {
                product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct3());
                if (null != product3.getCert()) {
                    cert3 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product3.getCert());
                }
            }
            DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
            // 更新企业
            if (respNode.get("source") != null) {
                enterprise.setInfo(respNode.get("source").getTextValue().getBytes());
            }
            enterprise.setReviewTime(new Date());
            enterprise.setAuthenticationLevel(product.getAuthentication());
            // 更新订单状态
            bill.setBillStatus(ComNames.BILL_STATUS_5);
            if (bill.getOldUserCert() != null) {
                bill.setBillStatus(ComNames.BILL_STATUS_12);
            }
            // 数字证书操作方式为用户下载(2)的,订单状态设置为待下载
            if (null != cert && null != cert.getInitBuy() && "2".equals(cert.getInitBuy())) {
                bill.setBillStatus(ComNames.BILL_STATUS_13);
            }
            // 当产品没有配置有数字证书的时候
            if (null == cert && null == cert1 && null == cert2 && null == cert3) {
                // 根据订单判断订单是否需要开票:0标识不需要开票,1需要开纸质发票,2需要开电子发票
                int type = billService.getBillInvoiceType(bill);
                switch(type) {
                    case 0:
                        bill.setBillStatus(ComNames.BILL_STATUS_8);
                        break;
                    case 1:
                        if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                            bill.setBillStatus(ComNames.BILL_STATUS_7);
                        } else {
                            bill.setBillStatus(ComNames.BILL_STATUS_6);
                        }
                        break;
                    case 2:
                        if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                            bill.setBillStatus(ComNames.BILL_STATUS_8);
                        } else {
                            bill.setBillStatus(ComNames.BILL_STATUS_6);
                        }
                        break;
                    default:
                        break;
                }
            }
            bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
            // 更新认证项状态
            itemStatus = 2;
            // 添加系统日志
            LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核通过");
        } else if (2 == auditstatus) {
            // 审核中
            throw new UserInfoServiceException(statusNode.get("auditmessage").getTextValue());
        }
        if (null != bl) {
            bl.setItemStatus(itemStatus);
            saveBl(bl, respNode.get("source"));
            enterprise.setHasBl(bl.getId());
        }
        if (null != oc) {
            oc.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", oc);
            enterprise.setHasOrgCode(oc.getId());
        }
        if (null != trc) {
            trc.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKeySelective", trc);
            enterprise.setHasTaxCert(trc.getId());
        }
        if (null != ic) {
            ic.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKeySelective", ic);
            enterprise.setHasIdCard(ic.getId());
        }
        if (null != at) {
            at.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", at);
            enterprise.setHasAgent(at.getId());
        }
        if (null != p) {
            p.setItemStatus(itemStatus);
        }
        // 更新企业
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKeyWithBLOBs", enterprise);
        // 更新订单
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        // 生成鉴证记录
        reviewLogService.saveReviewLog(1, null, auditstatus == 1 ? 1 : 2, reason, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), bl == null ? null : bl.getId(), oc == null ? null : oc.getId(), trc == null ? null : trc.getId(), ic == null ? null : ic.getId(), at == null ? null : at.getId(), p == null ? null : p.getId());
        return true;
    } else if (201 == respNode.get("status").asInt()) {
        // 查询失败
        String message = respNode.get("message").getTextValue();
        throw new UserInfoServiceException(message);
    }
    return false;
}
Also used : Agent(com.itrus.portal.db.Agent) HashMap(java.util.HashMap) AuditSystemConfig(com.itrus.portal.db.AuditSystemConfig) AuditSystemConfigExample(com.itrus.portal.db.AuditSystemConfigExample) Product(com.itrus.portal.db.Product) JsonNode(org.codehaus.jackson.JsonNode) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) DigitalCert(com.itrus.portal.db.DigitalCert) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Aggregations

Proxy (com.itrus.portal.db.Proxy)20 BusinessLicense (com.itrus.portal.db.BusinessLicense)11 IdentityCard (com.itrus.portal.db.IdentityCard)11 OrgCode (com.itrus.portal.db.OrgCode)11 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)11 Agent (com.itrus.portal.db.Agent)10 Enterprise (com.itrus.portal.db.Enterprise)10 Product (com.itrus.portal.db.Product)10 UserInfo (com.itrus.portal.db.UserInfo)10 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)10 Bill (com.itrus.portal.db.Bill)9 HashMap (java.util.HashMap)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 JSONObject (com.alibaba.fastjson.JSONObject)5 UserCert (com.itrus.portal.db.UserCert)5 File (java.io.File)5 Date (java.util.Date)5 Certification (com.itrus.portal.db.Certification)4 DigitalCert (com.itrus.portal.db.DigitalCert)4 TransactionStatus (org.springframework.transaction.TransactionStatus)4