Search in sources :

Example 41 with Product

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

the class BindCertWebController method getProjectByCertBase64.

/**
 * 获取产品信息
 *
 * @param certBase64
 * @return
 * @throws UserInfoServiceException
 */
public Product getProjectByCertBase64(String certBase64) throws UserInfoServiceException {
    UserCert userCert;
    try {
        userCert = userCertService.getUserCert(certBase64);
    } catch (CertificateException e) {
        throw new UserInfoServiceException(e.getMessage());
    } catch (SigningServerException e) {
        throw new UserInfoServiceException(e.getMessage());
    }
    Product product = null;
    // 证书序列号
    String CertSerialNumber = userCert.getCertSn();
    if (userCert.getBill() == null) {
        String accountHash = getRaInfo.getRaInfoByCertSerialNumber(CertSerialNumber);
        if (StringUtils.isBlank(accountHash))
            throw new UserInfoServiceException("获取AccountHash失败,请联系管理员");
        // Ra
        RaAccount raAccount = raAccountService.getRaByAccountHash(accountHash);
        if (null == raAccount)
            throw new UserInfoServiceException("获取RA信息失败,请联系管理员");
        // 产品
        // product = productService.getProductByRa(raAccount.getId());
        product = productService.getRenewProduct(raAccount.getId(), null, null, userCert.getCertDn());
    } else {
        // 证书关联了订单,根据订单获得projectId和productId
        Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCert.getBill());
        if (null == bill) {
            throw new UserInfoServiceException("获取产品信息失败,请联系管理员");
        }
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    }
    if (null == product)
        throw new UserInfoServiceException("获取对应产品信息失败");
    userCert.setProduct(product.getId());
    sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
    return product;
}
Also used : RaAccount(com.itrus.portal.db.RaAccount) Bill(com.itrus.portal.db.Bill) SigningServerException(com.itrus.cryptorole.SigningServerException) Product(com.itrus.portal.db.Product) CertificateException(java.security.cert.CertificateException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserCert(com.itrus.portal.db.UserCert)

Example 42 with Product

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

the class ClientPayWebController method updatePayInfo.

private void updatePayInfo(String billId, Long payConfigId, String transactionId, String payType, String payTime) throws Exception {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus s = null;
    try {
        s = transactionManager.getTransaction(def);
        BillExample be = new BillExample();
        BillExample.Criteria bc = be.createCriteria();
        bc.andBillIdEqualTo(billId);
        bc.andBillStatusIn(Arrays.asList(new Integer[] { 1, 11 }));
        Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", be);
        if (null == bill) {
            return;
        }
        bill.setBillStatus(3);
        bill.setPayTime(new Date(Long.parseLong(payTime)));
        // 产品
        Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
        // pfx流程判断begin
        DigitalCert digitalCert = null;
        if (null != product.getCert()) {
            digitalCert = digitalCertService.getDigitalCert(product.getCert());
            if (null != digitalCert && null != digitalCert.getCertType() && digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX)) {
                // 这个用户,这个企业,这个项目,有通过了实名认证的订单,则直接进入待下载,
                List<Bill> bills = billService.hasAuthticationLevel(bill.getUniqueId(), bill.getEnterprise(), product.getProject());
                if (null != bills && bills.size() > 0 && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2)) {
                    bill.setBillStatus(ComNames.BILL_STATUS_13);
                    // 新增审核通过的记录
                    reviewService.agreeBillReview(bill);
                }
            }
        }
        // 解锁产品流程判断gegin
        if (null != product.getKeyUnlockType()) {
            bill = unLockKeyBillService.updateBillStatusWhileHasPay(bill, product);
        }
        // 解锁产品流程判断end
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        OnPayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
        payInfo.setPayStatus(1);
        payInfo.setWcTime(bill.getPayTime());
        payInfo.setPayNo(transactionId);
        OnlinePayExample ope = new OnlinePayExample();
        OnlinePayExample.Criteria opc = ope.createCriteria();
        opc.andPayConfigEqualTo(payConfigId);
        // 1支付宝 2微信
        opc.andWayEqualTo((Integer.parseInt(payType) == 0 ? 1 : 2));
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByExample", ope);
        payInfo.setOnlinePay(onlinePay.getId());
        // payInfo.setComment(m.get("return_msg"));
        sqlSession.update("com.itrus.portal.db.OnPayInfoMapper.updateByPrimaryKeySelective", payInfo);
        transactionManager.commit(s);
    } catch (Exception e) {
        LogUtil.syslog(sqlSession, "在线支付", billId + "回调更新数据库错误:" + e.toString());
        throw new Exception(billId + "回调更新数据库错误:" + e.toString());
    } finally {
        if (null != s && !s.isCompleted()) {
            transactionManager.rollback(s);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) OnlinePayExample(com.itrus.portal.db.OnlinePayExample) TransactionStatus(org.springframework.transaction.TransactionStatus) Product(com.itrus.portal.db.Product) Date(java.util.Date) DigitalCert(com.itrus.portal.db.DigitalCert) BillExample(com.itrus.portal.db.BillExample) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) OnlinePay(com.itrus.portal.db.OnlinePay)

