Search in sources :

Example 21 with UserInfoServiceException

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

the class DynamicCodeServiceImpl method sendCodeJSSQYZ.

/**
 * 证书解锁申请验证码发送接口
 * @param mPhone
 * @param project
 * @param smsType
 * @throws UserInfoServiceException
 */
public void sendCodeJSSQYZ(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("JSSQYZ")) {
        smsType = "解锁申请验证";
    }
    if (!smsSendService.sendDynamicCodeSms(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());
        // 失效时间为30分钟后
        calendar.add(Calendar.MINUTE, FAIL_TIME_30_MINUTE);
        // 设置失效时间
        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);
        }
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) DynamicCodeExample(com.itrus.portal.db.DynamicCodeExample) HashMap(java.util.HashMap) Calendar(java.util.Calendar) DynamicCode(com.itrus.portal.db.DynamicCode) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 22 with UserInfoServiceException

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

the class DynamicCodeServiceImpl method sendCode.

/**
 * 用户登录/注册时,发送动态码
 *
 * @param mPhone
 *            手机
 * @param project
 *            项目id
 * @param smsType
 *            短信模版类型(DTM:动态码)
 *
 * @throws UserInfoServiceException
 */
public void sendCode(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 = "动态码";
    } else if (smsType.equals("ZSBD")) {
        smsType = "证书绑定";
    }
    if (!smsSendService.sendDynamicCodeSms(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);
        }
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) DynamicCodeExample(com.itrus.portal.db.DynamicCodeExample) HashMap(java.util.HashMap) Calendar(java.util.Calendar) DynamicCode(com.itrus.portal.db.DynamicCode) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 23 with UserInfoServiceException

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

the class BusinessServiceImpl method saveBusinessExtraBill.

