use of com.itrus.portal.db.Bill in project portal by ixinportal.
the class DownLoadCertWebController method certInstallStatus.
/**
* 安装成功后,将订单的certInstallStatus状态设置为1
*
* @param billId
* @param status
* 1标识安装成功
* @return
*/
@RequestMapping(value = "/certInstallStatus", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> certInstallStatus(@RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "status", required = true) Integer status) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("retCode", 0);
Bill bill = billService.getBill(billId);
if (null == bill) {
retMap.put("msg", "对应的订单不存在");
return retMap;
}
if (status.equals(1)) {
// 将订单中证书是否安装成功 设置为1,标识已安装成功;
bill.setCertInstallStatus(1);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
retMap.put("retCode", 1);
}
return retMap;
}
use of com.itrus.portal.db.Bill 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.Bill 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.Bill in project portal by ixinportal.
the class APIService method upload.
/**
* 证件图片上传
*
* @param authHmac
* hmac签名值,采用HmacSHA1算法
* @param appId
* 应用标识
* @param orderNumber
* 申请流水号
* @param image1
* 证件图片, base64形式
* @param image2
* 证件图片反面, base64形式(法定代表人和代理人证件类型为身份证时,必填)
* @param type
* 图片类型 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
* @return
*/
@PostMapping(value = "/auth/upload")
@ResponseBody
public Map<String, Object> upload(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "orderNumber", required = false) String orderNumber, @RequestParam(value = "image1", required = false) String image1, @RequestParam(value = "image2", required = false) String image2, @RequestParam(value = "type", required = false) String type, HttpServletRequest request) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("status", 0);
// 验证参数是否完整
if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(type) || StringUtils.isEmpty(orderNumber) || StringUtils.isEmpty(image1)) {
result.put("message", "提交的参数信息不完整");
return result;
}
try {
Bill bill = billService.getBillByOrderNumber(orderNumber);
if (bill == null) {
result.put("message", "申请流水号不存在");
return result;
}
UserInfo userInfo = userInfoService.getUserInfoByBillId(bill.getId());
// 得到应用信息 改成service
Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
ApplicationInfo applicationInfo = appInfoMap.get(appId);
if (applicationInfo == null) {
ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
appInfoExampleCriteria.andAppIdEqualTo(appId);
applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
}
if (applicationInfo == null) {
result.put("message", "应用标识不存在");
return result;
}
if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
result.put("status", -1);
result.put("message", "没有此服务权限");
log.error("APIService_AccsessIp : " + request.getRemoteAddr());
return result;
}
// 验证hmac有效性
try {
String macVal = CertService.hmacSha1(applicationInfo.getSecretKey().getBytes(), (appId + orderNumber + image1 + image2 + type).getBytes("utf-8"));
// sc.getAddressKey()), false);
if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
result.put("status", -2);
result.put("message", "服务密钥错误");
return result;
}
} catch (Exception e) {
result.put("status", -3);
result.put("message", "Hmac验证错误");
e.printStackTrace();
return result;
}
Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
// 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
List<Integer> modifiedStatus = new ArrayList<Integer>();
modifiedStatus.add(ComNames.BILL_STATUS_3);
modifiedStatus.add(ComNames.BILL_STATUS_4);
modifiedStatus.add(ComNames.BILL_STATUS_10);
// 不在以上状态中
if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
result.put("message", "该订单不能上传图片");
return result;
}
// 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
if (type.equals("1")) {
BusinessLicense lc = businessService.getBusinessByBillId(bill.getId(), null);
if (lc == null) {
result.put("message", "不需要上传营业执照或(事业单位)法人证书图片");
return result;
}
BusinessLicense business = businessService.portUpdateBusiness(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (business == null) {
result.put("message", "营业执照或(事业单位)法人证书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "营业执照或(事业单位)法人证书图片图片上传成功");
return result;
} else if (type.equals("2")) {
OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
if (oc == null) {
result.put("message", "不需要上传组织机构代码证书图片");
return result;
}
OrgCode orgCode = orgCodeService.portUpdateOrgCode(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (orgCode == null) {
result.put("message", "组织机构代码证书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "组织机构代码证书图片上传成功");
return result;
} else if (type.equals("3")) {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
if (tc == null) {
result.put("message", "不需要上传税务登记证图片");
return result;
}
TaxRegisterCert taxRegisterCert = taxCertService.portUpdateTaxCert(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (taxRegisterCert == null) {
result.put("message", "税务登记证图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "税务登记证图片上传成功");
return result;
} else if (type.equals("4")) {
IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
if (ic == null) {
result.put("message", "不需要上传法定代表人证件图片");
return result;
}
if (ic.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
result.put("message", "提交的参数信息不完整");
return result;
}
IdentityCard identityCard = identityCardService.portUpdateIdentityCard(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
if (identityCard == null) {
result.put("message", "法定代表人证件图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "法定代表人证件图片上传成功");
return result;
} else if (type.equals("5")) {
Agent at = agentService.getAgentByBillId(bill.getId(), null);
if (at == null) {
result.put("message", "不需要上传代理人证件图片");
return result;
}
if (at.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
result.put("message", "提交的参数信息不完整");
return result;
}
Agent agent = agentService.portUpdateAgent(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
if (agent == null) {
result.put("message", "代理人证件图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "代理人证件图片上传成功");
return result;
} else if (type.equals("6")) {
Proxy py = proxyService.getProxyByBillId(bill.getId());
if (py == null) {
result.put("message", "不需要上传授权书图片");
return result;
}
Proxy proxy = proxyService.portUpdateProxy(bill.getId(), userInfo.getUniqueId(), image1);
if (proxy == null) {
result.put("message", "授权书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "授权书图片上传成功");
return result;
} else {
result.put("message", "图片类型参数输入有误");
return result;
}
} catch (Exception e) {
e.printStackTrace();
if (e.getMessage().contains("图片大小不能")) {
result.put("status", 0);
result.put("message", e.getMessage());
return result;
}
// TODO Auto-generated catch block
result.put("status", 0);
result.put("message", "服务端出现未知错误,请联系管理员");
return result;
}
}
use of com.itrus.portal.db.Bill in project portal by ixinportal.
the class UserInfoController method detail.
/**
* 查看用户详情
*
* @param id
* 用户id
* @param item
* 用户关联的项(0企业、1证书、2订单、3认证)
* @param page
* @param size
* @param uiModel
* @return
*/
@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) {
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", id);
// 判断查询的用户是否属于当前管理员所管理的范围
Long[] manageProjectIds = getProjectLongIdsOfAdmin();
// 默认不属于当前管理员管理范围
boolean flag = false;
for (Long projectId : manageProjectIds) {
if (userInfo.getProject() == projectId) {
flag = true;
}
}
if (!flag) {
// 没有管理权限
return "status403";
}
// 根据省市区code值获取省市区最新名称
String regionCodes = userInfo.getRegionCodes();
String userAdds = userInfo.getUserAdds();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
userAdds = regionName + userAdds;
userInfo.setUserAdds(userAdds);
}
uiModel.addAttribute("userInfo", userInfo);
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 10;
}
// 总记录数
Integer count = 0;
// 当前页记录数
Integer itemcount = 0;
// null、0关联企业,1证书信息,2订单列表
if (null == item || 0 == item) {
item = 0;
// 关联企业
List<Enterprise> enterprises = new ArrayList<Enterprise>();
List<Long> enterpriseIds = userInfoEnterpriseService.getEnterpriseByUserInfo(userInfo.getId());
if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
count = enterpriseIds.size();
EnterpriseExample enterpriseExample = new EnterpriseExample();
EnterpriseExample.Criteria criteria = enterpriseExample.or();
criteria.andIdIn(enterpriseIds);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
enterpriseExample.setOffset(offset);
enterpriseExample.setLimit(size);
enterpriseExample.setOrderByClause("create_time desc");
enterprises = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
}
itemcount = enterprises.size();
uiModel.addAttribute("enterprises", enterprises);
} else if (1 == item) {
item = 1;
// TODO 证书信息
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", userInfo.getId());
count = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.countByUserInfoID", userInfo.getId());
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
map.put("offset", offset);
map.put("limit", size);
List<UserCert> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoID", map);
itemcount = userCertList.size();
uiModel.addAttribute("userCertList", userCertList);
} else if (2 == item) {
item = 2;
// 订单列表
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
criteria.andUniqueIdEqualTo(userInfo.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.getProjectMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("projectMap", projectMap);
Map<Long, Product> productMap = billService.getProductMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("productMap", productMap);
Map<Long, Enterprise> enterpriseMap = billService.getEnterpriseMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("enterpriseMap", enterpriseMap);
} else if (3 == item) {
item = 3;
Agent agent = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectNewAgentByUserId", id);
uiModel.addAttribute("agent", agent);
}
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 "userInfo/detail";
}
Aggregations