Example 43 with Product

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

the class DownLoadCertWebController method downLoadCert.

@RequestMapping("/{id}")
@ResponseBody
public Map<String, Object> downLoadCert(@PathVariable(value = "id") Long id, @RequestParam(value = "uidIdx", required = true) Integer uidIdx, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "keySn", required = false) String keySn, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    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;
    }
    Bill bill = billService.getBill(id);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    // 订单是否为当前用户当前企业
    if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
        retMap.put("retMsg", "您不能操作该订单");
        return retMap;
    }
    // 判断该订单状态是否为待下载,是否已经关联了证书
    List<String> certStatus = new ArrayList<String>();
    certStatus.add(ComNames.CERT_STATUS_1);
    certStatus.add(ComNames.CERT_STATUS_2);
    List<UserCert> userCerts = userCertService.getUserCertByBill(bill.getId(), certStatus);
    if (!bill.getBillStatus().equals(ComNames.BILL_STATUS_13) || !userCerts.isEmpty()) {
        retMap.put("retMsg", "该证书状态为已下载或订单还未审核");
        return retMap;
    }
    Product product = productService.getProduct(bill.getProduct());
    DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
    RaAccount ra = raAccountService.getRaAccount(product.getRa());
    // 下载证书
    String autoidType = "";
    Integer autoidValue = 0;
    try {
        // 下载证书
        CertInfo racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalCert, uidIdx, csr, autoidType, autoidValue);
        // 保存证书
        downLoadCertService.saveCertInfo(racertinfo, bill, ra.getId(), uidIdx, keySn, autoidType, autoidValue);
        // 返回数字证书
        retMap.put("retCode", 1);
        retMap.put("certChain", racertinfo.getCertSignBufP7());
        retMap.put("certSn", racertinfo.getCertSerialNumber());
        retMap.put("certSignBuf", racertinfo.getCertSignBuf());
        retMap.put("certKmcRep1", racertinfo.getCertKmcRep1());
        retMap.put("certKmcRep2", racertinfo.getCertKmcRep2());
        // 加密证书
        retMap.put("encUserCert", racertinfo.getCertSignBufKmc());
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("用户下载证书");
        userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功");
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    } catch (Exception e) {
        e.printStackTrace();
        retMap.put("retMsg", e.getMessage());
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("用户下载证书");
        userlog.setInfo("url:downLoadCert,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        return retMap;
    }
    return retMap;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) GenP10Exception(com.itrus.Exception.GenP10Exception) IOException(java.io.IOException) DigitalCert(com.itrus.portal.db.DigitalCert) RaAccount(com.itrus.portal.db.RaAccount) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 44 with Product

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

the class UnlockKeyBillController method reSubmitUnlockBill.

/**
 * 解锁订单重新提交授权书,注意授权书的id不能为null
 * @param billId
 * @param certSn
 * @param keySn
 * @param proxy
 * @param request
 * @return
 */
