Search in sources :

Example 46 with UserInfoServiceException

use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.

the class DoUnlockKeyController method sendCodeByZSJS.

/**
 * 发送解锁授权码
 * @param mphone
 * @return
 */
@RequestMapping("/sendCodeByZSJS")
@ResponseBody
public Map<String, Object> sendCodeByZSJS(@RequestParam("mPhone") String mPhone, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    Project project = null;
    try {
        // 根据key序列号,获取证书
        ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
        if (null == projectKeyInfo) {
            retMap.put("retMsg", "无法识别该序列号:" + keySn + ", 请联系系统管理进行配置");
            return retMap;
        }
        project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        if (null == userInfo) {
            retMap.put("retMsg", "手机号对应的用户不存在,请检查手机号是否正确:" + mPhone);
            return retMap;
        }
        // ZSJS表示短信模版类型为‘证书解锁’。
        if (dynamicCodeService.sendCodeZSJS(mPhone, project.getId(), "ZSJS")) {
            retMap.put("retCode", 1);
            return retMap;
        }
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        retMap.put("retMsg", "发送证书解锁短信出现异常,请联系系统管理员");
        UserLog userLog = new UserLog();
        userLog.setCreateTime(new Date());
        userLog.setHostId("未知");
        userLog.setInfo(e.getMessage());
        userLog.setIp("未知");
        userLog.setProject(project.getId());
        userLog.setSn(null);
        userLog.setType("发送证书解锁短信");
        return retMap;
    }
    retMap.put("retMsg", "发送证书解锁短信失败,请联系系统管理员");
    return retMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 47 with UserInfoServiceException

use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.

the class UserInfoWebController method verifyCode.

/**
 * 验证动态码/注册处理
 *
 * @param mPhone
 * @param code
 * @param password
 * @param projectId
 * @param request
 * @return
 */
@RequestMapping(value = "/verifyCode")
@ResponseBody
public Map<String, Object> verifyCode(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "password", required = true) String password, @RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识处理失败,1标识成功\
    retMap.put("retCode", 0);
    try {
        // 验证动态码,
        if (!dynamicCodeService.verifyCode(mPhone, code)) {
            // 验证码不通过
            retMap.put("retMsg", "动态码验证失败");
            return retMap;
        } else {
            // 注册用户
            UserInfo userInfo = userInfoService.registerUserInfo(mPhone, password, projectId);
            // 记录系统日志
            String info = mPhone + "注册成功";
            LogUtil.syslog(sqlSession, "注册用户", info);
            HttpSession session = request.getSession();
            // 验证码验证通过
            session.setAttribute("webverifyCodeStatus", true);
            session.setAttribute("webmPhone", mPhone);
            session.setAttribute("webuserInfo", userInfo);
            session.setAttribute("webproductId", productId);
            session.setAttribute("webprojectId", projectId);
            // TODO 20170328 begin 临时检查是否出现了返回的信息中,是否出现了项目id与产品中的id不一致的情况
            Long check_project_id = (Long) session.getAttribute("webprojectId");
            Long check_product_id = (Long) session.getAttribute("webproductId");
            Product check_product = productService.getProduct(check_product_id);
            if (null != check_product && !check_product.getProject().equals(check_project_id)) {
                LogUtil.syslog(sqlSession, "/verifyCode出现产品与项目不一致", "session中的项目:" + check_project_id + ", 产品中的项目" + check_product.getProject() + ",session中的产品:" + check_product_id);
            }
            // TODO 20170328 END
            retMap.put("retCode", 1);
        }
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        retMap.put("retMsg", "出现未知异常,请联系管理员处理");
        String info = mPhone + "注册失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "注册用户", info);
        return retMap;
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ParseException(java.text.ParseException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) BiffException(jxl.read.biff.BiffException) TerminalServiceException(com.itrus.portal.exception.TerminalServiceException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 48 with UserInfoServiceException

use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.

the class UserInfoWebController method genEmailValidLink.

/**
 * 生成链接
 *
 * @param email
 * @param userInfo
 * @return
 * @throws UserInfoServiceException
 * @throws UnsupportedEncodingException
 */
private String genEmailValidLink(String email, UserInfo userInfo) throws UserInfoServiceException, UnsupportedEncodingException {
    SysConfig sysConfig = cacheCustomer.getSysConfigByType(SystemConfigService.TS_URL);
    if (sysConfig == null || StringUtils.isBlank(sysConfig.getConfig()))
        throw new UserInfoServiceException("缺少终端后台地址配置信息");
    Long sendTime = new Date().getTime();
    String hmacVal = getHmacs(userInfo.getUniqueId(), email, sendTime.toString(), VERIFY_MAIL);
    hmacVal = URLEncoder.encode(hmacVal, "UTF-8");
    return sysConfig.getConfig() + "/userInfoWeb/validateEmail?syuid=" + userInfo.getUniqueId() + "&uemail=" + email + "&sendTime=" + sendTime + "&actionType=" + VERIFY_MAIL + "&hmac=" + hmacVal;
}
Also used : UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 49 with UserInfoServiceException

use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.

the class UserInfoWebController method trustMphone.

/**
 * 手机号验证(发送验证码)
 *
 * @param request
 * @return
 */
@RequestMapping("/trustMphone")
@ResponseBody
public Map<String, Object> trustMphone(@RequestParam(value = "mPhone", required = true) String mPhone, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
    UserInfo currentUserInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == verifyCodeStatus || !verifyCodeStatus || null == currentUserInfo) {
        // 登录状态失效,跳转到登录页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    if (StringUtils.isBlank(mPhone)) {
        retMap.put("retMsg", "手机号不能为空");
        return retMap;
    }
    if (mPhone.equals(currentUserInfo.getmPhone())) {
        retMap.put("retMsg", "请输入要更改的手机号");
        return retMap;
    }
    // 判断手机号是否已经注册过
    Integer count = userInfoService.countUserInfo(mPhone, currentUserInfo.getProject());
    if (count > 0) {
        retMap.put("retMsg", "该手机号已经绑定了用户,请重新输入手机号");
        return retMap;
    }
    try {
        dynamicCodeService.sendCode(mPhone, currentUserInfo.getProject(), // DTM表示短信模版类型为‘动态码’。
        "DTM");
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 50 with UserInfoServiceException

use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.

the class UserInfoWebController method register.

/**
 * 提交购买产品、企业、用户、认证信息
 *
 * @param projectId
 * @param productId
 * @param productNum
 * @param enterprise
 * @param userInfo
 * @param uid
 * @param delivery
 * @param invoice
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @return
 */
@RequestMapping("/register")
@ResponseBody
public synchronized Map<String, Object> register(@RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productId1", required = false) Long productId1, @RequestParam(value = "productId2", required = false) Long productId2, @RequestParam(value = "productId3", required = false) Long productId3, @RequestParam(value = "productNum", required = true) Integer productNum, @RequestParam(value = "productNum1", required = false) Integer productNum1, @RequestParam(value = "productNum2", required = false) Integer productNum2, @RequestParam(value = "productNum3", required = false) Integer productNum3, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @RequestParam(value = "uid", required = false) String uid, @ModelAttribute("delivery") Delivery delivery, @ModelAttribute("invoice") Invoice invoice, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, @RequestParam(value = "editBillId", required = false) Long editBillId, @RequestParam(value = "oldUserCertId", required = false) Long oldUserCertId, @RequestParam(value = "productSpecId", required = false) Long productSpecId, @RequestParam(value = "productSpecId1", required = false) Long productSpecId1, @RequestParam(value = "productSpecId2", required = false) Long productSpecId2, @RequestParam(value = "productSpecId3", required = false) Long productSpecId3, @RequestParam(value = "price1", required = false) double price1, @RequestParam(value = "price2", required = false) double price2, @RequestParam(value = "price3", required = false) double price3, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    /*Logger log = Logger.getLogger(UserInfoWebController.class);
		log.info("1");*/
    HttpSession session = request.getSession();
    Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == verifyCodeStatus || !verifyCodeStatus || null == webuserInfo) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    if (!verifyParams(enterprise, userInfo) || productNum.equals(0)) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    // 产品
    // log.info("2");
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
    if (null == product) {
        // 产品不存在
        retMap.put("retMsg", "您购买的产品不存在");
        return retMap;
    }
    // log.info("3");
    // 获取组合产品
    Product product1 = null;
    Product product2 = null;
    Product product3 = null;
    ProductSpec productSpec1 = null;
    ProductSpec productSpec2 = null;
    ProductSpec productSpec3 = null;
    // log.info("4");
    if (null != product.getIsCombined() && product.getIsCombined() == 1) {
        if (null != productId1 && 0 != productId1) {
            product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId1);
        }
        if (null != productId2 && 0 != productId2) {
            product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId2);
        }
        if (null != productId3 && 0 != productId3) {
            product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId3);
        }
        // 获取购买的产品规格
        if (null != productSpecId1 && 0 != productSpecId1) {
            productSpec1 = productSpecService.getProductSpec(productSpecId1);
            if (null == productSpec1 || !productSpec1.getIsValidity()) {
                retMap.put("retMsg", "该规格不存在或已下架,无法购买");
                return retMap;
            }
        }
        if (null != productSpecId2 && 0 != productSpecId2) {
            productSpec2 = productSpecService.getProductSpec(productSpecId2);
            if (null == productSpec2 || !productSpec2.getIsValidity()) {
                retMap.put("retMsg", "该规格不存在或已下架,无法购买");
                return retMap;
            }
        }
        if (null != productSpecId3 && 0 != productSpecId3) {
            productSpec3 = productSpecService.getProductSpec(productSpecId3);
            if (null == productSpec3 || !productSpec3.getIsValidity()) {
                retMap.put("retMsg", "该规格不存在或已下架,无法购买");
                return retMap;
            }
        }
    }
    // log.info("5");
    // 获取购买的产品规格
    ProductSpec productSpec = null;
    if (null != productSpecId && 0 != productSpecId) {
        productSpec = productSpecService.getProductSpec(productSpecId);
        if (null == productSpec || !productSpec.getIsValidity()) {
            retMap.put("retMsg", "该规格不存在或已下架,无法购买");
            return retMap;
        }
    }
    // 判断购买的产品是否为更新产品,假如是更新产品,且没有携带旧证书信息,直接返回错误信息给用户
    if (ComNames.TYPE_RENEW.equals(product.getType())) {
        if (null == oldUserCertId || 0 == oldUserCertId) {
            retMap.put("retMsg", "key中未包含旧证书信息,请检查插入的key是否正确");
            return retMap;
        }
    }
    // log.info("7");
    // 获取产品的认证等级需要认证的项
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    // log.info("8");
    try {
        /**
         * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
         */
        Long[] items = StringTools.getLong(certification.getCertItems());
        // 保存企业信息
        enterprise = enterpriseService.saveOrUpdateEnterprise(enterprise);
        String oldEnterpriseSn = enterprise.getEnterpriseSn();
        // 保存代理人信息
        userInfo.setId(webuserInfo.getId());
        userInfo.setUniqueId(webuserInfo.getUniqueId());
        userInfo = userInfoService.updateUserInfo(userInfo);
        // 添加企业-代理人关联关系
        userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
        // 保存订单配送信息
        if (null != delivery.getCourier() && -1 != delivery.getCourier()) {
            delivery = deliveryService.saveDelivery(userInfo.getId(), userInfo.getRealName(), userInfo.getmPhone(), delivery);
        } else {
            delivery = new Delivery();
        }
        // 保存发票信息(填写了发票信息才保存,未填写则不保存)
        if (StringUtils.isNotBlank(invoice.getName()) && null != invoice.getReceipt())
            invoice = invoiceService.saveInvoice(userInfo.getId(), invoice);
        if (StringUtils.isNotBlank(einvoice.getName()) && null != einvoice.geteReiceipt())
            einvoice = EinvoiceService.saveEInvoice(userInfo.getId(), einvoice);
        // 生成订单
        double billSum = 0;
        // 标识是否需要新增优惠记录
        boolean needToInsertPre = false;
        // 本次优惠价格购买的数量
        Integer preferentialNum = 0;
        // 有产品规格,则根据产品规格计算订单总价
        if (null != productSpec) {
            /*
				进行价格优惠:先判断购买数量是否大于可优惠数量,如果大于则用公式:
				优惠价格*(优惠数量-已经优惠的数量)+原价*(购买数量-(优惠数量-已经优惠的数量))
				如果不大于可优惠数量,则用公式
				优惠价格*(优惠数量-已经优惠的数量)
				 * */
            if (null != productSpec.getProductField1() && null != product.getPreferentialNum() && product.getPreferentialNum() > 0) {
                // 计算订单总价以及是否需要记录优惠记录
                Map<String, Object> map = preferentialPrice(product, productSpec, enterprise, userInfo, productNum);
                billSum = (Double) map.get("billSum");
                needToInsertPre = (boolean) map.get("needToInsertPre");
                preferentialNum = (Integer) map.get("preferentialNum");
            } else {
                billSum = productSpec.getPrice() * productNum;
            }
        } else {
            billSum = productNum * product.getPrice();
        }
        // 组合产品价格
        if (null != product.getIsCombined() && product.getIsCombined() == 1) {
            double sum1 = 0;
            double sum2 = 0;
            double sum3 = 0;
            if (null != product1) {
                sum1 = productNum1 * price1;
            }
            if (null != product2) {
                sum2 = productNum2 * price2;
            }
            if (null != product3) {
                sum3 = productNum3 * price3;
            }
            billSum = sum1 + sum2 + sum3;
        }
        // TODO 20170302临时解决一下项目id不对的问题.
        if (null != product.getProject() && !product.getProject().equals(projectId)) {
            LogUtil.syslog(sqlSession, "产品与项目不一致", "产品中的项目id:" + product.getProject() + ", 页面回传的项目id:" + projectId + ", 用户电话:" + userInfo.getmPhone());
            projectId = product.getProject();
        }
        Bill bill = null;
        if (null != product.getIsCombined() && product.getIsCombined() == 1) {
            bill = billService.saveBillCombined(userInfo.getId(), enterprise.getId(), product.getId(), null == product1 ? null : productId1, null == product2 ? null : productId2, null == product3 ? null : productId3, null == productSpec1 ? null : productSpecId1, null == productSpec2 ? null : productSpecId2, null == productSpec3 ? null : productSpecId3, null == delivery.getId() ? null : delivery.getId(), null == invoice.getId() ? null : invoice.getId(), null == einvoice.getId() ? null : einvoice.getId(), (null == product1 || null == product1.getCert()) ? null : uid1, (null == product2 || null == product2.getCert()) ? null : uid2, (null == product3 || null == product3.getCert()) ? null : uid3, projectId, productNum1, productNum2, productNum3, price1, price2, price3, billSum, userInfo.getId(), ComNames.BILL_STATUS_1);
        } else {
            bill = billService.saveBill(userInfo.getId(), enterprise.getId(), product.getId(), null == delivery.getId() ? null : delivery.getId(), null == invoice.getId() ? null : invoice.getId(), null == einvoice.getId() ? null : einvoice.getId(), uid, projectId, productNum, billSum, userInfo.getId(), ComNames.BILL_STATUS_1);
            // 是否需要记录优惠记录
            if (needToInsertPre) {
                preferentialRecordService.savePreferentialRecord(bill.getId(), userInfo.getId(), product.getId(), productSpec.getId(), enterprise.getId(), productSpec.getProductField1(), preferentialNum, productSpec.getPrice());
            }
            // 设置购买的产品规格id
            if (null != productSpec)
                bill.setProductSpec(productSpec.getId());
        }
        // 是否传递了旧证书id
        if (null != oldUserCertId && oldUserCertId > 0) {
            bill.setOldUserCert(oldUserCertId);
            UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", oldUserCertId);
            if (null == userCert) {
                retMap.put("retMsg", "您的证书无需购买更新产品");
                return retMap;
            }
            // 设置证书状态为待更新
            userCert.setCertStatus(ComNames.CERT_STATUS_2);
            sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
            sqlSession.flushStatements();
        }
        bill.setBillId(UniqueIDUtils.genBilUID(bill));
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        sqlSession.flushStatements();
        // 是否有营业执照信息,默认false没有
        boolean hasBl = false;
        for (Long item : items) {
            if (ComNames.BUSINESS_ITEM.equals(item) && !enterprise.getEnterpriseNature().equals(3)) {
                // 事业单位不填写营业执照
                hasBl = true;
                // 设置企业唯一标识
                if (enterprise.getEnterpriseNature().equals(1) || enterprise.getEnterpriseNature().equals(2)) {
                    enterprise.setEnterpriseSn(businessLicense.getLicenseNo());
                }
                // TODO 验证插入重复数据问题item是否重复了:
                System.out.println("UserInfoWebController-insert into businessLicense:item=" + item + ",billId=" + bill.getBillId());
                // 保存营业执照
                businessLicense = businessService.saveBusiness(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), businessLicense, null != businessLicense.getId() ? 2 : 1);
            } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
                if (hasBl && businessLicense.getBusinessType().equals(1))
                    // 五证合一企业不用提交组织机构代码、税务登记信息
                    continue;
                if (enterprise.getEnterpriseNature().equals(3)) {
                    // 类型为政府机关/事业单位:企业标识为组织机构代码
                    enterprise.setEnterpriseSn(orgCode.getOrgCode());
                }
                // 保存组织机构代码
                orgCode = orgCodeService.saveOrgCode(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), orgCode, null != orgCode.getId() ? 2 : 1);
            } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
                if (hasBl && businessLicense.getBusinessType().equals(1))
                    // 五证合一企业不用提交组织机构代码、税务登记信息
                    continue;
                // 保存税务登记证
                if (enterprise.getEnterpriseNature().equals(3))
                    // 事业单位不填写税务登记信息
                    continue;
                taxregisterCert = taxCertService.saveTaxCert(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), taxregisterCert, null != taxregisterCert.getId() ? 2 : 1);
            } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
                // 保存法定代表人
                identityCard = identityCardService.saveIdentityCard(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), identityCard, null != identityCard.getId() ? 2 : 1);
            } else if (ComNames.AGENT_ITEM.equals(item)) {
                // 保存代理人
                agent = agentService.saveAgent(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), agent, null != agent.getId() ? 2 : 1);
            } else if (ComNames.PROXY_ITEM.equals(item)) {
                // TODO 验证插入重复数据问题item是否重复了:
                System.out.println("UserInfoWebController-insert into proxy:item=" + item + ",billId=" + bill.getBillId());
                Project project = billService.getProjectByBillId(bill.getId());
                // 保存授权书
                proxy = proxyService.saveProxy(enterprise.getId(), userInfo.getUniqueId(), bill.getId(), userInfo.getId(), proxy, project);
            }
        }
        // 更新企业唯一标识
        enterprise = enterpriseService.updateEnterpriseSn(enterprise);
        transactionManager.commit(status);
        // 复制修改前的图片到新的文件夹中(旧目录为空不会复制)
        if (!oldEnterpriseSn.equals(enterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + enterprise.getEnterpriseSn());
        }
        // 判断是否存在填写中的订单
        if (null != editBillId) {
            EditBill editBill = editBillService.getEditBillById(editBillId);
            editBillService.delectEditInfo(editBill, webuserInfo.getUniqueId());
        }
        // 订单信息放入session
        session.setAttribute("webbill", bill);
        retMap.put("billId", bill.getId());
        session.setAttribute("webuserInfo", userInfo);
        session.setAttribute("webenterprise", enterprise);
        session.setAttribute("webcertification", certification.getRank());
        retMap.put("retCode", 1);
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(projectId);
        userlog.setType("购买产品");
        userlog.setInfo(userInfo.getmPhone() + "购买了" + product.getName());
        userlog.setHostId("未知");
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.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(projectId);
        userlog.setType("购买产品");
        userlog.setInfo("url:register,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.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) TransactionStatus(org.springframework.transaction.TransactionStatus) HttpSession(javax.servlet.http.HttpSession) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ParseException(java.text.ParseException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) BiffException(jxl.read.biff.BiffException) TerminalServiceException(com.itrus.portal.exception.TerminalServiceException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)73 Date (java.util.Date)39 HashMap (java.util.HashMap)31 File (java.io.File)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)22 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)21 Enterprise (com.itrus.portal.db.Enterprise)19 IOException (java.io.IOException)19 UserInfo (com.itrus.portal.db.UserInfo)17 TransactionStatus (org.springframework.transaction.TransactionStatus)14 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)14 SigningServerException (com.itrus.cryptorole.SigningServerException)11 IdentityCard (com.itrus.portal.db.IdentityCard)11 CertificateException (java.security.cert.CertificateException)11 BusinessLicense (com.itrus.portal.db.BusinessLicense)10 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)10 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)10 Agent (com.itrus.portal.db.Agent)9 OrgCode (com.itrus.portal.db.OrgCode)9 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)9