use of com.itrus.portal.db.UserInfo 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.UserInfo in project portal by ixinportal.
the class ExtraQueryBillController method show.
// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
ExtraBillExample billExample = new ExtraBillExample();
ExtraBillExample.Criteria criteria = billExample.or();
criteria.andIdEqualTo(id);
criteria.andProjectIn(projectsOfAdminList);
ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
if (null == bill) {
uiModel.addAttribute("errorMsg", "未找到该订单");
return "status403";
}
uiModel.addAttribute("bill", bill);
// 项目
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
uiModel.addAttribute("project", project);
// 企业
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
if (StringUtils.isNotBlank(enterprise.getProvince())) {
String province = sysRegionService.getProvince(enterprise.getProvince());
enterprise.setProvince(province);
}
if (StringUtils.isNotBlank(enterprise.getCity())) {
String city = sysRegionService.getCity(enterprise.getCity());
enterprise.setCity(city);
}
uiModel.addAttribute("enterprise", enterprise);
// 产品
ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
uiModel.addAttribute("product", product);
// 规格
ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
uiModel.addAttribute("productSpec", productSpec);
// 服务商
ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
uiModel.addAttribute("serviceProvider", serviceProvider);
// 用户
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
uiModel.addAttribute("userInfo", userInfo);
// 第三方支付信息
OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
uiModel.addAttribute("onPayInfo", onPayInfo);
if (onPayInfo != null) {
// 在线支付信息
OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
uiModel.addAttribute("onlinePay", onlinePay);
}
// 电子发票
Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
uiModel.addAttribute("einvoice", einvoice);
// 电子发票类型
if (einvoice != null && einvoice.geteReiceipt() != null) {
Ereceipt ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", einvoice.geteReiceipt());
uiModel.addAttribute("ereceipt", ereceipt);
}
// 其他附加信息
// 营业执照
BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
uiModel.addAttribute("bl", businessLicense);
// 税务登记
TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
uiModel.addAttribute("trc", taxRegisterCert);
// 组织机构代码
OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
uiModel.addAttribute("oc", orgCode);
// 代理人
Agent agent = agentService.getAgentByExtraBillId(id, null);
uiModel.addAttribute("agent", agent);
// 开户行信息
OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
uiModel.addAttribute("obi", openBankInfo);
// 法人信息
IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
uiModel.addAttribute("ic", identityCard);
// TODO 还需要补充订单对应的附加信息和第三方回调信息
return "extrabill/show";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class EnterpriseController method updateEnterpriseUI.
/**
* 修改企业信息
*
* @return
*/
@RequestMapping(value = "/updateEnterpriseUI/{id}")
public String updateEnterpriseUI(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
Enterprise enterprise = enterpriseService.getEnterpriseById(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;
// 查询企业关联的用户
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);
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
uiModel.addAttribute("itemcount", itemcount);
return "enterprise/update";
}
use of com.itrus.portal.db.UserInfo 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.UserInfo in project portal by ixinportal.
the class ExtraBillPayController method show.
// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "payStatus", required = false) Integer payStatus) {
uiModel.addAttribute("payStatus", payStatus);
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
ExtraBillExample billExample = new ExtraBillExample();
ExtraBillExample.Criteria criteria = billExample.or();
criteria.andIdEqualTo(id);
criteria.andProjectIn(projectsOfAdminList);
ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
if (null == bill) {
uiModel.addAttribute("errorMsg", "未找到该订单");
return "status403";
}
uiModel.addAttribute("bill", bill);
// 项目
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
uiModel.addAttribute("project", project);
// 企业
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
uiModel.addAttribute("enterprise", enterprise);
// 产品
ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
uiModel.addAttribute("product", product);
// 规格
ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
uiModel.addAttribute("productSpec", productSpec);
// 服务商
ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
uiModel.addAttribute("serviceProvider", serviceProvider);
// 用户
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
uiModel.addAttribute("userInfo", userInfo);
// 第三方支付信息
OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
uiModel.addAttribute("onPayInfo", onPayInfo);
if (onPayInfo != null && onPayInfo.getOnlinePay() != null) {
// 在线支付
OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
uiModel.addAttribute("onlinePay", onlinePay);
}
// 电子发票
Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
uiModel.addAttribute("einvoice", einvoice);
// 其他附加信息
// 营业执照
BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
uiModel.addAttribute("businessLicense", businessLicense);
// 税务登记
TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
// 组织机构代码
OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
uiModel.addAttribute("orgCode", orgCode);
// 代理人
Agent agent = agentService.getAgentByExtraBillId(id, null);
uiModel.addAttribute("agent", agent);
// 开户行信息
OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
uiModel.addAttribute("openBankInfo", openBankInfo);
// 法人信息
IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
uiModel.addAttribute("identityCard", identityCard);
// TODO 还需要补充订单对应的附加信息和第三方回调信息
return "extrabillpay/show";
}
Aggregations