use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class AgentServiceImpl method saveAgentExtraBill.
/**
* 增值订单保存代理人信息
* @param enterpriseId
* @param enterpriseSn
* @param billId
* @param userInfoId
* @param agent
* @param itemStatus
* @param old
* @return
* @throws Exception
*/
public Agent saveAgentExtraBill(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, Agent agent, Integer itemStatus, Agent old) throws Exception {
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
// 判断代理信息图片是否重新上传了,没有重新上传,则会提交代理人信息的id,重新上传,还是按照下面的方法处理
if (null != agent.getId()) {
Agent newAt = new Agent();
Agent oldAt = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", agent.getId());
newAt.setEnterpriseName(agent.getEnterpriseName());
newAt.setName(agent.getName());
newAt.setCardType(agent.getCardType());
newAt.setIdCode(agent.getIdCode());
newAt.setCreateTime(new Date());
newAt.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
newAt.setItemStatus(oldAt.getItemStatus());
newAt.setEnterprise(enterpriseId);
newAt.setExtraBill(billId);
newAt.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(agent.getFrontImg())) {
File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
newAt.setFrontImg(frontImg.getName());
newAt.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
} else {
newAt.setFrontImg(oldAt.getFrontImg());
newAt.setFrontImgHash(oldAt.getFrontImgHash());
}
// 反面图片
if (StringUtils.isNotBlank(agent.getBackImg())) {
File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
newAt.setBackImg(backImg.getName());
newAt.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
} else {
newAt.setBackImg(oldAt.getBackImg());
newAt.setBackImgHash(oldAt.getBackImgHash());
}
sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", newAt);
sqlSession.flushStatements();
return newAt;
}
if (null == agent || StringUtils.isBlank(agent.getEnterpriseName()) || StringUtils.isBlank(agent.getName()) || StringUtils.isBlank(agent.getIdCode()) || StringUtils.isBlank(agent.getFrontImg())) {
throw new UserInfoServiceException("请提交完整的代理人信息");
}
agent.setCreateTime(new Date());
agent.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
agent.setItemStatus(itemStatus);
agent.setEnterprise(enterpriseId);
agent.setExtraBill(billId);
agent.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(agent.getFrontImg()) && !agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
agent.setFrontImg(frontImg.getName());
agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
}
// 反面图片
if (StringUtils.isNotBlank(agent.getBackImg()) && !agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
agent.setBackImg(backImg.getName());
agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
}
if (old == null)
sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", agent);
else {
agent.setId(old.getId());
sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", agent);
}
sqlSession.flushStatements();
return agent;
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class AgentServiceImpl method portUpdateAgent.
/**
* 代理人证件图片上传(接口)
*
* @param billId
* @param enterpriseSn
* @param identityCard
* @return
* @throws Exception
*/
public Agent portUpdateAgent(Long billId, String enterpriseSn, String image1, String image2) throws Exception {
Agent agent = this.getAgentByBillId(billId, null);
if (null == agent) {
return null;
}
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
if (StringUtils.isNotBlank(agent.getBackImg())) {
FileUtils.deleteQuietly(new File(imgDir, agent.getBackImg()));
}
if (StringUtils.isNotBlank(agent.getFrontImg())) {
FileUtils.deleteQuietly(new File(imgDir, agent.getFrontImg()));
}
// 正面(或者合成)图片
if (StringUtils.isNotBlank(image1)) {
File frontImg = filePathUtils.saveImg(imgDir, null, image1, IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
agent.setFrontImg(frontImg.getName());
agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
}
// 反面图片
if (StringUtils.isNotBlank(image2)) {
File backImg = filePathUtils.saveImg(imgDir, null, image2, IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
agent.setBackImg(backImg.getName());
agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
}
sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", agent);
sqlSession.flushStatements();
return agent;
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class AgentServiceImpl method saveAgent1.
public Agent saveAgent1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, Agent agent, Integer itemStatus, Agent old) throws Exception {
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
// 判断代理信息图片是否重新上传了,没有重新上传,则会提交代理人信息的id,重新上传,还是按照下面的方法处理
if (null != agent.getId()) {
Agent newAt = new Agent();
Agent oldAt = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", agent.getId());
newAt.setEnterpriseName(agent.getEnterpriseName());
newAt.setName(agent.getName());
newAt.setCardType(agent.getCardType());
newAt.setIdCode(agent.getIdCode());
newAt.setCreateTime(new Date());
newAt.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
newAt.setItemStatus(oldAt.getItemStatus());
newAt.setEnterprise(enterpriseId);
newAt.setBill(billId);
newAt.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(agent.getFrontImg())) {
File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
newAt.setFrontImg(frontImg.getName());
newAt.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
} else {
newAt.setFrontImg(oldAt.getFrontImg());
newAt.setFrontImgHash(oldAt.getFrontImgHash());
}
// 反面图片
if (StringUtils.isNotBlank(agent.getBackImg())) {
File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
newAt.setBackImg(backImg.getName());
newAt.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
} else {
newAt.setBackImg(oldAt.getBackImg());
newAt.setBackImgHash(oldAt.getBackImgHash());
}
sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", newAt);
sqlSession.flushStatements();
return newAt;
}
if (null == agent || StringUtils.isBlank(agent.getEnterpriseName()) || StringUtils.isBlank(agent.getName()) || StringUtils.isBlank(agent.getIdCode()) || StringUtils.isBlank(agent.getFrontImg())) {
throw new UserInfoServiceException("请提交完整的代理人信息");
}
agent.setCreateTime(new Date());
agent.setLastModify(new Date());
// 审核状态:1未审核,2已审核,3已拒绝
agent.setItemStatus(itemStatus);
agent.setEnterprise(enterpriseId);
agent.setBill(billId);
agent.setUserInfo(userInfoId);
// 正面(或者合成)图片
if (StringUtils.isNotBlank(agent.getFrontImg()) && !agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
agent.setFrontImg(frontImg.getName());
agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
}
// 反面图片
if (StringUtils.isNotBlank(agent.getBackImg()) && !agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
agent.setBackImg(backImg.getName());
agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
}
if (old == null)
sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", agent);
else {
agent.setId(old.getId());
sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
}
sqlSession.flushStatements();
return agent;
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class AgentServiceImpl method updateAgent.
/**
* 修改代理人信息
*
* @param a_Id
* @param enterpriseSn
* @param agent
* @return
* @throws Exception
*/
public Agent updateAgent(Long a_Id, String enterpriseSn, Agent agent) throws Exception {
if (null == agent) {
return null;
}
agent.setId(a_Id);
Agent agent1 = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", a_Id);
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
if (StringUtils.isNotBlank(agent.getBackImg())) {
FileUtils.deleteQuietly(new File(imgDir, agent1.getBackImg()));
}
if (StringUtils.isNotBlank(agent.getFrontImg())) {
FileUtils.deleteQuietly(new File(imgDir, agent1.getFrontImg()));
}
// 正面(或者合成)图片
if (StringUtils.isNotBlank(agent.getFrontImg())) {
File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
if (frontImg != null && frontImg.isFile()) {
agent.setFrontImg(frontImg.getName());
agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
}
} else {
agent.setFrontImg(agent1.getFrontImg());
}
// 反面图片
if (StringUtils.isNotBlank(agent.getBackImg())) {
File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
if (backImg != null && backImg.isFile()) {
agent.setBackImg(backImg.getName());
agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
}
} else {
agent.setBackImg(agent1.getBackImg());
}
sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", agent);
sqlSession.flushStatements();
return agent;
}
use of com.itrus.portal.db.Agent 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