|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
|
|
@@ -12,6 +13,7 @@ import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.*;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.OrderParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.UserOrderListParam;
|
|
|
+import com.zanxiang.game.module.manage.pojo.vo.OrderExcelVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.OrderListVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.OrderVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.UserOrderListVO;
|
|
@@ -21,18 +23,20 @@ import com.zanxiang.game.module.mybatis.entity.Order;
|
|
|
import com.zanxiang.game.module.mybatis.entity.User;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.OrderMapper;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
+import com.zanxiang.module.util.excel.ExcelUtil;
|
|
|
+import com.zanxiang.module.util.exception.BaseException;
|
|
|
+import com.zanxiang.module.web.util.WebExcelUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -96,19 +100,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
|
|
|
@Override
|
|
|
public OrderListVO orderList(OrderParam param) {
|
|
|
- //渠道列表
|
|
|
- List<AgentDTO> agentDTOList = agentService.listUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
- //根据条件, 匹配渠道
|
|
|
- if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isManager()) {
|
|
|
+ //渠道获取
|
|
|
+ Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
+ List<Long> agentIds = tuple2.getT1();
|
|
|
+ if (CollectionUtils.isEmpty(agentIds)) {
|
|
|
return new OrderListVO(param.toPage().getSize());
|
|
|
}
|
|
|
- //渠道id列表
|
|
|
- List<Long> agentIds = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
|
|
|
- //管理员可见自然量数据
|
|
|
- if (SecurityUtil.isManager() && Strings.isBlank(param.getAccountId())
|
|
|
- && Strings.isBlank(param.getPitcherId()) && param.getChannelId() == null) {
|
|
|
- agentIds.add(Agent.DEFAULT_AGENT);
|
|
|
- }
|
|
|
//查询用户id和名字条件
|
|
|
List<Long> userIds = null;
|
|
|
if (Strings.isBlank(param.getUserId()) && Strings.isNotBlank(param.getUsername())) {
|
|
@@ -139,7 +136,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
List<Long> userIdList = orderListVOList.stream().map(OrderVO::getUserId).collect(Collectors.toList());
|
|
|
Map<Long, UserDTO> userMap = userService.getByUserIds(userIdList);
|
|
|
//渠道
|
|
|
- Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
+ Map<Long, AgentDTO> agentMap = tuple2.getT2().stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
//游戏信息
|
|
|
Map<Long, GameDTO> gameMap = gameService.gameMap(orderListVOList.stream()
|
|
|
.map(OrderVO::getGameId).collect(Collectors.toSet()));
|
|
@@ -173,6 +170,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
orderVO.setAccountType(agentDTO.getAccountType());
|
|
|
orderVO.setAgentName(agentDTO.getAgentName());
|
|
|
}
|
|
|
+ if (Objects.equals(orderVO.getAgentId(), Agent.DEFAULT_AGENT)) {
|
|
|
+ orderVO.setAgentName(Agent.DEFAULT_AGENT_NAME);
|
|
|
+ }
|
|
|
//CP名称
|
|
|
CpDTO cpDTO = cpMap.get(orderVO.getCpId());
|
|
|
orderVO.setCpName(cpDTO == null ? null : cpDTO.getCpName());
|
|
@@ -225,4 +225,43 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
return BeanUtil.copy(order, OrderVO.class);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getOrderExcel(OrderParam param, HttpServletResponse response) {
|
|
|
+ if (!SecurityUtil.isAdmin()) {
|
|
|
+ throw new BaseException("没有下载权限");
|
|
|
+ }
|
|
|
+ //渠道获取
|
|
|
+ Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
+ List<Long> agentIds = tuple2.getT1();
|
|
|
+ List<AgentDTO> agentDTOList = tuple2.getT2();
|
|
|
+ //查询用户id和名字条件
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if (Strings.isBlank(param.getUserId()) && Strings.isNotBlank(param.getUsername())) {
|
|
|
+ userList = userService.list(new LambdaQueryWrapper<User>()
|
|
|
+ .like(User::getUsername, param.getUsername()));
|
|
|
+ }
|
|
|
+ final List<Long> userIds = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ //excel下载
|
|
|
+ WebExcelUtil.httpExport(response, "游戏订单", OrderExcelVO.class, ((pageNumber, pageSize) -> {
|
|
|
+ //查询订单
|
|
|
+ List<OrderVO> orderVOList = page(new Page<>(pageNumber, pageSize), this.getListWrapper(param, agentIds, userIds, "*"))
|
|
|
+ .convert(this::orderToVo).getRecords();
|
|
|
+ //商户列表
|
|
|
+ Map<String, PayMerchantDTO> payMerchantMap = payMerchantService.payMerchantMap();
|
|
|
+ //cp信息
|
|
|
+ Map<Long, CpDTO> cpMap = cpService.cpMap();
|
|
|
+ //玩家信息
|
|
|
+ List<Long> userIdList = orderVOList.stream().map(OrderVO::getUserId).collect(Collectors.toList());
|
|
|
+ Map<Long, UserDTO> userMap = userService.getByUserIds(userIdList);
|
|
|
+ //游戏信息
|
|
|
+ Map<Long, GameDTO> gameMap = gameService.gameMap(orderVOList.stream().map(OrderVO::getGameId).collect(Collectors.toSet()));
|
|
|
+ //渠道
|
|
|
+ Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
+ //字段信息补充更新
|
|
|
+ orderVOList.forEach(vo -> this.toVO(vo, userMap, gameMap, cpMap, agentMap, payMerchantMap));
|
|
|
+ //excel字段赋值
|
|
|
+ return orderVOList.stream().map(orderVO -> BeanUtil.copy(orderVO, OrderExcelVO.class)).collect(Collectors.toList());
|
|
|
+ }), ExcelUtil.DEFAULT_MAX_DATA_SIZE);
|
|
|
+ }
|
|
|
}
|