Jelajahi Sumber

fix : 手动回调通知CP

bilingfeng 1 tahun lalu
induk
melakukan
643541db9a

+ 5 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameAuthEnum.java

@@ -21,6 +21,11 @@ public enum GameAuthEnum {
      */
     ADMIN("ADMIN", "超管"),
 
+    /**
+     * 管理员
+     */
+    MANAGE("MANAGE", "管理员"),
+
     /**
      * 投手
      */

+ 7 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/vo/GameAuthUserVO.java

@@ -24,13 +24,18 @@ public class GameAuthUserVO {
      */
     private Long userId;
 
+    /**
+     * 角色
+     */
+    private GameAuthEnum gameAuthEnum;
+
     /**
      * 游戏id列表
      */
     private List<Long> gameIdList;
 
     /**
-     * 授权类型
+     * 投手列表
      */
-    private GameAuthEnum gameAuthEnum;
+    private List<Long> pitcherList;
 }

+ 2 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/GameAuthRpc.java

@@ -10,10 +10,9 @@ import com.zanxiang.game.module.base.pojo.vo.GameAuthUserVO;
 public interface GameAuthRpc {
 
     /**
-     * 查询指定人的游戏列表, 查询自己则传null
+     * 查询游戏列表
      *
-     * @param userId 用户id
      * @return {@link GameAuthUserVO}
      */
-    GameAuthUserVO getGameAuthByUserIds(Long userId);
+    GameAuthUserVO getGameAuthByUserIds();
 }

+ 12 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/ChoiceController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -62,6 +63,9 @@ public class ChoiceController {
     @Autowired
     private IAgentService agentService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @ApiOperation(value = "vip等级选择列表")
     @GetMapping(value = "/vip/level/list")
     @PreAuthorize(permissionKey = "manage:choiceVipLevel:list")
@@ -132,6 +136,14 @@ public class ChoiceController {
         return ResultVO.ok(agentService.agentAccountChoiceList());
     }
 
+    @ApiOperation(value = "归因推广人员选择列表")
+    @GetMapping(value = "/agent/user/list")
+    @PreAuthorize(permissionKey = "manage:agentUserChoice:list")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Map.class)})
+    public ResultVO<Map<Long, String>> agentUserChoiceList() {
+        return ResultVO.ok(gameAuthService.agentUserChoiceList());
+    }
+
     @ApiOperation(value = "支付方式选择列表")
     @GetMapping(value = "/pay/way/list")
     @PreAuthorize(permissionKey = "manage:payWayChoice:list")

+ 9 - 4
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/OrderController.java

@@ -18,10 +18,7 @@ import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -75,4 +72,12 @@ public class OrderController {
     public ResultVO<IPage<GameRemitLogVO>> listOfPage(@Validated @RequestBody GameRemitLogListParam param) {
         return ResultVO.ok(gameRemitLogService.listOfPage(param));
     }
+
+    @ApiOperation(value = "订单通知CP手动")
+    @GetMapping(value = "/call/cp")
+    @PreAuthorize(permissionKey = "manage:order:callCp")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> callCp(@RequestParam String orderId, String payKey) {
+        return ResultVO.ok(orderService.callCp(orderId, payKey));
+    }
 }

+ 65 - 4
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameAuthRpcImpl.java

@@ -1,14 +1,28 @@
 package com.zanxiang.game.module.manage.rpc.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zanxiang.erp.base.ErpServer;
+import com.zanxiang.erp.base.pojo.vo.SysGameUserGroupRpcVO;
+import com.zanxiang.erp.base.rpc.ISysGameUserGroupRpc;
+import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.vo.GameAuthUserVO;
 import com.zanxiang.game.module.base.rpc.GameAuthRpc;
+import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
 import com.zanxiang.game.module.manage.service.IGameAuthService;
+import com.zanxiang.game.module.mybatis.entity.GameAuth;
+import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
+import com.zanxiang.module.util.exception.BaseException;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
 import reactor.util.function.Tuple2;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * @author : lingfeng
