|
@@ -1,12 +1,5 @@
|
|
package com.txz.cif.web.mng;
|
|
package com.txz.cif.web.mng;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import javax.servlet.ServletOutputStream;
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
-
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -16,91 +9,104 @@ import cn.hutool.poi.excel.ExcelUtil;
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.txz.cif.core.*;
|
|
import com.txz.cif.enums.BizTypeEnum;
|
|
import com.txz.cif.enums.BizTypeEnum;
|
|
|
|
+import com.txz.cif.model.Account;
|
|
|
|
+import com.txz.cif.model.ConfigMember;
|
|
|
|
+import com.txz.cif.model.Flow;
|
|
|
|
+import com.txz.cif.model.User;
|
|
|
|
+import com.txz.cif.service.*;
|
|
import com.txz.cif.web.bo.UserBo2;
|
|
import com.txz.cif.web.bo.UserBo2;
|
|
import com.txz.cif.web.bo.UserDetailBo;
|
|
import com.txz.cif.web.bo.UserDetailBo;
|
|
-import com.txz.cif.web.para.*;
|
|
|
|
-import com.txz.cif.core.*;
|
|
|
|
-import com.txz.cif.model.*;
|
|
|
|
-import com.txz.cif.service.*;
|
|
|
|
-import io.swagger.annotations.*;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import com.txz.cif.web.para.MyUserParam;
|
|
|
|
+import com.txz.cif.web.para.UserUpdateParam;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(value = "/user")
|
|
@RequestMapping(value = "/user")
|
|
@Api(tags = "[后台]用户管理")
|
|
@Api(tags = "[后台]用户管理")
|
|
@Slf4j
|
|
@Slf4j
|
|
public class UserController extends AbstractApiController {
|
|
public class UserController extends AbstractApiController {
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private UserService userService;
|
|
private UserService userService;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private FlowService flowService;
|
|
private FlowService flowService;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private AccountService accountService;
|
|
private AccountService accountService;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private RedEnvelopeService redEnvelopeService;
|
|
private RedEnvelopeService redEnvelopeService;
|
|
-
|
|
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private ConfigMemberService configMemberService;
|
|
private ConfigMemberService configMemberService;
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
- @ApiOperation(value = "更新用户资料",httpMethod = "POST")
|
|
|
|
|
|
+ @ApiOperation(value = "更新用户资料", httpMethod = "POST")
|
|
public Result update(@RequestBody UserUpdateParam param) {
|
|
public Result update(@RequestBody UserUpdateParam param) {
|
|
- if (param == null){
|
|
|
|
|
|
+ if (param == null) {
|
|
return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
}
|
|
}
|
|
- if (param.getId() == null){
|
|
|
|
|
|
+ if (param.getId() == null) {
|
|
return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
}
|
|
}
|
|
User user = userService.findById(param.getId());
|
|
User user = userService.findById(param.getId());
|
|
- if (user == null){
|
|
|
|
|
|
+ if (user == null) {
|
|
return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
}
|
|
}
|
|
- User temp = BeanUtil.toBean(param,User.class);
|
|
|
|
- if (StrUtil.isNotBlank(param.getPwd())){
|
|
|
|
|
|
+ User temp = BeanUtil.toBean(param, User.class);
|
|
|
|
+ if (StrUtil.isNotBlank(param.getPwd())) {
|
|
String pwd2 = SecureUtil.md5(param.getPwd() + user.getSalt()).toUpperCase();
|
|
String pwd2 = SecureUtil.md5(param.getPwd() + user.getSalt()).toUpperCase();
|
|
temp.setPwd(pwd2);
|
|
temp.setPwd(pwd2);
|
|
}
|
|
}
|
|
userService.update(temp);
|
|
userService.update(temp);
|
|
return ResultGenerator.genSuccessResult();
|
|
return ResultGenerator.genSuccessResult();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
- @ApiOperation(value = "获取用户",httpMethod = "POST")
|
|
|
|
|
|
+ @ApiOperation(value = "获取用户", httpMethod = "POST")
|
|
public Result<List<UserBo2>> list(@RequestBody MyUserParam param) {
|
|
public Result<List<UserBo2>> list(@RequestBody MyUserParam param) {
|
|
PageHelper.startPage(param.getPage(), param.getSize());
|
|
PageHelper.startPage(param.getPage(), param.getSize());
|
|
Condition condition = new Condition(User.class);
|
|
Condition condition = new Condition(User.class);
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
- if (param.getType() == null){
|
|
|
|
|
|
+ if (param.getType() == null) {
|
|
param.setType(0);
|
|
param.setType(0);
|
|
}
|
|
}
|
|
- if (param.getHasWithdraw() != null){
|
|
|
|
- criteria.andEqualTo("hasWithdraw",param.getHasWithdraw());
|
|
|
|
|
|
+ if (param.getHasWithdraw() != null) {
|
|
|
|
+ criteria.andEqualTo("hasWithdraw", param.getHasWithdraw());
|
|
}
|
|
}
|
|
- if (param.getHasLogin() != null){
|
|
|
|
- criteria.andEqualTo("hasLogin",param.getHasLogin());
|
|
|
|
|
|
+ if (param.getHasLogin() != null) {
|
|
|
|
+ criteria.andEqualTo("hasLogin", param.getHasLogin());
|
|
}
|
|
}
|
|
- if (param.getHasOrder() != null){
|
|
|
|
- criteria.andEqualTo("hasOrder",param.getHasOrder());
|
|
|
|
|
|
+ if (param.getHasOrder() != null) {
|
|
|
|
+ criteria.andEqualTo("hasOrder", param.getHasOrder());
|
|
}
|
|
}
|
|
- if (param.getType() == 1){
|
|
|
|
- criteria.andEqualTo("pid",param.getUserId());
|
|
|
|
- } else if (param.getType() == 2){
|
|
|
|
- criteria.andEqualTo("ppid",param.getUserId());
|
|
|
|
|
|
+ if (param.getType() == 1) {
|
|
|
|
+ criteria.andEqualTo("pid", param.getUserId());
|
|
|
|
+ } else if (param.getType() == 2) {
|
|
|
|
+ criteria.andEqualTo("ppid", param.getUserId());
|
|
}
|
|
}
|
|
- if (param.getStatus() != null){
|
|
|
|
- criteria.andEqualTo("status",param.getStatus());
|
|
|
|
|
|
+ if (param.getStatus() != null) {
|
|
|
|
+ criteria.andEqualTo("status", param.getStatus());
|
|
}
|
|
}
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
criteria.andLike("name", "%" + param.getName() + "%");
|
|
criteria.andLike("name", "%" + param.getName() + "%");
|
|
@@ -114,34 +120,34 @@ public class UserController extends AbstractApiController {
|
|
if (StrUtil.isNotBlank(param.getEndTime())) {
|
|
if (StrUtil.isNotBlank(param.getEndTime())) {
|
|
criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
PageInfo pageInfo = null;
|
|
PageInfo pageInfo = null;
|
|
try {
|
|
try {
|
|
condition.setOrderByClause("create_time desc");
|
|
condition.setOrderByClause("create_time desc");
|
|
List<User> list = userService.findByCondition(condition);
|
|
List<User> list = userService.findByCondition(condition);
|
|
pageInfo = new PageInfo(list);
|
|
pageInfo = new PageInfo(list);
|
|
pageInfo.setList(list.stream().map(u -> {
|
|
pageInfo.setList(list.stream().map(u -> {
|
|
- UserBo2 bo = BeanUtil.toBean(u,UserBo2.class);
|
|
|
|
- //邀请人数、团队人数
|
|
|
|
- Condition c = new Condition(User.class);
|
|
|
|
- c.createCriteria().andEqualTo("pid",u.getId());
|
|
|
|
|
|
+ UserBo2 bo = BeanUtil.toBean(u, UserBo2.class);
|
|
|
|
+ // 邀请人数、团队人数
|
|
|
|
+ Condition c = new Condition(User.class);
|
|
|
|
+ c.createCriteria().andEqualTo("pid", u.getId());
|
|
Integer inviteNum = userService.countByCondition(c);
|
|
Integer inviteNum = userService.countByCondition(c);
|
|
bo.setInviteNum(inviteNum);
|
|
bo.setInviteNum(inviteNum);
|
|
- c = new Condition(User.class);
|
|
|
|
- c.createCriteria().andEqualTo("ppid",u.getId());
|
|
|
|
|
|
+ c = new Condition(User.class);
|
|
|
|
+ c.createCriteria().andEqualTo("ppid", u.getId());
|
|
Integer inviteNextNum = userService.countByCondition(c);
|
|
Integer inviteNextNum = userService.countByCondition(c);
|
|
- bo.setTeamNum(inviteNum+inviteNextNum);
|
|
|
|
- //付款过的订单
|
|
|
|
- c = new Condition(Flow.class);
|
|
|
|
- c.createCriteria().andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(),BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
|
|
|
|
+ bo.setTeamNum(inviteNum + inviteNextNum);
|
|
|
|
+ // 付款过的订单
|
|
|
|
+ c = new Condition(Flow.class);
|
|
|
|
+ c.createCriteria().andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(), BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
Integer payNum = flowService.countByCondition(c);
|
|
Integer payNum = flowService.countByCondition(c);
|
|
bo.setSuccessGroupNum(payNum);
|
|
bo.setSuccessGroupNum(payNum);
|
|
- //钱包余额
|
|
|
|
|
|
+ // 钱包余额
|
|
Account wallet = accountService.getAccount(u.getId(), 1);
|
|
Account wallet = accountService.getAccount(u.getId(), 1);
|
|
bo.setWalletBalance(wallet.getBalance());
|
|
bo.setWalletBalance(wallet.getBalance());
|
|
Account earnings = accountService.getAccount(u.getId(), 2);
|
|
Account earnings = accountService.getAccount(u.getId(), 2);
|
|
bo.setEarningsBalance(earnings.getBalance());
|
|
bo.setEarningsBalance(earnings.getBalance());
|
|
-
|
|
|
|
|
|
+
|
|
return bo;
|
|
return bo;
|
|
}).collect(Collectors.toList()));
|
|
}).collect(Collectors.toList()));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -150,92 +156,93 @@ public class UserController extends AbstractApiController {
|
|
}
|
|
}
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@GetMapping("/detail")
|
|
@GetMapping("/detail")
|
|
- @ApiOperation(value = "获取用户详情",httpMethod = "GET")
|
|
|
|
|
|
+ @ApiOperation(value = "获取用户详情", httpMethod = "GET")
|
|
public Result<UserDetailBo> list(@RequestParam Long userId) {
|
|
public Result<UserDetailBo> list(@RequestParam Long userId) {
|
|
User u = userService.findById(userId);
|
|
User u = userService.findById(userId);
|
|
- if (u == null){
|
|
|
|
|
|
+ if (u == null) {
|
|
return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
}
|
|
}
|
|
- UserDetailBo bo = BeanUtil.toBean(u,UserDetailBo.class);
|
|
|
|
- Condition c = new Condition(User.class);
|
|
|
|
- c.createCriteria().andEqualTo("pid",u.getId());
|
|
|
|
|
|
+ UserDetailBo bo = BeanUtil.toBean(u, UserDetailBo.class);
|
|
|
|
+ Condition c = new Condition(User.class);
|
|
|
|
+ c.createCriteria().andEqualTo("pid", u.getId());
|
|
Integer inviteNum = userService.countByCondition(c);
|
|
Integer inviteNum = userService.countByCondition(c);
|
|
bo.setInviteNum(inviteNum);
|
|
bo.setInviteNum(inviteNum);
|
|
- c = new Condition(User.class);
|
|
|
|
- c.createCriteria().andEqualTo("ppid",u.getId());
|
|
|
|
|
|
+ c = new Condition(User.class);
|
|
|
|
+ c.createCriteria().andEqualTo("ppid", u.getId());
|
|
Integer inviteNextNum = userService.countByCondition(c);
|
|
Integer inviteNextNum = userService.countByCondition(c);
|
|
- bo.setTeamNum(inviteNum+inviteNextNum);
|
|
|
|
- //付款过的订单
|
|
|
|
- c = new Condition(Flow.class);
|
|
|
|
- c.createCriteria().andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(),BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
|
|
|
|
+ bo.setTeamNum(inviteNum + inviteNextNum);
|
|
|
|
+ // 付款过的订单
|
|
|
|
+ // fixme 不确定业务逻辑,可能存在想减负数场景
|
|
|
|
+ c = new Condition(Flow.class);
|
|
|
|
+ c.createCriteria().andEqualTo("userId", u.getId()).andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(), BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
Integer payNum = flowService.countByCondition(c);
|
|
Integer payNum = flowService.countByCondition(c);
|
|
- if (payNum == null){
|
|
|
|
|
|
+ if (payNum == null) {
|
|
payNum = 0;
|
|
payNum = 0;
|
|
}
|
|
}
|
|
- c = new Condition(Flow.class);
|
|
|
|
- c.createCriteria().andEqualTo("bizType", BizTypeEnum.FAIL_GROUP_REFUND.getKey());
|
|
|
|
|
|
+ c = new Condition(Flow.class);
|
|
|
|
+ c.createCriteria().andEqualTo("userId", u.getId()).andEqualTo("bizType", BizTypeEnum.FAIL_GROUP_REFUND.getKey());
|
|
Integer unpayNum = flowService.countByCondition(c);
|
|
Integer unpayNum = flowService.countByCondition(c);
|
|
- if (unpayNum == null){
|
|
|
|
|
|
+ if (unpayNum == null) {
|
|
unpayNum = 0;
|
|
unpayNum = 0;
|
|
}
|
|
}
|
|
- bo.setSuccessGroupNum(payNum-unpayNum);
|
|
|
|
- //钱包余额
|
|
|
|
|
|
+ bo.setSuccessGroupNum(payNum - unpayNum);
|
|
|
|
+ // 钱包余额
|
|
Account wallet = accountService.getAccount(u.getId(), 1);
|
|
Account wallet = accountService.getAccount(u.getId(), 1);
|
|
bo.setWalletBalance(wallet.getBalance());
|
|
bo.setWalletBalance(wallet.getBalance());
|
|
Account earnings = accountService.getAccount(u.getId(), 2);
|
|
Account earnings = accountService.getAccount(u.getId(), 2);
|
|
bo.setEarningsBalance(earnings.getBalance());
|
|
bo.setEarningsBalance(earnings.getBalance());
|
|
-
|
|
|
|
|
|
+
|
|
// 可参团数
|
|
// 可参团数
|
|
ConfigMember member = configMemberService.findBy("level", u.getVipLevel());
|
|
ConfigMember member = configMemberService.findBy("level", u.getVipLevel());
|
|
bo.setGroupNum(member.getJoinedGroupsNo());
|
|
bo.setGroupNum(member.getJoinedGroupsNo());
|
|
- BigDecimal totalEarnings = redEnvelopeService.sumWithDay(null, u.getId(), 3);
|
|
|
|
|
|
+ BigDecimal totalEarnings = redEnvelopeService.sumWithDay(null, u.getId(), 3);
|
|
bo.setTotalEarnings(totalEarnings);
|
|
bo.setTotalEarnings(totalEarnings);
|
|
-
|
|
|
|
- c = new Condition(Flow.class);
|
|
|
|
- c.createCriteria().andGreaterThanOrEqualTo("createTime",DateUtil.today())
|
|
|
|
- .andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(),BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
|
|
|
|
+
|
|
|
|
+ c = new Condition(Flow.class);
|
|
|
|
+ c.createCriteria().andGreaterThanOrEqualTo("createTime", DateUtil.today())
|
|
|
|
+ .andIn("bizType", CollUtil.newArrayList(BizTypeEnum.OPEN_GROUP_PAY.getKey(), BizTypeEnum.JOIN_GROUP_PAY.getKey()));
|
|
Integer payNumToday = flowService.countByCondition(c);
|
|
Integer payNumToday = flowService.countByCondition(c);
|
|
- if (payNumToday == null){
|
|
|
|
|
|
+ if (payNumToday == null) {
|
|
payNumToday = 0;
|
|
payNumToday = 0;
|
|
}
|
|
}
|
|
- c = new Condition(Flow.class);
|
|
|
|
|
|
+ c = new Condition(Flow.class);
|
|
c.createCriteria().andEqualTo("bizType", BizTypeEnum.FAIL_GROUP_REFUND.getKey())
|
|
c.createCriteria().andEqualTo("bizType", BizTypeEnum.FAIL_GROUP_REFUND.getKey())
|
|
- .andGreaterThanOrEqualTo("createTime",DateUtil.today())
|
|
|
|
|
|
+ .andGreaterThanOrEqualTo("createTime", DateUtil.today())
|
|
;
|
|
;
|
|
Integer unpayNumToday = flowService.countByCondition(c);
|
|
Integer unpayNumToday = flowService.countByCondition(c);
|
|
- if (unpayNumToday == null){
|
|
|
|
|
|
+ if (unpayNumToday == null) {
|
|
unpayNumToday = 0;
|
|
unpayNumToday = 0;
|
|
}
|
|
}
|
|
- bo.setOpenGroupNum(payNumToday-unpayNumToday);
|
|
|
|
- //已结算金额
|
|
|
|
|
|
+ bo.setOpenGroupNum(payNumToday - unpayNumToday);
|
|
|
|
+ // 已结算金额
|
|
bo.setSettledEarnings(earnings.getTotalInamount());
|
|
bo.setSettledEarnings(earnings.getTotalInamount());
|
|
- //充值总金额
|
|
|
|
|
|
+ // 充值总金额
|
|
bo.setRechargeAmount(wallet.getTotalInamount());
|
|
bo.setRechargeAmount(wallet.getTotalInamount());
|
|
- BigDecimal l7DEarnings = redEnvelopeService.sumWithDay(DateUtil.offsetDay(DateUtil.date(),-7).toDateStr(), u.getId(), null);
|
|
|
|
|
|
+ BigDecimal l7DEarnings = redEnvelopeService.sumWithDay(DateUtil.offsetDay(DateUtil.date(), -7).toDateStr(), u.getId(), null);
|
|
bo.setL7DEarnings(l7DEarnings);
|
|
bo.setL7DEarnings(l7DEarnings);
|
|
- BigDecimal pendingEarnings = redEnvelopeService.sumWithDay(null, u.getId(), 1);
|
|
|
|
|
|
+ BigDecimal pendingEarnings = redEnvelopeService.sumWithDay(null, u.getId(), 1);
|
|
bo.setPendingEarnings(pendingEarnings);
|
|
bo.setPendingEarnings(pendingEarnings);
|
|
- bo.setWithdrawAmount(earnings.getTotalOutAmount());
|
|
|
|
|
|
+ bo.setWithdrawAmount(earnings.getTotalOutAmount().add(wallet.getTotalOutAmount()));
|
|
bo.setVipLevel(u.getVipLevel());
|
|
bo.setVipLevel(u.getVipLevel());
|
|
return ResultGenerator.genSuccessResult(bo);
|
|
return ResultGenerator.genSuccessResult(bo);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@PostMapping("/myUsers")
|
|
@PostMapping("/myUsers")
|
|
- @ApiOperation(value = "获取我的下级用户和下下级",httpMethod = "POST")
|
|
|
|
|
|
+ @ApiOperation(value = "获取我的下级用户和下下级", httpMethod = "POST")
|
|
public Result<List<User>> myUsers(@RequestBody MyUserParam param) {
|
|
public Result<List<User>> myUsers(@RequestBody MyUserParam param) {
|
|
PageHelper.startPage(param.getPage(), param.getSize());
|
|
PageHelper.startPage(param.getPage(), param.getSize());
|
|
Condition condition = new Condition(User.class);
|
|
Condition condition = new Condition(User.class);
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
- if (param.getType() == null){
|
|
|
|
|
|
+ if (param.getType() == null) {
|
|
param.setType(0);
|
|
param.setType(0);
|
|
}
|
|
}
|
|
- if (param.getType() == 1){
|
|
|
|
- criteria.andEqualTo("pid",param.getUserId());
|
|
|
|
- } else if (param.getType() == 2){
|
|
|
|
- criteria.andEqualTo("ppid",param.getUserId());
|
|
|
|
|
|
+ if (param.getType() == 1) {
|
|
|
|
+ criteria.andEqualTo("pid", param.getUserId());
|
|
|
|
+ } else if (param.getType() == 2) {
|
|
|
|
+ criteria.andEqualTo("ppid", param.getUserId());
|
|
}
|
|
}
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
criteria.andLike("name", "%" + param.getName() + "%");
|
|
criteria.andLike("name", "%" + param.getName() + "%");
|
|
@@ -249,7 +256,7 @@ public class UserController extends AbstractApiController {
|
|
if (StrUtil.isNotBlank(param.getEndTime())) {
|
|
if (StrUtil.isNotBlank(param.getEndTime())) {
|
|
criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
PageInfo pageInfo = null;
|
|
PageInfo pageInfo = null;
|
|
try {
|
|
try {
|
|
List<User> list = userService.findByCondition(condition);
|
|
List<User> list = userService.findByCondition(condition);
|
|
@@ -264,43 +271,43 @@ public class UserController extends AbstractApiController {
|
|
}
|
|
}
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
return ResultGenerator.genSuccessResult(pageInfo);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@GetMapping("/report")
|
|
@GetMapping("/report")
|
|
@ApiOperation(value = "导出", httpMethod = "GET")
|
|
@ApiOperation(value = "导出", httpMethod = "GET")
|
|
public void report(
|
|
public void report(
|
|
- @RequestParam(required = false) Integer hasWithdraw ,
|
|
|
|
- @RequestParam(required = false) Integer hasLogin ,
|
|
|
|
- @RequestParam(required = false) Integer hasOrder ,
|
|
|
|
- @RequestParam(required = false) Long userId ,
|
|
|
|
- @RequestParam(required = false) String name ,
|
|
|
|
- @RequestParam(required = false) String phoneNo ,
|
|
|
|
- @RequestParam(required = false) Integer status ,
|
|
|
|
- @RequestParam(required = false,defaultValue = "0") Integer type ,
|
|
|
|
- @RequestParam(required = false) String startTime ,
|
|
|
|
- @RequestParam(required = false) String endTime ,
|
|
|
|
|
|
+ @RequestParam(required = false) Integer hasWithdraw,
|
|
|
|
+ @RequestParam(required = false) Integer hasLogin,
|
|
|
|
+ @RequestParam(required = false) Integer hasOrder,
|
|
|
|
+ @RequestParam(required = false) Long userId,
|
|
|
|
+ @RequestParam(required = false) String name,
|
|
|
|
+ @RequestParam(required = false) String phoneNo,
|
|
|
|
+ @RequestParam(required = false) Integer status,
|
|
|
|
+ @RequestParam(required = false, defaultValue = "0") Integer type,
|
|
|
|
+ @RequestParam(required = false) String startTime,
|
|
|
|
+ @RequestParam(required = false) String endTime,
|
|
HttpServletResponse response) {
|
|
HttpServletResponse response) {
|
|
Condition condition = new Condition(User.class);
|
|
Condition condition = new Condition(User.class);
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
- if (hasWithdraw != null){
|
|
|
|
- criteria.andEqualTo("hasWithdraw",hasWithdraw);
|
|
|
|
|
|
+ if (hasWithdraw != null) {
|
|
|
|
+ criteria.andEqualTo("hasWithdraw", hasWithdraw);
|
|
}
|
|
}
|
|
- if (hasLogin != null){
|
|
|
|
- criteria.andEqualTo("hasLogin",hasLogin);
|
|
|
|
|
|
+ if (hasLogin != null) {
|
|
|
|
+ criteria.andEqualTo("hasLogin", hasLogin);
|
|
}
|
|
}
|
|
- if (hasOrder != null){
|
|
|
|
- criteria.andEqualTo("hasOrder",hasOrder);
|
|
|
|
|
|
+ if (hasOrder != null) {
|
|
|
|
+ criteria.andEqualTo("hasOrder", hasOrder);
|
|
}
|
|
}
|
|
- if (type == 1){
|
|
|
|
- if (userId != null){
|
|
|
|
- criteria.andEqualTo("pid",userId);
|
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
+ if (userId != null) {
|
|
|
|
+ criteria.andEqualTo("pid", userId);
|
|
}
|
|
}
|
|
- } else if (type == 2){
|
|
|
|
- if (userId != null){
|
|
|
|
- criteria.andEqualTo("ppid",userId);
|
|
|
|
|
|
+ } else if (type == 2) {
|
|
|
|
+ if (userId != null) {
|
|
|
|
+ criteria.andEqualTo("ppid", userId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (status != null){
|
|
|
|
- criteria.andEqualTo("status",status);
|
|
|
|
|
|
+ if (status != null) {
|
|
|
|
+ criteria.andEqualTo("status", status);
|
|
}
|
|
}
|
|
if (StrUtil.isNotBlank(name)) {
|
|
if (StrUtil.isNotBlank(name)) {
|
|
criteria.andLike("name", "%" + name + "%");
|
|
criteria.andLike("name", "%" + name + "%");
|
|
@@ -316,40 +323,40 @@ public class UserController extends AbstractApiController {
|
|
}
|
|
}
|
|
condition.setOrderByClause("create_time desc");
|
|
condition.setOrderByClause("create_time desc");
|
|
List<User> users = userService.findByCondition(condition);
|
|
List<User> users = userService.findByCondition(condition);
|
|
- List<String> rowHead = CollUtil.newArrayList("编号", "用户号", "邀请码", "昵称", "名字", "银行", "银行账号", "银行用户名字", "电话", "vip等级", "备注", "是否有提现权限 1是 2否", "是否有登录权限 1是 2否", "是否有下单权限 1是 2否","注册时间");
|
|
|
|
|
|
+ List<String> rowHead = CollUtil.newArrayList("编号", "用户号", "邀请码", "昵称", "名字", "银行", "银行账号", "银行用户名字", "电话", "vip等级", "备注", "是否有提现权限 1是 2否", "是否有登录权限 1是 2否", "是否有下单权限 1是 2否", "注册时间");
|
|
ExcelWriter writer = ExcelUtil.getWriter();
|
|
ExcelWriter writer = ExcelUtil.getWriter();
|
|
try {
|
|
try {
|
|
writer.writeHeadRow(rowHead);
|
|
writer.writeHeadRow(rowHead);
|
|
List<List<Object>> rows = new LinkedList<>();
|
|
List<List<Object>> rows = new LinkedList<>();
|
|
if (CollUtil.isNotEmpty(users)) {
|
|
if (CollUtil.isNotEmpty(users)) {
|
|
for (User temp : users) {
|
|
for (User temp : users) {
|
|
- List<Object> rowA = CollUtil.newArrayList(temp.getId()+"",
|
|
|
|
|
|
+ List<Object> rowA = CollUtil.newArrayList(temp.getId() + "",
|
|
temp.getUserNo(),
|
|
temp.getUserNo(),
|
|
temp.getInvitedCode(),
|
|
temp.getInvitedCode(),
|
|
temp.getNickname()
|
|
temp.getNickname()
|
|
- ,temp.getName(),
|
|
|
|
|
|
+ , temp.getName(),
|
|
temp.getBank(),
|
|
temp.getBank(),
|
|
temp.getBankAccount(),
|
|
temp.getBankAccount(),
|
|
temp.getBankAccountName(),
|
|
temp.getBankAccountName(),
|
|
temp.getPhoneNo(),
|
|
temp.getPhoneNo(),
|
|
- temp.getVipLevel()+"",
|
|
|
|
|
|
+ temp.getVipLevel() + "",
|
|
temp.getMemo(),
|
|
temp.getMemo(),
|
|
- temp.getHasWithdraw()+"",
|
|
|
|
- temp.getHasLogin()+"",
|
|
|
|
- temp.getHasOrder()+"",
|
|
|
|
|
|
+ temp.getHasWithdraw() + "",
|
|
|
|
+ temp.getHasLogin() + "",
|
|
|
|
+ temp.getHasOrder() + "",
|
|
DateUtil.format(temp.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
DateUtil.format(temp.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
rows.add(rowA);
|
|
rows.add(rowA);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
writer.write(rows);
|
|
writer.write(rows);
|
|
- //设置宽度自适应
|
|
|
|
|
|
+ // 设置宽度自适应
|
|
writer.setColumnWidth(-1, 22);
|
|
writer.setColumnWidth(-1, 22);
|
|
- //response为HttpServletResponse对象
|
|
|
|
|
|
+ // response为HttpServletResponse对象
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
- //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
|
|
|
|
|
+ // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + new String(("数据列表").getBytes("UTF-8"), "ISO-8859-1") + ".xls");
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + new String(("数据列表").getBytes("UTF-8"), "ISO-8859-1") + ".xls");
|
|
ServletOutputStream out = response.getOutputStream();
|
|
ServletOutputStream out = response.getOutputStream();
|
|
- //out为OutputStream,需要写出到的目标流
|
|
|
|
|
|
+ // out为OutputStream,需要写出到的目标流
|
|
writer.flush(out);
|
|
writer.flush(out);
|
|
log.info("导出结束");
|
|
log.info("导出结束");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -361,6 +368,6 @@ public class UserController extends AbstractApiController {
|
|
log.info("导出结束");
|
|
log.info("导出结束");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|