use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class UserInfoServiceImpl method saveUserInfo.
/**
* 新增用户
*
* @param userInfo
* @return
* @throws UserInfoServiceException
*/
public UserInfo saveUserInfo(UserInfo userInfo) throws UserInfoServiceException {
UserInfo userInfo0 = getUserInfoByMphone(userInfo.getmPhone());
if (null != userInfo0)
throw new UserInfoServiceException("该手机号已经注册过用户,请重新登录");
userInfo.setCreateTime(new Date());
userInfo.setLastModify(new Date());
// 设置用户唯一标识
userInfo.setUniqueId(UniqueIDUtils.genUserInfoUID(sqlSession));
userInfo.setTrustMPhone(true);
userInfo.setTrustEmail(false);
sqlSession.insert("com.itrus.portal.db.UserInfoMapper.insert", userInfo);
sqlSession.flushStatements();
return userInfo;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class EnterpriseServiceImpl method updateEnterpriseSn.
/**
* 更新企业唯一标识
*
* @param enterprise
* @return
* @throws UserInfoServiceException
*/
public Enterprise updateEnterpriseSn(Enterprise enterprise) throws UserInfoServiceException {
// 根据企业名称查找企业
EnterpriseExample example = new EnterpriseExample();
EnterpriseExample.Criteria criteria = example.or();
criteria.andEnterpriseSnEqualTo(enterprise.getEnterpriseSn());
Enterprise enterprise0 = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByExample", example);
if (null != enterprise0) {
if (!enterprise.getEnterpriseName().equals(enterprise0.getEnterpriseName()) && enterprise.getEnterpriseSn().equals(enterprise0.getEnterpriseSn())) {
// 已经存在相同企业标识了(企业名称不同企业标识相同):
if (enterprise.getEnterpriseNature().equals(3)) {
throw new UserInfoServiceException("组织机构代码已被其他公司注册,请确认输入是否有误");
} else {
throw new UserInfoServiceException("营业执照号或统一社会信用代码已被其他公司注册,请确认输入是否有误");
}
}
}
sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", enterprise);
sqlSession.flushStatements();
return enterprise;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class IdentityCardServiceImpl method saveIdentityCardExtraBill.
/**
* 增值订单保存法人信息
* @param enterpriseId
* @param enterpriseSn
* @param billId
* @param userInfoId
* @param identityCard
* @param itemStatus
* @param old
* @return
* @throws Exception
*/
public IdentityCard saveIdentityCardExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, IdentityCard identityCard, Integer itemStatus, IdentityCard old) throws Exception {
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
// 判断法人信息图片是否重新上传了,没有重新上传,则会提交法人信息的id,重新上传,还是按照下面的方法处理
if (null != identityCard.getId()) {
IdentityCard newIde = new IdentityCard();
IdentityCard oldIde = sqlSession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", identityCard.getId());
newIde.setEnterpriseName(identityCard.getEnterpriseName());
newIde.setName(identityCard.getName());
newIde.setCardType(identityCard.getCardType());
newIde.setIdCode(identityCard.getIdCode());
newIde.setCreateTime(new Date());
newIde.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
newIde.setItemStatus(oldIde.getItemStatus());
newIde.setEnterprise(enterpriseId);
newIde.setExtraBill(billId);
newIde.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(identityCard.getFrontImg())) {
File frontImg = filePathUtils.saveImg(imgDir, null, identityCard.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
newIde.setFrontImg(frontImg.getName());
newIde.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
} else {
newIde.setFrontImg(oldIde.getFrontImg());
newIde.setFrontImgHash(oldIde.getFrontImgHash());
}
if (StringUtils.isNotBlank(identityCard.getBackImg())) {
File backImg = filePathUtils.saveImg(imgDir, null, identityCard.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
newIde.setBackImg(backImg.getName());
newIde.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
} else {
newIde.setBackImg(oldIde.getBackImg());
newIde.setBackImgHash(oldIde.getBackImgHash());
}
sqlSession.insert("com.itrus.portal.db.IdentityCardMapper.insert", newIde);
sqlSession.flushStatements();
return newIde;
}
if (null == identityCard || StringUtils.isBlank(identityCard.getEnterpriseName()) || StringUtils.isBlank(identityCard.getName()) || StringUtils.isBlank(identityCard.getIdCode()) || StringUtils.isBlank(identityCard.getFrontImg())) {
throw new UserInfoServiceException("请提交完整的法人信息");
}
identityCard.setCreateTime(new Date());
identityCard.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
identityCard.setItemStatus(itemStatus);
identityCard.setEnterprise(enterpriseId);
identityCard.setExtraBill(billId);
identityCard.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(identityCard.getFrontImg()) && !identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
File frontImg = filePathUtils.saveImg(imgDir, null, identityCard.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
identityCard.setFrontImg(frontImg.getName());
identityCard.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
}
// 反面图片
if (StringUtils.isNotBlank(identityCard.getBackImg()) && !identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
File backImg = filePathUtils.saveImg(imgDir, null, identityCard.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
identityCard.setBackImg(backImg.getName());
identityCard.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
}
if (old == null) {
sqlSession.insert("com.itrus.portal.db.IdentityCardMapper.insert", identityCard);
} else {
identityCard.setId(old.getId());
sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKeySelective", identityCard);
}
sqlSession.flushStatements();
return identityCard;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class IdentityCardServiceImpl method saveIdentityCard1.
public IdentityCard saveIdentityCard1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, IdentityCard identityCard, Integer itemStatus, IdentityCard old) throws Exception {
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
// 判断法人信息图片是否重新上传了,没有重新上传,则会提交法人信息的id,重新上传,还是按照下面的方法处理
if (null != identityCard.getId()) {
IdentityCard newIde = new IdentityCard();
IdentityCard oldIde = sqlSession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", identityCard.getId());
newIde.setEnterpriseName(identityCard.getEnterpriseName());
newIde.setName(identityCard.getName());
newIde.setCardType(identityCard.getCardType());
newIde.setIdCode(identityCard.getIdCode());
newIde.setCreateTime(new Date());
newIde.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
newIde.setItemStatus(oldIde.getItemStatus());
newIde.setEnterprise(enterpriseId);
newIde.setBill(billId);
newIde.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(identityCard.getFrontImg())) {
File frontImg = filePathUtils.saveImg(imgDir, null, identityCard.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
newIde.setFrontImg(frontImg.getName());
newIde.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
} else {
newIde.setFrontImg(oldIde.getFrontImg());
newIde.setFrontImgHash(oldIde.getFrontImgHash());
}
// 反面图片
if (StringUtils.isNotBlank(identityCard.getBackImg())) {
File backImg = filePathUtils.saveImg(imgDir, null, identityCard.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
newIde.setBackImg(backImg.getName());
newIde.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
} else {
newIde.setBackImg(oldIde.getBackImg());
newIde.setBackImgHash(oldIde.getBackImgHash());
}
sqlSession.insert("com.itrus.portal.db.IdentityCardMapper.insert", newIde);
sqlSession.flushStatements();
return newIde;
}
if (null == identityCard || StringUtils.isBlank(identityCard.getEnterpriseName()) || StringUtils.isBlank(identityCard.getName()) || StringUtils.isBlank(identityCard.getIdCode()) || StringUtils.isBlank(identityCard.getFrontImg())) {
throw new UserInfoServiceException("请提交完整的法人信息");
}
identityCard.setCreateTime(new Date());
identityCard.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
identityCard.setItemStatus(itemStatus);
identityCard.setEnterprise(enterpriseId);
identityCard.setBill(billId);
identityCard.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(identityCard.getFrontImg()) && !identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
File frontImg = filePathUtils.saveImg(imgDir, null, identityCard.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
identityCard.setFrontImg(frontImg.getName());
identityCard.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
}
// 反面图片
if (StringUtils.isNotBlank(identityCard.getBackImg()) && !identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
File backImg = filePathUtils.saveImg(imgDir, null, identityCard.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
identityCard.setBackImg(backImg.getName());
identityCard.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
}
if (old == null) {
sqlSession.insert("com.itrus.portal.db.IdentityCardMapper.insert", identityCard);
} else {
identityCard.setId(old.getId());
sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
}
sqlSession.flushStatements();
return identityCard;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class DynamicCodeServiceImpl method sendCodeCert.
/**
* 银行卡认证时,发送动态码
*
* @param mPhone
* 手机
* @param project
* 项目id
* @param smsType
* 短信模版类型(DTM:动态码)
*
* @throws UserInfoServiceException
*/
public void sendCodeCert(String mPhone, Long project, String smsType) throws UserInfoServiceException {
// 同一手机号指定时间内不能重发
DynamicCodeExample dynamicCodeExample = new DynamicCodeExample();
DynamicCodeExample.Criteria criteria = dynamicCodeExample.or();
Calendar c = Calendar.getInstance();
c.add(Calendar.SECOND, -RESEND_TIME);
criteria.andMPhoneEqualTo(mPhone);
// 发送时间大于等于当前时间减去1分钟
criteria.andSendTimeGreaterThanOrEqualTo(c.getTime());
List<DynamicCode> dynamicCodes = sqlSession.selectList("com.itrus.portal.db.DynamicCodeMapper.selectByExample", dynamicCodeExample);
if (null != dynamicCodes && !dynamicCodes.isEmpty()) {
throw new UserInfoServiceException("此手机号" + RESEND_TIME + "秒内不能连续发送,请稍后重试");
}
// 产生动态码
DynamicCode code = genCode();
if (null == code) {
throw new UserInfoServiceException("发送动态码失败,请稍后重试");
}
// 发送动态码,获取发送的短信内容
MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(project, smsType);
if (null == messageTemplate) {
throw new UserInfoServiceException("未找到对应的短信模版,请联系管理员配置");
}
String content = messageTemplate.getMessageContent();
content = content.replaceAll("code", code.getCode());
if (smsType.equals("DTM")) {
smsType = "动态码";
}
if (!smsSendService.sendDynamicCodeSmsCert(mPhone, content, smsType, project)) {
// 发送失败
throw new UserInfoServiceException("动态码发送失败,请联系管理员查看原因");
} else {
// 记录动态码之前将该手机号关联的有效验证码设置为无效
dynamicCodeExample.clear();
criteria = dynamicCodeExample.createCriteria();
criteria.andMPhoneEqualTo(mPhone);
criteria.andCodeStatusEqualTo(ComNames.DYNAMIC_CODE_ENROLL);
DynamicCode updateCode = new DynamicCode();
updateCode.setCodeStatus(ComNames.DYNAMIC_CODE_USED);
updateCode.setFailTime(new Date());
Map<String, Object> map = new HashMap<String, Object>();
map.put("record", updateCode);
map.put("example", dynamicCodeExample);
sqlSession.update("com.itrus.portal.db.DynamicCodeMapper.updateByExampleSelective", map);
// 发送成功: 记录动态码
Calendar calendar = Calendar.getInstance();
code.setSendTime(calendar.getTime());
// 失效时间为5分钟后
calendar.add(Calendar.MINUTE, FAIL_TIME);
// 设置失效时间
code.setFailTime(calendar.getTime());
code.setmPhone(mPhone);
if (code.getId() == null) {
sqlSession.insert("com.itrus.portal.db.DynamicCodeMapper.insert", code);
} else {
sqlSession.update("com.itrus.portal.db.DynamicCodeMapper.updateByPrimaryKey", code);
}
}
}
Aggregations