@@ -21,13 +35,60 @@ public class GameAuthRpcImpl implements GameAuthRpc {
     @Autowired
     private IGameAuthService gameAuthService;
 
+    @Autowired
+    private IGameAuthRoleService gameAuthRoleService;
+
+    @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
+    private ISysGameUserGroupRpc sysGameUserGroupRpc;
+
     @Override
-    public GameAuthUserVO getGameAuthByUserIds(Long userId) {
-        Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(userId.toString());
+    public GameAuthUserVO getGameAuthByUserIds() {
+        //游戏列表
+        Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
+        //角色
+        GameAuthEnum gameAuthEnum = GameAuthEnum.getByValue(tuple2.getT1());
+        if (gameAuthEnum == null) {
+            throw new BaseException("参数错误, 未查询到相应的角色类型");
+        }
+        //投手列表
+        List<Long> pitcherList = new ArrayList<>();
+        //超管或者管理员, 返回所有角色人
+        if (SecurityUtil.isAdmin() || Objects.equals(gameAuthEnum.getValue(), GameAuthEnum.MANAGE.getValue())) {
+            pitcherList = gameAuthRoleService.list(new LambdaQueryWrapper<GameAuthRole>()
+                    .eq(GameAuthRole::getAuthType, GameAuthEnum.PITCHER.getValue())
+            ).stream().map(GameAuthRole::getUserId).collect(Collectors.toList());
+        }
+        //所有投手
+        List<Long> pitcherIdList = gameAuthRoleService.list(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getAuthType, GameAuthEnum.PITCHER.getValue())
+        ).stream().map(GameAuthRole::getUserId).collect(Collectors.toList());
+        //运营权限
+        if (pitcherList.isEmpty() && Objects.equals(gameAuthEnum.getValue(), GameAuthEnum.OPERATE.getValue())) {
+            pitcherList = gameAuthService.list(new LambdaQueryWrapper<GameAuth>()
+                    .in(GameAuth::getGameId, tuple2.getT2())
+                    .in(GameAuth::getUserId, pitcherIdList)
+            ).stream().map(GameAuth::getUserId).collect(Collectors.toList());
+        }
+        //判断是否是组长, 返回组员
+        SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
+                SecurityUtil.getUserId()).getData();
+        if (pitcherList.isEmpty() && sysGameUserGroupRpcVO != null) {
+            Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
+                    SecurityUtil.getUserId()).getData();
+            List<Long> userIdList = memberUserIdList.stream().filter(pitcherIdList::contains).collect(Collectors.toList());
+            pitcherList.addAll(userIdList);
+        }
+        //投手必定返回自己
+        if (Objects.equals(gameAuthEnum.getValue(), GameAuthEnum.PITCHER.getValue())
+                && !pitcherList.contains(SecurityUtil.getUserId())) {
+            pitcherList.add(SecurityUtil.getUserId());
+        }
+        //构造返回
         return GameAuthUserVO.builder()
-                .userId(userId)
+                .userId(SecurityUtil.getUserId())
                 .gameIdList(tuple2.getT2())
-                .gameAuthEnum(GameAuthEnum.getByValue(tuple2.getT1()))
+                .gameAuthEnum(gameAuthEnum)
+                .pitcherList(pitcherList)
                 .build();
     }
 }

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAuthService.java

@@ -10,6 +10,7 @@ import com.zanxiang.game.module.mybatis.entity.GameAuth;
 import reactor.util.function.Tuple2;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author : lingfeng
@@ -57,4 +58,11 @@ public interface IGameAuthService extends IService<GameAuth> {
      * @return {@link Tuple2}<{@link String}, {@link List}<{@link Long}>>
      */
     Tuple2<String, List<Long>> getUserGameList(String userId);
+
+    /**
+     * 代理用户选择列表
+     *
+     * @return {@link Map}<{@link Long}, {@link String}>
+     */
+    Map<Long, String> agentUserChoiceList();
 }

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

@@ -40,4 +40,13 @@ public interface IOrderService extends IService<Order> {
      * @param response 响应
      */
     void getOrderExcel(OrderParam param, HttpServletResponse response);
+
+    /**
+     * 叫cp
+     *
+     * @param orderId 订单id
+     * @param payKey  支付关键
+     * @return {@link Boolean}
+     */
+    Boolean callCp(String orderId, String payKey);
 }

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

@@ -248,8 +248,8 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         List<Agent> agentList;
         //是否需要自然量
         boolean defaultAgent = true;
