use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class BillWebController method showTwo.
/**
* 订单详情
*
* @param id
* @param uiModel
* @param autoShowPfxMessage 从订单信息页面 点击下载证书跳转到下载证书页面,若为 1 自动弹出短信输入框,
* @return
*/
@RequestMapping(value = "/bill/{id}.html", produces = "text/html")
public String showTwo(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "typenum", required = false) String typenum, @RequestParam(value = "num", required = false) Long num, @RequestParam(value = "updateAuditBill", required = false) String updateAuditBill, @RequestParam(value = "autoShowPfxMessage", required = false) String autoShowPfxMessage, HttpServletRequest request) {
HttpSession session = request.getSession();
Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectDingdanByBill", id);
if (billAll.size() == 0) {
return "redirect:/userInfoWeb/denglu.html";
}
// 解析订单中uid信息{"ADDTIONAL_FIELD1_1":"","ADDTIONAL_FIELD3_1":"","ADDTIONAL_FIELD4_1":"G2016071301","inputName":"inputValue"}\
Bill bill = billService.getBill(id);
if (null != bill.getUid()) {
uiModel.addAttribute("uid", bill.getUid().toString());
}
if (null != bill.getUid1()) {
uiModel.addAttribute("uid1", bill.getUid1().toString());
}
if (null != bill.getUid2()) {
uiModel.addAttribute("uid2", bill.getUid2().toString());
}
if (null != bill.getUid3()) {
uiModel.addAttribute("uid3", bill.getUid3().toString());
}
/*if(!bill.getUid().equals("{}")){
List<String> listStr = new ArrayList<String>();
JSONObject uid = JSONObject.parseObject(bill.getUid().toString());
for(int i= 0; i< (int)bill.getProductNum();i++){
//uiModel.addAttribute("uid"+ (i+1), uid.get(("ADDTIONAL_FIELD"+ (i+ 1)) + "_1"));
listStr.add(uid.get(("ADDTIONAL_FIELD1_"+ (i+ 1))).toString());
}
uiModel.addAttribute("listStr", listStr);
}*/
// 得到证书信息项
Product pdt = productService.getProductById(bill.getProduct());
uiModel.addAttribute("pdt", pdt);
if (pdt.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr", escapeTool.javascript(pdt.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr", "[]");
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
String descript = billAll.get(0).get("descript").toString().replace("\r\n", "<br/>");
uiModel.addAttribute("descript", descript);
// 如配置了产品规格,则将产品规格返回:产品期限、产品描述
if (billAll.get(0).containsKey("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
ProductSpec productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
descript = "产品期限:" + productSpec.getProductValid() + "年<br/>" + "产品描述:" + productSpec.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript", descript);
}
// 组合产品以及产品规格以及证书信息项
String descript1 = "";
String descript2 = "";
String descript3 = "";
if (billAll.get(0).containsKey("product_spec1") && !"0".equals(billAll.get(0).get("product_spec1"))) {
ProductSpec productSpec1 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec1"));
descript1 = "产品期限:" + productSpec1.getProductValid() + "年<br/>" + "产品描述:" + productSpec1.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript1", descript1);
}
if (billAll.get(0).containsKey("product_spec2") && !"0".equals(billAll.get(0).get("product_spec2"))) {
ProductSpec productSpec2 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec2"));
descript2 = "产品期限:" + productSpec2.getProductValid() + "年<br/>" + "产品描述:" + productSpec2.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript2", descript2);
}
if (billAll.get(0).containsKey("product_spec3") && !"0".equals(billAll.get(0).get("product_spec3"))) {
ProductSpec productSpec3 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec3"));
descript3 = "产品期限:" + productSpec3.getProductValid() + "年<br/>" + "产品描述:" + productSpec3.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript3", descript3);
}
if (null != bill.getProduct1()) {
Product product1 = productService.getProductById(bill.getProduct1());
uiModel.addAttribute("product1", product1);
if (product1.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr1", escapeTool.javascript(product1.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr1", "[]");
}
}
if (null != bill.getProduct2()) {
Product product2 = productService.getProductById(bill.getProduct2());
uiModel.addAttribute("product2", product2);
if (product2.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr2", escapeTool.javascript(product2.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr2", "[]");
}
}
if (null != bill.getProduct3()) {
Product product3 = productService.getProductById(bill.getProduct3());
uiModel.addAttribute("product3", product3);
if (product3.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr3", escapeTool.javascript(product3.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr3", "[]");
}
}
if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo || !(billAll.get(0).get("enterprise").equals(enterprise.getId()))) {
// 登录状态失效,跳转到登录页面
return "redirect:/userInfoWeb/denglu.html";
}
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
// 获取产品的认证等级需要认证的项
Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", billAll.get(0).get("authentication"));
List<Map> courierinfos = new ArrayList<Map>();
if (billAll.get(0).get("delivery") != null) {
courierinfos = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectItemsByCourierInfo", billAll.get(0).get("id"));
uiModel.addAttribute("courierinfos", courierinfos);
}
Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
Map<Long, DigitalCert> certmap = sqlSession.selectMap("com.itrus.portal.db.DigitalCertMapper.selectByExample", null, "id");
// 判断订单对应的产品是否配置有数字证书
Product product = productService.getProductById((Long) billAll.get(0).get("product"));
if (null == product.getCert()) {
uiModel.addAttribute("billhasnotcert", 1);
// 判断无数字证书的订单是否需要配送
if (null != billAll.get(0).get("delivery")) {
uiModel.addAttribute("billneedtodelivery", 1);
} else {
uiModel.addAttribute("billneedtodelivery", 0);
}
} else {
uiModel.addAttribute("billhasnotcert", 0);
}
// 根据省市区code值获取省市区最新名称
String regionCodes = billAll.get(0).get("d_codes") == null ? "" : billAll.get(0).get("d_codes").toString();
String detailAdds = billAll.get(0).get("d_adds") == null ? "" : billAll.get(0).get("d_adds").toString();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
detailAdds = regionName + detailAdds;
}
uiModel.addAttribute("detailAdd", detailAdds);
if (null != billAll.get(0).get("u_adds")) {
String regionCodes1 = billAll.get(0).get("u_codes").toString();
String detailAdds1 = billAll.get(0).get("u_adds").toString();
if (StringUtils.isNotBlank(regionCodes1) && regionCodes1.indexOf("@") >= 0) {
String[] codes1 = regionCodes1.split("@");
String regionName1 = sysRegionService.getAllName(codes1[1], codes1[2], codes1[3]);
detailAdds1 = regionName1 + detailAdds1;
}
uiModel.addAttribute("detailAdd1", detailAdds1);
}
int num1 = 0;
if (num != null) {
num1 = Integer.parseInt(num.toString());
}
// 该订单是否有价格优惠记录
PreferentialRecord pr = preferentialRecordService.selectPreferentialRecordSByBillId(id);
if (null != pr) {
// 原价
Double originalCost = pr.getOriginalPrice();
// 优惠价
Double preCost = pr.getPreferentialPrice();
uiModel.addAttribute("originalCost", originalCost);
uiModel.addAttribute("preCost", preCost);
}
uiModel.addAttribute("num", num1);
uiModel.addAttribute("billAll", billAll);
uiModel.addAttribute("receiptmap", receiptmap);
uiModel.addAttribute("ereceiptmap", ereceiptmap);
uiModel.addAttribute("certmap", certmap);
uiModel.addAttribute("certification", certification);
uiModel.addAttribute("product", product);
// 根据订单id返回签章模版
try {
makeSeal((Long) billAll.get(0).get("id"), uiModel);
} catch (EncDecException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (typenum == null)
typenum = "0";
// 判断是否是审核中进入的订单修改页面
if (StringUtils.isNotBlank(updateAuditBill) && updateAuditBill.equals("1")) {
// 判断订单状态是否1,2,3,10
List<Integer> modifiedStatus = new ArrayList<Integer>();
modifiedStatus.add(ComNames.BILL_STATUS_1);
modifiedStatus.add(ComNames.BILL_STATUS_2);
modifiedStatus.add(ComNames.BILL_STATUS_3);
modifiedStatus.add(ComNames.BILL_STATUS_10);
// 不在以上状态中
if (modifiedStatus.indexOf(billAll.get(0).get("bill_status")) == -1) {
// 重定向
return "redirect:/billWeb/bill/" + id + ".html";
}
return "ixinweb/dingdanxiangqing_shenhezhong_chongxintijiao";
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
// 支付待确认时间
if (billAll.get(0).get("pay_info") != null) {
List<PayInfo> pays = sqlSession.selectList("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
PayInfo dp = pays.get(0);
uiModel.addAttribute("pay_time", dp.getCreateTime());
uiModel.addAttribute("pay_confirm_time", dp.getPayConfirmTime());
}
// 判断订单状态
if (billAll.get(0).get("bill_status").equals(1) || billAll.get(0).get("bill_status").equals(2)) {
// 更新证书前 ,显示旧证书
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
Object[] info = getCertInfo(oldUserCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("oldUserCert", oldUserCert);
// 根据订单id返回签章模版
try {
makeSeal(oldUserCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "ixinweb/dingdanxiangqing_daizhifu";
} else if (billAll.get(0).get("bill_status").equals(3) || billAll.get(0).get("bill_status").equals(4) || billAll.get(0).get("bill_status").equals(11) || billAll.get(0).get("bill_status").equals(10)) {
// 更新证书前 ,显示旧证书
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
Object[] info = getCertInfo(oldUserCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("oldUserCert", oldUserCert);
// 根据订单id返回签章模版
try {
makeSeal(oldUserCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
if (billAll.get(0).get("bill_status").equals(11)) {
PayInfo payinfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
uiModel.addAttribute("payinfo", payinfo);
}
if (Integer.parseInt(typenum) == 1) {
if (null != product && product.getProject() != null) {
EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
qqEx.andProjectIdEqualTo(product.getProject());
EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseE);
if (enterpriseqq != null && enterpriseqq.getEnterpriseQqLinks() != null) {
uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
}
}
return "ixinweb/dingdanxiangqing_chongxintijiao";
} else {
return "ixinweb/dingdanxiangqing_dengdaishenhe";
}
} else if (billAll.get(0).get("bill_status").equals(12)) {
// 待更新
List<UserCert> userCerts = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
if (userCerts.size() > 0) {
UserCert userCert = userCerts.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCerts.get(0));
// 根据订单id返回签章模版
try {
makeSeal(userCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "ixinweb/dingdanxiangqing_gengxinshenhetongguo";
} else if (billAll.get(0).get("bill_status").equals(5) || billAll.get(0).get("bill_status").equals(6) || billAll.get(0).get("bill_status").equals(7)) {
// 初购产品 已制证 在订单详情显示 证书信息
if ((Integer) billAll.get(0).get("bill_status") >= 6) {
List<String> certStatus = new ArrayList<String>();
List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
if (certs != null && certs.size() > 0) {
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
UserCert userCert = certs.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCert);
}
}
// 返回老证书序列号
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
try {
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
makeSeal(oldUserCert.getBill(), uiModel);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (EncDecException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
if (courierinfos.size() > 0) {
uiModel.addAttribute("couriercount", courierinfos.size());
return "ixinweb/dingdanxiangqing_yifahuo";
} else {
return "ixinweb/dingdanxiangqing_dengdaifahuo";
}
} else if (billAll.get(0).get("bill_status").equals(8)) {
List<String> certStatus = new ArrayList<String>();
List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
if (certs != null && certs.size() > 0) {
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
UserCert userCert = certs.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCert);
}
// 返回老证书序列号
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
try {
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return "ixinweb/dingdanxiangqing_yifahuo";
// 下载证书
} else if (billAll.get(0).get("bill_status").equals(13)) {
uiModel.addAttribute("autoShowPfxMessage", autoShowPfxMessage);
return "ixinweb/dingdanxiangqing_xiazaizhengshu";
} else {
return "ixinweb/dingdanxiangqing_yichuihui";
}
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class BillClientController method reNewCertConfirm.
// 订单详情,待更新确认
@RequestMapping(value = "/reNewCertConfirm/{id}", produces = "text/html")
public String reNewCertConfirm(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
if (null == userInfo || null == enterprise) {
return ComNames.DENG_LU_CLIENT;
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
Map param = new HashMap();
// 设置查询条件,选择属于当前用户,当前企业的订单
param.put("id", id);
// param.put("userinfoid", userInfo.getId());
// param.put("enterpriseid", enterprise.getId());
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductBillCertById", param);
if (0 == billAll.size()) {
return ComNames.DENG_LU_CLIENT;
}
uiModel.addAttribute("bills", billAll.get(0));
// 获取数字证书
Product product = productService.getProduct((Long) billAll.get(0).get("product"));
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
// 获取产品规格
ProductSpec productSpec = null;
if (null != billAll.get(0).get("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
uiModel.addAttribute("digitalCert", digitalCert);
// 返回订单对应的老证书的base64
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectCertBufByBillId", id);
if (null != certBuf) {
uiModel.addAttribute("oldCertB64", certBuf.getCertBuf().replaceAll("\n", ""));
}
// 判断是否有签章服务,有则显示授权
if (null != product.getMakeSealServer()) {
uiModel.addAttribute("makesealserver", product.getMakeSealServer());
uiModel.addAttribute("billId", billAll.get(0).get("id"));
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
try {
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
} catch (EncDecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
}
// TODO
return "clientFW/dingdanxiangqing_gengxinqueren";
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class BillClientController method showTwo.
/**
* 订单详情
*
* @param id
* @param uiModel
* @param autoShowPfxMessage 从订单信息页面 点击下载证书跳转到下载证书页面,若为 1 自动弹出短信输入框,
* @return
*/
@RequestMapping(value = "/bill/{id}.html", produces = "text/html")
public String showTwo(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "typenum", required = false) String typenum, @RequestParam(value = "num", required = false) Long num, @RequestParam(value = "updateAuditBill", required = false) String updateAuditBill, @RequestParam(value = "autoShowPfxMessage", required = false) String autoShowPfxMessage, HttpServletRequest request) {
HttpSession session = request.getSession();
Boolean verifyCodeStatus = (Boolean) session.getAttribute(ComNames.WEB_VERIFY_CODE_STATUS);
Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
// 登录状态失效,跳转到登录页面
return ComNames.DENG_LU_CLIENT;
}
if (userInfo != null && enterprise == null) {
// 登录未获取到企业信息,跳转到选择企业页面
return ComNames.DENG_LU_CLIENT;
}
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectDingdanByBill", id);
if (billAll.size() == 0) {
return ComNames.DENG_LU_CLIENT;
}
// 解析订单中uid信息{"ADDTIONAL_FIELD1_1":"","ADDTIONAL_FIELD3_1":"","ADDTIONAL_FIELD4_1":"G2016071301","inputName":"inputValue"}\
Bill bill = billService.getBill(id);
if (null != bill.getUid()) {
uiModel.addAttribute("uid", bill.getUid().toString());
}
if (null != bill.getUid1()) {
uiModel.addAttribute("uid1", bill.getUid1().toString());
}
if (null != bill.getUid2()) {
uiModel.addAttribute("uid2", bill.getUid2().toString());
}
if (null != bill.getUid3()) {
uiModel.addAttribute("uid3", bill.getUid3().toString());
}
/*if(!bill.getUid().equals("{}")){
List<String> listStr = new ArrayList<String>();
JSONObject uid = JSONObject.parseObject(bill.getUid().toString());
for(int i= 0; i< (int)bill.getProductNum();i++){
//uiModel.addAttribute("uid"+ (i+1), uid.get(("ADDTIONAL_FIELD"+ (i+ 1)) + "_1"));
listStr.add(uid.get(("ADDTIONAL_FIELD1_"+ (i+ 1))).toString());
}
uiModel.addAttribute("listStr", listStr);
}*/
// 得到证书信息项
Product pdt = productService.getProductById(bill.getProduct());
uiModel.addAttribute("pdt", pdt);
if (pdt.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr", escapeTool.javascript(pdt.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr", "[]");
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
String descript = billAll.get(0).get("descript").toString().replace("\r\n", "<br/>");
uiModel.addAttribute("descript", descript);
// 如配置了产品规格,则将产品规格返回:产品期限、产品描述
if (billAll.get(0).containsKey("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
ProductSpec productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
descript = "产品期限:" + productSpec.getProductValid() + "年<br/>" + "产品描述:" + productSpec.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript", descript);
}
// 组合产品以及产品规格以及证书信息项
String descript1 = "";
String descript2 = "";
String descript3 = "";
if (billAll.get(0).containsKey("product_spec1") && !"0".equals(billAll.get(0).get("product_spec1"))) {
ProductSpec productSpec1 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec1"));
descript1 = "产品期限:" + productSpec1.getProductValid() + "年<br/>" + "产品描述:" + productSpec1.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript1", descript1);
}
if (billAll.get(0).containsKey("product_spec2") && !"0".equals(billAll.get(0).get("product_spec2"))) {
ProductSpec productSpec2 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec2"));
descript2 = "产品期限:" + productSpec2.getProductValid() + "年<br/>" + "产品描述:" + productSpec2.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript2", descript2);
}
if (billAll.get(0).containsKey("product_spec3") && !"0".equals(billAll.get(0).get("product_spec3"))) {
ProductSpec productSpec3 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec3"));
descript3 = "产品期限:" + productSpec3.getProductValid() + "年<br/>" + "产品描述:" + productSpec3.getDescript().replace("\r\n", "<br/>");
uiModel.addAttribute("descript3", descript3);
}
if (null != bill.getProduct1()) {
Product product1 = productService.getProductById(bill.getProduct1());
uiModel.addAttribute("product1", product1);
if (product1.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr1", escapeTool.javascript(product1.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr1", "[]");
}
}
if (null != bill.getProduct2()) {
Product product2 = productService.getProductById(bill.getProduct2());
uiModel.addAttribute("product2", product2);
if (product2.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr2", escapeTool.javascript(product2.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr2", "[]");
}
}
if (null != bill.getProduct3()) {
Product product3 = productService.getProductById(bill.getProduct3());
uiModel.addAttribute("product3", product3);
if (product3.getCertinfo() != null) {
uiModel.addAttribute("certinfoStr3", escapeTool.javascript(product3.getCertinfo()));
} else {
uiModel.addAttribute("certinfoStr3", "[]");
}
}
if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo || !(billAll.get(0).get("enterprise").equals(enterprise.getId()))) {
// 登录状态失效,跳转到登录页面
return ComNames.DENG_LU_CLIENT;
}
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
// 获取产品的认证等级需要认证的项
Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", billAll.get(0).get("authentication"));
List<Map> courierinfos = new ArrayList<Map>();
if (billAll.get(0).get("delivery") != null) {
courierinfos = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectItemsByCourierInfo", billAll.get(0).get("id"));
uiModel.addAttribute("courierinfos", courierinfos);
}
Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
Map<Long, DigitalCert> certmap = sqlSession.selectMap("com.itrus.portal.db.DigitalCertMapper.selectByExample", null, "id");
// 判断订单对应的产品是否配置有数字证书
Product product = productService.getProductById((Long) billAll.get(0).get("product"));
if (null == product.getCert()) {
uiModel.addAttribute("billhasnotcert", 1);
// 判断无数字证书的订单是否需要配送
if (null != billAll.get(0).get("delivery")) {
uiModel.addAttribute("billneedtodelivery", 1);
} else {
uiModel.addAttribute("billneedtodelivery", 0);
}
} else {
uiModel.addAttribute("billhasnotcert", 0);
}
// 根据省市区code值获取省市区最新名称
String regionCodes = billAll.get(0).get("d_codes") == null ? "" : billAll.get(0).get("d_codes").toString();
String detailAdds = billAll.get(0).get("d_adds") == null ? "" : billAll.get(0).get("d_adds").toString();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
detailAdds = regionName + detailAdds;
}
uiModel.addAttribute("detailAdd", detailAdds);
if (null != billAll.get(0).get("u_adds")) {
String regionCodes1 = billAll.get(0).get("u_codes").toString();
String detailAdds1 = billAll.get(0).get("u_adds").toString();
if (StringUtils.isNotBlank(regionCodes1) && regionCodes1.indexOf("@") >= 0) {
String[] codes1 = regionCodes1.split("@");
String regionName1 = sysRegionService.getAllName(codes1[1], codes1[2], codes1[3]);
detailAdds1 = regionName1 + detailAdds1;
}
uiModel.addAttribute("detailAdd1", detailAdds1);
}
int num1 = 0;
if (num != null) {
num1 = Integer.parseInt(num.toString());
}
// 该订单是否有价格优惠记录
PreferentialRecord pr = preferentialRecordService.selectPreferentialRecordSByBillId(id);
if (null != pr) {
// 原价
Double originalCost = pr.getOriginalPrice();
// 优惠价
Double preCost = pr.getPreferentialPrice();
uiModel.addAttribute("originalCost", originalCost);
uiModel.addAttribute("preCost", preCost);
}
uiModel.addAttribute("num", num1);
uiModel.addAttribute("billAll", billAll);
uiModel.addAttribute("receiptmap", receiptmap);
uiModel.addAttribute("ereceiptmap", ereceiptmap);
uiModel.addAttribute("certmap", certmap);
uiModel.addAttribute("certification", certification);
uiModel.addAttribute("product", product);
// 根据订单id返回签章模版
try {
makeSeal((Long) billAll.get(0).get("id"), uiModel);
} catch (EncDecException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (typenum == null)
typenum = "0";
// 判断是否是审核中进入的订单修改页面
if (StringUtils.isNotBlank(updateAuditBill) && updateAuditBill.equals("1")) {
// 判断订单状态是否1,2,3,10
List<Integer> modifiedStatus = new ArrayList<Integer>();
modifiedStatus.add(ComNames.BILL_STATUS_1);
modifiedStatus.add(ComNames.BILL_STATUS_2);
modifiedStatus.add(ComNames.BILL_STATUS_3);
modifiedStatus.add(ComNames.BILL_STATUS_10);
// 不在以上状态中
if (modifiedStatus.indexOf(billAll.get(0).get("bill_status")) == -1) {
// 重定向
return "redirect:/billClient/bill/" + id + ".html";
}
return "clientFW/dingdanxiangqing_shenhezhong_chongxintijiao";
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
// 支付待确认时间
if (billAll.get(0).get("pay_info") != null) {
List<PayInfo> pays = sqlSession.selectList("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
PayInfo dp = pays.get(0);
uiModel.addAttribute("pay_time", dp.getCreateTime());
uiModel.addAttribute("pay_confirm_time", dp.getPayConfirmTime());
}
// 判断订单状态
if (billAll.get(0).get("bill_status").equals(1) || billAll.get(0).get("bill_status").equals(2)) {
// 更新证书前 ,显示旧证书
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
Object[] info = getCertInfo(oldUserCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("oldUserCert", oldUserCert);
// 根据订单id返回签章模版
try {
makeSeal(oldUserCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "clientFW/dingdanxiangqing_daizhifu";
} else if (billAll.get(0).get("bill_status").equals(3) || billAll.get(0).get("bill_status").equals(4) || billAll.get(0).get("bill_status").equals(11) || billAll.get(0).get("bill_status").equals(10)) {
// 更新证书前 ,显示旧证书
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
Object[] info = getCertInfo(oldUserCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("oldUserCert", oldUserCert);
// 根据订单id返回签章模版
try {
makeSeal(oldUserCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
if (billAll.get(0).get("bill_status").equals(11)) {
PayInfo payinfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
uiModel.addAttribute("payinfo", payinfo);
}
if (Integer.parseInt(typenum) == 1) {
return "clientFW/dingdanxiangqing_chongxintijiao";
} else {
return "clientFW/dingdanxiangqing_daishenhe";
}
} else if (billAll.get(0).get("bill_status").equals(12)) {
// 待更新
List<UserCert> userCerts = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
if (userCerts.size() > 0) {
UserCert userCert = userCerts.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCerts.get(0));
// 根据订单id返回签章模版
try {
makeSeal(userCert.getBill(), uiModel);
} catch (EncDecException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "clientFW/dingdanxiangqing_gengxinshenhetongguo";
} else if (billAll.get(0).get("bill_status").equals(5) || billAll.get(0).get("bill_status").equals(6) || billAll.get(0).get("bill_status").equals(7)) {
// 初购产品 已制证 在订单详情显示 证书信息
if ((Integer) billAll.get(0).get("bill_status") >= 6) {
List<String> certStatus = new ArrayList<String>();
List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
if (certs != null && certs.size() > 0) {
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
UserCert userCert = certs.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCert);
}
}
// 返回老证书序列号
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
try {
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
makeSeal(oldUserCert.getBill(), uiModel);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (EncDecException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
if (courierinfos.size() > 0) {
uiModel.addAttribute("couriercount", courierinfos.size());
return "clientFW/dingdanxiangqing_yifahuo";
} else {
return "clientFW/dingdanxiangqing_dengdaifahuo";
}
} else if (billAll.get(0).get("bill_status").equals(8)) {
List<String> certStatus = new ArrayList<String>();
List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
if (certs != null && certs.size() > 0) {
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
UserCert userCert = certs.get(0);
Object[] info = getCertInfo(userCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", userCert);
}
// 返回老证书序列号
if (billAll.get(0).get("old_user_cert") != null) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
try {
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// 解锁订单,返回证书信息
if (null != product && null != product.getKeyUnlockType()) {
UserCert unlockUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("unlock_user_cert"));
if (null != unlockUserCert) {
Object[] info = getCertInfo(unlockUserCert);
uiModel.addAttribute("remainingDays", info[0]);
uiModel.addAttribute("owner", info[1]);
uiModel.addAttribute("userCert", unlockUserCert);
}
}
return "clientFW/dingdanxiangqing_yifahuo";
// 下载证书
} else if (billAll.get(0).get("bill_status").equals(13)) {
uiModel.addAttribute("autoShowPfxMessage", autoShowPfxMessage);
return "clientFW/dingdanxiangqing_xiazaizhengshu";
} else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_14) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15) || bill.getBillStatus().equals(ComNames.BILL_STATUS_16) || bill.getBillStatus().equals(ComNames.BILL_STATUS_17) || bill.getBillStatus().equals(ComNames.BILL_STATUS_18)) {
Proxy proxy = proxyService.getProxyByBillId(bill.getId());
OnPayInfo onPayInfo = onPayInfoService.selectByPrimaryKey(bill.getOnPayInfo());
UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
uiModel.addAttribute("mPhone", userInfo.getmPhone());
uiModel.addAttribute("userCert", userCert);
uiModel.addAttribute("product", product);
uiModel.addAttribute("bill", bill);
uiModel.addAttribute("onPayInfo", onPayInfo);
if (null != proxy) {
// 授权书不一定有
uiModel.addAttribute("proxy", proxy);
}
// 解锁订单对应的订单状态
if (bill.getBillStatus().equals(ComNames.BILL_STATUS_14)) {
// * 2.订单处于已支付,待解锁审批,则跳转查询页面,
return "clientFW/dengdaishenhe_unlock";
} else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
// * 3.订单为审批拒绝,跳转审核拒绝重新提交页面
return "clientFW/dengdaishenhe_unlock";
} else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_16)) {
// * 4.订单为审批通过,待解锁,跳转解锁页面
return "clientFW/unlock";
} else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_17)) {
// * 5.订单为解锁异常,则跳转解锁异常页面
return "clientFW/jiesuoyichang";
} else {
// TODO 到解锁完成,等待开票的页面
return "clientFW/dingdanxiangqing_dengdaifahuo";
}
} else {
return "clientFW/dingdanxiangqing_yichuihui";
}
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class RenewUserCertClientController method reNewCertConfirm.
// 订单详情,待更新确认
@RequestMapping(value = "/reNewCertConfirm/{id}", produces = "text/html")
public String reNewCertConfirm(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
if (null == userInfo || null == enterprise) {
return ComNames.DENG_LU_CLIENT;
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
Map param = new HashMap();
// 设置查询条件,选择属于当前用户,当前企业的订单
param.put("id", id);
// param.put("userinfoid", userInfo.getId());
// param.put("enterpriseid", enterprise.getId());
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductBillCertById", param);
if (0 == billAll.size()) {
return ComNames.DENG_LU_CLIENT;
}
uiModel.addAttribute("bills", billAll.get(0));
// 获取数字证书
Product product = productService.getProduct((Long) billAll.get(0).get("product"));
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
// 获取产品规格
ProductSpec productSpec = null;
if (null != billAll.get(0).get("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
uiModel.addAttribute("digitalCert", digitalCert);
// 返回订单对应的老证书的base64
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectCertBufByBillId", id);
if (null != certBuf) {
uiModel.addAttribute("oldCertB64", certBuf.getCertBuf().replaceAll("\n", ""));
}
// 判断是否有签章服务,有则显示授权
if (null != product.getMakeSealServer()) {
uiModel.addAttribute("makesealserver", product.getMakeSealServer());
uiModel.addAttribute("billId", billAll.get(0).get("id"));
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
try {
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
} catch (EncDecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
}
return "clientFW/dingdanxiangqing_gengxinqueren";
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class RenewUserCertWebController method updateCert.
@RequestMapping(value = "/updateCert", method = RequestMethod.POST)
// TODO 更新证书
@ResponseBody
public Map<String, Object> updateCert(// 证书序列号
@RequestParam(value = "certSn", required = true) String certSn, // 旧的证书的请求,目前随便写:45564
@RequestParam(value = "csr", required = true) String csr, // 证书base64
@RequestParam(value = "crt", required = true) String crt, // 原证书所在容器生成的新的证书请求
@RequestParam(value = "newCSR", required = true) String newCSR, // 老证书对csr签名后的base64字符串
@RequestParam(value = "pkcs7", required = true) String pkcs7, // 订单id
@RequestParam(value = "billid", required = true) Long billId, // 证书所属的keysn,没有key则为""
@RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "oldCertDn", required = false) String oldCertDn, Model uimModel, HttpSession session) {
// TODO,参数有效性验证
Map<String, Object> ret = new HashMap<String, Object>();
ret.put("status", 1);
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
// 2标识登录已经失效,需跳转到登录页面
ret.put("retCode", 2);
ret.put("retMsg", "登录状态失效");
return ret;
}
Bill bill = billService.getBill(billId);
if (null == bill) {
ret.put("retMsg", "该订单不存在");
return ret;
}
// 订单是否为当前用户当前企业
if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
ret.put("retMsg", "您不能操作该订单");
return ret;
}
// 判断是否是更新过了的订单,是的话直接从本地数据库获取证书的base64传递给页面
if ((bill.getBillStatus() == ComNames.BILL_STATUS_8 || bill.getBillStatus() == ComNames.BILL_STATUS_7 || bill.getBillStatus() == ComNames.BILL_STATUS_6) && null != bill.getOldUserCert()) {
// 根据订单号,找到订单更新后的证书信息
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectNewCertBufByBillId", billId);
// 证书更新信息发给浏览器,写入证书
// 用户证书,Base64编码 (公钥证书),因为记录的时候,存的都是公钥证书,所以这个证书链也是个单证书而已
ret.put("certChain", certBuf.getCertBuf());
// 用户证书,Base64编码 (公钥证书)
ret.put("certBase64", certBuf.getCertBuf());
// 用户证书,Base64编码 (公钥证书)
ret.put("certSignBuf", certBuf.getCertsignBuf());
// KMC协议响应1
ret.put("certKmcRep1", certBuf.getCertKmcRep1());
// KMC协议响应2
ret.put("certKmcRep2", certBuf.getCertKmcRep2());
// //加密证书
// 用户加密证书
ret.put("encUserCert", certBuf.getEncUserCert());
ret.put("status", 0);
List<UserCert> userCert2 = userCertService.getUserCertByBill(bill.getId(), null);
ret.put("certId", userCert2.get(0).getId());
return ret;
}
String accountHash = "";
// 根据订单ID从本地查找ra哈希值
accountHash = sqlSession.selectOne("com.itrus.portal.db.RaAccountMapper.selectRaHashByBillId", billId);
if (!StringUtils.isNotBlank(accountHash)) {
// 根据证书序列号查找RA哈希值
try {
accountHash = getRaInfo.getRaInfoByCertSerialNumber(certSn);
} catch (UserInfoServiceException e) {
ret.put("message", e.getMessage());
return ret;
}
}
// 查找raAccount
RaAccountExample rae = new RaAccountExample();
RaAccountExample.Criteria criteria = rae.or();
criteria.andAccountHashEqualTo(accountHash);
rae.setLimit(1);
RaAccount raAccount = sqlSession.selectOne("com.itrus.portal.db.RaAccountMapper.selectByExample", rae);
CertUtlis certUtlis = new CertUtlis();
CertInfo certInfo = new CertInfo();
UserCert oldUsercert = null;
try {
if (!bill.getBillStatus().equals(ComNames.BILL_STATUS_12)) {
ret.put("message", "该订单下的证书未处于可更新状态");
ret.put("status", 1007);
return ret;
}
// 解密ra密码
if (null != raAccount.getAaPassword()) {
raAccount.setAaPassword(AESencrp.decrypt(raAccount.getAaPassword(), dbEncKey));
}
// 判断证书是否过期并且处于90天内的有效期
oldUsercert = userCertService.getUserCertByCertSn(certSn);
Date certEndTime = oldUsercert.getCertEndTime();
logger.error("************过期时间********certEndTime" + certEndTime);
int result = compareDate(certEndTime, new Date());
logger.error("************过期状态********result" + result);
// 用户证书剩余的天数
Integer surplusDay = 0;
surplusDay = differenceDate(certEndTime, new Date());
Integer certValidity = null;
// 判断订单中是否配了产品规格且有期限
if (null != bill.getProductSpec() && 0 != bill.getProductSpec()) {
ProductSpec productSpec = productSpecService.getProductSpec(bill.getProductSpec());
Integer day = Integer.parseInt(productSpec.getProductValid());
certValidity = 365 * day + 1 + (day / 4);
}
logger.error("产品规格期限************certValidity" + certValidity);
if (result == 2) {
logger.error("************证书过期更新********result=" + result);
// 证书已经过期了,直接进行新证书申请
if (null != certValidity) {
logger.error("****给走申请证书接口的用户补充上剩余天数****certValidity=" + certValidity);
// 给走申请证书接口的用户补充上剩余天数,因为用户指定的更新期限,可能跟原证书的年限不一致
certValidity = certValidity + surplusDay;
certInfo = renewUserService.applyCert(newCSR, productService.getProductById(bill.getProduct()), oldCertDn, certValidity);
} else {
logger.error("****证书更新方法****certSn=" + certSn);
certInfo = certUtlis.renewAA(certSn, crt, raAccount.getAaPassword(), accountHash, raAccount.getAaPassword(), "", newCSR, pkcs7, raAccount);
}
// certInfo = renewUserService.applyCert(newCSR,
// productService.getProductById(bill.getProduct()),
// oldCertDn, certValidity);
} else if (result == 3) {
// 当证书过期,且超过90天
ret.put("status", 1008);
ret.put("message", "该证书已经过期超过了90天,无法更新");
return ret;
} else if (result == 1) {
logger.error("****证书更新方法2****result=" + result);
if (null != certValidity) {
// 给走申请证书接口的用户补充上剩余天数,因为用户指定的更新期限,可能跟原证书的年限不一致
certValidity = certValidity + surplusDay;
certInfo = renewUserService.applyCert(newCSR, productService.getProductById(bill.getProduct()), oldCertDn, certValidity);
} else {
// 判断是否为passcord模式
CaPasscode passcode = new CaPasscode();
if (raAccount.getCertSignType() == 2) {
// 获取对应ra账号的passcode
RaAccountInfoExample raInfoExample = new RaAccountInfoExample();
RaAccountInfoExample.Criteria raInfoCriteria = raInfoExample.createCriteria();
raInfoCriteria.andHashValEqualTo(raAccount.getAccountHash());
raInfoExample.setOrderByClause("create_time desc");
raInfoExample.setLimit(1);
RaAccountInfo raAccountInfo = sqlSession.selectOne("com.itrus.portal.db.RaAccountInfoMapper.selectByExample", raInfoExample);
if (raAccountInfo == null) {
LogUtil.syslog(sqlSession, "制作证书", "不存在指定RA帐号");
}
// 获取对应passcode
try {
passcode = codeService.IssuedCode4Cert(raAccountInfo);
if (passcode == null) {
LogUtil.syslog(sqlSession, "制作证书", "没有有效授权码,请联系管理员");
}
} catch (TerminalServiceException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// 进行证书更新,直接在原证书的基础上,签发一张新证书,需要有
certInfo = certUtlis.renewAA(certSn, crt, raAccount.getAaPassword(), accountHash, raAccount.getAaPassword(), passcode.getPasscode(), newCSR, pkcs7, raAccount);
} else {
// 进行证书更新,直接在原证书的基础上,签发一张新证书,需要有
certInfo = certUtlis.renewAA(certSn, crt, raAccount.getAaPassword(), accountHash, raAccount.getAaPassword(), "", newCSR, pkcs7, raAccount);
}
}
}
UserCert userCert = updateUserCertAndCertBuf(certSn, certInfo, billId, raAccount.getId());
UserLog userLog = new UserLog();
userLog.setType("更新证书成功");
userLog.setInfo("成功更新证书:" + certSn);
userLog.setHostId("未知");
userLog.setProject(bill.getProject());
LogUtil.userlog(sqlSession, userLog);
// 证书更新信息发给浏览器,写入证书
// 用户证书PKCS7格式(含证书链)
ret.put("certChain", certInfo.getCertSignBufP7());
// 用户证书,Base64编码 (公钥证书)
ret.put("certBase64", certInfo.getCertSignBuf());
ret.put("certId", userCert.getId());
// 用户证书,Base64编码 (公钥证书)
ret.put("certSignBuf", certInfo.getCertSignBuf());
// KMC协议响应1
ret.put("certKmcRep1", certInfo.getCertKmcRep1());
// KMC协议响应2
ret.put("certKmcRep2", certInfo.getCertKmcRep2());
// 加密证书
// 用户加密证书
ret.put("encUserCert", certInfo.getCertSignBufKmc());
ret.put("status", 0);
// 更新usercert和cerbuf
return ret;
} catch (MalformedURLException | RaServiceUnavailable_Exception e) {
logger.error("更新证书:" + certSn + "出现异常,异常信息:" + e.getMessage());
UserLog userLog = new UserLog();
userLog.setType("更新证书失败");
userLog.setInfo("url:updateCert,出错的证书:" + certSn + ",详细错误:" + e.getMessage());
userLog.setHostId("未知");
userLog.setProject(bill.getProject());
LogUtil.userlog(sqlSession, userLog);
ret.put("status", 1004);
ret.put("message", "出现未知异常,请联系管理员处理");
return ret;
} catch (EncDecException e) {
// TODO Auto-generated catch block
logger.error("更新证书:" + certSn + "出现异常,异常信息:" + e.getMessage());
UserLog userLog = new UserLog();
userLog.setType("更新证书失败");
userLog.setInfo("url:updateCert,出错的证书:" + certSn + ",详细错误:" + e.getMessage());
userLog.setHostId("未知");
userLog.setProject(bill.getProject());
LogUtil.userlog(sqlSession, userLog);
ret.put("status", 1005);
ret.put("message", "出现未知异常,请联系管理员处理");
return ret;
} catch (Exception e) {
if (StringUtils.isNotBlank(certInfo.getCertSerialNumber())) {
// 新证书已签发,但未保存到数据库时 需打印新证书序列号
logger.error("旧证书序列号:" + oldUsercert.getCertSn() + ",异常的新证书序列号:" + certInfo.getCertSerialNumber());
}
logger.error("更新证书:" + certSn + "出现异常,异常信息:" + e.getMessage());
UserLog userLog = new UserLog();
userLog.setType("更新证书失败");
userLog.setInfo("url:updateCert,出错的证书:" + certSn + ",详细错误:" + e.getMessage());
userLog.setHostId("未知");
userLog.setProject(bill.getProject());
LogUtil.userlog(sqlSession, userLog);
ret.put("status", 1006);
ret.put("message", "出现未知异常,请联系管理员处理");
return ret;
}
}
Aggregations