@RequestMapping("/reSubmitUnlockBill")
@ResponseBody
public Map<String, Object> reSubmitUnlockBill(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @ModelAttribute("proxy") Proxy proxy, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserInfo webUserInfo = null;
    Project project = null;
    // 校验证书和证书所绑定的用户和企业
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        retMap.put("retMsg", "该证书未注册,请您先注册");
        return retMap;
    }
    // if(null == userCert.getUserinfo()){
    // retMap.put("retMsg", "该证书未绑定用户,请检查您插入的key是否正确");
    // return retMap;
    // }
    // 校验订单和证书所对应的用户与企业
    Bill bill = billService.getBill(billId);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    webUserInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    if (null == webUserInfo) {
        retMap.put("retMsg", "订单所对应的用户不存在,请检查");
        return retMap;
    }
    if (!(bill.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
        retMap.put("errorMsg", "该订单不处于可以重新提交的状态");
        return retMap;
    }
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        retMap.put("errorMsg", "您无权操作该订单");
        return retMap;
    }
    Product product = productService.getProduct(bill.getProduct());
    if (null == product.getKeyUnlockType()) {
        retMap.put("retMsg", "您选择的产品不属于解锁产品,请重新选择");
        return retMap;
    }
    project = projectService.selectByPrimaryKey(product.getProject());
    DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
    dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(dtd);
    try {
        if (null != proxy && (StringUtils.isNotBlank(proxy.getImgFile()) || null != proxy.getId())) {
            // 保存授权书
            Proxy oldProxy = null;
            if (null != proxy.getId()) {
                oldProxy = new Proxy();
                oldProxy.setId(proxy.getId());
                proxy.setId(null);
            }
            proxy = proxyService.saveProxy1(bill.getEnterprise(), webUserInfo.getUniqueId(), bill.getId(), bill.getUniqueId(), proxy, oldProxy, project);
        }
        // 审核拒绝后的订单,重新提交,则修改订单状态和审核拒绝的短信发送
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
            bill.setBillStatus(ComNames.BILL_STATUS_14);
            bill.setIsSms(false);
            billService.updateBill(bill);
        }
        transactionManager.commit(status);
        LogUtil.userlog(sqlSession, project.getId(), "重新提交解锁订单", webUserInfo.getmPhone() + "重新提交解锁订单:" + bill.getBillId(), "未知", "", null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        retMap.put("retCode", 1);
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
        UserLog userlog = new UserLog();
        userlog.setProject(project.getId());
        userlog.setType("重新提交解锁订单");
        userlog.setInfo("url:reSubmitUnlockBill,详细错误:" + e.getMessage() + ",订单号" + bill.getBillId());
        userlog.setHostId("未知");
        userlog.setSn(null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    } finally {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 45 with Product

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

the class UnlockKeyBillController method toReSubmitUnlockBillPage.

/**
 * 页面申请信息有误,或者审核拒绝,重新提交
 *
 * @param billId
 * @param certSn
 * @param keySn
 * @param uiModel
 * @return
 */
@RequestMapping("/toReSubmitUnlockBillPage/{billId}")
public String toReSubmitUnlockBillPage(@PathVariable("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, Model uiModel) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确,证书序列号:" + certSn);
        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.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
        uiModel.addAttribute("errorMsg", "该订单不处于可以重新提交授权书的状态");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    uiModel.addAttribute("bill", bill);
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    if (null != proxy) {
        uiModel.addAttribute("proxy", proxy);
    }
    Product product = productService.getProduct(bill.getProduct());
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("userCert", userCert);
    return "clientWF/xiugaishouquanshu";
}
Also used : Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Product (com.itrus.portal.db.Product)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)43 HashMap (java.util.HashMap)42 Bill (com.itrus.portal.db.Bill)39 Enterprise (com.itrus.portal.db.Enterprise)27 UserInfo (com.itrus.portal.db.UserInfo)27 DigitalCert (com.itrus.portal.db.DigitalCert)24 JSONObject (com.alibaba.fastjson.JSONObject)19 UserCert (com.itrus.portal.db.UserCert)19 ArrayList (java.util.ArrayList)19 IOException (java.io.IOException)18 Map (java.util.Map)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 ProductExample (com.itrus.portal.db.ProductExample)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 Date (java.util.Date)15 List (java.util.List)14 HttpSession (javax.servlet.http.HttpSession)14 BillExample (com.itrus.portal.db.BillExample)10 Project (com.itrus.portal.db.Project)10