Commit 62efa1b3 authored by 技术部-任文超's avatar 技术部-任文超

Merge branch '20180730-loopholes'

parents a9ad2771 1f876e54
package cn.quantgroup.xyqb.controller.external.querylog;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.gson.*;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.entity.UserDetail;
......@@ -15,24 +38,6 @@ import cn.quantgroup.xyqb.util.IdcardValidator;
import cn.quantgroup.xyqb.util.ValidationUtil;
import cn.quantgroup.xyqb.util.encrypt.MD5Util;
import cn.quantgroup.xyqb.util.encrypt.RSA;
import com.google.gson.*;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.hssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by zenglibin on 17/06/13.
......@@ -321,11 +326,6 @@ public class UserQueryLogController {
LOGGER.info("签名校验失败!");
}
}
// else{
// phonesMap.put("errorMsg",obj.get("msg").getAsString());
// LOGGER.info("从支付中心接口返回data为null");
// }
} catch (Exception e) {
phonesMap.put("errorMsg", "查询银行卡信息接口返回解析异常");
LOGGER.info("查询银行卡信息接口返回解析异常");
......@@ -336,8 +336,6 @@ public class UserQueryLogController {
@RequestMapping("/exportUserInfo")
@ApiOperation(value = "给运营系统提供的导出用户信息的接口", notes = "给运营系统提供的导出用户信息的接口", httpMethod = "POST")
public JsonResult exportExcel(final HttpServletResponse response, HttpServletRequest request, String key, String keyValues, String columns) {
String token = request.getHeader(Constants.X_AUTH_TOKEN);
if (StringUtils.isEmpty(token)) {
LOGGER.info("token为空,非法查询");
......@@ -354,16 +352,13 @@ public class UserQueryLogController {
}
List<UserQueryInfo> uqls = new ArrayList<>();
String[] values = keyValues.split(";");
List<String> queryV = Arrays.asList(values);
LOGGER.info("[UserQueryLogController][exportExcel]运营系统导出用户信息开始 size:{}, key:{}, keyValues:{}, columns:{}", queryV.size(), key, keyValues, columns);
if (queryV != null && queryV.size() > 3000) {
return JsonResult.buildErrorStateResult("查询记录数是" + queryV.size() + ",超过3000条限制", null);
}
//如果维度里面没有保护查询条件则加入条件
if (!columns.contains(key)) {
columns = columns + "," + key;
......@@ -406,7 +401,6 @@ public class UserQueryLogController {
userDetails = userDetailService.findByIdnos(queryV);
}
if (columns.contains("bankCard")) {
//需加银行卡信息
if (key.equals(Constants.PHONE_NO)) {
......@@ -457,16 +451,6 @@ public class UserQueryLogController {
}
// //不保存记录
// UserQueryLog log=new UserQueryLog();
// log.setQueryItems(columns.replace("userId","用户ID").replace(Constants.PHONE_NO,"手机号").replace("idNo","身份证号").replace("bankCard","银行卡号").replace("address","地址"));
// log.setResultAmount(Long.valueOf(userDetails.size()));
// //转换存储
// log.setQueryCondition(key.replace("userId","用户ID").replace(Constants.PHONE_NO,"手机号").replace("idNo","身份证号"));
// log.setQueryDetail(keyValues.replace("\n",";"));
// log.setLoginUserName(userName);
// userQueryLogService.save(log);
HSSFWorkbook wb = new HSSFWorkbook();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet("用户信息列表");
......@@ -474,7 +458,8 @@ public class UserQueryLogController {
HSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
// 创建一个居中格式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFCell cell = row.createCell(0);
cell.setCellValue("userId");
......@@ -496,7 +481,6 @@ public class UserQueryLogController {
cell.setCellStyle(style);
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
//List list = CreateSimpleExcelToDisk.getStudent();
for (int i = 0; i < uqls.size(); i++) {
row = sheet.createRow(i + 1);
......@@ -505,7 +489,7 @@ public class UserQueryLogController {
if (user != null && row != null) {
HSSFCell cell0 = row.createCell(0);
if (cell0 != null) {
cell0.setCellValue(user.getUserId() == null ? " " : String.valueOf(user.getUserId()));//user.getUserId()==null?" ":String.valueOf(user.getUserId())
cell0.setCellValue(user.getUserId() == null ? " " : String.valueOf(user.getUserId()));
}
HSSFCell cell1 = row.createCell(1);
......@@ -535,18 +519,20 @@ public class UserQueryLogController {
}
}
// 第六步,将文件存到指定位置
try {
OutputStream output = response.getOutputStream();
/*
* 第六步,将文件存到指定位置
* 采用时间戳命名方式,避免同主机出现并发同名文件冲突引起的文件流被动关闭现象
*/
try(OutputStream output = response.getOutputStream()){
String filename = "users-".concat(LocalDateTime.now().toString()).concat(".xlsx");
response.reset();
response.setHeader("Content-disposition", "attachment; filename=users.xlsx");
response.setHeader("Content-disposition", "attachment; filename=".concat(filename));
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setCharacterEncoding("utf-8");
wb.write(output);
output.close();
LOGGER.info("[UserQueryLogController][exportExcel]运营系统导出用户信息完成 filename:{}, size:{}, key:{}, keyValues:{}, columns:{}", filename, queryV.size(), key, keyValues, columns);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("解析运营系统用户token返回结果resultStr异常", e);
}
return JsonResult.buildSuccessResult("导出成功", null);
}
......
......@@ -265,7 +265,8 @@ public class WeChatController implements IBaseController {
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (Objects.isNull(user)) {
// 用户不存在或已注销
if (Objects.isNull(user) || !user.getEnable()) {
// 用户已经微信登录了,但是关联信用钱包用户信息无效,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom, domain);
return;
......
......@@ -2,6 +2,8 @@ package common;
import java.sql.Timestamp;
import org.apache.commons.codec.binary.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
......@@ -77,4 +79,10 @@ public class JsonTest {
}
}
@Test
public void test() throws Exception{
String extData = "eyJyZWRpcmVjdCI6ImxvY2FsIiwicmVnaXN0ZXJGcm9tIjoyMjJ9";
System.out.println(new String(Base64.decodeBase64(extData), "UTF-8"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment