use of com.itrus.portal.db.BusinessLicense 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);
}
}
}
}
use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.
the class BusinessServiceImpl method getBusinessLicensesNews.
/**
* 根据企业名称查找营业执照信息,按生成时间降序排序
*
* @param enterpriseId
* @return
*/
public List<BusinessLicense> getBusinessLicensesNews(Long enterpriseId) {
List<BusinessLicense> bus = new ArrayList<BusinessLicense>();
BusinessLicenseExample example = new BusinessLicenseExample();
example.setOrderByClause("create_time DESC");
BusinessLicenseExample.Criteria criteria = example.or();
criteria.andEnterpriseEqualTo(enterpriseId);
bus = sqlSession.selectList("com.itrus.portal.db.BusinessLicenseMapper.selectByExample", example);
return bus;
}
use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.
the class BusinessServiceImpl method portUpdateBusiness.
/**
* 营业执照图片上传(API接口)
* @param billId
* @param enterpriseSn
* @param image
* @return
* @throws Exception
*/
public BusinessLicense portUpdateBusiness(long billId, String enterpriseSn, String image) throws Exception {
BusinessLicense businessLicense = this.getBusinessByBillId(billId, null);
if (null == businessLicense) {
return null;
}
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
if (businessLicense.getImgFile() != null) {
FileUtils.deleteQuietly(new File(imgDir, businessLicense.getImgFile()));
}
File liceImg = filePathUtils.saveImg(imgDir, null, image, IMG_DEFAULT_TYPE, IMG_NAME_BL);
if (liceImg != null && liceImg.isFile()) {
businessLicense.setImgFile(liceImg.getName());
businessLicense.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
}
sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKeySelective", businessLicense);
sqlSession.flushStatements();
return businessLicense;
}
use of com.itrus.portal.db.BusinessLicense 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;
}
use of com.itrus.portal.db.BusinessLicense in project portal by ixinportal.
the class BusinessServiceImpl method getBusinessByExtraBillId.
/**
* 根据增值订单id查询订单的营业执照信息
*
* @param billId
* @param status
* 营业执照状态
* @return
*/
public BusinessLicense getBusinessByExtraBillId(Long billId, Integer status) {
BusinessLicenseExample example = new BusinessLicenseExample();
BusinessLicenseExample.Criteria criteria = example.or();
criteria.andExtraBillEqualTo(billId);
if (null != status) {
criteria.andItemStatusEqualTo(status);
}
BusinessLicense businessLicense = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByExample", example);
return businessLicense;
}
Aggregations