use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class ReviewServiceImpl method queryAudit.
/**
* 查询送审结果
*
* @param appsecret
* @param appId
* @param dataid
* @return
*/
public boolean queryAudit(String appsecret, Long appId, String dataid, Bill bill) throws Exception {
AuditSystemConfig auditSystemConfig = auditSystemConfigService.getAuditSystemConfig(new AuditSystemConfigExample());
if (null == auditSystemConfig) {
// 未配置第三方鉴证信息
return false;
}
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("appId", appId);
jsonMap.put("appsecret", appsecret);
// 待查询的记录id
jsonMap.put("dataid", dataid);
String jsonString = jsonTool.writeValueAsString(jsonMap);
String result = RequestUtils.post(auditSystemConfig.getAuditSystemUrl() + ComNames.QUERYAPIS, jsonString, appsecret);
JsonNode respNode = jsonTool.readTree(result);
if (200 == respNode.get("status").asInt()) {
// 查询成功
JsonNode statusNode = respNode.get("result");
// 0是未通过,1是通过,2是审核中
int auditstatus = statusNode.get("auditstatus").asInt();
BusinessLicense bl = businessService.getBusinessByBillId(bill.getId(), null);
OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
TaxRegisterCert trc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
Agent at = agentService.getAgentByBillId(bill.getId(), null);
Proxy p = proxyService.getProxyByBillId(bill.getId());
// 默认未审核
Integer itemStatus = 1;
String reason = null;
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
if (0 == auditstatus) {
// 未通过(审核拒绝)
// 记录未通过原因
reason = statusNode.get("auditresult").getTextValue();
// 更新订单状态
bill.setBillStatus(ComNames.BILL_STATUS_4);
bill.setCancelReason(reason);
bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
// 发送短信
if (sendSmsBySHJJ(bill.getId())) {
bill.setIsSms(true);
bill.setSendTime(new Date());
}
// 更新认证项状态
itemStatus = 3;
// 添加系统日志
LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核拒绝");
} else if (1 == auditstatus) {
// 通过
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
Product product1 = null;
Product product2 = null;
Product product3 = null;
DigitalCert cert1 = null;
DigitalCert cert2 = null;
DigitalCert cert3 = null;
if (null != bill.getProduct1()) {
product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
if (null != product1.getCert()) {
cert1 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product1.getCert());
}
}
if (null != bill.getProduct2()) {
product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct2());
if (null != product2.getCert()) {
cert2 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product2.getCert());
}
}
if (null != bill.getProduct3()) {
product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct3());
if (null != product3.getCert()) {
cert3 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product3.getCert());
}
}
DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
// 更新企业
if (respNode.get("source") != null) {
enterprise.setInfo(respNode.get("source").getTextValue().getBytes());
}
enterprise.setReviewTime(new Date());
enterprise.setAuthenticationLevel(product.getAuthentication());
// 更新订单状态
bill.setBillStatus(ComNames.BILL_STATUS_5);
if (bill.getOldUserCert() != null) {
bill.setBillStatus(ComNames.BILL_STATUS_12);
}
// 数字证书操作方式为用户下载(2)的,订单状态设置为待下载
if (null != cert && null != cert.getInitBuy() && "2".equals(cert.getInitBuy())) {
bill.setBillStatus(ComNames.BILL_STATUS_13);
}
// 当产品没有配置有数字证书的时候
if (null == cert && null == cert1 && null == cert2 && null == cert3) {
// 根据订单判断订单是否需要开票:0标识不需要开票,1需要开纸质发票,2需要开电子发票
int type = billService.getBillInvoiceType(bill);
switch(type) {
case 0:
bill.setBillStatus(ComNames.BILL_STATUS_8);
break;
case 1:
if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
bill.setBillStatus(ComNames.BILL_STATUS_7);
} else {
bill.setBillStatus(ComNames.BILL_STATUS_6);
}
break;
case 2:
if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
} else {
bill.setBillStatus(ComNames.BILL_STATUS_6);
}
break;
default:
break;
}
}
bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
// 更新认证项状态
itemStatus = 2;
// 添加系统日志
LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核通过");
} else if (2 == auditstatus) {
// 审核中
throw new UserInfoServiceException(statusNode.get("auditmessage").getTextValue());
}
if (null != bl) {
bl.setItemStatus(itemStatus);
saveBl(bl, respNode.get("source"));
enterprise.setHasBl(bl.getId());
}
if (null != oc) {
oc.setItemStatus(itemStatus);
sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", oc);
enterprise.setHasOrgCode(oc.getId());
}
if (null != trc) {
trc.setItemStatus(itemStatus);
sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKeySelective", trc);
enterprise.setHasTaxCert(trc.getId());
}
if (null != ic) {
ic.setItemStatus(itemStatus);
sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKeySelective", ic);
enterprise.setHasIdCard(ic.getId());
}
if (null != at) {
at.setItemStatus(itemStatus);
sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", at);
enterprise.setHasAgent(at.getId());
}
if (null != p) {
p.setItemStatus(itemStatus);
}
// 更新企业
sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKeyWithBLOBs", enterprise);
// 更新订单
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
// 生成鉴证记录
reviewLogService.saveReviewLog(1, null, auditstatus == 1 ? 1 : 2, reason, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), bl == null ? null : bl.getId(), oc == null ? null : oc.getId(), trc == null ? null : trc.getId(), ic == null ? null : ic.getId(), at == null ? null : at.getId(), p == null ? null : p.getId());
return true;
} else if (201 == respNode.get("status").asInt()) {
// 查询失败
String message = respNode.get("message").getTextValue();
throw new UserInfoServiceException(message);
}
return false;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class SubmitReviewServiceImpl method getAuditJsonParam.
/**
* 获取单个送审的数据json格式
*
* @param bill
* @return
*/
public String getAuditJsonParam(Bill bill) throws Exception {
SysConfig sysConfig = cacheCustomer.getSysConfigByType(SystemConfigService.TS_URL);
if (sysConfig == null || StringUtils.isBlank(sysConfig.getConfig()))
throw new UserInfoServiceException("缺少终端后台地址配置信息");
// 查询企业表是是否含有dataid的值
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
String dataId = bill.getDataId();
// 获取产品的认证等级需要认证的项
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
/**
* 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者
*/
Long[] items = StringTools.getLong(certification.getCertItems());
BusinessLicense businessLicense = null;
OrgCode orgCode = null;
TaxRegisterCert taxRegister = null;
IdentityCard identityCard = null;
Proxy proxy = null;
Agent agent = null;
for (Long item : items) {
if (ComNames.BUSINESS_ITEM == item) {
// 查询订单的营业执照信息
businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
} else if (ComNames.ORG_CODE_ITEM == item) {
// 查询订单的组织机构代码信息
orgCode = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
} else if (ComNames.TAX_CERT_ITEM == item) {
// 查询订单的税务登记证信息
taxRegister = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
} else if (ComNames.IDENTITY_CARD_ITEM == item) {
// 查询订单的法人信息
identityCard = identityCardService.getIdentityCardByBillId(bill.getId(), null);
} else if (ComNames.PROXY_ITEM == item) {
// 查询订单的授权书信息
proxy = proxyService.getProxyByBillId(bill.getId());
} else if (ComNames.AGENT_ITEM == item) {
agent = agentService.getAgentByBillId(bill.getId(), null);
}
}
Map<String, Object> jsonMap = new HashMap<String, Object>();
String appId = product.getAppId().toString();
String appsecret = product.getAppsecret();
jsonMap.put("appId", appId);
jsonMap.put("appsecret", appsecret);
if (StringUtils.isNotBlank(dataId))
// 用户查询记录回执id,当审核失败后重新提交时,必填(上一次返回的dataid)
jsonMap.put("dataid", dataId);
// 企业信息
// 企业类型(1为企业;
jsonMap.put("comptype", enterprise.getEnterpriseNature());
// 2为个体工商户;3为事业单位/政府机关)
// 注册省份
jsonMap.put("compaddress", "");
// 企业名称
jsonMap.put("companyname", enterprise.getEnterpriseName());
// 营业执照信息:当企业类型comptype值为1和2时,必填
if (null != businessLicense) {
if (businessLicense.getBusinessType() == 1) {
// 三证合一企业
jsonMap.put("businesslicensetype", 1);
} else {
// 非三证合一企业
jsonMap.put("businesslicensetype", 0);
}
// 统一社会信用代码/营业执照注册号
jsonMap.put("compcode", businessLicense.getLicenseNo());
if (StringUtils.isNotBlank(businessLicense.getImgFile()) && StringUtils.isNotBlank(businessLicense.getImgFileHash())) {
jsonMap.put("businesslicense", sysConfig.getConfig() + "/reviewWeb/audit/img/0/" + businessLicense.getId() + "/0/" + // 营业执照照片的URL
businessLicense.getImgFileHash());
}
}
// 组织机构代码信息:当企业类型comptype值为3时,必填
if (null != orgCode) {
if (null != orgCode.getOrgCodeType() && orgCode.getOrgCodeType().equals(1)) {
// 三证合一企业
jsonMap.put("businesslicensetype", 1);
if (StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getImgFileHash())) {
jsonMap.put("businesslicense", sysConfig.getConfig() + "/reviewWeb/audit/img/1/" + orgCode.getId() + "/0/" + // 组织机构代码证照片的URL
orgCode.getImgFileHash());
}
// 统一社会信用代码/营业执照注册号
jsonMap.put("compcode", orgCode.getOrgCode());
} else {
// 组织机构代码(号码)
jsonMap.put("organizationcode", orgCode.getOrgCode());
if (StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getImgFileHash())) {
jsonMap.put("orgcodecertificate", sysConfig.getConfig() + "/reviewWeb/audit/img/1/" + orgCode.getId() + "/0/" + // 组织机构代码证照片的URL
orgCode.getImgFileHash());
}
}
}
// 税务登记证信息
if (null != taxRegister) {
jsonMap.put("taxregistratno", taxRegister.getCertNo());
jsonMap.put("taxregcertificate", sysConfig.getConfig() + "/reviewWeb/audit/img/2/" + taxRegister.getId() + "/0/" + // 税务登记证的URL
taxRegister.getImgFileHash());
}
// 授权书信息
if (null != proxy) {
jsonMap.put("powerofattorney", // 授权书的URL
sysConfig.getConfig() + "/reviewWeb/audit/img/3/" + proxy.getId() + "/0/" + proxy.getImgFileHash());
}
// 法人信息
if (null != identityCard) {
// 法人姓名
jsonMap.put("legalname", identityCard.getName());
// 法人证件类型(1为身份证;2为护照;3为其他)
jsonMap.put("legalnotype", identityCard.getCardType());
// 法人证件号码
jsonMap.put("legalidcardno", identityCard.getIdCode());
jsonMap.put("legalpzmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/4/" + identityCard.getId() + "/0/" + // 法人证件正面照片的URL
identityCard.getFrontImgHash());
if (StringUtils.isNotBlank(identityCard.getBackImg()) && StringUtils.isNotBlank(identityCard.getBackImgHash())) {
jsonMap.put("legalpfmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/4/" + identityCard.getId() + "/1/" + // 法人证件反面照片的URL
identityCard.getBackImgHash());
}
}
// 代理人信息
// 代理人姓名
jsonMap.put("proxyname", userInfo.getRealName());
// 代理人手机号
jsonMap.put("proxyphone", userInfo.getmPhone());
// 代理人座机
jsonMap.put("proxytele", userInfo.getTelephone());
// 代理人邮箱
jsonMap.put("proxyemail", userInfo.getEmail());
if (null != agent) {
// 代理人证件类型(1为身份证;2为护照;3为其他)
jsonMap.put("proxynotype", agent.getCardType());
// 代理人身份证号
jsonMap.put("proxypidcardno", agent.getIdCode());
jsonMap.put("proxypzmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/5/" + agent.getId() + "/0/" + // 代理人身份证正面照片
agent.getFrontImgHash());
if (StringUtils.isNotBlank(agent.getBackImg()) && StringUtils.isNotBlank(agent.getBackImgHash())) {
jsonMap.put("proxypfmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/5/" + agent.getId() + "/1/" + // 代理人身份证反面照片
agent.getBackImgHash());
}
}
return jsonTool.writeValueAsString(jsonMap);
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class TaxCertServiceImpl method saveTaxCert1.
public TaxRegisterCert saveTaxCert1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, TaxRegisterCert taxRegisterCert, Integer itemStatus, TaxRegisterCert old) throws Exception {
File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
// 判断税务登记证图片是否重新上传了,没有重新上传,则会提交税务登记证的id,重新上传,还是按照下面的方法处理
if (null != taxRegisterCert.getId()) {
TaxRegisterCert newTax = new TaxRegisterCert();
TaxRegisterCert oldTax = sqlSession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByPrimaryKey", taxRegisterCert.getId());
newTax.setEnterpriseName(taxRegisterCert.getEnterpriseName());
newTax.setCertNo(taxRegisterCert.getCertNo());
newTax.setCreateTime(new Date());
newTax.setLastModify(new Date());
newTax.setEnterprise(enterpriseId);
newTax.setBill(billId);
newTax.setUserInfo(userInfoId);
// 审核状态:1未审核,2已审核,3已拒绝
newTax.setItemStatus(oldTax.getItemStatus());
if (StringUtils.isNotBlank(taxRegisterCert.getImgFile())) {
File liceImg = filePathUtils.saveImg(imgDir, null, taxRegisterCert.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_TAX);
if (liceImg != null && liceImg.isFile()) {
newTax.setImgFile(liceImg.getName());
newTax.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
}
} else {
newTax.setImgFile(oldTax.getImgFile());
newTax.setImgFileHash(oldTax.getImgFileHash());
}
sqlSession.insert("com.itrus.portal.db.TaxRegisterCertMapper.insert", newTax);
sqlSession.flushStatements();
return newTax;
}
if (null == taxRegisterCert || StringUtils.isBlank(taxRegisterCert.getEnterpriseName()) || StringUtils.isBlank(taxRegisterCert.getCertNo())) {
throw new UserInfoServiceException("请提交完整的税务登记证信息");
}
taxRegisterCert.setCreateTime(new Date());
taxRegisterCert.setLastModify(new Date());
taxRegisterCert.setEnterprise(enterpriseId);
taxRegisterCert.setBill(billId);
taxRegisterCert.setUserInfo(userInfoId);
// 审核状态:1未审核,2已审核,3已拒绝
taxRegisterCert.setItemStatus(itemStatus);
if (StringUtils.isNotBlank(taxRegisterCert.getImgFile()) && !ComNames.USE_OLD_IMG.equals(taxRegisterCert.getImgFile())) {
File liceImg = filePathUtils.saveImg(imgDir, null, taxRegisterCert.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_TAX);
if (liceImg != null && liceImg.isFile()) {
taxRegisterCert.setImgFile(liceImg.getName());
taxRegisterCert.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
}
}
if (old == null) {
sqlSession.insert("com.itrus.portal.db.TaxRegisterCertMapper.insert", taxRegisterCert);
} else {
taxRegisterCert.setId(old.getId());
sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKey", taxRegisterCert);
}
sqlSession.flushStatements();
return taxRegisterCert;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class UserInfoServiceImpl method updateUserInfo.
/**
* 更新用户信息
*
* @param userInfo
* 需要更新的用户信息
* @return
* @throws UserInfoServiceException
*/
public UserInfo updateUserInfo(UserInfo userInfo) throws UserInfoServiceException {
UserInfo userInfo0 = getUserInfoByMphone(userInfo.getmPhone());
if (null != userInfo0 && !userInfo.getId().equals(userInfo0.getId()))
throw new UserInfoServiceException("该手机号已经存在关联用户");
userInfo.setLastModify(new Date());
sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKeySelective", userInfo);
userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", userInfo.getId());
return userInfo;
}
use of com.itrus.portal.exception.UserInfoServiceException in project portal by ixinportal.
the class UserInfoServiceImpl method updateByPrimaryKeySelective.
/**
* 更新用户信息
*
* @param userInfo
* 需要更新的用户信息
* @return
* @throws UserInfoServiceException
*/
public UserInfo updateByPrimaryKeySelective(UserInfo userInfo) throws UserInfoServiceException {
if (null != userInfo && StringUtils.isNotBlank(userInfo.getmPhone())) {
UserInfo userInfo0 = getUserInfoByMphone(userInfo.getmPhone());
if (null != userInfo0 && !userInfo.getId().equals(userInfo0.getId()))
throw new UserInfoServiceException("该手机号已经存在关联用户");
}
userInfo.setLastModify(new Date());
sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKeySelective", userInfo);
return userInfo;
}
Aggregations