Bläddra i källkod

fix : 上线一大波需求

bilingfeng 1 år sedan
förälder
incheckning
7c68b85f1c
16 ändrade filer med 197 tillägg och 22 borttagningar
  1. 8 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/UserController.java
  2. 24 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameUserRoleListParam.java
  3. 6 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameUserListVO.java
  4. 6 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameUserRoleListVO.java
  5. 6 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/OrderVO.java
  6. 6 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserListVO.java
  7. 26 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserWeChatVO.java
  8. 0 11
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserWechatVO.java
  9. 9 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IAgentService.java
  10. 19 6
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IUserService.java
  11. 32 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AgentServiceImpl.java
  12. 7 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java
  13. 5 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java
  14. 7 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java
  15. 1 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java
  16. 35 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

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

@@ -128,4 +128,12 @@ public class UserController {
     public ResultVO<IPage<UserCardVO>> authList(@Validated @RequestBody UserNameAuthListParam param) {
         return ResultVO.ok(userCardService.getUserCardList(param));
     }
+
+    @ApiOperation(value = "获取用户微信信息")
+    @GetMapping(value = "/weChat/info")
+    @PreAuthorize(permissionKey = "manage:user:weChatInfo")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = UserWeChatVO.class)})
+    public ResultVO<UserWeChatVO> getUserWeChat(@RequestParam Long userId) {
+        return ResultVO.ok(userService.getUserWeChat(userId));
+    }
 }

+ 24 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameUserRoleListParam.java

@@ -138,4 +138,28 @@ public class GameUserRoleListParam extends BaseListDTO<GameUserRole> {
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "结束时间")
     private LocalDate endDate;
+
+    /**
+     * 最小角色等级
+     */
+    @ApiModelProperty(value = "最小角色等级")
+    private Long roleLevelMin;
+
+    /**
+     * 最大角色等级
+     */
+    @ApiModelProperty(value = "最大角色等级")
+    private Long roleLevelMax;
+
+    /**
+     * 注册开始时间
+     */
+    @ApiModelProperty(value = "注册开始时间")
+    private LocalDate regTimeBeginDate;
+
+    /**
+     * 注册结束时间
+     */
+    @ApiModelProperty(value = "注册结束时间")
+    private LocalDate regTimeEndDate;
 }

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameUserListVO.java

@@ -176,4 +176,10 @@ public class GameUserListVO {
     @ApiModelProperty(notes = "最新游戏角色名称")
     private String lastGameRoleName;
 
+    /**
+     * 注册充值时间差
+     */
+    @ApiModelProperty(notes = "注册充值时间差")
+    private Long regPayTimeDiff;
+
 }

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameUserRoleListVO.java

@@ -208,4 +208,10 @@ public class GameUserRoleListVO {
     @ApiModelProperty(notes = "归因推广账号类型(1:腾讯、2:头条)")
     private Integer accountType;
 
+    /**
+     * 注册充值时间差
+     */
+    @ApiModelProperty(notes = "注册充值时间差")
+    private Long regPayTimeDiff;
+
 }

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/OrderVO.java

@@ -260,4 +260,10 @@ public class OrderVO {
      */
     @ApiModelProperty(notes = "是否首充 0 否 1 是")
     private Integer isFirstRecharge;
+
+    /**
+     * 注册充值时间差
+     */
+    @ApiModelProperty(notes = "注册充值时间差")
+    private Long regPayTimeDiff;
 }

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserListVO.java

@@ -188,4 +188,10 @@ public class UserListVO {
     @ApiModelProperty(notes = "最新游戏角色名称")
     private String lastGameRoleName;
 
+    /**
+     * 注册充值时间差
+     */
+    @ApiModelProperty(notes = "注册充值时间差")
+    private Long regPayTimeDiff;
+
 }

+ 26 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserWeChatVO.java

@@ -0,0 +1,26 @@
+package com.zanxiang.game.module.manage.pojo.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-07-26
+ * @description : 用户微信信息
+ */
+@Data
+public class UserWeChatVO {
+
+    /**
+     * 微信昵称
+     */
+    @ApiModelProperty(notes = "微信昵称")
+    private String name;
+
+    /**
+     * 微信头像
+     */
+    @ApiModelProperty(notes = "微信头像")
+    private String avatar;
+
+}

