Search in sources :

Example 1 with UserLog

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

the class BillWebController method delete.

// 删除未支付订单
@RequestMapping(value = "/bill/{id}.html", method = RequestMethod.PUT, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, HttpServletRequest request, Model uiModel) {
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
    HttpSession session = request.getSession();
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    /*
		 * Invoice iv = sqlSession.selectOne(
		 * "com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey",
		 * bill.getInvoice()); Delivery dl = sqlSession.selectOne(
		 * "com.itrus.portal.db.DeliveryMapper.selectByPrimaryKey",
		 * bill.getDelivery()); PayInfo pi = sqlSession.selectOne(
		 * "com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey",
		 * bill.getPayInfo());
		 */
    if (bill == null) {
        return "未找到要删除订单";
    } else {
        if (!bill.getBillStatus().equals(ComNames.BILL_STATUS_1)) {
            return "该订单不允许删除";
        }
        bill.setIsDelete(true);
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        // 订单是否有优惠记录,有则置为无效
        Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
        if (null != product.getPreferentialNum() && product.getPreferentialNum() > 0) {
            try {
                preferentialRecordService.deletePreferentialRecordSByBillId(bill.getId());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        UserLog userlog = new UserLog();
        userlog.setProject(userInfo.getProject());
        userlog.setType("删除订单");
        userlog.setInfo(userInfo.getmPhone() + "删除了订单" + bill.getBillId());
        userlog.setHostId("未知");
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    }
    /*
		 * if (iv != null) { try { sqlSession
		 * .delete("com.itrus.portal.db.InvoiceMapper.deleteByPrimaryKey",
		 * iv.getId());
		 * 
		 * String oper = "删除发票信息"; String info = "订单号: " + bill.getBillId() +
		 * "发票id: "+iv.getId(); LogUtil.adminlog(sqlSession, oper, info); }
		 * catch (Exception e) { return "订单【" + bill.getBillId() +
		 * "】的发票信息存在关联,无法删除"; } }
		 * 
		 * if (dl != null) { try { sqlSession
		 * .delete("com.itrus.portal.db.DeliveryMapper.deleteByPrimaryKey",
		 * dl.getId());
		 * 
		 * String oper = "删除配送信息"; String info = "订单号: " + bill.getBillId() +
		 * "配送id: "+iv.getId(); LogUtil.adminlog(sqlSession, oper, info); }
		 * catch (Exception e) { return "订单【" + bill.getBillId() +
		 * "】的配送信息存在关联,无法删除"; } } if (pi != null) { try { sqlSession
		 * .delete("com.itrus.portal.db.PayInfoMapper.deleteByPrimaryKey",
		 * pi.getId());
		 * 
		 * String oper = "删除支付信息"; String info = "订单号: " + bill.getBillId() +
		 * "支付id: "+pi.getId(); LogUtil.adminlog(sqlSession, oper, info); }
		 * catch (Exception e) { return "订单【" + bill.getBillId() +
		 * "】的支付信息存在关联,无法删除"; } }
		 */
    return null;
}
Also used : HttpSession(javax.servlet.http.HttpSession) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) 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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with UserLog

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

the class ClientWebController method reSubmitOrder.

/**
 * 审核拒绝,重新提交信息接口
 * @param enterprise
 * @param userInfo
 * @param einvoice
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param agent
 * @param openBankInfo
 * @param identityCard
 * @param request
 * @return
 */
@RequestMapping("/reSubmitOrder")
@ResponseBody
public Map<String, Object> reSubmitOrder(@RequestParam(value = "extraBillId", required = true) Long id, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("agent") Agent agent, @ModelAttribute("openBankInfo") OpenBankInfo openBankInfo, @ModelAttribute("identityCard") IdentityCard identityCard, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    if (!bill.getUniqueId().equals(webuserInfo.getId())) {
        retMap.put("retMsg", "您无权操作该订单");
        return retMap;
    }
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 更新用户信息和企业信息
        enterprise.setId(webenterprise.getId());
        // ""字符串判断,改为Null,避免覆盖数据库中的信息
        if (null != enterprise) {
            if (StringUtils.isBlank(enterprise.getProvince())) {
                enterprise.setProvince(null);
            }
            if (StringUtils.isBlank(enterprise.getCity())) {
                enterprise.setCity(null);
            }
            if (StringUtils.isBlank(enterprise.getShortName())) {
                enterprise.setShortName(null);
            }
            if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                enterprise.setNsrsbh(null);
            }
        }
        enterprise = enterpriseService.updateByPrimaryKeySelective(enterprise);
        userInfo.setId(webuserInfo.getId());
        userInfo = userInfoService.updateByPrimaryKeySelective(userInfo);
        // 根据订单id,获取该订单的旧认证项:
        BusinessLicense oldBl = businessService.getBusinessByExtraBillId(id, null);
        OrgCode oldOc = orgCodeService.getOrgCodeByExtraBillId(id, null);
        TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
        IdentityCard oldIc = identityCardService.getIdentityCardByBillId(id, null);
        Agent oldAgent = agentService.getAgentByExtraBillId(id, null);
        OpenBankInfo oldBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
        // 新认证项id置null,便于执行新增或者修改处理
        businessLicense.setId(null);
        orgCode.setId(null);
        taxregisterCert.setId(null);
        identityCard.setId(null);
        agent.setId(null);
        openBankInfo.setId(null);
        // 获取产品需要的附加信息项
        ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
        // 是否有营业执照信息,默认false没有
        boolean hasBl = false;
        if (null != extraMessage) {
            // //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
            if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
                if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
                    if (extraMessage.getEnterpriseItems().contains("2") && !webenterprise.getEnterpriseNature().equals(3)) {
                        // 事业单位不填写营业执照
                        hasBl = true;
                        businessLicense = businessService.saveBusinessExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, oldBl);
                    }
                    if (extraMessage.getEnterpriseItems().contains("3")) {
                        // 需要统一组织机构代码认证项,但是页面没有传递过来的时候,用老的
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            orgCode = orgCodeService.saveOrgCodeExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, oldOc);
                        }
                    }
                    if (extraMessage.getEnterpriseItems().contains("4")) {
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            // 保存税务登记证
                            if (// 事业单位不填写税务登记信息
                            !webenterprise.getEnterpriseNature().equals(3)) {
                                taxregisterCert = taxCertService.saveTaxCertExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, oldTc);
                            }
                        }
                    }
                }
            }
            // field string --fieldName agentItems
            if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
                agent = agentService.saveAgentExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), agent, ComNames.ITEM_STATUS_2, oldAgent);
            }
            // field string --fieldName bankItems
            if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
                openBankInfo = openBankInfoService.saveOpenBankInfoExtraBill(webenterprise.getId(), bill.getId(), webuserInfo.getId(), openBankInfo, ComNames.ITEM_STATUS_2, oldBankInfo);
            }
            // field string  --fieldName identityCardItems
            if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
                identityCard = identityCardService.saveIdentityCardExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, oldIc);
            }
        }
        retMap.put("retCode", 1);
        retMap.put("billId", bill.getId());
        bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
        extraBillService.updateByPrimaryKeySelective(bill);
        transactionManager.commit(status);
        // 更新session用户和企业信息
        webenterprise = enterpriseService.getEnterpriseById(webenterprise.getId());
        webuserInfo = userInfoService.getUserInfoById(webuserInfo.getId());
        session.setAttribute("webenterprise", webenterprise);
        session.setAttribute("webuserInfo", webuserInfo);
        UserLog userlog = new UserLog();
        userlog.setProject(bill.getProject());
        userlog.setType("审核拒绝重新提交");
        userlog.setInfo("提交成功,订单id:" + bill.getBillId());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        return retMap;
    } 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.setProject(bill.getProject());
        userlog.setType("审核拒绝重新提交");
        userlog.setInfo("url:reSubmitOrder,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    }
}
Also used : Agent(com.itrus.portal.db.Agent) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) 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) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) ExtraMessage(com.itrus.portal.db.ExtraMessage) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with UserLog

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

