use of com.itrus.portal.db.Product in project portal by ixinportal.
the class MakeCertController method downloadPfxCert.
/**
* 后台管理员下载pfx证书的接口
*
* @param id,订单id
* @param request
* @param response
* @return
*/
@RequestMapping("/pfx/{id}")
public String downloadPfxCert(@PathVariable(value = "id") Long id, HttpServletRequest request, HttpServletResponse response) {
Bill bill = billService.getBill(id);
if (null == bill) {
return null;
}
Integer uidIdx = 1;
UserInfo webuserInfo = userInfoService.getUserInfoByBillId(id);
Enterprise webenterprise = enterpriseService.getEnterpriseByBillId(id);
boolean billFlag = webuserInfo.getId().equals(bill.getUniqueId()) && webenterprise.getId().equals(bill.getEnterprise());
if (!billFlag) {
return null;
}
// 用户已经下载过了,再次下载
boolean downLoadFlag = bill.getBillStatus().equals(ComNames.BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.BILL_STATUS_7) || bill.getBillStatus().equals(ComNames.BILL_STATUS_8);
if (downLoadFlag) {
// 根据订单号,找到订单对应的证书信息
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
Date date = new Date();
// 获取证书第一次下载时间和当前时间比较,如果超过了十五天,则不允许下载
int day = DateUtils.daysOfTwo(date, certBuf.getCreateTime());
if (day > 16) {
return null;
}
// 从数据库中取出数据,返回给客户端.
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = webenterprise.getEnterpriseName() + "功能证书.pfx";
filename = encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是pfx的文件,设置导出文件的响应头部信息
response.setContentType("application/x-pkcs12");
OutputStream os = null;
try {
os = response.getOutputStream();
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
byte[] byteCert = Base64.decode(certBuf.getPfxCert());
os.write(byteCert);
os.flush();
// 关闭os
if (os != null) {
os.close();
}
certBuf.setLastDownloadTime(new Date());
certBuf.setCertDownloadNumber(certBuf.getCertDownloadNumber() + 1);
downLoadCertService.updatePfxCert(certBuf);
// 记录日志
LogUtil.adminlog(sqlSession, "下载pfx证书", "企业名称:" + webenterprise.getEnterpriseName());
return null;
} catch (IOException e) {
// TODO Auto-generated catch block
LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
}
} else {
// 用户未下载过,第一次下载
if (bill.getBillStatus().equals(ComNames.BILL_STATUS_13)) {
// 查询项目产品
Product product = productService.getProduct(bill.getProduct());
// 企业
Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
// 获取产品、RA配置
RaAccount ra = raAccountService.getRaAccount(product.getRa());
// 证书配置
DigitalCert digitalcert = digitalCertService.getDigitalCert(product.getCert());
// 下载证书
String autoidType = "";
Integer autoidValue = 0;
String pfxCert = "";
// 用户ID,用来最终匹配公钥证书和密钥对,一个用户id,只能使用一次,所以考虑使用订单号来作为用户id,避免一个用户只能下载一个证书.
String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
// TODO
String certPass = product.getPassword();
// 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
// 产生CSR证书请求
String certReqBuf = "";
// 算法
String algorithm = digitalCertService.getAlgorithm(digitalcert);
// 下载证书
CertInfo racertinfo = null;
try {
certReqBuf = GenUtil.GenP10(userid, "", algorithm);
racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalcert, uidIdx, certReqBuf, autoidType, autoidValue);
pfxCert = GenUtil.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), false, enterprise.getEnterpriseName());
// 保存证书
downLoadCertService.savePfxCertInfo(racertinfo, bill, ra.getId(), uidIdx, "", autoidType, autoidValue, pfxCert);
// 从数据库中取出数据,返回给客户端.
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = webenterprise.getEnterpriseName() + "通讯证书.pfx";
filename = encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是pfx的文件,设置导出文件的响应头部信息
response.setContentType("application/x-pkcs12");
OutputStream os = null;
os = response.getOutputStream();
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
byte[] byteCert = Base64.decode(pfxCert);
os.write(byteCert);
os.flush();
// 关闭os
if (os != null) {
os.close();
}
// 记录日志
LogUtil.adminlog(sqlSession, "下载pfx证书", "下载成功,企业名称:" + webenterprise.getEnterpriseName());
return null;
} catch (Exception e) {
// TODO: handle exception
LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
}
}
}
return null;
}
use of com.itrus.portal.db.Product in project portal by ixinportal.
the class MakeCertController method update.
// 显示制证详情
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String update(@PathVariable("id") Long id, Model uiModel) throws EncDecException, Exception {
List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
uiModel.addAttribute("makecerts", makecerts);
uiModel.addAttribute("enterpriseSn", makecerts.get(0).get("enterprise_sn"));
DigitalCert digitalcert = null;
ProductSpec productSpec = null;
Product product = null;
Map<String, Object> params = new HashMap<String, Object>();
// 添加组合产品
if (makecerts.get(0).get("is_combined") != null && makecerts.get(0).get("is_combined").equals(1)) {
try {
uiModel.addAttribute("billStr", jsonTool.writeValueAsString(makecerts.get(0)));
} catch (Exception e) {
e.printStackTrace();
}
// 得到三条组合产品的产品信息
for (int i = 1; i < 4; i++) {
if (makecerts.get(0).get("product" + i) == null) {
uiModel.addAttribute("usercertallStr" + i, "{}");
continue;
}
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product" + i));
uiModel.addAttribute("product" + i, product);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
uiModel.addAttribute("digitalcert" + i, digitalcert);
params.put("id", id);
params.put("pid", product.getId());
List<Map<String, Object>> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillAndProductKey", params);
uiModel.addAttribute("makecertexall" + i, makecertexall);
// 获取产品规格
if (makecerts.get(0).containsKey("product_spec" + i) && !"0".equals(makecerts.get(0).get("product_spec" + i))) {
productSpec = productSpecService.getProductSpec((Long) makecerts.get(0).get("product_spec" + i));
}
uiModel.addAttribute("productSpec" + i, productSpec);
try {
uiModel.addAttribute("digitalcertStr" + i, jsonTool.writeValueAsString(digitalcert));
uiModel.addAttribute("productStr" + i, jsonTool.writeValueAsString(product));
uiModel.addAttribute("productSpecStr" + i, jsonTool.writeValueAsString(productSpec));
uiModel.addAttribute("usercertallStr" + i, jsonTool.writeValueAsString(makecertexall));
} catch (Exception e) {
e.printStackTrace();
}
// 解析项目产品中,certinfo配置信息
JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
for (int j = 0; certinfo != null && j < certinfo.size(); j++) {
JSONObject obj = certinfo.getJSONObject(j);
String autoid = obj.getString("autoid");
if (autoid == null)
continue;
String autoidType = obj.getString("autoidType");
String autoidPrev = obj.getString("autoidPrev");
String autoidPrevDate = obj.getString("autoidPrevDate");
String autoidLength = obj.getString("autoidLength");
// 从user_cert表查询,该autoidType的最大值,如果没有最大值,则设置为0
Map param = new HashMap();
String enterpriseId = makecerts.get(0).get("enterprise").toString();
param.put("enterpriseId", makecerts.get(0).get("enterprise"));
param.put("type", autoidType);
Integer autoidValue = null;
if (autoidPrevDate == null)
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditon", param);
else
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditonDate", param);
if (autoidValue == null)
autoidValue = 0;
uiModel.addAttribute("enterpriseId" + i, enterpriseId);
uiModel.addAttribute("autoidType" + i, autoidType);
uiModel.addAttribute("autoidPrev" + i, autoidPrev);
uiModel.addAttribute("autoidLength" + i, autoidLength);
uiModel.addAttribute("autoidValue" + i, autoidValue);
break;
}
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
if (null != makeSealServer) {
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(id, makeSealServer.getSealName()));
}
uiModel.addAttribute("makeSealServer" + i, makeSealServer);
}
}
return "makecert/update1";
}
List<Map> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillKey", id);
uiModel.addAttribute("makecertexall", makecertexall);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", makecerts.get(0).get("cert"));
uiModel.addAttribute("digitalcert", digitalcert);
if (makecerts.get(0).containsKey("product_spec") && !"0".equals(makecerts.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) makecerts.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product"));
uiModel.addAttribute("product", product);
try {
uiModel.addAttribute("billStr", jsonTool.writeValueAsString(makecerts.get(0)));
uiModel.addAttribute("usercertallStr", jsonTool.writeValueAsString(makecertexall));
uiModel.addAttribute("digitalcertStr", jsonTool.writeValueAsString(digitalcert));
uiModel.addAttribute("productStr", jsonTool.writeValueAsString(product));
uiModel.addAttribute("productSpecStr", jsonTool.writeValueAsString(productSpec));
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println(makecerts.get(0).get("product_num"));
// 处理autoid自动编号信息
// 解析项目产品中,certinfo配置信息
JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
for (int i = 0; certinfo != null && i < certinfo.size(); i++) {
JSONObject obj = certinfo.getJSONObject(i);
String autoid = obj.getString("autoid");
if (autoid == null)
continue;
String autoidType = obj.getString("autoidType");
String autoidPrev = obj.getString("autoidPrev");
String autoidPrevDate = obj.getString("autoidPrevDate");
String autoidLength = obj.getString("autoidLength");
// 从user_cert表查询,该autoidType的最大值,如果没有最大值,则设置为0
Map param = new HashMap();
String enterpriseId = makecerts.get(0).get("enterprise").toString();
param.put("enterpriseId", makecerts.get(0).get("enterprise"));
param.put("type", autoidType);
Integer autoidValue = null;
if (autoidPrevDate == null)
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditon", param);
else
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditonDate", param);
if (autoidValue == null)
autoidValue = 0;
uiModel.addAttribute("enterpriseId", enterpriseId);
uiModel.addAttribute("autoidType", autoidType);
uiModel.addAttribute("autoidPrev", autoidPrev);
uiModel.addAttribute("autoidLength", autoidLength);
uiModel.addAttribute("autoidValue", autoidValue);
break;
}
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
if (null != makeSealServer) {
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(id, makeSealServer.getSealName()));
}
uiModel.addAttribute("makeSealServer", makeSealServer);
}
return "makecert/update";
}
use of com.itrus.portal.db.Product in project portal by ixinportal.
the class EnterpriseController method detail.
@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", id);
if (null == enterprise) {
return "status403";
}
uiModel.addAttribute("enterprise", enterprise);
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 10;
}
// 总记录数
Integer count = 0;
// 当前页记录数
Integer itemcount = 0;
// ===0认证信息、1关联用户、2订单列表
if (null == item || 0 == item) {
item = 0;
// 认证信息
BusinessLicense businessLicense = null;
OrgCode orgCode = null;
TaxRegisterCert taxRegisterCert = null;
IdentityCard identityCard = null;
if (null != enterprise.getAuthenticationLevel()) {
// 审核通过:
// 获取企业的认证等级
Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", enterprise.getAuthenticationLevel());
uiModel.addAttribute("certification", certification);
}
if (null != enterprise.getHasBl()) {
businessLicense = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", enterprise.getHasBl());
}
if (null != enterprise.getHasOrgCode()) {
orgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", enterprise.getHasOrgCode());
}
if (null != enterprise.getHasTaxCert()) {
taxRegisterCert = sqlSession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByPrimaryKey", enterprise.getHasTaxCert());
}
if (null != enterprise.getHasIdCard()) {
identityCard = sqlSession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", enterprise.getHasIdCard());
}
uiModel.addAttribute("businessLicense", businessLicense);
uiModel.addAttribute("orgCode", orgCode);
uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
uiModel.addAttribute("identityCard", identityCard);
// 查询增值订单中开户行信息
OpenBankInfoExample obie = new OpenBankInfoExample();
Criteria obiec = obie.createCriteria();
obiec.andEnterpriseEqualTo(enterprise.getId());
obie.setOrderByClause("create_time desc");
List<OpenBankInfo> openBankInfos = sqlSession.selectList("com.itrus.portal.db.OpenBankInfoMapper.selectByExample", obie);
if (openBankInfos != null && openBankInfos.size() > 0) {
uiModel.addAttribute("openBankInfos", openBankInfos);
}
} else if (1 == item) {
item = 1;
// 关联用户
List<UserInfo> userInfos = new ArrayList<UserInfo>();
List<Long> userInfoIds = userInfoEnterpriseService.getUserInfoByEnterprise(enterprise.getId());
if (null != userInfoIds && !userInfoIds.isEmpty()) {
count = userInfoIds.size();
UserInfoExample userInfoExample = new UserInfoExample();
UserInfoExample.Criteria criteria = userInfoExample.or();
criteria.andIdIn(userInfoIds);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
userInfoExample.setOffset(offset);
userInfoExample.setLimit(size);
userInfoExample.setOrderByClause("create_time desc");
userInfos = sqlSession.selectList("com.itrus.portal.db.UserInfoMapper.selectByExample", userInfoExample);
}
itemcount = userInfos.size();
uiModel.addAttribute("userInfos", userInfos);
} else if (2 == item) {
item = 2;
// 订单列表
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
criteria.andEnterpriseEqualTo(enterprise.getId());
criteria.andIsDeleteEqualTo(false);
count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
billExample.setOffset(offset);
billExample.setLimit(size);
billExample.setOrderByClause("create_time desc");
List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
itemcount = billList.size();
uiModel.addAttribute("billList", billList);
Map<Long, Project> projectMap = billService.getProjectMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("projectMap", projectMap);
Map<Long, Product> productMap = billService.getProductMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("productMap", productMap);
Map<Long, UserInfo> userInfoMap = billService.getUserInfoMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("userInfoMap", userInfoMap);
} else if (3 == item) {
item = 3;
// 增值订单列表
ExtraBillExample extraBillExample = new ExtraBillExample();
ExtraBillExample.Criteria criteria = extraBillExample.or();
criteria.andEnterpriseEqualTo(enterprise.getId());
criteria.andIsDeleteEqualTo(false);
count = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.countByExample", extraBillExample);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
extraBillExample.setOffset(offset);
extraBillExample.setLimit(size);
extraBillExample.setOrderByClause("create_time desc");
List<ExtraBill> extraBillList = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByExample", extraBillExample);
itemcount = extraBillList.size();
uiModel.addAttribute("billList", extraBillList);
Map<Long, Project> projectMap = extraBillService.getProjectMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("projectMap", projectMap);
Map<Long, ExtraProduct> productMap = extraBillService.getProductMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("productMap", productMap);
Map<Long, UserInfo> userInfoMap = extraBillService.getUserInfoMapByEnterpriseId(enterprise.getId());
uiModel.addAttribute("userInfoMap", userInfoMap);
}
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
uiModel.addAttribute("itemcount", itemcount);
uiModel.addAttribute("item", item);
return "enterprise/detail";
}
use of com.itrus.portal.db.Product 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.db.Product in project portal by ixinportal.
the class ReviewServiceImpl method sendSmsBySHJJ.
// 拒绝后台的订单,发送短信通知
/**
* 发送审核拒绝短信通知(模版类型:SHJJ)
*
* @param billId
* @return
*/
public boolean sendSmsBySHJJ(Long billId) {
if (null == billId) {
return false;
}
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
if (null == bill) {
return false;
}
// 查询短信模版
// 查找对应项目的消息模版:SHJJ
MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
if (null == messageTemplate) {
logger.error("发送短信失败,未找到对应的鉴证审核消息模版");
return false;
}
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
String content = messageTemplate.getMessageContent();
// 替换特定内容:企业名称:enterpriseName,产品名称:productName,项目名称:projectName,拒绝原因:reason
if (content.contains("enterpriseName")) {
content = content.replaceAll("enterpriseName", enterprise.getEnterpriseName());
}
if (content.contains("productName")) {
content = content.replaceAll("productName", product.getName());
}
if (content.contains("projectName")) {
content = content.replaceAll("projectName", project.getName());
}
if (content.contains("reason")) {
content = content.replaceAll("reason", bill.getCancelReason());
}
// 发送短信
try {
if (smsSendService.sendRefuseReview(userInfo.getmPhone(), content, "SHJJ", project.getId(), userInfo.getUniqueId(), bill.getBillId())) {
// 发送成功
return true;
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
Aggregations