Search in sources :

Example 6 with Product

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

the class DownLoadCertWebController method downloadPfxCert.

/**
 * 用户下载pfx证书的接口
 * @param id,订单id
 * @param session
 * @param request
 * @param response
 * @return
 */
@RequestMapping("/pfx/{id}")
public String downloadPfxCert(@PathVariable(value = "id") Long id, HttpSession session, HttpServletRequest request, HttpServletResponse response) {
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        return null;
    }
    Integer uidIdx = 1;
    Bill bill = billService.getBill(id);
    if (null == bill) {
        return null;
    }
    boolean billFlag = webuserInfo.getId().equals(bill.getUniqueId()) && webenterprise.getId().equals(bill.getEnterprise());
    if (!billFlag) {
        return null;
    }
    // 用户已经下载过了,再次下载
    boolean downLoadFlag = bill.getBillStatus().equals(ComNames.BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.BILL_STATUS_7) || bill.getBillStatus().equals(ComNames.BILL_STATUS_8);
    if (downLoadFlag) {
        // 根据订单号,找到订单对应的证书信息
        CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
        Date date = new Date();
        // 获取证书第一次下载时间和当前时间比较,如果超过了十五天,则不允许下载
        int day = DateUtils.daysOfTwo(date, certBuf.getCreateTime());
        if (day > 16) {
            return null;
        }
        // 从数据库中取出数据,返回给客户端.
        // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
        response.reset();
        String filename = webenterprise.getEnterpriseName() + "功能证书.pfx";
        filename = encodeFilename(filename, request);
        response.setHeader("Content-disposition", "attachment;filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
        response.setContentType("application/x-pkcs12");
        OutputStream os = null;
        try {
            os = response.getOutputStream();
            // 清理刷新缓冲区,将缓存中的数据将数据导出excel
            byte[] byteCert = Base64.decode(certBuf.getPfxCert());
            os.write(byteCert);
            os.flush();
            // 关闭os
            if (os != null) {
                os.close();
            }
            certBuf.setLastDownloadTime(new Date());
            certBuf.setCertDownloadNumber(certBuf.getCertDownloadNumber() + 1);
            downLoadCertService.updatePfxCert(certBuf);
            // 记录日志
            UserLog userlog = new UserLog();
            userlog.setProject(webuserInfo.getProject());
            userlog.setType("用户下载证书pfx");
            userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功");
            userlog.setHostId("未知");
            userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
            return null;
        } catch (IOException e) {
            UserLog userlog = new UserLog();
            userlog.setProject(bill.getProject());
            userlog.setType("用户下载证书pfx");
            userlog.setInfo(webenterprise.getEnterpriseName() + "失败,错误信息:" + e.getMessage());
            userlog.setHostId("未知");
            userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
        }
    } else {
        // 用户未下载过,第一次下载
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_13)) {
            // 查询项目产品
            Product product = productService.getProduct(bill.getProduct());
            // 企业
            Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
            // 获取产品、RA配置
            RaAccount ra = raAccountService.getRaAccount(product.getRa());
            // 证书配置
            DigitalCert digitalcert = digitalCertService.getDigitalCert(product.getCert());
            // 下载证书
            String autoidType = "";
            Integer autoidValue = 0;
            String pfxCert = "";
            // 用户ID,用来最终匹配公钥证书和密钥对
            String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
            // TODO 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
            String certPass = product.getPassword();
            // 产生CSR证书请求
            String certReqBuf = "";
            // 算法
            String algorithm = digitalCertService.getAlgorithm(digitalcert);
            // 下载证书
            CertInfo racertinfo = null;
            try {
                certReqBuf = GenUtil.GenP10(userid, "", algorithm);
                racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalcert, uidIdx, certReqBuf, autoidType, autoidValue);
                // pfxCert = GenUtil.GenPFX(userid, certPass,
                // racertinfo.getCertSignBuf(), false);
                // pfxCert = GenUtil2.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), pfxCert, false, enterprise.getEnterpriseName());
                pfxCert = GenUtil.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), false, enterprise.getEnterpriseName());
                // 保存证书
                downLoadCertService.savePfxCertInfo(racertinfo, bill, ra.getId(), uidIdx, "", autoidType, autoidValue, pfxCert);
                // 从数据库中取出数据,返回给客户端.
                // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
                response.reset();
                String filename = webenterprise.getEnterpriseName() + "通讯证书.pfx";
                filename = encodeFilename(filename, request);
                response.setHeader("Content-disposition", "attachment;filename=" + filename);
                response.setCharacterEncoding("utf-8");
                // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
                response.setContentType("application/x-pkcs12");
                OutputStream os = null;
                os = response.getOutputStream();
                // 清理刷新缓冲区,将缓存中的数据将数据导出excel
                byte[] byteCert = Base64.decode(pfxCert);
                os.write(byteCert);
                os.flush();
                // 关闭os
                if (os != null) {
                    os.close();
                }
                // 记录日志
                UserLog userlog = new UserLog();
                userlog.setProject(bill.getProject());
                userlog.setType("用户下载证书pfx");
                userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功,企业名称:" + webenterprise.getEnterpriseName());
                userlog.setHostId("未知");
                userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
                LogUtil.userlog(sqlSession, userlog);
                return null;
            } catch (Exception e) {
                // 记录日志
                UserLog userlog = new UserLog();
                userlog.setProject(bill.getProject());
                userlog.setType("用户下载证书pfx");
                userlog.setInfo(webenterprise.getEnterpriseName() + "失败,错误信息:" + e.getMessage());
                userlog.setHostId("未知");
                userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
                LogUtil.userlog(sqlSession, userlog);
            }
        }
    }
    return null;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) OutputStream(java.io.OutputStream) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) Date(java.util.Date) 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) CertBuf(com.itrus.portal.db.CertBuf) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Product

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

