Search in sources :

Example 16 with Admin

use of com.itrus.portal.db.Admin 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)

Aggregations

Admin (com.itrus.portal.db.Admin)16 AdminExample (com.itrus.portal.db.AdminExample)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 Project (com.itrus.portal.db.Project)4 ProjectExample (com.itrus.portal.db.ProjectExample)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 SecurityContext (org.springframework.security.core.context.SecurityContext)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 AdminRole (com.itrus.portal.db.AdminRole)2 List (java.util.List)2 Map (java.util.Map)2 AdminLog (com.itrus.portal.db.AdminLog)1 AdminLogExample (com.itrus.portal.db.AdminLogExample)1 AdminRoleExample (com.itrus.portal.db.AdminRoleExample)1 Agent (com.itrus.portal.db.Agent)1 BusinessLicense (com.itrus.portal.db.BusinessLicense)1 Certification (com.itrus.portal.db.Certification)1 DigitalCert (com.itrus.portal.db.DigitalCert)1 Enterprise (com.itrus.portal.db.Enterprise)1