use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class BindCertWebController method loginCertSendCode.
/**
* 证书登陆绑定手机,发送验证码 szy 2016年8月18日 下午3:54:40
*
* @param mPhone
* 手机号
* @param projectId
* 项目id
* @param productId
* 产品id
* @param code
* 短信验证码
* @param certBase64
* 证书信息
* @return Map<String,Object> retCode -1失败,0成功,1该证书已经绑定过用户 hasUserInfo -1
* 没有用户, 0 有用户
*/
@RequestMapping("/loginCertSendCode")
@ResponseBody
public Map<String, Object> loginCertSendCode(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "productId", required = false) Long productId, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam(value = "enterpriseName", required = true) String enterpriseName, HttpSession session) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 默认发送失败
retMap.put("retCode", -1);
// 查询使用手机号mPhone注册的用户
UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
// -1表示没有用户
retMap.put("hasUserInfo", -1);
try {
if (null != userInfo) {
// 0表示有用户
retMap.put("hasUserInfo", 0);
// false 是未关联, true已经关联
if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
retMap.put("retCode", 1);
retMap.put("retMsg", "该证书已绑定过用户");
return retMap;
}
}
if (null != projectId && null != productId) {
session.setAttribute("webnoProduct", false);
} else {
Product product = getProjectByCertBase64(certBase64);
projectId = product.getProject();
productId = product.getId();
session.setAttribute("webnoProduct", true);
}
// 发送验证码
// ZSBD表示短信模版类型为‘绑定证书’。
dynamicCodeService.sendCode(mPhone, projectId, "ZSBD");
// 发送成功
retMap.put("retCode", 0);
// 返回企業信息
Enterprise et = enterpriseService.getEntByName(enterpriseName);
retMap.put("enterprise", et);
// 将productId, projectId放入session
session.setAttribute("webproductId", productId);
session.setAttribute("webprojectId", projectId);
// session.setAttribute("certBase64", certBase64);
retMap.put("productId", productId);
retMap.put("projectId", projectId);
} catch (CertificateException e) {
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (SigningServerException e) {
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (UserInfoServiceException e) {
retMap.put("retMsg", e.getMessage());
return retMap;
}
return retMap;
}
use of com.itrus.portal.exception.UserInfoServiceException 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;
}
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class UserFromClientLoginController method loginCertBind.
/**
* 证书绑定.
* retCode.0为失败,弹出错误信息.1为成功,跳转首页
* @param has_userInfo
* @param has_enterpriseInfo
* @param certSn
* @param keySn
* @param mPhone
* @param password
* @param code
* @param certBase64
* @param enterprise
* @param session
* @return
*/
@RequestMapping("/loginCertBind")
@ResponseBody
public Map<String, Object> loginCertBind(@RequestParam(value = "has_userInfo", required = true) Integer has_userInfo, @RequestParam(value = "has_enterpriseInfo", required = true) Integer has_enterpriseInfo, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "certBase64", required = true) String certBase64, @ModelAttribute("enterprise") Enterprise enterprise, HttpSession session) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 错误
retMap.put("retCode", 0);
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(def);
try {
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
retMap.put("retMsg", "无法识别Key序列号:" + keySn + ",所属的项目,请联系系统管理员配置");
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
// 验证动态码,
if (!dynamicCodeService.verifyCode(mPhone, code)) {
retMap.put("retMsg", "动态码验证失败");
return retMap;
}
UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
if (null != has_userInfo && has_userInfo.equals(0)) {
// 绑定用户和证书
if (null == userInfo) {
if (StringUtils.isBlank(password)) {
retMap.put("retMsg", "请先设置登录口令");
return retMap;
}
if (project != null) {
// 先自动创建用户
userInfo = userInfoService.registerUserInfo(mPhone, password, project.getId());
// 记录系统日志
String info = mPhone + "注册成功";
LogUtil.syslog(sqlSession, "注册用户", info);
}
}
}
if (null != has_enterpriseInfo && has_enterpriseInfo.equals(0)) {
// 没有企业,则新建企业信息
if (null == enterprise || StringUtils.isBlank(enterprise.getEnterpriseSn()) || StringUtils.isBlank(enterprise.getEnterpriseName()) || null == enterprise.getEnterpriseNature() || null == enterprise.getOrgIndustry()) {
retMap.put("retMsg", "您提交的企业信息不完整");
return retMap;
}
// 校验企业信息
enterpriseValidator.validator(enterprise);
enterprise = enterpriseService.addEnterPrise(enterprise);
}
if ((null == enterprise || null == enterprise.getId()) && null != has_enterpriseInfo && has_enterpriseInfo.equals(1)) {
enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
}
// 添加企业-代理人关联关系
UserinfoEnterprise userinfoEnterprise = userInfoEnterpriseServiceImpl.selectOne(enterprise.getId(), userInfo.getId());
if (null == userinfoEnterprise) {
userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
}
// 获取证书
UserCert userCert = userCertService.getUserCert(certBase64);
// 判断是否已和证书绑定
if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
retMap.put("retMsg", "该证书已绑定过用户");
return retMap;
}
// key序列号
if (StringUtils.isNotBlank(keySn)) {
userCert.setKeySn(keySn);
}
// 绑定证书与用户关系
userCert.setUserinfo(userInfo.getId());
userCert.setEnterprise(enterprise.getId());
sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
session.setAttribute(ComNames.WEB_USER_INFO, userInfo);
session.setAttribute(ComNames.WEB_ENTERPRISE, enterprise);
session.setAttribute(ComNames.WEB_VERIFY_CODE_STATUS, true);
transactionManager.commit(status);
// 返回绑定成功
retMap.put("retCode", 1);
} catch (CertificateException e) {
if (!status.isCompleted())
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (UserInfoServiceException e) {
if (!status.isCompleted())
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (SigningServerException e) {
if (!status.isCompleted())
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (Exception e) {
if (!status.isCompleted())
transactionManager.rollback(status);
retMap.put("retMsg", "服务端出现未知异常,请联系管理员");
String info = mPhone + "绑定证书失败,原因:" + e.getMessage();
LogUtil.syslog(sqlSession, "绑定证书", info);
return retMap;
} finally {
if (!status.isCompleted())
transactionManager.rollback(status);
}
return retMap;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class PersonCertificationController method verifyCode.
/**
* 验证动态码/注册处理
*
* @param mPhone
* @param code
* @param password
* @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, 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 {
// 注册用户
PersonInfo personInfo = personCertificationService.registerPersonInfo(mPhone, password);
// 记录系统日志
String info = mPhone + "个人用户注册成功";
LogUtil.syslog(sqlSession, "注册个人用户", info);
HttpSession session = request.getSession();
// 验证码验证通过
session.setAttribute("webverifyCodeStatus", true);
session.setAttribute("webmPhone", mPhone);
session.setAttribute("webuserInfo", personInfo);
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;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class PersonCertificationController 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 = personCertificationService.countPersonInfo(mPhone);
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;
}
Aggregations