Search in sources :

Example 26 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class ReviewServiceImpl method agreeBillReview.

/**
 * pfx证书,当不要审核的时候,自动生成审核记录
 * @param bill
 */
public void agreeBillReview(Bill bill) {
    if (null == bill) {
        return;
    }
    // 填充营业执照运营时间
    Enterprise enterpriseInBill = enterpriseService.getEnterpriseByBillId(bill.getId());
    String soperationStart = null;
    String soperationEnd = null;
    List<BusinessLicense> oldBusinessLicenses = businessService.getBusinessLicensesNews(bill.getEnterprise());
    if (null != oldBusinessLicenses && !oldBusinessLicenses.isEmpty()) {
        for (BusinessLicense businessLicense1 : oldBusinessLicenses) {
            if (null != businessLicense1.getOperationStart() || null != businessLicense1.getOperationEnd()) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                if (null != businessLicense1.getOperationStart()) {
                    soperationStart = format.format(businessLicense1.getOperationStart());
                }
                if (null != businessLicense1.getOperationEnd()) {
                    soperationEnd = format.format(businessLicense1.getOperationEnd());
                }
                break;
            }
        }
    }
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    Project project = billService.getProjectByBillId(bill.getId());
    BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
    OrgCode orgCode = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
    TaxRegisterCert taxregisterCert = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
    IdentityCard identityCard = identityCardService.getIdentityCardByBillId(bill.getId(), null);
    Agent agent = agentService.getAgentByBillId(bill.getId(), null);
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    // 更新管理员提交的认证项资料信息
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        Long businessId = null;
        Long orgCodeId = null;
        Long taxregisterId = null;
        Long identityCardId = null;
        Long agentId = null;
        Long proxyId = null;
        // 更新营业执照信息
        if (null != businessLicense && null != businessLicense.getId()) {
            businessLicense = businessService.updateBusinessLicense(soperationStart, soperationEnd, businessLicense, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            businessId = businessLicense.getId();
        }
        // 更新组织机构代码
        if (null != orgCode && null != orgCode.getId()) {
            orgCode = orgCodeService.updateOrgCode(orgCode, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            orgCodeId = orgCode.getId();
        }
        // 更新税务登记
        if (null != taxregisterCert && null != taxregisterCert.getId()) {
            taxregisterCert = taxCertService.updateTaxRegisterCert(taxregisterCert, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            taxregisterId = taxregisterCert.getId();
        }
        // 更新法定代表人
        if (null != identityCard && null != identityCard.getId()) {
            identityCard = identityCardService.updateIdentityCard(identityCard, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            identityCardId = identityCard.getId();
        }
        // 更新代理人
        if (null != agent && null != agent.getId()) {
            agent = agentService.updateAgent(agent, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            agentId = agent.getId();
        }
        // 更新授权书
        if (null != proxy && null != proxy.getId()) {
            proxy = proxyService.updateProxy(proxy, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null, project);
            proxyId = proxy.getId();
        }
        // 设置第一个admin账号
        AdminExample adminExample = new AdminExample();
        adminExample.setOrderByClause("create_time ASC");
        List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminExample);
        // 更新企业信息
        Enterprise enterprise = enterpriseService.updateEnterprise(bill.getEnterprise(), certification.getId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId);
        // 生成认证记录
        reviewLogService.saveReviewLog(2, admins.get(0).getId(), 1, null, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId, proxyId);
        bill.setCheckTime(new Date());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : Agent(com.itrus.portal.db.Agent) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) Admin(com.itrus.portal.db.Admin) Certification(com.itrus.portal.db.Certification) Date(java.util.Date) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) DigitalCert(com.itrus.portal.db.DigitalCert) Project(com.itrus.portal.db.Project) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) SimpleDateFormat(java.text.SimpleDateFormat) AdminExample(com.itrus.portal.db.AdminExample) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 27 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class OrgCodeServiceImpl method getOrgCodeByBillId.

/**
 * 根据订单id获取订单的组织机构代码信息
 *
 * @param billId
 * @param itemStatus
 * @return
 */
public OrgCode getOrgCodeByBillId(Long billId, Integer itemStatus) {
    OrgCodeExample example = new OrgCodeExample();
    OrgCodeExample.Criteria criteria = example.or();
    criteria.andBillEqualTo(billId);
    if (null != itemStatus) {
        criteria.andItemStatusEqualTo(itemStatus);
    }
    OrgCode orgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByExample", example);
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) OrgCodeExample(com.itrus.portal.db.OrgCodeExample)

Example 28 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class OrgCodeServiceImpl method saveOrgCode1.

public OrgCode saveOrgCode1(Long enterPriseId, String enterpriseSn, Long billId, Long userInfoId, OrgCode orgCode, Integer itemStatus, OrgCode old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    Enterprise ent = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", enterPriseId);
    // 判断组织机构代码图片是否重新上传了,没有重新上传,则会提交组织机构代码的id,重新上传,还是按照下面的方法处理
    if (null != orgCode.getId()) {
        OrgCode newOrgCode = new OrgCode();
        OrgCode oldOrgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", orgCode.getId());
        newOrgCode.setEnterpriseName(orgCode.getEnterpriseName());
        newOrgCode.setOrgCode(orgCode.getOrgCode());
        newOrgCode.setCreateTime(new Date());
        newOrgCode.setLastModify(new Date());
        newOrgCode.setEnterprise(enterPriseId);
        newOrgCode.setBill(billId);
        newOrgCode.setUserInfo(userInfoId);
        // 审核状态:1未审核,2已审核,3已拒绝
        newOrgCode.setItemStatus(oldOrgCode.getItemStatus());
        if (null != orgCode.getOrgCodeType())
            newOrgCode.setOrgCodeType(orgCode.getOrgCodeType());
        if (StringUtils.isNotBlank(orgCode.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
            if (liceImg != null && liceImg.isFile()) {
                newOrgCode.setImgFile(liceImg.getName());
                newOrgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newOrgCode.setImgFile(oldOrgCode.getImgFile());
            newOrgCode.setImgFileHash(oldOrgCode.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", newOrgCode);
        sqlSession.flushStatements();
        return newOrgCode;
    }
    if ((null == orgCode || StringUtils.isBlank(orgCode.getEnterpriseName()) || StringUtils.isBlank(orgCode.getOrgCode())) && ent.getEnterpriseNature() != 2) {
        throw new UserInfoServiceException("请提交完整的组织机构代码信息");
    }
    orgCode.setCreateTime(new Date());
    orgCode.setLastModify(new Date());
    orgCode.setEnterprise(enterPriseId);
    orgCode.setBill(billId);
    orgCode.setUserInfo(userInfoId);
    // 审核状态:1未审核,2已审核,3已拒绝
    orgCode.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(orgCode.getImgFile()) && !ComNames.USE_OLD_IMG.equals(orgCode.getImgFile())) {
        File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
        if (liceImg != null && liceImg.isFile()) {
            orgCode.setImgFile(liceImg.getName());
            orgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", orgCode);
    } else {
        orgCode.setId(old.getId());
        sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKey", orgCode);
    }
    sqlSession.flushStatements();
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Enterprise(com.itrus.portal.db.Enterprise) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 29 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class OrgCodeServiceImpl method getOrgCodeByExtraBillId.

/**
 * 根据增值订单id获取订单的组织机构代码信息
 *
 * @param billId
 * @param itemStatus
 * @return
 */
public OrgCode getOrgCodeByExtraBillId(Long billId, Integer itemStatus) {
    OrgCodeExample example = new OrgCodeExample();
    OrgCodeExample.Criteria criteria = example.or();
    criteria.andExtraBillEqualTo(billId);
    if (null != itemStatus) {
        criteria.andItemStatusEqualTo(itemStatus);
    }
    OrgCode orgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByExample", example);
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) OrgCodeExample(com.itrus.portal.db.OrgCodeExample)

Example 30 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class OrgCodeServiceImpl method updateSaveOrgCode.

/**
 * 修改图片时添加
 *
 * @param enterPriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param orgCode
 * @param itemStatus
 * @return
 * @throws Exception
 */
public OrgCode updateSaveOrgCode(Long enterPriseId, String enterpriseSn, Long billId, Long userInfoId, OrgCode orgCode, Integer itemStatus) throws Exception {
    if (null == orgCode || StringUtils.isBlank(orgCode.getEnterpriseName()) || StringUtils.isBlank(orgCode.getOrgCode())) {
        return null;
    } else {
        File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
        // 判断组织机构代码图片是否重新上传了,没有重新上传,则会提交组织机构代码的id,重新上传,还是按照下面的方法处理
        if (null != orgCode.getId()) {
            OrgCode newOrgCode = new OrgCode();
            OrgCode oldOrgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", orgCode.getId());
            newOrgCode.setEnterpriseName(orgCode.getEnterpriseName());
            newOrgCode.setOrgCode(orgCode.getOrgCode());
            newOrgCode.setCreateTime(new Date());
            newOrgCode.setLastModify(new Date());
            newOrgCode.setEnterprise(enterPriseId);
            newOrgCode.setBill(billId);
            newOrgCode.setUserInfo(userInfoId);
            // 审核状态:1未审核,2已审核,3已拒绝
            newOrgCode.setItemStatus(oldOrgCode.getItemStatus());
            if (null != orgCode.getOrgCodeType())
                newOrgCode.setOrgCodeType(orgCode.getOrgCodeType());
            if (StringUtils.isNotBlank(orgCode.getImgFile())) {
                File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
                if (liceImg != null && liceImg.isFile()) {
                    newOrgCode.setImgFile(liceImg.getName());
                    newOrgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
                }
            } else {
                newOrgCode.setImgFile(oldOrgCode.getImgFile());
                newOrgCode.setImgFileHash(oldOrgCode.getImgFileHash());
            }
            sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", newOrgCode);
            sqlSession.flushStatements();
            return newOrgCode;
        }
        orgCode.setCreateTime(new Date());
        orgCode.setLastModify(new Date());
        orgCode.setEnterprise(enterPriseId);
        orgCode.setBill(billId);
        orgCode.setUserInfo(userInfoId);
        // 审核状态:1未审核,2已审核,3已拒绝
        orgCode.setItemStatus(itemStatus);
        if (StringUtils.isNotBlank(orgCode.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
            if (liceImg != null && liceImg.isFile()) {
                orgCode.setImgFile(liceImg.getName());
                orgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        }
        sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", orgCode);
        sqlSession.flushStatements();
    }
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) File(java.io.File) Date(java.util.Date)

Aggregations

OrgCode (com.itrus.portal.db.OrgCode)34 BusinessLicense (com.itrus.portal.db.BusinessLicense)25 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)24 Enterprise (com.itrus.portal.db.Enterprise)23 IdentityCard (com.itrus.portal.db.IdentityCard)22 Agent (com.itrus.portal.db.Agent)20 UserInfo (com.itrus.portal.db.UserInfo)19 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Proxy (com.itrus.portal.db.Proxy)11 ExtraProduct (com.itrus.portal.db.ExtraProduct)10 HashMap (java.util.HashMap)10 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)9 ExtraBill (com.itrus.portal.db.ExtraBill)8 Product (com.itrus.portal.db.Product)8 Project (com.itrus.portal.db.Project)8 File (java.io.File)8 Date (java.util.Date)8 JSONObject (com.alibaba.fastjson.JSONObject)7 Bill (com.itrus.portal.db.Bill)7