Search in sources :

Example 51 with UserInfoServiceException

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

the class IdentityCardServiceImpl method saveIdentityCardExtraBillFromUkey.

/**
 * 保存从ukey平台传递过来的法人信息
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param identityCard
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public IdentityCard saveIdentityCardExtraBillFromUkey(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, IdentityCard identityCard, Integer itemStatus, IdentityCard old) throws Exception {
    // 若ukey平台的法人图片信息是合并上传,没有反面,则本平台存储为两张一样的图片
    if (null != identityCard.getBackImg() && identityCard.getBackImg().replaceAll(" ", "").toLowerCase().equals("null")) {
        identityCard.setBackImg(identityCard.getFrontImg());
    }
    if (null != identityCard.getBackImg() && identityCard.getBackImg().length() < 20) {
        identityCard.setBackImg(identityCard.getFrontImg());
    }
    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;
}
Also used : File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 52 with UserInfoServiceException

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

the class IdentityCardServiceImpl method updateIdentityCardExtraBill.

/**
 * 增值订单重新提交法人信息
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param identityCard
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public IdentityCard updateIdentityCardExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, IdentityCard identityCard, Integer itemStatus, IdentityCard old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    if (null == identityCard || StringUtils.isBlank(identityCard.getEnterpriseName()) || StringUtils.isBlank(identityCard.getName()) || StringUtils.isBlank(identityCard.getIdCode()) || StringUtils.isBlank(identityCard.getFrontImg())) {
        throw new UserInfoServiceException("请提交完整的法人信息");
    }
    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));
        }
    }
    sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKeySelective", identityCard);
    sqlSession.flushStatements();
    return identityCard;
}
Also used : File(java.io.File) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 53 with UserInfoServiceException

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

the class IdentityCardServiceImpl method portSaveIdentityCard1.

public IdentityCard portSaveIdentityCard1(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())) {
        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;
}
Also used : File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 54 with UserInfoServiceException

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

the class BillWebServiceImpl method saveBillAuthenticationItems.

/**
 * 保存订单对应的认证项,并删除之前关联的认证项
 *
 * @param certItems
 *            需要认证的项
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 *            营业制证
 * @param orgCode
 *            组织机构代码
 * @param taxregisterCert
 *            税务登记
 * @param identityCard
 *            法人
 * @param agent
 *            代理人
 * @param proxy
 *            授权书
 * @param webenterprise
 *            企业
 * @param webuserInfo
 *            用户
 * @throws Exception
 */