the class ClientWebController method getAllInfo.

/**
 * 接收客户端传递的项目,用户,企业信息,返回项目下面的的产品信息,如果传递了用户信息和企业信息,则查询是否存在了,不存在则注册.
 * @param projectName,项目名称
 * @param type,类型.web.app,客户端,目前是客户端,跟发布平台的值相同:{1:"web", 2:"客户端", 3:"app"}
 * @param isregister,是否已经注册或者需要更新附加信息的标识.0标识未注册或者需要更新信息,1标识已经注册且是最新信息.由ukey平台传递给客户端,客户端直接回传
 * @param keySn,key序列号
 * @param certSn,证书序列号
 * @param enterprise,企业信息
 * @param userInfo,用户信息
 * @param businessLicense,营业执照信息
 * @param orgCode,组织机构代码信息
 * @param taxregisterCert,税务登记信息
 * @param identityCard,法人信息
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping("/getProductInfo")
public String getAllInfo(@RequestParam(value = "projectName", required = true) String projectName, @RequestParam(value = "type", required = true) String type, @RequestParam(value = "isregister", required = true) Integer isregister, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, Model uiModel, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识处理失败,1标识成功
    retMap.put("retCode", 0);
    // projectName = "宁波CA";
    Project project = projectService.getProjectByName(projectName);
    HttpSession session = request.getSession();
    if (null == project) {
        uiModel.addAttribute("errorMsg", "项目名称:" + projectName + ", 在ixin运营服务平台中不存在,请联系系统管理员进行配置");
        return "client/errorpage";
    }
    session.setAttribute("webproject", project);
    session.setAttribute("isregister", isregister);
    try {
        List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectAndType(project.getId(), type);
        // 获取项目下所有的发布产品
        List<ExtraProduct> extraProducts = extraProductService.getproductByEPR(extraProductReleases);
        session.setAttribute("webExtraProducts", extraProducts);
        // 增值产品的类型
        Set<Object> productTypeSet = new LinkedHashSet<>();
        for (ExtraProduct ep : extraProducts) {
            productTypeSet.add(ep.getAppType());
        }
        session.setAttribute("webProductTypes", productTypeSet);
        // 若用户已经存在了,则标识用户
        UserInfo userInfo2 = null;
        if (null != userInfo && StringUtils.isNotBlank(userInfo.getmPhone())) {
            userInfo2 = userInfoService.getUserInfoByMphone(userInfo.getmPhone());
            if (null != userInfo2) {
                if (isNeedToUpdateUserInfo(userInfo, userInfo2)) {
                    userInfo.setId(userInfo2.getId());
                    userInfoService.updateByPrimaryKeySelective(userInfo);
                    userInfo2 = userInfoService.getUserInfoByMphone(userInfo.getmPhone());
                }
                userInfo = userInfo2;
                session.setAttribute("webuserInfo", userInfo2);
            } else {
                // 用户密码取手机号后六位
                String password = userInfo.getmPhone().substring(userInfo.getmPhone().length() - 6, userInfo.getmPhone().length());
                userInfo = userInfoService.registerUserInfoExtraProduct(userInfo, password, project.getId());
                session.setAttribute("webuserInfo", userInfo);
            }
        }
        // 企业信息
        Enterprise enterprise2 = null;
        if (null != enterprise && StringUtils.isNotBlank(enterprise.getEnterpriseName()) && StringUtils.isNotBlank(enterprise.getEnterpriseSn())) {
            enterprise2 = enterpriseService.getEntByName(enterprise.getEnterpriseName());
            if (null != enterprise2) {
                enterprise = enterprise2;
                if (StringUtils.isNotBlank(userInfo.getRegionCodes()) && (StringUtils.isBlank(enterprise.getProvince()) || StringUtils.isBlank(enterprise.getCity()))) {
                    // 组装企业信息中的企业省,市
                    String[] regegions = userInfo.getRegionCodes().split("@");
                    enterprise.setProvince(regegions[1]);
                    enterprise.setCity(regegions[2]);
                    enterpriseService.updateEnterprise(enterprise);
                }
            } else {
                if (StringUtils.isNotBlank(userInfo.getRegionCodes()) && (StringUtils.isBlank(enterprise.getProvince()) || StringUtils.isBlank(enterprise.getCity()))) {
                    // 组装企业信息中的企业省,市
                    String[] regegions = userInfo.getRegionCodes().split("@");
                    enterprise.setProvince(regegions[1]);
                    enterprise.setCity(regegions[2]);
                }
                enterpriseService.addEnterPrise(enterprise);
            }
            session.setAttribute("webenterprise", enterprise);
        }
        if (null != userInfo && null != userInfo.getId() && null != enterprise && null != enterprise.getId()) {
            // 若用户和企业之间没有关联关系,则关联起来
            UserinfoEnterprise userinfoEnterprise = UserInfoEnterpriseService.selectOne(enterprise.getId(), userInfo.getId());
            if (null == userinfoEnterprise) {
                UserInfoEnterpriseService.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
            }
            // 保存营业执照.覆盖服务器中最新的信息..如果有则覆盖,没有则新增
            if (isregister != 1 && null != businessLicense && StringUtils.isNotBlank(businessLicense.getEnterpriseName()) && StringUtils.isNotBlank(businessLicense.getImgFile()) && StringUtils.isNotBlank(businessLicense.getLicenseNo())) {
                // 查询数据库中是否存在该用户,该企业,未关联订单和增值订单.并且认证通过的营业执照信息,如果有的话,就对营业执照进行更新
                BusinessLicense oldBl = businessService.getBusinessLicensesNews2(enterprise.getId(), userInfo.getId());
                // 判断是否三证合一
                if (null == businessLicense.getBusinessType()) {
                    Integer businessType = 0;
                    if (businessLicense.getLicenseNo().length() == 18) {
                        businessType = 1;
                        // 填充企业纳税人识别号
                        if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                            enterprise.setNsrsbh(businessLicense.getLicenseNo());
                        }
                    }
                    businessLicense.setBusinessType(businessType);
                }
                businessLicense = businessService.saveBusinessExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, oldBl);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasBl()) {
                    enterprise.setHasBl(businessLicense.getId());
                }
            }
            if (isregister != 1 && null != orgCode && StringUtils.isNotBlank(orgCode.getEnterpriseName()) && StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getOrgCode())) {
                OrgCode oldoc = orgCodeService.getOrgCodesNews2(enterprise.getId(), userInfo.getId());
                orgCode = orgCodeService.saveOrgCodeExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, oldoc);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasOrgCode()) {
                    enterprise.setHasOrgCode(orgCode.getId());
                }
            }
            if (isregister != 1 && null != taxregisterCert && StringUtils.isNotBlank(taxregisterCert.getEnterpriseName()) && StringUtils.isNotBlank(taxregisterCert.getImgFile()) && StringUtils.isNotBlank(taxregisterCert.getCertNo())) {
                TaxRegisterCert oldTaxRegisterCert = taxCertService.getTaxRegisterCertsNews2(enterprise.getId(), userInfo.getId());
                taxregisterCert = taxCertService.saveTaxCertExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, oldTaxRegisterCert);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasTaxCert()) {
                    enterprise.setHasTaxCert(taxregisterCert.getId());
                }
                // 填充企业纳税人识别号
                if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                    enterprise.setNsrsbh(taxregisterCert.getCertNo());
                }
            }
            if (isregister != 1 && null != identityCard && StringUtils.isNotBlank(identityCard.getEnterpriseName()) && StringUtils.isNotBlank(identityCard.getName()) && StringUtils.isNotBlank(identityCard.getFrontImg())) {
                IdentityCard oldIdentityCard = identityCardService.getIdentityCardsNews2(enterprise.getId(), userInfo.getId());
                identityCard = identityCardService.saveIdentityCardExtraBillFromUkey(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, oldIdentityCard);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasIdCard()) {
                    enterprise.setHasIdCard(identityCard.getId());
                }
            }
            enterpriseService.updateEnterprise(enterprise);
        }
        // 如果用户是第一次来登录,并且用户没有通过认证,则不能认为用户认证通过了.(只有当本次输入是没有注册过,并且本次有通过认证的附加信息项,才能认为本次是注册成功了.)
        boolean hasOnePass = (null != businessLicense && null != businessLicense.getId()) || (null != orgCode && null != orgCode.getId()) || (null != taxregisterCert && null != taxregisterCert.getId()) || (null != identityCard && null != identityCard.getId());
        if (isregister != 1 && (null != userInfo.getId() && null != enterprise.getId()) && hasOnePass) {
            ixinUkeyRegrecordService.insertOrUpdate(keySn, certSn);
            // 判定用户是否已经在本平台注册成功.是否可以开始购买
            boolean isCanBuy = isCanBuy(enterprise, businessLicense, taxregisterCert, orgCode, identityCard);
            if (isCanBuy) {
                session.setAttribute("isregister", 1);
            }
        }
        UserLog userlog = new UserLog();
        userlog.setCreateTime(new Date());
        userlog.setHostId("未知");
        if (null == userInfo2) {
            userlog.setInfo("用户登录" + userInfo.getmPhone());
            userlog.setType("用户登录_增值产品");
        } else {
            userlog.setInfo("用户注册:" + userInfo.getmPhone());
            userlog.setType("用户注册_增值产品");
        }
        userlog.setProject(project.getId());
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    } catch (Exception e) {
        UserLog userlog = new UserLog();
        userlog.setCreateTime(new Date());
        userlog.setHostId("未知");
        userlog.setInfo("增值订单用户注册出现异常,异常信息:" + e.getMessage());
        userlog.setProject(project.getId());
        userlog.setType("用户登录_增值产品");
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    }
    return "client/yingyongzhanshi";
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) UserInfo(com.itrus.portal.db.UserInfo) IdentityCard(com.itrus.portal.db.IdentityCard) HttpSession(javax.servlet.http.HttpSession) UserLog(com.itrus.portal.db.UserLog) Date(java.util.Date) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with UserLog

use of com.itrus.portal.db.UserLog 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 5 with UserLog

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

the class ExtraBillWebController method delete.

// 删除未支付订单
@RequestMapping(value = "/bill/{id}.html", method = RequestMethod.PUT, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, HttpServletRequest request, Model uiModel) {
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    HttpSession session = request.getSession();
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == userInfo) {
        return "登录失效,请重新登录";
    }
    if (bill == null) {
        return "未找到要删除订单";
    } else {
        if (!bill.getUniqueId().equals(userInfo.getId())) {
            return "您无权操作改订单";
        }
        if (!bill.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_1)) {
            return "该订单不允许删除";
        }
        bill.setIsDelete(true);
        try {
            extraBillService.updateByPrimaryKeySelective(bill);
            UserLog userlog = new UserLog();
            userlog.setProject(userInfo.getProject());
            userlog.setType("删除增值订单");
            userlog.setInfo(userInfo.getmPhone() + "删除了订单" + bill.getBillId());
            userlog.setHostId("未知");
            userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return null;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserLog (com.itrus.portal.db.UserLog)23 UserInfo (com.itrus.portal.db.UserInfo)20 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 IOException (java.io.IOException)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 Enterprise (com.itrus.portal.db.Enterprise)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 HashMap (java.util.HashMap)15 HttpSession (javax.servlet.http.HttpSession)12 Bill (com.itrus.portal.db.Bill)9 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)9 TransactionStatus (org.springframework.transaction.TransactionStatus)8 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)8 ExtraProduct (com.itrus.portal.db.ExtraProduct)7 Product (com.itrus.portal.db.Product)7 BusinessLicense (com.itrus.portal.db.BusinessLicense)6 ExtraBill (com.itrus.portal.db.ExtraBill)6 IdentityCard (com.itrus.portal.db.IdentityCard)6 OrgCode (com.itrus.portal.db.OrgCode)6 Project (com.itrus.portal.db.Project)6