+ 0 - 11
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserWechatVO.java

@@ -1,11 +0,0 @@
-package com.zanxiang.game.module.manage.pojo.vo;
-
-/**
- * @author : lingfeng
- * @time : 2023-07-26
- * @description : 用户微信信息
- */
-public class UserWechatVO {
-
-
-}

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

@@ -12,6 +12,7 @@ import com.zanxiang.game.module.mybatis.entity.Agent;
 import reactor.util.function.Tuple2;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author wcc
@@ -75,4 +76,12 @@ public interface IAgentService extends IService<Agent> {
      * @return {@link List}<{@link AgentChoiceVO}>
      */
     List<AgentChoiceVO> agentChoiceList();
+
+    /**
+     * 通道变换
+     *
+     * @param channel 通道
+     * @return {@link Map}<{@link String}, {@link String}>
+     */
+    Map<String, String> channelTransform(String channel);
 }

+ 19 - 6
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IUserService.java

@@ -7,8 +7,10 @@ import com.zanxiang.game.module.manage.pojo.params.UserListParam;
 import com.zanxiang.game.module.manage.pojo.params.UserUpdateParam;
 import com.zanxiang.game.module.manage.pojo.vo.UserListVO;
 import com.zanxiang.game.module.manage.pojo.vo.UserVO;
+import com.zanxiang.game.module.manage.pojo.vo.UserWeChatVO;
 import com.zanxiang.game.module.mybatis.entity.User;
 
+import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
 