-        //超管权限, 返回所有渠道
-        if (SecurityUtil.isAdmin()) {
+        //超管/管理员权限, 返回所有渠道
+        if (SecurityUtil.isAdmin() || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
             agentList = super.list(new LambdaQueryWrapper<Agent>()
                     .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
                     .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
@@ -265,7 +265,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
             //组长权限, 获取组员id, 查询组内所有渠道
             Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
                     SecurityUtil.getUserId()).getData();
-            if (CollectionUtils.isEmpty(memberUserIdList)){
+            if (CollectionUtils.isEmpty(memberUserIdList)) {
                 return Tuples.of(Collections.emptyList(), Collections.emptyList());
             }
             agentList = super.list(new LambdaQueryWrapper<Agent>()
@@ -327,7 +327,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         //是否需要自然量
         boolean defaultAgent = true;
         //超管权限, 返回所有渠道
-        if (SecurityUtil.isAdmin()) {
+        if (SecurityUtil.isAdmin() || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
             agentList = super.list();
         } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
             //运营权限, 获取拥有的游戏的所有渠道

+ 63 - 8
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthServiceImpl.java

@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.erp.base.ErpServer;
+import com.zanxiang.erp.base.pojo.vo.SysGameUserGroupRpcVO;
+import com.zanxiang.erp.base.rpc.ISysGameUserGroupRpc;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
@@ -54,6 +57,9 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
     @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
     private ISysUserRpc sysUserRpc;
 
+    @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
+    private ISysGameUserGroupRpc sysGameUserGroupRpc;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean gameAuthAdd(GameAuthAddParam param) {
@@ -148,19 +154,23 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
 
     @Override
     public Tuple2<String, List<Long>> getUserGameList(String userId) {
+        //查询用户权限角色
+        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
+        if (!SecurityUtil.isAdmin() && gameAuthRole == null) {
+            throw new BaseException("参数错误, 无法查询到用户的权限角色信息");
+        }
         //超管权限
-        if (SecurityUtil.isAdmin()) {
+        if (SecurityUtil.isAdmin() && Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
             List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
                     .eq(Strings.isNotBlank(userId), GameAuth::getUserId, Strings.isBlank(userId) ? null : Long.valueOf(userId))
             ).stream().map(GameAuth::getGameId).collect(Collectors.toList());
-            return Tuples.of(GameAuthEnum.ADMIN.getValue(), gameIdList);
-        }
-        //非超管权限
-        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
-                .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
-        if (gameAuthRole == null) {
-            throw new BaseException("参数错误, 无法查询到用户的权限角色信息");
+            if (SecurityUtil.isAdmin()) {
+                return Tuples.of(GameAuthEnum.ADMIN.getValue(), gameIdList);
+            }
+            return Tuples.of(gameAuthRole.getAuthType(), gameIdList);
         }
+        //非超管权限查询
         List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
                 .eq(Strings.isBlank(userId), GameAuth::getUserId, SecurityUtil.getUserId())
                 .eq(Strings.isNotBlank(userId), GameAuth::getUserId, Strings.isBlank(userId) ? null : Long.valueOf(userId))
@@ -168,4 +178,49 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
         //返回角色权限以及游戏
         return Tuples.of(gameAuthRole.getAuthType(), gameIdList);
     }
+
+    @Override
+    public Map<Long, String> agentUserChoiceList() {
+        //判断是否是组长
+        SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
+                SecurityUtil.getUserId()).getData();
+        //判断运营
+        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
+        //所有投手
+        List<Long> pitcherIdList = gameAuthRoleService.list(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getAuthType, GameAuthEnum.PITCHER.getValue())
+        ).stream().map(GameAuthRole::getUserId).collect(Collectors.toList());
+        //游戏权限
+        Tuple2<String, List<Long>> userGameTuple2 = this.getUserGameList(null);
+        if (CollectionUtils.isEmpty(userGameTuple2.getT2())) {
+            throw new BaseException("未查询到用户游戏列表");
+        }
+        List<GameAuth> gameAuthList;
+        //超管或者管理员
+        if (SecurityUtil.isAdmin() || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
+            gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
+                    .in(GameAuth::getUserId, pitcherIdList));
+        } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
+            //运营权限
+            gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
+                    .in(GameAuth::getGameId, userGameTuple2.getT2())
+                    .in(GameAuth::getUserId, pitcherIdList));
+        } else if (sysGameUserGroupRpcVO != null) {
+            //组长权限, 获取组员id, 查询组内所有人
+            Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
+                    SecurityUtil.getUserId()).getData();
+            List<Long> userIdList = memberUserIdList.stream().filter(pitcherIdList::contains).collect(Collectors.toList());
+            gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
+                    .in(GameAuth::getGameId, userGameTuple2.getT2())
+                    .in(GameAuth::getUserId, userIdList));
+        } else {
+            gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
+                    .in(GameAuth::getGameId, userGameTuple2.getT2())
+                    .eq(GameAuth::getUserId, SecurityUtil.getUserId()));
+        }
+        return sysUserRpc.getUserNameByIds(gameAuthList.stream().map(GameAuth::getUserId)
+                .distinct().collect(Collectors.toList())
+        ).getData();
+    }
 }

+ 11 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java

@@ -7,10 +7,12 @@ 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.ServerInfo;
 import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.pojo.enums.PayDeviceEnum;
 import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
+import com.zanxiang.game.module.base.rpc.IOrderServiceRpc;
 import com.zanxiang.game.module.base.util.DateUtils;
 import com.zanxiang.game.module.manage.pojo.dto.*;
 import com.zanxiang.game.module.manage.pojo.params.OrderParam;
@@ -30,6 +32,7 @@ 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.dubbo.config.annotation.DubboReference;
 import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -77,6 +80,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Autowired
     private IGameAuthService gameAuthService;
 
+    @DubboReference(providedBy = ServerInfo.SERVER_SDK_DUBBO_NAME)
+    private IOrderServiceRpc orderServiceRpc;
+
     @Override
     public IPage<UserOrderListVO> orderList(UserOrderListParam param) {
         //执行查询
@@ -312,4 +318,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             return orderVOList.stream().map(orderVO -> BeanUtil.copy(orderVO, OrderExcelVO.class)).collect(Collectors.toList());
         }), ExcelUtil.DEFAULT_MAX_DATA_SIZE);
     }
+
+    @Override
+    public Boolean callCp(String orderId, String payKey) {
+        return orderServiceRpc.orderCpCall(orderId, payKey);
+    }
 }