use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class PersonCertificationServiceImpl method registerPersonInfo.
/**
* 注册用户(第一步)
*
* @param mPhone
* @param password
* @return
* @throws UserInfoServiceException
*/
public synchronized PersonInfo registerPersonInfo(String mPhone, String password) throws UserInfoServiceException {
PersonInfo personInfo0 = getPersonInfoByMphone(mPhone);
if (null != personInfo0)
throw new UserInfoServiceException("该手机号已经注册过用户,请重新登录");
PersonInfo personInfo = new PersonInfo();
personInfo.setCreateTime(new Date());
personInfo.setModifyTime(new Date());
personInfo.setProject(sysconfigService.getPersonProject());
ProductExample ex1 = new ProductExample();
ProductExample.Criteria crt1 = ex1.or();
crt1.andProjectEqualTo(personInfo.getProject());
List<Product> products = sqlSession.selectList("com.itrus.portal.db.ProductMapper.selectByExample", ex1);
String auth = "";
for (int i = 0; i < products.size(); i++) {
auth = auth + products.get(i).getAuthentication().toString() + ",";
}
auth = auth.substring(0, auth.length() - 1);
personInfo.setAuthentication(auth);
personInfo.setmPhone(mPhone);
personInfo.setPassword(passwordEncoder.encodePassword(password, ComNames.SALT));
// 设置用户唯一标识
personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(sqlSession));
personInfo.setTrustMPhone(true);
sqlSession.insert("com.itrus.portal.db.PersonInfoMapper.insert", personInfo);
sqlSession.flushStatements();
// 更新用户唯一标识
personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(personInfo));
sqlSession.update("com.itrus.portal.db.PersonInfoMapper.updateByPrimaryKey", personInfo);
return personInfo;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class PersonCertificationServiceImpl method savePersonInfo.
/**
* 新增用户
*
* @param personInfo
* @return
* @throws UserInfoServiceException
*/
public PersonInfo savePersonInfo(PersonInfo personInfo) throws UserInfoServiceException {
PersonInfo personInfo0 = getPersonInfoByMphone(personInfo.getmPhone());
if (null != personInfo0)
throw new UserInfoServiceException("该手机号已经注册过用户,请重新登录");
personInfo.setCreateTime(new Date());
personInfo.setModifyTime(new Date());
// 设置用户唯一标识
personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(sqlSession));
personInfo.setTrustMPhone(true);
sqlSession.insert("com.itrus.portal.db.PersonInfoMapper.insert", personInfo);
sqlSession.flushStatements();
return personInfo;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class MakeCerServiceImpl method sendReNewInfo.
/**
* 向用户发送待更新证书短信通知
*
* @param mPhone
* 手机
* @param project
* 项目id
* @param smsType
* 短信模版类型(ZSGX:证书更新)
*
* @throws UserInfoServiceException
*/
public void sendReNewInfo(Bill bill, String mPhone, Long project, String smsType, String keySn, String enterpriseName, Date endTime, String productName) throws UserInfoServiceException {
// 发送动态码,获取发送的短信内容
MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(project, smsType);
if (null == messageTemplate) {
throw new UserInfoServiceException("未找到对应的短信模版,请联系管理员配置");
}
String content = messageTemplate.getMessageContent();
String end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endTime);
// 进行替换
content = content.replaceAll("enterpriseName", enterpriseName);
content = content.replaceAll("keySn", keySn);
content = content.replaceAll("endTime", end);
content = content.replaceAll("productName", productName);
// TODO 接口欠费,成功应该改回true,但是现在是欠费的,所以是false,为了通过,先改成这样,正确的应该是:!smsSendService.sendReNewInfoSms(mPhone, content, "更新证书", project)
if (!smsSendService.sendReNewInfoSms(mPhone, content, "更新证书", project)) {
// 发送失败
throw new UserInfoServiceException("更新证书通知送失败,请联系管理员查看原因");
} else {
// 发送成功: 记录信息
bill.setRenewSms(true);
bill.setRenewSendTime(new Date());
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
}
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class GetRaInfoTask method getRaInfoByCertSerialNumber.
/**
* 根据证书序列号,从本地数据库或者远程数据库获取证书对应的RA信息
*
* @param CertSerialNumber
* :证书序列号
* @return
* @throws UserInfoServiceException
*/
public String getRaInfoByCertSerialNumber(String CertSerialNumber) throws UserInfoServiceException {
// 从本地数据库中查询是否存在该证书对应的ra哈希值
RaInfoExample raInfoExample = new RaInfoExample();
RaInfoExample.Criteria criteria = raInfoExample.or();
criteria.andCertSerialnumberEqualTo(CertSerialNumber);
RaInfo raInfo = sqlSession.selectOne("com.itrus.portal.db.RaInfoMapper.selectByExample", raInfoExample);
Map<String, Object> retmMap = new HashMap<String, Object>();
if (null != raInfo && !raInfo.getAccountHash().equals("")) {
return raInfo.getAccountHash();
} else {
// 判断系统是否配置了RA信息同步地址
SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoUrl");
if (null == sysConfig) {
throw new UserInfoServiceException("未配置RA信息同步地址");
}
// http://localhost:8080/raInfo/getRa.jsp
String url = sysConfig.getConfig() + "/getRa.jsp";
// 从远程数据库中获取证书对应的RA哈希值
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("certSn", CertSerialNumber);
try {
String resStr = restTemplate.postForObject(url, map, String.class);
Map<String, Object> remap = jsonTool.readValue(resStr, Map.class);
Integer status = (Integer) remap.get("status");
if (0 == status) {
String type = "查询证书RA信息出错";
String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + (String) remap.get("message");
LogUtil.syslog(sqlSession, type, info);
throw new UserInfoServiceException("查询RA信息出错,请联系管理员");
} else {
raInfo = insertOneRaInfoIntoDB(remap, raInfo);
retmMap.put("accountHash", raInfo.getAccountHash());
String type = "查询证书归属的RA信息成功";
String info = "查询证书:" + CertSerialNumber + "的RA信息成功,归属RA:" + raInfo.getAccountHash();
LogUtil.syslog(sqlSession, type, info);
return raInfo.getAccountHash();
}
} catch (Exception e) {
e.printStackTrace();
String type = "查询证书RA信息出错";
String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
throw new UserInfoServiceException("查询证书RA信息出错,请联系管理员");
}
}
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class SendReNewInfoTask method sendReNewInfo.
/**
* 心跳更新。启动时执行一次,之后每隔24小时执行一次
*/
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void sendReNewInfo() {
// 筛选出所有是待更新的,而且未发送短信的订单
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
// 订单状态是12的时候,表示是待更新的订单
criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_12);
// 订单的短信发送时间是Null的时候,表示未发送过通知短信
criteria.andRenewSendTimeIsNull();
criteria.andIsDeleteEqualTo(false);
// billExample.setLimit(100);
List<Bill> bills = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
if (null == bills || bills.size() < 1) {
return;
}
String billSn = "";
String mPhone = "";
try {
// 向每个订单发送短信通知
for (int i = 0; i < bills.size(); i++) {
billSn = bills.get(i).getBillId();
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bills.get(i).getUniqueId());
mPhone = userInfo.getmPhone();
UserCertExample userCertExample = new UserCertExample();
UserCertExample.Criteria ucriteria = userCertExample.or();
ucriteria.andIdEqualTo(bills.get(i).getOldUserCert());
UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userCertExample);
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bills.get(i).getEnterprise());
Long projectId = bills.get(i).getProject();
String keySn = "";
if (null == userCert.getKeySn()) {
keySn = "该证书未绑定key";
} else {
keySn = userCert.getKeySn();
}
String enterpriseName = enterprise.getEnterpriseName();
Date endTime = userCert.getCertEndTime();
// 获取订单对应的产品信息
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bills.get(i).getProduct());
String productName = product.getName();
try {
makeCerServiceImpl.sendReNewInfo(bills.get(i), mPhone, projectId, "ZSGX", keySn, enterpriseName, endTime, productName);
} catch (UserInfoServiceException e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
} catch (Exception e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
}
}
} catch (Exception e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + billSn + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
}
}
Aggregations