the class DownLoadCertWebController method downLoadCertPage.

// 进入下载证书页面
@RequestMapping("/downLoadCertPage/{id}")
public String downLoadCertPage(@PathVariable(value = "id") Long id, HttpSession session, Model uiModel) {
    // 是否登录
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    Bill bill = billService.getBill(id);
    if (null == bill) {
        logger.error("id为" + id + "的订单不存在");
        return "redirect:/userInfoWeb/denglu.html";
    }
    // 订单是否为当前用户当前企业
    if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
        logger.error(webuserInfo.getmPhone() + "不能操作订单" + bill.getBillId());
        return "redirect:/userInfoWeb/denglu.html";
    }
    Product product = productService.getProduct(bill.getProduct());
    DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
    // 获取产品规格
    ProductSpec productSpec = null;
    if (null != bill.getProductSpec() && !"0".equals(bill.getProductSpec())) {
        productSpec = productSpecService.getProductSpec(bill.getProductSpec());
    }
    // 获取订单在线支付方式
    if (bill.getOnPayInfo() != null) {
        OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
        uiModel.addAttribute("onPayInfo", onPayInfo);
    } else if (bill.getPayInfo() != null) {
        PayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", bill.getPayInfo());
        uiModel.addAttribute("payInfo", payInfo);
    }
    // 审核记录信息
    ReviewLog reviewLog = reviewLogService.getReviewLog(id);
    if (reviewLog != null) {
        uiModel.addAttribute("reviewLog", reviewLog);
    }
    uiModel.addAttribute("bill", bill);
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("digitalCert", digitalCert);
    uiModel.addAttribute("productSpec", productSpec);
    // 当是pfx证书的时候,告知页面
    boolean pfxFlag = digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX) && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2);
    if (pfxFlag) {
        uiModel.addAttribute("ispfx", 1);
    }
    List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
    List<Map> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillKey", id);
    uiModel.addAttribute("makecerts", makecerts);
    uiModel.addAttribute("enterpriseSn", makecerts.get(0).get("enterprise_sn"));
    DigitalCert digitalcert = null;
    Map<String, Object> params = new HashMap<String, Object>();
    uiModel.addAttribute("makecertexall", makecertexall);
    digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", makecerts.get(0).get("cert"));
    uiModel.addAttribute("digitalcert", digitalcert);
    if (makecerts.get(0).containsKey("product_spec") && !"0".equals(makecerts.get(0).get("product_spec"))) {
        productSpec = productSpecService.getProductSpec((Long) makecerts.get(0).get("product_spec"));
    }
    uiModel.addAttribute("productSpec", productSpec);
    product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product"));
    uiModel.addAttribute("product", product);
    try {
        uiModel.addAttribute("billStr", jsonTool.writeValueAsString(makecerts.get(0)));
        uiModel.addAttribute("usercertallStr", jsonTool.writeValueAsString(makecertexall));
        uiModel.addAttribute("digitalcertStr", jsonTool.writeValueAsString(digitalcert));
        uiModel.addAttribute("productStr", jsonTool.writeValueAsString(product));
        uiModel.addAttribute("productSpecStr", jsonTool.writeValueAsString(productSpec));
    } catch (Exception e) {
        e.printStackTrace();
    }
    // System.out.println(makecerts.get(0).get("product_num"));
    // 处理autoid自动编号信息
    // 解析项目产品中,certinfo配置信息
    JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
    for (int i = 0; certinfo != null && i < certinfo.size(); i++) {
        JSONObject obj = certinfo.getJSONObject(i);
        String autoid = obj.getString("autoid");
        if (autoid == null)
            continue;
        String autoidType = obj.getString("autoidType");
        String autoidPrev = obj.getString("autoidPrev");
        String autoidPrevDate = obj.getString("autoidPrevDate");
        String autoidLength = obj.getString("autoidLength");
        // 从user_cert表查询,该autoidType的最大值,如果没有最大值,则设置为0
        Map param = new HashMap();
        String enterpriseId = makecerts.get(0).get("enterprise").toString();
        param.put("enterpriseId", makecerts.get(0).get("enterprise"));
        param.put("type", autoidType);
        Integer autoidValue = null;
        if (autoidPrevDate == null)
            autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditon", param);
        else
            autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditonDate", param);
        if (autoidValue == null)
            autoidValue = 0;
        uiModel.addAttribute("enterpriseId", enterpriseId);
        uiModel.addAttribute("autoidType", autoidType);
        uiModel.addAttribute("autoidPrev", autoidPrev);
        uiModel.addAttribute("autoidLength", autoidLength);
        uiModel.addAttribute("autoidValue", autoidValue);
        break;
    }
    return "ixinweb/dingdanxiangqing_xiazaiqueren";
}
Also used : HashMap(java.util.HashMap) JSONArray(com.alibaba.fastjson.JSONArray) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) ProductSpec(com.itrus.portal.db.ProductSpec) GenP10Exception(com.itrus.Exception.GenP10Exception) IOException(java.io.IOException) DigitalCert(com.itrus.portal.db.DigitalCert) OnPayInfo(com.itrus.portal.db.OnPayInfo) PayInfo(com.itrus.portal.db.PayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) JSONObject(com.alibaba.fastjson.JSONObject) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) ReviewLog(com.itrus.portal.db.ReviewLog) JSONObject(com.alibaba.fastjson.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Product

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

the class UnlockKeyBillController method getUnlockProducts.

/**
 * 返回key对应的解锁产品列表
 *		1.证书有绑定的用户,用户选择自助解锁,不需要进行短信码校验,直接提交
 *		2.证书有绑定的用户,用户选择人工解锁(因为之前绑定的手机号可能没有了),进行短信校验后提交
 *		3.证书没有绑定的用户,用户只能选择人工解锁(后台不返回自助解锁的产品了),进行短信码校验后,直接提交
 * @param CertSn
 * @param keySn
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping("/getUnlockProducts")
public String getUnlockProducts(@RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel, HttpServletRequest request) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    // if (null == userCert.getUserinfo()) {
    // uiModel.addAttribute("errorMsg", "该证书尚未绑定用户,请先绑定后再使用");
    // return ComNames.CLIENTFW_ERRORPAGE;
    // }
    UserInfo webUserInfo = null;
    uiModel.addAttribute("has_userInfo", 0);
    if (null != userCert.getUserinfo()) {
        webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
        uiModel.addAttribute("userInfo", webUserInfo);
        uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
        uiModel.addAttribute("has_userInfo", 1);
    }
    Enterprise enterprise = enterpriseService.getEntByName(enterpriseName);
    uiModel.addAttribute("has_enterpriseInfo", 0);
    if (null != enterprise) {
        uiModel.addAttribute("enterprise", enterprise);
        uiModel.addAttribute("has_enterpriseInfo", 1);
    }
    ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
    if (null == projectKeyInfo) {
        uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
    if (null == products || products.isEmpty()) {
        uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    uiModel.addAttribute("products", products);
    // 电子开票服务
    Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
    Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
    if (null == products.get(0).geteBill()) {
        uiModel.addAttribute("ereceiptMapSize", 0);
    }
    uiModel.addAttribute("ereceiptMap", ereceiptMap);
    return "clientFW/unlock_out";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) 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 9 with Product

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

the class UnlockKeyBillController method getUnlockProductsByLogin.

/**
 * 用户登录后点击解锁,返回key对应的解锁产品列表
 * @param CertSn
 * @param keySn
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping(value = "/getUnlockProductsByLogin")
public String getUnlockProductsByLogin(@RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, Model uiModel, HttpServletRequest request) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    UserInfo webUserInfo = (UserInfo) request.getSession().getAttribute(ComNames.WEB_USER_INFO);
    if (null == webUserInfo) {
        uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Enterprise enterprise = (Enterprise) request.getSession().getAttribute(ComNames.WEB_ENTERPRISE);
    if (null == enterprise) {
        uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
    if (null == projectKeyInfo) {
        uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    HttpSession session = request.getSession();
    Integer has_enterpriseInfoInsession = (Integer) session.getAttribute("has_enterpriseInfo");
    Integer hhas_userInfoInsession = (Integer) session.getAttribute("has_userInfo");
    if (null == hhas_userInfoInsession) {
        uiModel.addAttribute("has_userInfo", 0);
        if (null != userCert.getUserinfo()) {
            webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
            uiModel.addAttribute("userInfo", webUserInfo);
            uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
            uiModel.addAttribute("has_userInfo", 1);
        }
    }
    if (null == has_enterpriseInfoInsession) {
        uiModel.addAttribute("has_enterpriseInfo", 0);
        if (null != enterprise) {
            uiModel.addAttribute("enterprise", enterprise);
            uiModel.addAttribute("has_enterpriseInfo", 1);
        }
    }
    Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
    if (null == products || products.isEmpty()) {
        uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    uiModel.addAttribute("products", products);
    uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
    // 电子开票服务
    Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
    Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
    if (null == products.get(0).geteBill()) {
        uiModel.addAttribute("ereceiptMapSize", 0);
    }
    uiModel.addAttribute("ereceiptMap", ereceiptMap);
    return "clientFW/unlock_out";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) Project(com.itrus.portal.db.Project) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Product

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

the class BankCertificationController method verifyCode.

/**
 * 验证动态码/银行卡认证处理
 *
 * @param mPhone
 * @param code
 * @param request
 * @return
 */
@RequestMapping(value = "/verifyCode")
@ResponseBody
public Map<String, Object> verifyCode(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "personId", required = false) Long personId, @RequestParam(value = "productId", required = false) Long productId, @RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "personName", required = true) String personName, @RequestParam(value = "personNo", required = true) String personNo, @RequestParam(value = "bankNo", required = true) String bankNo, HttpServletRequest request) {
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到当前产品信息
    Product product = productService.getProductById(productId);
    // 判断是否已经存在订单
    List list = personalBillService.selectPersonalBillByPersonId(2, personId, productId, 8);
    PersonalBill personalBill = null;
    if (list.size() == 0) {
        // 产生新订单
        personalBill = personalBillService.saveBill(personId, personInfo.getmPhone(), productId, 2, product.getProject(), 1, product.getPrice(), personId, 3);
    } else {
        personalBill = (PersonalBill) list.get(0);
    }
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识处理失败,1标识成功
    retMap.put("retCode", 0);
    try {
        // 验证动态码,
        if (!dynamicCodeService.verifyCode(mPhone, code)) {
            // if(false){
            // 验证码不通过
            retMap.put("retMsg", "动态码验证失败");
            return retMap;
        } else {
            // 调用银行卡认证
            String str = pbankrealtestsms(authHmac, personName, personNo, bankNo, mPhone, "1");
            retMap.put("retCode", 1);
            JSONObject jasonObject = JSONObject.parseObject(str);
            Map map = (Map) jasonObject;
            String status = (String) map.get("status");
            PersonInfo personInfo1 = personInfoService.getSelectById(personInfo.getId());
            if ("200".equals(status)) {
                retMap.put("retCode", 1);
                // 添加银行卡信息
                BankcardInfo bank = bankcardInfoService.saveBankcardInfo(personName, mPhone, personNo, bankNo, personId, null);
                // 认证成功修改订单信息
                personalBill.setReservedPhone(mPhone);
                personalBill.setBankNo(bankNo);
                personalBill.setRealName(personName);
                personalBill.setIdCode(personNo);
                personalBill.setBillStatus(8);
                personalBill.setCheckTime(new Date());
                personalBillService.updateByPersonalBill(personalBill);
                // 修改个人用户信息
                personInfo1.setRealName(personName);
                personInfo1.setPersonName(personName);
                personInfo1.setIdCode(personNo);
                personInfoService.updateByPersonInfo(personInfo1);
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 1, null, personalBill.getId(), personId, bank.getId());
                // 添加系统日志
                LogUtil.syslog(sqlSession, "银行卡认证送审成功", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
            } else {
                if ("201".equals(status)) {
                    retMap.put("retMsg", map.get("message"));
                } else if ("205".equals(status)) {
                    retMap.put("retMsg", map.get("error"));
                }
                // 认证失败修改订单状态
                personalBill.setBillStatus(4);
                personalBillService.updateByPersonalBill(personalBill);
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 2, map.get("error").toString(), personalBill.getId(), personId, null);
                // 添加系统日志
                LogUtil.syslog(sqlSession, "银行卡认证送审失败", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
            }
        }
    } catch (Exception e) {
        retMap.put("retMsg", "出现未知异常,请联系管理员处理");
        String info = mPhone + "认证失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "银行卡认证", info);
        return retMap;
    }
    return retMap;
}
Also used : BankcardInfo(com.itrus.portal.db.BankcardInfo) PersonInfo(com.itrus.portal.db.PersonInfo) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Date(java.util.Date) PersonalBill(com.itrus.portal.db.PersonalBill) JSONObject(com.alibaba.fastjson.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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