@@ -19,6 +21,14 @@ import java.util.Map;
  */
 public interface IUserService extends IService<User> {
 
+    /**
+     * 获取用户微信
+     *
+     * @param userId 用户id
+     * @return {@link UserWeChatVO}
+     */
+    UserWeChatVO getUserWeChat(Long userId);
+
     /**
      * 玩家列表查询
      *
@@ -46,14 +56,17 @@ public interface IUserService extends IService<User> {
     /**
      * 玩家相关条件查询用户信息
      *
-     * @param userId      : 用户id
-     * @param agentIdList : 渠道id列表
-     * @param userName    : 用户名称
-     * @param nickname    : 用户昵称
-     * @param regIp       : 用户注册ip
+     * @param userId           : 用户id
+     * @param agentIdList      : 渠道id列表
+     * @param userName         : 用户名称
+     * @param nickname         : 用户昵称
+     * @param regIp            : 用户注册ip
+     * @param regTimeBeginDate 注册时间开始日期
+     * @param regTimeEndDate   注册时间结束日期
      * @return {@link Map}<{@link Long}, {@link UserDTO}>
      */
-    Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname, String regIp);
+    Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname,
+                                     String regIp, LocalDate regTimeBeginDate, LocalDate regTimeEndDate);
 
     /**
      * 根据用户id查询信息

+ 32 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AgentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.module.manage.service.impl;
 
+import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -28,6 +29,7 @@ import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
+import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
@@ -288,4 +290,34 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         choiceVOList.add(AgentChoiceVO.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
         return choiceVOList;
     }
+
+    @Override
+    public Map<String, String> channelTransform(String channel) {
+        //判断是否是json, 是就直接转成map
+        if (this.isJsonStr(channel)) {
+            return JsonUtil.toMap(channel, Map.class, String.class);
+        }
+        //非json, 自己解析
+        Map<String, String> paramMap = new HashMap<>(11);
+        String[] params = channel.split("&");
+        for (String param : params) {
+            String[] keyValue = param.split("=");
+            if (keyValue.length > 1) {
+                String key = keyValue[0];
+                String value = keyValue[1];
+                paramMap.put(key, value);
+            }
+        }
+        return paramMap;
+    }
+
+    private boolean isJsonStr(String str) {
+        boolean result = false;
+        try {
+            JSON.parse(str);
+            result = true;
+        } catch (Exception ignored) {
+        }
+        return result;
+    }
 }

+ 7 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import reactor.util.function.Tuple2;
 
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.*;
@@ -116,7 +117,7 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         }
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
-                param.getNickname(), param.getRegIp());
+                param.getNickname(), param.getRegIp(), param.getRegTimeBeginDate(), param.getRegTimeEndDate());
         //根据条件, 匹配不到玩家
         if (userMap != null && userMap.isEmpty()) {
             return new Page<>();
@@ -140,6 +141,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
                 .le(param.getEndDate() != null, GameUserRole::getCreateTime, param.getEndDate() == null ? null : LocalDateTime.of(param.getEndDate(), LocalTime.MAX))
                 .ge(param.getRechargeBeginDate() != null, GameUserRole::getLastRechargeTime, param.getRechargeBeginDate() == null ? null : LocalDateTime.of(param.getRechargeBeginDate(), LocalTime.MIN))
                 .le(param.getRechargeEndDate() != null, GameUserRole::getLastRechargeTime, param.getRechargeEndDate() == null ? null : LocalDateTime.of(param.getRechargeEndDate(), LocalTime.MAX))
+                .ge(param.getRoleLevelMin() != null, GameUserRole::getRoleLevel, param.getRoleLevelMin())
+                .le(param.getRoleLevelMax() != null, GameUserRole::getRoleLevel, param.getRoleLevelMax())
                 .orderByDesc(GameUserRole::getCreateTime)
         ).convert(u -> this.toVo(u, userMap, gameMap, cpMap, agentMap));
     }
@@ -160,6 +163,9 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
             gameUserRoleListVO.setRegIp(userDTO.getIp());
             gameUserRoleListVO.setRegTime(userDTO.getCreateTime());
             gameUserRoleListVO.setAgentId(userDTO.getAgentId());
+            if (gameUserRoleListVO.getLastRechargeTime() != null) {
+                gameUserRoleListVO.setRegPayTimeDiff(Duration.between(userDTO.getCreateTime(), gameUserRoleListVO.getLastRechargeTime()).getSeconds());
+            }
             AgentDTO agentDTO = agentMap.get(userDTO.getAgentId());
             if (agentDTO != null) {
                 gameUserRoleListVO.setAgentName(agentDTO.getAgentName());

+ 5 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import reactor.util.function.Tuple2;
 
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.List;
@@ -74,7 +75,7 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
         }
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
-                param.getNickname(), null);
+                param.getNickname(), null, null, null);
         //根据条件, 匹配不到玩家
         if (userMap != null && userMap.isEmpty()) {
             return new Page<>();
@@ -110,6 +111,9 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
         if (userDTO != null) {
             gameUserListVO.setNickname(userDTO.getNickname());
             gameUserListVO.setUsername(userDTO.getUsername());
+            if (gameUserListVO.getLastRechargeTime() != null) {
+                gameUserListVO.setRegPayTimeDiff(Duration.between(userDTO.getCreateTime(), gameUserListVO.getLastRechargeTime()).getSeconds());
+            }
             //用户渠道
             AgentDTO agentDTO = agentMap.get(userDTO.getAgentId());
             if (agentDTO != null) {

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

@@ -34,6 +34,7 @@ import reactor.util.function.Tuple2;
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.*;
@@ -160,7 +161,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         orderVO.setDateTime(orderVO.getCreateTime().toLocalDate());
         //用户信息补充
         UserDTO userDTO = userMap.get(orderVO.getUserId());
-        orderVO.setUsername(userDTO == null ? null : userDTO.getUsername());
+        if (userDTO != null) {
+            orderVO.setUsername(userDTO.getUsername());
+            if (orderVO.getPayTime() != null) {
+                orderVO.setRegPayTimeDiff(Duration.between(userDTO.getCreateTime(), orderVO.getPayTime()).getSeconds());
+            }
+        }
         //渠道账号
         AgentDTO agentDTO = agentMap.get(orderVO.getAgentId());
         if (agentDTO != null) {

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java

@@ -51,7 +51,7 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
         List<Long> agentIdList = tuple2.getT1();
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
-                param.getNickname(), null);
+                param.getNickname(), null, null, null);
         //根据条件, 匹配不到玩家
         if (userMap != null && userMap.isEmpty()) {
             return new Page<>();

+ 35 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -7,6 +7,9 @@ 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.corp.base.CorpServer;
+import com.zanxiang.corp.base.pojo.dto.CorpExternalUserDTO;
+import com.zanxiang.corp.base.rpc.ICorpExternalUserServiceRpc;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
 import com.zanxiang.game.module.manage.pojo.dto.CpDTO;
@@ -17,6 +20,7 @@ import com.zanxiang.game.module.manage.pojo.params.UserUpdateParam;
 import com.zanxiang.game.module.manage.pojo.vo.UserCardVO;
 import com.zanxiang.game.module.manage.pojo.vo.UserListVO;
 import com.zanxiang.game.module.manage.pojo.vo.UserVO;
+import com.zanxiang.game.module.manage.pojo.vo.UserWeChatVO;
 import com.zanxiang.game.module.manage.service.*;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.GameUserRole;
@@ -26,12 +30,15 @@ import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.encryption.Md5Util;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import reactor.util.function.Tuple2;
 
+import java.time.Duration;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.Collections;
@@ -65,6 +72,26 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     @Autowired
     private IGameUserRoleService gameUserRoleService;
 
+    @DubboReference(providedBy = CorpServer.SERVER_DUBBO_NAME)
+    private ICorpExternalUserServiceRpc corpExternalUserServiceRpc;
+
+    @Override
+    public UserWeChatVO getUserWeChat(Long userId) {
+        User user = super.getById(userId);
+        if (user == null) {
+            throw new BaseException("参数错误, 用户信息不存在");
+        }
+        Map<String, String> channelTransform = agentService.channelTransform(user.getChannel());
+        if (channelTransform.containsKey("params")) {
+            String[] params = channelTransform.get("params").split(":");
+            CorpExternalUserDTO corpExternalUser = corpExternalUserServiceRpc.getCorpExternalUser(params[0], params[1]);
+            if (corpExternalUser != null) {
+                return BeanUtil.copy(corpExternalUser, UserWeChatVO.class);
+            }
+        }
+        throw new BaseException("未查询到用户微信信息");
+    }
+
     @Override
     public IPage<UserListVO> list(UserListParam param) {
         //游戏条件处理
@@ -138,6 +165,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         //最近角色
         GameUserRole gameUserRole = gameUserRoleService.getLastGameUserRoleName(user.getId(), user.getGameId());
         userListVO.setLastGameRoleName(gameUserRole == null ? null : gameUserRole.getRoleName());
+        //注册充值时间差
+        if (userListVO.getLastRechargeTime() != null) {
+            userListVO.setRegPayTimeDiff(Duration.between(userListVO.getCreateTime(), userListVO.getLastRechargeTime()).getSeconds());
+        }
         //返回
         return userListVO;
     }
@@ -199,7 +230,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     }
 
     @Override
-    public Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname, String regIp) {
+    public Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname,
+                                            String regIp, LocalDate regTimeBeginDate, LocalDate regTimeEndDate) {
         //用户信息条件处理
         if (userId == null && CollectionUtils.isEmpty(agentIdList) && Strings.isBlank(userName)
                 && Strings.isBlank(nickname) && Strings.isBlank(regIp)) {
@@ -212,6 +244,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 .eq(Strings.isNotBlank(regIp), User::getIp, regIp)
                 .like(Strings.isNotBlank(userName), User::getUsername, userName)
                 .like(Strings.isNotBlank(nickname), User::getNickname, nickname)
+                .ge(regTimeBeginDate != null, User::getCreateTime, regTimeBeginDate == null ? null : LocalDateTime.of(regTimeBeginDate, LocalTime.MIN))
+                .le(regTimeEndDate != null, User::getCreateTime, regTimeEndDate == null ? null : LocalDateTime.of(regTimeEndDate, LocalTime.MAX))
                 .select(User::getId, User::getUsername, User::getNickname, User::getIp, User::getCreateTime, User::getAgentId));
         if (CollectionUtils.isEmpty(userList)) {
             return Collections.emptyMap();