|
@@ -4,7 +4,9 @@ import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
@@ -13,6 +15,8 @@ import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
+import cn.hutool.poi.excel.ExcelUtil;
|
|
|
+import cn.hutool.poi.excel.ExcelWriter;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.txz.cif.enums.BizTypeEnum;
|
|
@@ -82,7 +86,7 @@ public class UserController extends AbstractApiController {
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
@ApiOperation(value = "获取用户",httpMethod = "POST")
|
|
|
- public Result<List<UserBo2>> list(@RequestBody MyUserParam param, HttpServletRequest request) {
|
|
|
+ public Result<List<UserBo2>> list(@RequestBody MyUserParam param) {
|
|
|
PageHelper.startPage(param.getPage(), param.getSize());
|
|
|
Condition condition = new Condition(User.class);
|
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
@@ -241,5 +245,76 @@ public class UserController extends AbstractApiController {
|
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/report")
|
|
|
+ @ApiOperation(value = "导出维度", httpMethod = "GET")
|
|
|
+ public void report(@RequestParam MyUserParam param , HttpServletResponse response) {
|
|
|
+ Condition condition = new Condition(User.class);
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
+ Example.Criteria criteria2 = condition.or();
|
|
|
+ if (param.getType() == null){
|
|
|
+ param.setType(0);
|
|
|
+ }
|
|
|
+ if (param.getType() == 1){
|
|
|
+ criteria.andEqualTo("pid",param.getUserId());
|
|
|
+ criteria2.andEqualTo("pid",param.getUserId());
|
|
|
+ } else if (param.getType() == 2){
|
|
|
+ criteria.andEqualTo("ppid",param.getUserId());
|
|
|
+ criteria2.andEqualTo("ppid",param.getUserId());
|
|
|
+ }
|
|
|
+ if (param.getStatus() != null){
|
|
|
+ criteria.andEqualTo("status",param.getStatus());
|
|
|
+ criteria2.andEqualTo("status",param.getStatus());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(param.getName())) {
|
|
|
+ criteria.andLike("name", "%" + param.getName() + "%");
|
|
|
+ criteria2.andLike("name", "%" + param.getName() + "%");
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(param.getPhone())) {
|
|
|
+ criteria.andEqualTo("phoneNo", param.getPhone());
|
|
|
+ criteria2.andEqualTo("phoneNo", param.getPhone());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(param.getStartTime())) {
|
|
|
+ criteria.andGreaterThanOrEqualTo("createTime", param.getStartTime());
|
|
|
+ criteria2.andGreaterThanOrEqualTo("createTime", param.getStartTime());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(param.getEndTime())) {
|
|
|
+ criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
|
+ criteria2.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
|
+ }
|
|
|
+ condition.setOrderByClause("create_time desc");
|
|
|
+ List<User> users = userService.findByCondition(condition);
|
|
|
+ List<String> rowHead = CollUtil.newArrayList("编号", "用户号", "邀请码", "昵称", "名字", "银行", "银行账号", "银行用户名字", "电话", "vip等级", "备注", "是否有提现权限 1是 2否", "是否有登录权限 1是 2否", "是否有下单权限 1是 2否","注册时间");
|
|
|
+ ExcelWriter writer = ExcelUtil.getWriter();
|
|
|
+ try {
|
|
|
+ writer.writeHeadRow(rowHead);
|
|
|
+ List<List<Object>> rows = new LinkedList<>();
|
|
|
+ if (CollUtil.isNotEmpty(users)) {
|
|
|
+ for (User temp : users) {
|
|
|
+ List<Object> rowA = CollUtil.newArrayList(temp.getId(), temp.getUserNo(), temp.getInvitedCode(),temp.getNickname()
|
|
|
+ ,temp.getName(),temp.getBank(),temp.getBankAccount(),temp.getBankAccountName(),temp.getPhoneNo(),temp.getVipLevel(),temp.getMemo(),temp.getHasWithdraw(),temp.getHasLogin(),temp.getHasOrder(), DateUtil.format(temp.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ rows.add(rowA);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ writer.write(rows);
|
|
|
+ //设置宽度自适应
|
|
|
+ writer.setColumnWidth(-1, 22);
|
|
|
+ //response为HttpServletResponse对象
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + new String(("数据列表").getBytes("UTF-8"), "ISO-8859-1") + ".xls");
|
|
|
+ ServletOutputStream out = response.getOutputStream();
|
|
|
+ //out为OutputStream,需要写出到的目标流
|
|
|
+ writer.flush(out);
|
|
|
+ log.info("导出结束");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导出异常", e);
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ // 关闭writer,释放内存
|
|
|
+ writer.close();
|
|
|
+ log.info("导出结束");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|