Search in sources :

Example 51 with UserInfo

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

the class BillWebController method updateAuditBill.

/**
 * 修改审核中订单
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @param session
 * @return
 */
@RequestMapping("/updateAuditBill")
@ResponseBody
public Map<String, Object> updateAuditBill(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "enterprise_nature", required = false) Integer enterpriseNature, @RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "uid", required = true) String uid, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    // 验证参数完整性
    if (null == enterpriseNature || 0 == enterpriseNature || null == billId) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    if (!webuserInfo.getId().equals(bill.getUniqueId())) {
        retMap.put("retMsg", "您不能修改该订单");
        return retMap;
    }
    // 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
    List<Integer> modifiedStatus = new ArrayList<Integer>();
    modifiedStatus.add(ComNames.BILL_STATUS_1);
    modifiedStatus.add(ComNames.BILL_STATUS_2);
    modifiedStatus.add(ComNames.BILL_STATUS_3);
    modifiedStatus.add(ComNames.BILL_STATUS_10);
    // 不在以上状态中
    if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
        retMap.put("retMsg", "该订单不能修改");
        return retMap;
    }
    // 根据订单id获取产品需要认证项,
    List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", billId);
    if (null == certItems || certItems.isEmpty()) {
        retMap.put("retMsg", "服务端出现异常,请联系管理员");
        log.error("获取订单对应产品的认证项失败:订单Id=" + billId + ".");
        return retMap;
    }
    // 记录旧的企业唯一标识:
    String oldEnterpriseSn = webenterprise.getEnterpriseSn();
    // 设置企业唯一标识
    if (enterpriseNature.equals(1) || enterpriseNature.equals(2)) {
        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
        webenterprise.setEnterpriseSn(businessLicense.getLicenseNo());
    }
    if (enterpriseNature.equals(3)) {
        // 类型为政府机关/事业单位:企业标识为组织机构代码
        webenterprise.setEnterpriseSn(orgCode.getOrgCode());
    }
    // 修改企业名称
    webenterprise.setEnterpriseName(enterpriseName.trim());
    // 修改企业性质
    webenterprise.setEnterpriseNature(enterpriseNature);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 删除订单关联的旧认证项,新增订单对应的新认证项
        billWebService.saveBillAuthenticationItems(certItems.get(0), enterpriseNature, billId, businessLicense, orgCode, taxregisterCert, identityCard, agent, proxy, webenterprise, webuserInfo);
        // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
        if (null != webenterprise.getAuthenticationLevel())
            webenterprise.setAuthenticationLevel(null);
        if (null != webenterprise.getHasBl())
            webenterprise.setHasBl(null);
        if (null != webenterprise.getHasOrgCode())
            webenterprise.setHasOrgCode(null);
        if (null != webenterprise.getHasTaxCert())
            webenterprise.setHasTaxCert(null);
        if (null != webenterprise.getHasIdCard())
            webenterprise.setHasIdCard(null);
        if (null != webenterprise.getHasAgent())
            webenterprise.setHasAgent(null);
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", webenterprise);
        // 修改发票
        if (bill.getInvoice() != null && bill.getIsInvoiced() == null) {
            Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.getInvoice());
            invoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.InvoiceMapper.updateByPrimaryKey", invoice);
        }
        if (bill.geteInvoice() != null && bill.getIsInvoiced() == null) {
            Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
            einvoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKey", einvoice);
        }
        // 判断该订单状态是否为送审中,假如是,则设置为 3已支付,待审核(用于重新送审)
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_10)) {
            bill.setBillStatus(ComNames.BILL_STATUS_3);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        if (StringUtils.isNotEmpty(uid) && !uid.equals("{}")) {
            bill.setUid(uid);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        } else {
            if (StringUtils.isNotEmpty(uid1) && !uid1.equals("{}")) {
                bill.setUid1(uid1);
            }
            if (StringUtils.isNotEmpty(uid2) && !uid2.equals("{}")) {
                bill.setUid2(uid2);
            }
            if (StringUtils.isNotEmpty(uid3) && !uid3.equals("{}")) {
                bill.setUid3(uid3);
            }
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        transactionManager.commit(status);
        session.setAttribute("webenterprise", webenterprise);
        // 企业标识改变后,将旧目录中的图片复制到新目录中
        if (!oldEnterpriseSn.equals(webenterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + webenterprise.getEnterpriseSn());
        }
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setType("修改订单");
        userlog.setInfo("url:updateAuditBill,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setProject(webuserInfo.getProject());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        log.error(e.getMessage());
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Invoice(com.itrus.portal.db.Invoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Einvoice(com.itrus.portal.db.Einvoice) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 52 with UserInfo

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

the class BindCertWebController method bindPage.

@RequestMapping("/bindCertPage")
public String bindPage(@RequestParam(value = "certSn", required = true) String certSn, HttpSession session, Model uiModel) throws UserInfoServiceException {
    // 是否登录
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    // 返回所有信任源所有
    List<String> allIssUerDn = new ArrayList<String>();
    allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
    try {
        uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    UserCert userCert = null;
    userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert)
        throw new UserInfoServiceException("未找到对应的证书信息");
    // DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    UserCertPojo ucp = new UserCertPojo(userCert, userCert.getCertStartTime().getTime() + "", userCert.getCertEndTime().getTime() + "");
    CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByPrimaryKey", userCert.getCertBuf());
    uiModel.addAttribute("userCert", ucp);
    uiModel.addAttribute("certBase64", certBuf.getCertBuf().replaceAll("\n", ""));
    return "ixinweb/bangding";
}
Also used : UserCertPojo(com.itrus.portal.utils.UserCertPojo) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) Enterprise(com.itrus.portal.db.Enterprise) ArrayList(java.util.ArrayList) CertBuf(com.itrus.portal.db.CertBuf) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with UserInfo

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

the class BindCertWebController method loginCertBind.

/**
 * 绑定登陆证书页面 szy 2016年8月18日 下午3:24:01
 *
 * @param mPhone
 *            手机号
 * @param password
 *            对应手机号的登陆密码
 * @param code
 *            验证码
 * @param productId
 *            产品id
 * @param projectId
 *            项目id
 * @param certBase64
 *            证书信息
 * @param enterprise
 *            企业信息包括,唯一表标识
 *            enterpriseSn,企业名称enterpriseName,企业类型enterpriseNature
 *            ,行业orgIndustry
 * @return Map<String,Object> retCode 返回状态码: -1默认错误,1验证码错误,2密码为空,3证书已经被绑定过,4
 *         企业信息不完整,0绑定成功 redirectCode 跳转标识码 -1默认错误,1购买产品页面,2安全服务页面 retMsg
 *         返回信息
 */
@RequestMapping("/loginCertBind")
@ResponseBody
public Map<String, Object> loginCertBind(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "projectId", required = true) Long projectId, @ModelAttribute("enterprise") Enterprise enterprise, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 错误
    retMap.put("retCode", -1);
    // 错误
    retMap.put("redirectCode", -1);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        if (null == enterprise || StringUtils.isBlank(enterprise.getEnterpriseSn()) || StringUtils.isBlank(enterprise.getEnterpriseName()) || null == enterprise.getEnterpriseNature() || null == enterprise.getOrgIndustry()) {
            retMap.put("retCode", 4);
            retMap.put("retMsg", "您提交的企业信息不完整");
            return retMap;
        }
        // 验证动态码,
        if (!dynamicCodeService.verifyCode(mPhone, code)) {
            // 验证码不通过,状态 1
            retMap.put("retCode", 1);
            retMap.put("retMsg", "动态码验证失败");
            return retMap;
        }
        // 绑定用户和证书
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        enterprise = enterpriseService.addEnterPrise(enterprise);
        if (null == userInfo) {
            if (StringUtils.isBlank(password)) {
                retMap.put("retCode", 2);
                retMap.put("retMsg", "请先设置登录口令");
                return retMap;
            }
            if (projectId != null) {
                // 先自动创建用户
                userInfo = userInfoService.registerUserInfo(mPhone, password, projectId);
                // 记录系统日志
                String info = mPhone + "注册成功";
                LogUtil.syslog(sqlSession, "注册用户", info);
            }
        }
        // 添加企业-代理人关联关系
        userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
        // 获取证书
        UserCert userCert = userCertService.getUserCert(certBase64);
        // 判断是否已和证书绑定
        if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
            retMap.put("retCode", 3);
            retMap.put("retMsg", "该证书已绑定过用户");
            return retMap;
        }
        // key序列号
        if (StringUtils.isNotBlank(keySn))
            userCert.setKeySn(keySn);
        // 绑定证书与用户关系
        userCert.setUserinfo(userInfo.getId());
        userCert.setEnterprise(enterprise.getId());
        sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
        // 如果是从项目页面中链接过来,跳转到购买产品页面
        // 否则 跳转到安全服务页面
        Boolean webnoProduct = (Boolean) session.getAttribute("webnoProduct");
        if (webnoProduct != null && webnoProduct) {
            retMap.put("redirectCode", 1);
        } else {
            retMap.put("redirectCode", 2);
        }
        session.setAttribute("webuserInfo", userInfo);
        session.setAttribute("webenterprise", enterprise);
        session.setAttribute("webverifyCodeStatus", true);
        // 返回绑定成功
        retMap.put("retCode", 0);
        transactionManager.commit(status);
    } catch (CertificateException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (SigningServerException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", "服务端出现未知异常,请联系管理员");
        String info = mPhone + "绑定证书失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "绑定证书", info);
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) CertificateException(java.security.cert.CertificateException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) SigningServerException(com.itrus.cryptorole.SigningServerException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 54 with UserInfo

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

the class BindCertWebController method bindCert.

// 绑定用户和证书
@RequestMapping("/bindCert")
@ResponseBody
public Map<String, Object> bindCert(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam(value = "keySn", required = false) String keySn, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识发送验证码失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2标识登录已经失效,需跳转到登录页面
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效");
        return retMap;
    }
    // 验证动态码,
    if (!dynamicCodeService.verifyCode(mPhone, code)) {
        // 验证码不通过
        retMap.put("retMsg", "动态码验证失败");
        return retMap;
    }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 绑定用户和证书
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        if (null == userInfo) {
            if (StringUtils.isBlank(password)) {
                retMap.put("retMsg", "请先设置登录口令");
                return retMap;
            }
            // 先自动创建用户
            userInfo = userInfoService.registerUserInfo(mPhone, password, projectId);
            // 记录系统日志
            String info = mPhone + "注册成功";
            LogUtil.syslog(sqlSession, "注册用户", info);
        }
        // 添加企业-代理人关联关系
        userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(userInfo.getId(), webenterprise.getId());
        // 获取证书
        UserCert userCert = userCertService.getUserCert(certBase64);
        // 判断是否已和证书绑定
        if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
            retMap.put("retMsg", "该证书已绑定过用户");
            return retMap;
        }
        // 绑定证书与用户关系
        if (StringUtils.isNotBlank(keySn))
            userCert.setKeySn(keySn);
        userCert.setUserinfo(userInfo.getId());
        userCert.setEnterprise(webenterprise.getId());
        sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
        retMap.put("retCode", 1);
        transactionManager.commit(status);
        return retMap;
    } catch (CertificateException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (SigningServerException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", "服务端出现未知异常,请联系管理员");
        String info = mPhone + "绑定证书失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "绑定证书", info);
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) CertificateException(java.security.cert.CertificateException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Enterprise(com.itrus.portal.db.Enterprise) SigningServerException(com.itrus.cryptorole.SigningServerException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 55 with UserInfo

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

the class BindCertWebController method sendCode.

/**
 * 绑定证书时发送验证码
 *
 * @param mPhone
 * @param project
 * @param certBase64
 * @return
 */
@RequestMapping("/sendCode")
@ResponseBody
public Map<String, Object> sendCode(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "project", required = true) Long project, @RequestParam(value = "certBase64", required = true) String certBase64, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识发送验证码失败,1标识成功
    retMap.put("retCode", 0);
    // 是否登录
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2标识登录已经失效,需跳转到登录页面
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效");
        return retMap;
    }
    try {
        // 判断该证书是否已经绑定有用户
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        // 0表示没有用户,1表示有用户
        retMap.put("hasUserInfo", 0);
        if (null != userInfo) {
            // 1表示有用户
            retMap.put("hasUserInfo", 1);
            // 判断是否和证书绑定
            if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
                retMap.put("retMsg", "该证书已绑定过用户");
                return retMap;
            }
        }
        // 发送验证码
        // ZSBD表示短信模版类型为‘绑定证书’。
        dynamicCodeService.sendCode(mPhone, project, "ZSBD");
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (CertificateException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (SigningServerException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) Enterprise(com.itrus.portal.db.Enterprise) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfo(com.itrus.portal.db.UserInfo) CertificateException(java.security.cert.CertificateException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserInfo (com.itrus.portal.db.UserInfo)99 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)79 Enterprise (com.itrus.portal.db.Enterprise)68 HashMap (java.util.HashMap)52 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)40 IOException (java.io.IOException)39 HttpSession (javax.servlet.http.HttpSession)37 Bill (com.itrus.portal.db.Bill)31 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)31 Product (com.itrus.portal.db.Product)26 ExtraProduct (com.itrus.portal.db.ExtraProduct)24 Project (com.itrus.portal.db.Project)24 UserCert (com.itrus.portal.db.UserCert)24 BusinessLicense (com.itrus.portal.db.BusinessLicense)21 ExtraBill (com.itrus.portal.db.ExtraBill)20 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)20 UserLog (com.itrus.portal.db.UserLog)20 IdentityCard (com.itrus.portal.db.IdentityCard)19 OrgCode (com.itrus.portal.db.OrgCode)19 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)19