use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method choiceExtraProduct.
/**
* 用户点击购要购买某个产品,返回这个产品对应的信息.购买信息.对应于:应用详情页面
*
* @param productId
* ,增值产品id
* @param old_billId
* @param request
* @param uiModel
* @return
*/
@RequestMapping("/choiceExtraProduct")
public String choiceExtraProduct(@RequestParam(value = "productId", required = true) Long productId, // enterpriseId,
@RequestParam(value = "old_billId", required = false) Long old_billId, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
// 判断用户和企业信息是否存在了,不存在不能购买
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
if (null == enterprise || null == userInfo) {
return "";
}
ExtraProduct product = null;
try {
product = extraProductService.selectByPrimaryKey(productId);
if (null == product) {
uiModel.addAttribute("errorMsg", "产品不存在");
return "client/errorpage";
}
uiModel.addAttribute("webExtraproduct", product);
// 产品对应的服务商信息
Long serviceProviderId = product.getServiceProvider();
ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(serviceProviderId);
uiModel.addAttribute("webServiceProvider", serviceProvider);
// 服务商对应的网点信息
List<ServiceHall> serviceHalls = new ArrayList<>();
serviceHalls = serviceHallService.getServiceHalls(serviceProviderId);
uiModel.addAttribute("webServiceHalls", serviceHalls);
// 产品对应的规格信息
List<ExtraProductSpec> extraProductSpecs = extraProductSpecService.getSpecByProductIdValid(product.getId());
uiModel.addAttribute("extraProductSpecs", extraProductSpecs);
Set<String> periodSet = new LinkedHashSet<>();
Set<String> specSet = new LinkedHashSet<>();
Map<String, Map<String, Object>> specPeriodMap = new HashMap<>();
for (ExtraProductSpec eps : extraProductSpecs) {
Map<String, Object> map = new HashMap<>();
map.put("id", eps.getId());
map.put("price", eps.getPrice());
specPeriodMap.put(eps.getSpec() + "||" + eps.getCycle1() + ";" + eps.getCycleUnit(), map);
String spec = eps.getSpec();
specSet.add(spec);
periodSet.add(eps.getCycle1() + ";" + eps.getCycleUnit());
}
ObjectMapper objectMapper = new ObjectMapper();
uiModel.addAttribute("specSet", specSet);
uiModel.addAttribute("periodSet", periodSet);
uiModel.addAttribute("specPeriodMapJson", objectMapper.writeValueAsString(specPeriodMap));
} catch (Exception e) {
// TODO: handle exception
}
// 仅用户授权产品.发票校验产品,直接跳转发票校验
if (null != product.getProductOpenType() && product.getProductOpenType().equals(ComNames.PRODUCT_OPEN_TYPE_1)) {
// 查询用户是否曾经买过了该产品对于的订单,如果买了,则提示只能购买一次
List<ExtraBill> bills = extraBillService.getHasByExtraBill(userInfo.getId(), enterprise.getId(), productId);
if (null != bills && bills.size() > 0) {
uiModel.addAttribute("ifHasOpen", 1);
}
return "client/yingyongxiangqing_jyhsq";
}
return "client/yingyongxiangqing";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class DownLoadCertWebController method downloadPfxCert.
/**
* 用户下载pfx证书的接口
* @param id,订单id
* @param session
* @param request
* @param response
* @return
*/
@RequestMapping("/pfx/{id}")
public String downloadPfxCert(@PathVariable(value = "id") Long id, HttpSession session, HttpServletRequest request, HttpServletResponse response) {
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
return null;
}
Integer uidIdx = 1;
Bill bill = billService.getBill(id);
if (null == bill) {
return null;
}
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);
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(webuserInfo.getProject());
userlog.setType("用户下载证书pfx");
userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功");
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
return null;
} catch (IOException e) {
UserLog userlog = new UserLog();
userlog.setProject(bill.getProject());
userlog.setType("用户下载证书pfx");
userlog.setInfo(webenterprise.getEnterpriseName() + "失败,错误信息:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
}
} 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,用来最终匹配公钥证书和密钥对
String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
// TODO 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
String certPass = product.getPassword();
// 产生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);
// pfxCert = GenUtil2.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), pfxCert, false, enterprise.getEnterpriseName());
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();
}
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(bill.getProject());
userlog.setType("用户下载证书pfx");
userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功,企业名称:" + webenterprise.getEnterpriseName());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
return null;
} catch (Exception e) {
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(bill.getProject());
userlog.setType("用户下载证书pfx");
userlog.setInfo(webenterprise.getEnterpriseName() + "失败,错误信息:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
}
}
}
return null;
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class DownLoadCertWebController method downLoadCertPage.
// 进入下载证书页面
@RequestMapping("/downLoadCertPage/{id}")
public String downLoadCertPage(@PathVariable(value = "id") Long id, HttpSession session, Model uiModel) {
// 是否登录
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
// 登录状态失效,跳转到注册页面
return "redirect:/userInfoWeb/denglu.html";
}
Bill bill = billService.getBill(id);
if (null == bill) {
logger.error("id为" + id + "的订单不存在");
return "redirect:/userInfoWeb/denglu.html";
}
// 订单是否为当前用户当前企业
if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
logger.error(webuserInfo.getmPhone() + "不能操作订单" + bill.getBillId());
return "redirect:/userInfoWeb/denglu.html";
}
Product product = productService.getProduct(bill.getProduct());
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
// 获取产品规格
ProductSpec productSpec = null;
if (null != bill.getProductSpec() && !"0".equals(bill.getProductSpec())) {
productSpec = productSpecService.getProductSpec(bill.getProductSpec());
}
// 获取订单在线支付方式
if (bill.getOnPayInfo() != null) {
OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
uiModel.addAttribute("onPayInfo", onPayInfo);
} else if (bill.getPayInfo() != null) {
PayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", bill.getPayInfo());
uiModel.addAttribute("payInfo", payInfo);
}
// 审核记录信息
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
uiModel.addAttribute("bill", bill);
uiModel.addAttribute("product", product);
uiModel.addAttribute("digitalCert", digitalCert);
uiModel.addAttribute("productSpec", productSpec);
// 当是pfx证书的时候,告知页面
boolean pfxFlag = digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX) && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2);
if (pfxFlag) {
uiModel.addAttribute("ispfx", 1);
}
List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
List<Map> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillKey", id);
uiModel.addAttribute("makecerts", makecerts);
uiModel.addAttribute("enterpriseSn", makecerts.get(0).get("enterprise_sn"));
DigitalCert digitalcert = null;
Map<String, Object> params = new HashMap<String, Object>();
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;
}
return "ixinweb/dingdanxiangqing_xiazaiqueren";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class UnlockKeyBillController method loadProxyPdf.
@RequestMapping("/loadPorxyZSJSPdf")
public String loadProxyPdf(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "mPhone", required = false) String mPhone, HttpSession session, HttpServletRequest request, HttpServletResponse response) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
UserInfo webuserInfo = null;
if (null != userCert && null != userCert.getUserinfo()) {
webuserInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
}
String firstMphone = "";
// 手机号处理,如果用户第一次申请解锁,而且没有绑定手机号,则先取用户输入的,再取证书绑定的,实在没有就放空
if (StringUtils.isNotBlank(mPhone)) {
firstMphone = mPhone;
} else if (null != webuserInfo) {
firstMphone = webuserInfo.getmPhone();
}
try {
enterpriseName = URLDecoder.decode(enterpriseName, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
InputStream proxyIn = null;
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
try {
proxyIn = UserInfoWebController.class.getClassLoader().getResourceAsStream("/porxyZSJS.pdf");
response.reset();
String filename = "授权书.pdf";
filename = encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/pdf");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
byte[] bos = PDFUtils.readPDF2(proxyIn, enterpriseName, keySn, certSn, firstMphone).toByteArray();
os.write(bos);
os.flush();
// 关闭os
if (os != null) {
os.close();
}
if (null != proxyIn) {
proxyIn.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class UnlockKeyBillController method getUnlockProducts.
/**
* 返回key对应的解锁产品列表
* 1.证书有绑定的用户,用户选择自助解锁,不需要进行短信码校验,直接提交
* 2.证书有绑定的用户,用户选择人工解锁(因为之前绑定的手机号可能没有了),进行短信校验后提交
* 3.证书没有绑定的用户,用户只能选择人工解锁(后台不返回自助解锁的产品了),进行短信码校验后,直接提交
* @param CertSn
* @param keySn
* @param uiModel
* @param request
* @return
*/
@RequestMapping("/getUnlockProducts")
public String getUnlockProducts(@RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel, HttpServletRequest request) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
return ComNames.CLIENTFW_ERRORPAGE;
}
// if (null == userCert.getUserinfo()) {
// uiModel.addAttribute("errorMsg", "该证书尚未绑定用户,请先绑定后再使用");
// return ComNames.CLIENTFW_ERRORPAGE;
// }
UserInfo webUserInfo = null;
uiModel.addAttribute("has_userInfo", 0);
if (null != userCert.getUserinfo()) {
webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
uiModel.addAttribute("userInfo", webUserInfo);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
uiModel.addAttribute("has_userInfo", 1);
}
Enterprise enterprise = enterpriseService.getEntByName(enterpriseName);
uiModel.addAttribute("has_enterpriseInfo", 0);
if (null != enterprise) {
uiModel.addAttribute("enterprise", enterprise);
uiModel.addAttribute("has_enterpriseInfo", 1);
}
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
return ComNames.CLIENTFW_ERRORPAGE;
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
if (null == products || products.isEmpty()) {
uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
return ComNames.CLIENTFW_ERRORPAGE;
}
uiModel.addAttribute("products", products);
// 电子开票服务
Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
if (null == products.get(0).geteBill()) {
uiModel.addAttribute("ereceiptMapSize", 0);
}
uiModel.addAttribute("ereceiptMap", ereceiptMap);
return "clientFW/unlock_out";
}
Aggregations