use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class UnlockKeyBillController method getUnlockProductsByLogin.
/**
* 用户登录后点击解锁,返回key对应的解锁产品列表
* @param CertSn
* @param keySn
* @param uiModel
* @param request
* @return
*/
@RequestMapping(value = "/getUnlockProductsByLogin")
public String getUnlockProductsByLogin(@RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, Model uiModel, HttpServletRequest request) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
return ComNames.CLIENTFW_ERRORPAGE;
}
UserInfo webUserInfo = (UserInfo) request.getSession().getAttribute(ComNames.WEB_USER_INFO);
if (null == webUserInfo) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return ComNames.CLIENTFW_ERRORPAGE;
}
Enterprise enterprise = (Enterprise) request.getSession().getAttribute(ComNames.WEB_ENTERPRISE);
if (null == enterprise) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return ComNames.CLIENTFW_ERRORPAGE;
}
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
return ComNames.CLIENTFW_ERRORPAGE;
}
HttpSession session = request.getSession();
Integer has_enterpriseInfoInsession = (Integer) session.getAttribute("has_enterpriseInfo");
Integer hhas_userInfoInsession = (Integer) session.getAttribute("has_userInfo");
if (null == hhas_userInfoInsession) {
uiModel.addAttribute("has_userInfo", 0);
if (null != userCert.getUserinfo()) {
webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
uiModel.addAttribute("userInfo", webUserInfo);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
uiModel.addAttribute("has_userInfo", 1);
}
}
if (null == has_enterpriseInfoInsession) {
uiModel.addAttribute("has_enterpriseInfo", 0);
if (null != enterprise) {
uiModel.addAttribute("enterprise", enterprise);
uiModel.addAttribute("has_enterpriseInfo", 1);
}
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
if (null == products || products.isEmpty()) {
uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
return ComNames.CLIENTFW_ERRORPAGE;
}
uiModel.addAttribute("products", products);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
// 电子开票服务
Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
if (null == products.get(0).geteBill()) {
uiModel.addAttribute("ereceiptMapSize", 0);
}
uiModel.addAttribute("ereceiptMap", ereceiptMap);
return "clientFW/unlock_out";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class UnlockKeyBillController method loadPorxy.
/**
* 加载授权书
*
* @return
*/
@RequestMapping("/loadPorxyZSJS")
public String loadPorxy(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "mPhone", required = false) String mPhone, HttpSession session, HttpServletResponse response) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
UserInfo webuserInfo = null;
if (null != userCert && null != userCert.getUserinfo()) {
webuserInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
}
String firstMphone = "";
// 手机号处理,如果用户第一次申请解锁,而且没有绑定手机号,则先取用户输入的,再取证书绑定的,实在没有就放空
if (StringUtils.isNotBlank(mPhone)) {
firstMphone = mPhone;
} else if (null != webuserInfo) {
firstMphone = webuserInfo.getmPhone();
}
OutputStream os = null;
InputStream proxyIn = null;
InputStream streamTemp = null;
try {
proxyIn = UserInfoWebController.class.getClassLoader().getResourceAsStream("/porxy_ZSJS.html");
String proxyHtml = StringTools.readTextFile2(proxyIn, "UTF-8", enterpriseName, keySn, certSn, firstMphone);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("text/html; charset=utf-8");
os = response.getOutputStream();
os.write(proxyHtml.getBytes("UTF-8"));
os.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 关闭流!
try {
if (null != proxyIn) {
proxyIn.close();
}
if (null != streamTemp) {
streamTemp.close();
}
if (null != os) {
os.close();
}
} catch (IOException e) {
}
}
return null;
}
use of com.itrus.portal.db.UserInfo 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.UserInfo in project portal by ixinportal.
the class UserInfoController method update.
/**
* 用户信息修改处理
*
* @param userInfo
* @param bindingResult
* @param uiModel
* @return
*/
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(UserInfo userInfo, BindingResult bindingResult, Model uiModel) {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("userInfo", userInfo);
return "userInfo/update";
}
UserInfo oldUserInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", userInfo.getId());
// 判断修改的用户是否属于当前管理员所管理的范围
Long[] manageProjectIds = getProjectLongIdsOfAdmin();
// 默认不属于当前管理员管理范围
boolean flag = false;
for (Long projectId : manageProjectIds) {
if (oldUserInfo.getProject() == projectId) {
flag = true;
}
}
if (!flag) {
// 没有管理权限
return "status403";
}
// 真实姓名
oldUserInfo.setRealName(userInfo.getRealName());
// 手机号是否验证
oldUserInfo.setTrustMPhone(userInfo.getTrustMPhone());
// 邮箱是否验证
oldUserInfo.setTrustEmail(userInfo.getTrustEmail());
// 固定电话
oldUserInfo.setTelephone(userInfo.getTelephone());
// 省市区代码
oldUserInfo.setRegionCodes(userInfo.getRegionCodes());
// 详细地址
oldUserInfo.setUserAdds(userInfo.getUserAdds());
sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKey", oldUserInfo);
// 添加管理员日志
String oper = "修改用户";
String info = "用户名: " + oldUserInfo.getRealName();
LogUtil.adminlog(sqlSession, oper, info);
return "redirect:/userinfo/detail?id=" + userInfo.getId();
}
use of com.itrus.portal.db.UserInfo 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