Parcourir la source

fix : 玩家角色列表增加下载

bilingfeng il y a 1 an
Parent
commit
1094710de1

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <权限修改提交修改完成!!!!!> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <玩家角色新增下载> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 9 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/UserController.java

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -121,6 +122,14 @@ public class UserController {
         return ResultVO.ok(gameUserRoleService.list(param));
     }
 
+    @ApiOperation(value = "玩家游戏角色Excel下载")
+    @PostMapping(value = "/role/list/excel")
+    @PreAuthorize(permissionKey = "manage:user:roleListExcel")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功")})
+    public void getGameUserRoleExcel(@Validated @RequestBody GameUserRoleListParam param, HttpServletResponse response) {
+        gameUserRoleService.getGameUserRoleExcel(param, response);
+    }
+
     @ApiOperation(value = "玩家实名认证列表")
     @PostMapping(value = "/card/list")
     @PreAuthorize(permissionKey = "manage:userCard:list")

+ 184 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameUserRoleExcelVO.java

@@ -0,0 +1,184 @@
+package com.zanxiang.game.module.manage.pojo.vo;
+
+import com.zanxiang.module.util.excel.ExcelAnno;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-23
+ * @description : 玩家角色表格
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class GameUserRoleExcelVO {
+
+    /**
+     * 玩家id
+     */
+    @ExcelAnno(title = "玩家id")
+    private Long userId;
+
+    /**
+     * 玩家账号
+     */
+    @ExcelAnno(title = "玩家账号")
+    private String username;
+
+    /**
+     * 玩家昵称
+     */
+    @ExcelAnno(title = "玩家昵称")
+    private String nickname;
+
+    /**
+     * 注册IP
+     */
+    @ExcelAnno(title = "注册IP")
+    private String regIp;
+
+    /**
+     * 玩家注册时间
+     */
+    @ExcelAnno(title = "玩家注册时间")
+    private LocalDateTime regTime;
+
+    /**
+     * 注册渠道名称
+     */
+    @ExcelAnno(title = "注册渠道名称")
+    private String agentName;
+
+    /**
+     * cp名称
+     */
+    @ExcelAnno(title = "cp名称")
+    private String cpName;
+
+    /**
+     * 游戏名称
+     */
+    @ExcelAnno(title = "游戏名称")
+    private String gameName;
+
+    /**
+     * 游戏应用类型名称
+     */
+    @ExcelAnno(title = "游戏应用类型名称")
+    private String gameCategoryName;
+
+    /**
+     * 原始服务器名称
+     */
+    @ExcelAnno(title = "原始服务器名称")
+    private String sourceServerName;
+
+    /**
+     * 游戏区服
+     */
+    @ExcelAnno(title = "游戏区服")
+    private String serverName;
+
+    /**
+     * 游戏角色
+     */
+    @ExcelAnno(title = "游戏角色")
+    private String roleName;
+
+    /**
+     * 游戏角色id
+     */
+    @ExcelAnno(title = "游戏角色id")
+    private String roleId;
+
+    /**
+     * 角色等级
+     */
+    @ExcelAnno(title = "角色等级")
+    private Long roleLevel;
+
+    /**
+     * 游戏战力
+     */
+    @ExcelAnno(title = "游戏战力")
+    private Long rolePower;
+
+    /**
+     * 角色vip
+     */
+    @ExcelAnno(title = "角色vip")
+    private Long roleVipLevel;
+
+    /**
+     * 操作系统
+     */
+    @ExcelAnno(title = "操作系统")
+    private String os;
+
+    /**
+     * 充值金额
+     */
+    @ExcelAnno(title = "充值金额")
+    private BigDecimal rechargeMoney;
+
+    /**
+     * 充值次数
+     */
+    @ExcelAnno(title = "充值次数")
+    private Integer rechargeCount;
+
+    /**
+     * 角色创建时间
+     */
+    @ExcelAnno(title = "角色创建时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 最近登录时间
+     */
+    @ExcelAnno(title = "最近登录时间")
+    private LocalDateTime lastLoginTime;
+
+    /**
+     * 游戏角色更新时间
+     */
+    @ExcelAnno(title = "游戏角色更新时间")
+    private LocalDateTime updateTime;
+
+    /**
+     * 最近充值时间
+     */
+    @ExcelAnno(title = "最近充值时间")
+    private LocalDateTime lastRechargeTime;
+
+    /**
+     * 归因投放人员名字
+     */
+    @ExcelAnno(title = "归因投放人员名字")
+    private String pitcherName;
+
+    /**
+     * 归因推广账号id
+     */
+    @ExcelAnno(title = "归因推广账号id")
+    private Long accountId;
+
+    /**
+     * 归因推广账号类型(1:腾讯、2:头条)
+     */
+    @ExcelAnno(title = "因推广账号类型(1:腾讯、2:头条)")
+    private Integer accountType;
+
+    /**
+     * 注册充值时间差
+     */
+    @ExcelAnno(title = "注册充值时间差")
+    private Long regPayTimeDiff;
+}

+ 9 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameUserRoleService.java

@@ -8,6 +8,7 @@ import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleListVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleVO;
 import com.zanxiang.game.module.mybatis.entity.GameUserRole;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -51,4 +52,12 @@ public interface IGameUserRoleService extends IService<GameUserRole> {
      * @return {@link IPage}<{@link GameUserRoleListVO}>
      */
     IPage<GameUserRoleListVO> list(GameUserRoleListParam param);
+
+    /**
+     * 游戏用户角色excel
+     *
+     * @param param    参数
+     * @param response 响应
+     */
+    void getGameUserRoleExcel(GameUserRoleListParam param, HttpServletResponse response);
 }

+ 70 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -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(param.toPage(), 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);
+    }
 }

+ 7 - 8
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java

@@ -277,18 +277,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
         List<Long> gameIdList = gameTuple.getT2();
         if (CollectionUtils.isEmpty(gameIdList)) {
-            throw new BaseException("参数错误, 未配置游戏权限");
+            return;
         }
         //渠道获取
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIds = tuple2.getT1();
-        List<AgentDTO> agentDTOList = tuple2.getT2();
+        //渠道
+        Map<Long, AgentDTO> agentMap = tuple2.getT2().stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
         //查询用户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()));
         }
+        //商户列表
+        Map<String, PayMerchantDTO> payMerchantMap = payMerchantService.payMerchantMap();
+        //cp信息
+        Map<Long, CpDTO> cpMap = cpService.cpMap();
         final List<Long> userIds = userList.stream().map(User::getId).collect(Collectors.toList());
         List<String> serverIdList = gameServerService.listServerId(param.getGameId(), param.getServerName());
         //excel下载
@@ -296,17 +301,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //查询订单
             List<OrderVO> orderVOList = page(new Page<>(pageNumber, pageSize), this.getListWrapper(param, gameTuple,
                     agentIds, userIds, serverIdList, "*")).convert(this::toVO).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字段赋值