/**
 * 增值订单存储营业执照
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param businessLicense
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public BusinessLicense saveBusinessExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, BusinessLicense businessLicense, Integer itemStatus, BusinessLicense old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断营业执照图片是否重新上传了,没有重新上传,则会提交营业执照的id,重新上传,还是按照下面的方法处理
    if (null != businessLicense.getId()) {
        BusinessLicense bu0 = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", businessLicense.getId());
        BusinessLicense newBu = new BusinessLicense();
        newBu.setEnterpriseName(businessLicense.getEnterpriseName());
        newBu.setBusinessType(businessLicense.getBusinessType());
        newBu.setLicenseNo(businessLicense.getLicenseNo());
        newBu.setAbode(businessLicense.getAbode());
        newBu.setBusinessScope(businessLicense.getBusinessScope());
        newBu.setBusinessPlace(businessLicense.getBusinessPlace());
        newBu.setRegFund(businessLicense.getRegFund());
        newBu.setOperationStart(businessLicense.getOperationStart());
        newBu.setOperationEnd(businessLicense.getOperationEnd());
        newBu.setOperator(businessLicense.getOperator());
        newBu.setLegalPerson(businessLicense.getLegalPerson());
        newBu.setEnterprise(enterpriseId);
        newBu.setExtraBill(billId);
        newBu.setUserInfo(userInfoId);
        newBu.setIsDateless(true);
        newBu.setCreateTime(new Date());
        newBu.setLastModify(new Date());
        // 审核状态:1未审核,2已审核,3已拒绝
        newBu.setItemStatus(bu0.getItemStatus());
        if (StringUtils.isNotBlank(businessLicense.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
            if (liceImg != null && liceImg.isFile()) {
                newBu.setImgFile(liceImg.getName());
                newBu.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newBu.setImgFile(bu0.getImgFile());
            newBu.setImgFileHash(bu0.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", newBu);
        sqlSession.flushStatements();
        return newBu;
    }
    if (null == businessLicense || StringUtils.isBlank(businessLicense.getImgFile()) || StringUtils.isBlank(businessLicense.getEnterpriseName()) || StringUtils.isBlank(businessLicense.getLicenseNo())) {
        throw new UserInfoServiceException("请提交完整的营业执照信息");
    }
    businessLicense.setEnterprise(enterpriseId);
    businessLicense.setExtraBill(billId);
    businessLicense.setUserInfo(userInfoId);
    businessLicense.setIsDateless(true);
    businessLicense.setCreateTime(new Date());
    businessLicense.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    businessLicense.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(businessLicense.getImgFile()) && !businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
        File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
        if (liceImg != null && liceImg.isFile()) {
            businessLicense.setImgFile(liceImg.getName());
            businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", businessLicense);
    } else {
        businessLicense.setId(old.getId());
        sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKeySelective", businessLicense);
    }
    sqlSession.flushStatements();
    return businessLicense;
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 24 with UserInfoServiceException

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

the class BusinessServiceImpl method updateBusinessExtraBill.

/**
 * 增值订单重新提交营业执照
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param businessLicense
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public BusinessLicense updateBusinessExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, BusinessLicense businessLicense, Integer itemStatus, BusinessLicense old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断营业执照图片是否重新上传了,没有重新上传,则会提交营业执照的id,重新上传,还是按照下面的方法处理
    if (null == businessLicense || StringUtils.isBlank(businessLicense.getImgFile()) || StringUtils.isBlank(businessLicense.getEnterpriseName()) || StringUtils.isBlank(businessLicense.getLicenseNo())) {
        throw new UserInfoServiceException("请提交完整的营业执照信息");
    }
    businessLicense.setEnterprise(enterpriseId);
    businessLicense.setExtraBill(billId);
    businessLicense.setUserInfo(userInfoId);
    businessLicense.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    businessLicense.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(businessLicense.getImgFile()) && !businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
        File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
        if (liceImg != null && liceImg.isFile()) {
            businessLicense.setImgFile(liceImg.getName());
            businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKeySelective", businessLicense);
    sqlSession.flushStatements();
    return businessLicense;
}
Also used : File(java.io.File) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 25 with UserInfoServiceException

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

the class BusinessServiceImpl method saveBusiness1.

public BusinessLicense saveBusiness1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, BusinessLicense businessLicense, Integer itemStatus, BusinessLicense old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断营业执照图片是否重新上传了,没有重新上传,则会提交营业执照的id,重新上传,还是按照下面的方法处理
    if (null != businessLicense.getId()) {
        BusinessLicense bu0 = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", businessLicense.getId());
        BusinessLicense newBu = new BusinessLicense();
        newBu.setEnterpriseName(businessLicense.getEnterpriseName());
        newBu.setBusinessType(businessLicense.getBusinessType());
        newBu.setLicenseNo(businessLicense.getLicenseNo());
        newBu.setEnterprise(enterpriseId);
        newBu.setBill(billId);
        newBu.setUserInfo(userInfoId);
        newBu.setIsDateless(true);
        newBu.setCreateTime(new Date());
        newBu.setLastModify(new Date());
        // 审核状态:1未审核,2已审核,3已拒绝
        newBu.setItemStatus(bu0.getItemStatus());
        if (StringUtils.isNotBlank(businessLicense.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
            if (liceImg != null && liceImg.isFile()) {
                newBu.setImgFile(liceImg.getName());
                newBu.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newBu.setImgFile(bu0.getImgFile());
            newBu.setImgFileHash(bu0.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", newBu);
        sqlSession.flushStatements();
        return newBu;
    }
    if (null == businessLicense || StringUtils.isBlank(businessLicense.getImgFile()) || StringUtils.isBlank(businessLicense.getEnterpriseName()) || StringUtils.isBlank(businessLicense.getLicenseNo())) {
        throw new UserInfoServiceException("请提交完整的营业执照信息");
    }
    businessLicense.setEnterprise(enterpriseId);
    businessLicense.setBill(billId);
    businessLicense.setUserInfo(userInfoId);
    businessLicense.setIsDateless(true);
    businessLicense.setCreateTime(new Date());
    businessLicense.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    businessLicense.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(businessLicense.getImgFile()) && !businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
        File liceImg = filePathUtils.saveImg(imgDir, null, businessLicense.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_BL);
        if (liceImg != null && liceImg.isFile()) {
            businessLicense.setImgFile(liceImg.getName());
            businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.BusinessLicenseMapper.insert", businessLicense);
    } else {
        businessLicense.setId(old.getId());
        ;
        sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
    }
    sqlSession.flushStatements();
    return businessLicense;
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

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