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);
}
}
Aggregations