public void saveBillAuthenticationItems(String certItems, Integer enterpriseNature, Long billId, BusinessLicense businessLicense, OrgCode orgCode, TaxRegisterCert taxregisterCert, IdentityCard identityCard, Agent agent, Proxy proxy, Enterprise webenterprise, UserInfo webuserInfo) throws Exception {
    // 根据订单id,获取该订单的旧认证项:
    BusinessLicense oldBl = businessService.getBusinessByBillId(billId, null);
    OrgCode oldOc = orgCodeService.getOrgCodeByBillId(billId, null);
    TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByBillId(billId, null);
    IdentityCard oldIc = identityCardService.getIdentityCardByBillId(billId, null);
    Agent oldAgent = agentService.getAgentByBillId(billId, null);
    Proxy oldProxy = proxyService.getProxyByBillId(billId);
    // 新认证项id置null,便于执行新增处理
    businessLicense.setId(null);
    orgCode.setId(null);
    taxregisterCert.setId(null);
    identityCard.setId(null);
    agent.setId(null);
    proxy.setId(null);
    // 从数据库中删除旧认证项
    if (false) {
        if (null != oldBl) {
            sqlSession.delete("com.itrus.portal.db.BusinessLicenseMapper.deleteByPrimaryKey", oldBl.getId());
        }
        if (null != oldOc) {
            sqlSession.delete("com.itrus.portal.db.OrgCodeMapper.deleteByPrimaryKey", oldOc.getId());
        }
        if (null != oldTc) {
            sqlSession.delete("com.itrus.portal.db.TaxRegisterCertMapper.deleteByPrimaryKey", oldTc.getId());
        }
        if (null != oldIc) {
            sqlSession.delete("com.itrus.portal.db.IdentityCardMapper.deleteByPrimaryKey", oldIc.getId());
        }
        if (null != oldAgent) {
            sqlSession.delete("com.itrus.portal.db.AgentMapper.deleteByPrimaryKey", oldAgent.getId());
        }
        if (null != oldProxy) {
            sqlSession.delete("com.itrus.portal.db.ProxyMapper.deleteByPrimaryKey", oldProxy.getId());
        }
    }
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
     */
    Long[] items = StringTools.getLong(certItems);
    // 是否有营业执照信息,默认false没有
    boolean hasBl = false;
    for (Long item : items) {
        if (ComNames.BUSINESS_ITEM.equals(item) && !enterpriseNature.equals(3)) {
            // 事业单位不填写营业执照
            hasBl = true;
            // 判断新认证项是否是使用旧认证项的图片
            if (null != oldBl && StringUtils.isBlank(businessLicense.getImgFile())) {
                businessLicense.setImgFile(ComNames.USE_OLD_IMG);
            }
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into businessLicense:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            businessLicense = businessService.saveBusiness1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_1, oldBl);
            if (businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                businessLicense.setImgFile(oldBl.getImgFile());
                businessLicense.setImgFileHash(oldBl.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
            }
        } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 假如企业性质为2(个体工商户)并且组织机构代码没有填,则不用保存
            if (enterpriseNature.equals(2) && StringUtils.isBlank(orgCode.getOrgCode()))
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldOc && StringUtils.isBlank(orgCode.getImgFile())) {
                if (StringUtils.isBlank(oldOc.getImgFile())) {
                    if (orgCode.getOrgCodeType().equals(1)) {
                        throw new UserInfoServiceException("事业单位法人证书不能为空");
                    } else {
                        throw new UserInfoServiceException("组织机构代码图不能为空");
                    }
                }
                orgCode.setImgFile(ComNames.USE_OLD_IMG);
            } else if (StringUtils.isBlank(orgCode.getImgFile())) {
                if (orgCode.getOrgCodeType().equals(1)) {
                    throw new UserInfoServiceException("事业单位法人证书不能为空");
                } else {
                    throw new UserInfoServiceException("组织机构代码图不能为空");
                }
            }
            orgCode = orgCodeService.saveOrgCode1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_1, oldOc);
            if (orgCode.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                orgCode.setImgFile(oldOc.getImgFile());
                orgCode.setImgFileHash(oldOc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKey", orgCode);
            }
        } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 保存税务登记证
            if (enterpriseNature.equals(3))
                // 事业单位不填写税务登记信息
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldTc && StringUtils.isBlank(taxregisterCert.getImgFile())) {
                if (StringUtils.isBlank(oldTc.getImgFile()))
                    throw new UserInfoServiceException("税务登记证不能为空");
                taxregisterCert.setImgFile(ComNames.USE_OLD_IMG);
            }
            taxregisterCert = taxCertService.saveTaxCert1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_1, oldTc);
            if (taxregisterCert.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                taxregisterCert.setImgFile(oldTc.getImgFile());
                taxregisterCert.setImgFileHash(oldTc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKey", taxregisterCert);
            }
        } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
            // 判断是否需要使用旧的认证项图片
            if (null != oldIc) {
                if (StringUtils.isBlank(identityCard.getFrontImg())) {
                    identityCard.setFrontImg(ComNames.USE_OLD_IMG);
                    identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                }
                if (StringUtils.isBlank(identityCard.getBackImg()))
                    identityCard.setBackImg(ComNames.USE_OLD_IMG);
            }
            identityCard = identityCardService.saveIdentityCard1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_1, oldIc);
            if (identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setFrontImg(oldIc.getFrontImg());
                identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
            if (identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setBackImg(oldIc.getBackImg());
                identityCard.setBackImgHash(oldIc.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
        } else if (ComNames.AGENT_ITEM.equals(item)) {
            // 保存代理人
            if (null != oldAgent) {
                if (StringUtils.isBlank(agent.getFrontImg())) {
                    agent.setFrontImg(ComNames.USE_OLD_IMG);
                    agent.setFrontImgHash(oldAgent.getFrontImgHash());
                }
                if (StringUtils.isBlank(agent.getBackImg()))
                    agent.setBackImg(ComNames.USE_OLD_IMG);
            }
            agent = agentService.saveAgent1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), agent, ComNames.ITEM_STATUS_1, oldAgent);
            if (agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setFrontImg(oldAgent.getFrontImg());
                agent.setFrontImgHash(oldAgent.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
            if (agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setBackImg(oldAgent.getBackImg());
                agent.setBackImgHash(oldAgent.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
        } else if (ComNames.PROXY_ITEM.equals(item)) {
            // 保存授权书
            if (null != oldProxy && StringUtils.isBlank(proxy.getImgFile()))
                proxy.setImgFile(ComNames.USE_OLD_IMG);
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into proxy:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            Project project = billService.getProjectByBillId(billId);
            proxy = proxyService.saveProxy1(webenterprise.getId(), webuserInfo.getUniqueId(), billId, webuserInfo.getId(), proxy, oldProxy, project);
            if (proxy.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                proxy.setImgFile(oldProxy.getImgFile());
                proxy.setImgFileHash(oldProxy.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.ProxyMapper.updateByPrimaryKey", proxy);
            }
        }
    }
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Agent(com.itrus.portal.db.Agent) Project(com.itrus.portal.db.Project) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 55 with UserInfoServiceException

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

the class BusinessServiceImpl method portSaveBusiness1.

public BusinessLicense portSaveBusiness1(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.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