|
@@ -6,11 +6,13 @@ 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.GameAuthEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
|
|
|
import com.zanxiang.game.module.base.util.DateUtils;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.*;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.GameUserRoleListParam;
|
|
|
+import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleExcelVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleListVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleVO;
|
|
|
import com.zanxiang.game.module.manage.service.*;
|
|
@@ -19,12 +21,16 @@ import com.zanxiang.game.module.mybatis.entity.GameServer;
|
|
|
import com.zanxiang.game.module.mybatis.entity.GameUserRole;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.GameUserRoleMapper;
|
|
|
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.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
@@ -211,4 +217,68 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
|
|
|
}
|
|
|
return gameUserRoleListVO;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getGameUserRoleExcel(GameUserRoleListParam param, HttpServletResponse response) {
|
|
|
+ if (!SecurityUtil.isAdmin()) {
|
|
|
+ throw new BaseException("没有下载权限");
|
|
|
+ }
|
|
|
+ //游戏获取
|
|
|
+ Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
|
|
|
+ if (CollectionUtils.isEmpty(gameTuple.getT2())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //游戏条件处理
|
|
|
+ Map<Long, GameDTO> gameMap = gameService.gameCondition(gameTuple.getT2(), param.getCpId(), param.getGameId(), param.getGameCategoryId());
|
|
|
+ //根据条件, 匹配不到游戏
|
|
|
+ if (gameMap != null && gameMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //渠道获取
|
|
|
+ Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
+ List<Long> agentIdList = tuple2.getT1();
|
|
|
+ List<AgentDTO> agentDTOList = tuple2.getT2();
|
|
|
+ if (Objects.equals(gameTuple.getT1(), GameAuthEnum.PITCHER.getValue()) && CollectionUtils.isEmpty(agentIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //玩家条件处理
|
|
|
+ Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
|
|
|
+ param.getNickname(), param.getRegIp(), param.getRegTimeBeginDate(), param.getRegTimeEndDate());
|
|
|
+ //根据条件, 匹配不到玩家
|
|
|
+ if (userMap != null && userMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //区服筛选
|
|
|
+ List<String> serverIdList = gameServerService.listServerId(param.getGameId(), param.getServerName());
|
|
|
+ Map<Long, CpDTO> cpMap = cpService.cpMap();
|
|
|
+ //相关用户id
|
|
|
+ Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
+ Set<Long> userIdSet = userMap == null ? null : userMap.keySet();
|
|
|
+ //下载查询
|
|
|
+ WebExcelUtil.httpExport(response, "玩家角色", GameUserRoleExcelVO.class, ((pageNumber, pageSize) -> {
|
|
|
+ //查询订单
|
|
|
+ return page(new Page<>(pageNumber, pageSize), new QueryWrapper<GameUserRole>().lambda()
|
|
|
+ .in(CollectionUtils.isNotEmpty(userIdSet), GameUserRole::getUserId, userIdSet)
|
|
|
+ .in(CollectionUtils.isNotEmpty(serverIdList), GameUserRole::getServerId, serverIdList)
|
|
|
+ .in(gameMap != null, GameUserRole::getGameId, gameMap != null ? gameMap.keySet() : null)
|
|
|
+ .like(Strings.isNotBlank(param.getRoleName()), GameUserRole::getRoleName, param.getRoleName())
|
|
|
+ .eq(Objects.equals(param.getIsRecharge(), Boolean.FALSE), GameUserRole::getRechargeCount, 0)
|
|
|
+ .eq(Strings.isNotBlank(param.getOs()), GameUserRole::getOs, param.getOs())
|
|
|
+ .gt(Objects.equals(param.getIsRecharge(), Boolean.TRUE), GameUserRole::getRechargeCount, 0)
|
|
|
+ .gt(param.getVipLevel() != null && param.getVipLevel() > 10, GameUserRole::getRoleVipLevel, param.getVipLevel())
|
|
|
+ .eq(param.getVipLevel() != null && param.getVipLevel() <= 10, GameUserRole::getRoleVipLevel, param.getVipLevel())
|
|
|
+ .le(param.getEndDate() != null, GameUserRole::getCreateTime, param.getEndDate() == null ? null : LocalDateTime.of(param.getEndDate(), LocalTime.MAX))
|
|
|
+ .ge(param.getBeginDate() != null, GameUserRole::getCreateTime, param.getBeginDate() == null ? null : LocalDateTime.of(param.getBeginDate(), LocalTime.MIN))
|
|
|
+ .le(param.getRechargeEndDate() != null, GameUserRole::getLastRechargeTime, param.getRechargeEndDate() == null ? null : LocalDateTime.of(param.getRechargeEndDate(), LocalTime.MAX))
|
|
|
+ .ge(param.getRechargeBeginDate() != null, GameUserRole::getLastRechargeTime, param.getRechargeBeginDate() == null ? null : LocalDateTime.of(param.getRechargeBeginDate(), LocalTime.MIN))
|
|
|
+ .le(param.getRoleLevelMax() != null, GameUserRole::getRoleLevel, param.getRoleLevelMax())
|
|
|
+ .ge(param.getRoleLevelMin() != null, GameUserRole::getRoleLevel, param.getRoleLevelMin())
|
|
|
+ .apply(param.getRegPayIntervalTimeMax() != null, "if(last_recharge_time is not null, TIMESTAMPDIFF(minute, reg_time, last_recharge_time), null) <= {0}", param.getRegPayIntervalTimeMax())
|
|
|
+ .apply(param.getRegPayIntervalTimeMin() != null, "if(last_recharge_time is not null, TIMESTAMPDIFF(minute, reg_time, last_recharge_time), null) >= {0}", param.getRegPayIntervalTimeMin())
|
|
|
+ .orderByDesc(GameUserRole::getCreateTime)
|
|
|
+ ).convert(u -> this.toVo(u, userMap, gameMap, cpMap, agentMap)).getRecords()
|
|
|
+ .stream().map(gameUserRoleListVO -> BeanUtil.copy(gameUserRoleListVO, GameUserRoleExcelVO.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }), ExcelUtil.DEFAULT_MAX_DATA_SIZE);
|
|
|
+ }
|
|
|
}
|