Browse Source

游戏配置

kk 8 months ago
parent
commit
8a15c0ab12

+ 3 - 3
game-business/src/main/java/com/game/business/config/AsyncConfig.java

@@ -15,9 +15,9 @@ public class AsyncConfig {
     @Bean(name = "asyncExecutor")
     public Executor asyncExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(5); // 核心线程数
-        executor.setMaxPoolSize(10); // 最大线程数
-        executor.setQueueCapacity(25); // 队列大小
+        executor.setCorePoolSize(50); // 核心线程数
+        executor.setMaxPoolSize(200); // 最大线程数
+        executor.setQueueCapacity(250); // 队列大小
         executor.setKeepAliveSeconds(60); // 线程空闲时的存活时间
         executor.setThreadNamePrefix("aynTask-"); // 线程名前缀
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 拒绝策略

+ 2 - 2
game-business/src/main/java/com/game/business/config/GameOneConfig.java

@@ -16,7 +16,7 @@ public class GameOneConfig implements CommandLineRunner {
     @Override
     @Async
     public void run(String... args) throws Exception {
-//        webSocketConnent = new WebSocketConnent(Common.WS_GAME_URL, Common.GANME_ONE_NAME);
-//        webSocketConnent.connect();
+        webSocketConnent = new WebSocketConnent(Common.WS_GAME_URL, Common.GANME_ONE_NAME);
+        webSocketConnent.connect();
     }
 }

+ 2 - 2
game-business/src/main/java/com/game/business/controller/AppGameBettingController.java

@@ -246,10 +246,10 @@ public class AppGameBettingController extends BaseController{
     @PostMapping(value = "/listByGameId")
     @ApiOperation(value = "游戏输赢统计(详情)", notes = "游戏输赢统计(详情)")
     public HttpRetPageArr<AppGameBetting> getListByGameId(@RequestParam(name = "gameId") Long gameId, @RequestParam(name = "userId") Long userId,
-                                                          @RequestParam(name = "isWinning") Integer isWinning)
+                                                          @RequestParam(name = "isWinning") Integer isWinning, @RequestParam(name = "strDate", required = false) String strDate)
     {
         startPage();
-        List<AppGameBetting> list = appGameBettingService.selectListByGameId(gameId, userId, isWinning);
+        List<AppGameBetting> list = appGameBettingService.selectListByGameId(gameId, userId, isWinning, strDate);
         return HttpRetPageArr.success("查询成功",getDataTable(list));
     }
 }

+ 103 - 36
game-business/src/main/java/com/game/business/controller/AppUserAgentController.java

@@ -16,6 +16,7 @@ import com.game.business.util.Md5Utils;
 import com.game.business.vo.AppGameBettingDetailsCountVO;
 import com.game.business.vo.AppGameCommissionVO;
 import com.game.business.vo.AppUserAgentVO;
+import com.game.business.vo.AppUserPAgentVO;
 import com.game.common.annotation.Anonymous;
 import com.game.common.core.domain.*;
 import com.game.common.utils.StringUtils;
@@ -59,14 +60,14 @@ public class AppUserAgentController extends BaseController
     @Anonymous
     @PostMapping("/addAgent")
     @ApiOperation(value = "添加代理", notes = "添加代理")
-    public HttpRet addAgent(@RequestBody AppUserDTO appUserDTO)
+    public HttpRet<AppUserAgentVO> addAgent(@RequestBody AppUserDTO appUserDTO)
     {
 
-        if(appUserService.getMobileCount(appUserDTO.getMobile())){
+        if(appUserService.getMobileCount(appUserDTO.getUserName())){
             return HttpRet.fail("用户手机号码已存在。");
         }
 
-        AppUser appUser = getAppUser(appUserDTO.getMobile(), appUserDTO.getPassWord());
+        AppUser appUser = getAppUser(appUserDTO.getUserName(), appUserDTO.getPassWord());
 
         appUserService.insertAppUser(appUser);
 
@@ -81,15 +82,47 @@ public class AppUserAgentController extends BaseController
         AppUserAgent dbPuserAgent = pList.get(0);
 
         AppUserAgent appUserAgent = new AppUserAgent();
+        appUserAgent.setId(IdUtil.getSnowflakeNextId());
         appUserAgent.setTopId(dbPuserAgent.getTopId() == null ? dbPuserAgent.getUserId() : dbPuserAgent.getTopId());
         appUserAgent.setPid(dbPuserAgent.getUserId());
         appUserAgent.setUserId(appUser.getUserid());
         appUserAgent.setAuditStatus("1");
+        appUserAgent.setLiveRate(0L);
+        appUserAgent.setDividendGuaranteeRate(0L);
         appUserAgent.setCreateTime(new Date());
 
         appUserAgentService.insertAppUserAgent(appUserAgent);
 
-        return HttpRet.success("添加成功");
+        AppUserAgentVO appUserAgentVO = new AppUserAgentVO();
+        BeanUtils.copyProperties(appUserAgent, appUserAgentVO);
+        appUserAgentVO.setUserId(appUser.getUserid());
+        appUserAgentVO.setNickName(appUser.getUsername());
+        appUserAgentVO.setAvatar("");
+
+        List<AppGameCommissionVO> gameCommissionVOList = new ArrayList<>();
+        List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
+        if(gameList != null && !gameList.isEmpty()){
+            for (int i = 0; i < gameList.size(); i++) {
+                AppGame appGame = gameList.get(i);
+
+
+                AppGameCommissionVO appGameCommissionVO = new AppGameCommissionVO();
+                appGameCommissionVO.setPid(dbPuserAgent.getUserId());
+                appGameCommissionVO.setUserId(appUser.getUserid());
+                appGameCommissionVO.setGameRate(0L);
+
+                appGameCommissionVO.setGameId(appGame.getId());
+                appGameCommissionVO.setGameName(appGame.getName());
+                appGameCommissionVO.setLogoUrl(appGame.getLogoUrl());
+                appGameCommissionVO.setGamePath(appGame.getGamePath());
+
+
+                gameCommissionVOList.add(appGameCommissionVO);
+            }
+        }
+        appUserAgentVO.setCommissions(gameCommissionVOList);
+
+        return HttpRet.success("添加成功", appUserAgentVO);
     }
 
 
@@ -125,39 +158,22 @@ public class AppUserAgentController extends BaseController
         return  HttpRet.success("修改成功");
     }
 
-    /**
-     * 获取代理成员列表
-     */
-    @Anonymous
-    @PostMapping(value = "/getUserAgentList")
-    @ApiOperation(value = "获取代理成员列表", notes = "获取代理成员列表")
-    public HttpRetArr<AppUserAgentVO> getUserAgentList(@RequestParam(name = "userId") Long userId)
-    {
-        AppUserAgent userAgent = new AppUserAgent();
-        userAgent.setPid(userId);
-        List<AppUserAgent> userAgents = appUserAgentService.selectAppUserAgentList(userAgent);
-        List<AppUserAgentVO> resultList = new ArrayList<>();
-        for (int i = 0; i < userAgents.size(); i++) {
-            AppUserAgentVO appUserAgentVO = new AppUserAgentVO();
-            BeanUtils.copyProperties(userAgents.get(0), appUserAgentVO);
-
-            AppUser appUser = appUserService.selectAppUserByUserid(appUserAgentVO.getUserId());
-            if(appUser != null){
-                appUserAgentVO.setNickName(appUser.getNickname());
-                appUserAgentVO.setAvatar(appUser.getAvatar());
-            }
-        }
-        return HttpRetArr.success("查询成功", resultList);
-    }
-
     /**
      * 获取代理成员设置
      */
     @Anonymous
     @PostMapping(value = "/getUserAgent")
     @ApiOperation(value = "获取代理成员设置", notes = "获取代理成员设置")
-    public HttpRet<AppUserAgentVO> getListByGameId(@RequestParam(name = "pid") Long pid, @RequestParam(name = "userId") Long userId)
+    public HttpRet<AppUserPAgentVO> getListByGameId(@RequestParam(name = "pid") Long pid, @RequestParam(name = "userId") Long userId)
     {
+
+        AppUserPAgentVO appUserPAgentVO = new AppUserPAgentVO();
+
+        AppUser appUser = appUserService.selectAppUserByUserid(userId);
+        if(appUser == null ){
+            return HttpRet.fail("用户信息不存在。");
+        }
+
         AppUserAgent userAgent = new AppUserAgent();
         userAgent.setPid(pid);
         userAgent.setUserId(userId);
@@ -167,8 +183,18 @@ public class AppUserAgentController extends BaseController
             return HttpRet.fail("代理信息不存在。");
         }
 
+        AppUserAgent userPAgent = new AppUserAgent();
+        userPAgent.setUserId(pid);
+        List<AppUserAgent> userpAgents = appUserAgentService.selectAppUserAgentList(userPAgent);
+        if(userpAgents == null || userpAgents.isEmpty()){
+            return HttpRet.fail("上级代理信息不存在。");
+        }
+
         AppUserAgentVO appUserAgentVO = new AppUserAgentVO();
         BeanUtils.copyProperties(userAgents.get(0), appUserAgentVO);
+        appUserAgentVO.setUserId(appUser.getUserid());
+        appUserAgentVO.setNickName(StringUtils.isEmpty(appUser.getNickname()) ? appUser.getUsername() : appUser.getNickname());
+        appUserAgentVO.setAvatar(appUser.getAvatar());
 
         AppGameCommission appGameCommission = new AppGameCommission();
         appGameCommission.setPid(pid);
@@ -181,7 +207,32 @@ public class AppUserAgentController extends BaseController
             idGameMap = new HashMap<>();
         }
 
+        AppUserAgentVO appUserpAgentVO = new AppUserAgentVO();
+        BeanUtils.copyProperties(userpAgents.get(0), appUserpAgentVO);
+
+        Map<Long, List<AppGameCommission>> idGamePMap = new HashMap<>();
+
+        if(appUserpAgentVO.getPid() != null){
+            AppGameCommission appGamePCommission = new AppGameCommission();
+            appGamePCommission.setPid(appUserpAgentVO.getPid());
+            appGamePCommission.setUserId(appUserpAgentVO.getUserId());
+            List<AppGameCommission> gamePCommissions = appGameCommissionService.selectAppGameCommissionList(appGamePCommission);
+
+            if(gamePCommissions != null && !gamePCommissions.isEmpty()){
+                idGamePMap = gamePCommissions.stream().collect(Collectors.groupingBy(AppGameCommission::getGameId));
+            }
+        }
+
+        if(appUserpAgentVO.getLiveRate() == null){
+            appUserpAgentVO.setLiveRate(100L);
+        }
+        if(appUserpAgentVO.getDividendGuaranteeRate() == null){
+            appUserpAgentVO.setDividendGuaranteeRate(100L);
+        }
+
         List<AppGameCommissionVO> gameCommissionVOList = new ArrayList<>();
+        List<AppGameCommissionVO> gamePCommissionVOList = new ArrayList<>();
+
         List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
         if(gameList != null && !gameList.isEmpty()){
             for (int i = 0; i < gameList.size(); i++) {
@@ -189,10 +240,11 @@ public class AppUserAgentController extends BaseController
 
 
                 AppGameCommissionVO appGameCommissionVO = new AppGameCommissionVO();
-
                 if(idGameMap.containsKey(appGame.getId())){
                     AppGameCommission gameCommission = idGameMap.get(appGame.getId()).get(0);
                     BeanUtils.copyProperties(gameCommission, appGameCommissionVO);
+                }else{
+                    appGameCommissionVO.setGameRate(0L);
                 }
 
                 appGameCommissionVO.setGameId(appGame.getId());
@@ -201,11 +253,27 @@ public class AppUserAgentController extends BaseController
                 appGameCommissionVO.setGamePath(appGame.getGamePath());
 
                 gameCommissionVOList.add(appGameCommissionVO);
+
+                AppGameCommissionVO appGamePCommissionVO = new AppGameCommissionVO();
+                if(idGamePMap.containsKey(appGame.getId())){
+                    AppGameCommission gameCommission = idGamePMap.get(appGame.getId()).get(0);
+                    BeanUtils.copyProperties(gameCommission, appGamePCommissionVO);
+                }else{
+                    appGamePCommissionVO.setGameRate(100L);
+                }
+                appGamePCommissionVO.setGameId(appGame.getId());
+
+                gamePCommissionVOList.add(appGamePCommissionVO);
             }
         }
 
         appUserAgentVO.setCommissions(gameCommissionVOList);
-        return HttpRet.success("查询成功", appUserAgentVO);
+        appUserPAgentVO.setAppUserAgent(appUserAgentVO);
+
+        appUserpAgentVO.setCommissions(gamePCommissionVOList);
+        appUserPAgentVO.setAppUserPAgent(appUserpAgentVO);
+
+        return HttpRet.success("查询成功", appUserPAgentVO);
     }
 
     /**
@@ -214,7 +282,7 @@ public class AppUserAgentController extends BaseController
      * @author jiang
      * @date 2021/9/25 16:28
      */
-    public AppUser getAppUser(String mobile, String password) {
+    public AppUser getAppUser(String userName, String password) {
 
         AppUser appUser = new AppUser();
 
@@ -222,15 +290,14 @@ public class AppUserAgentController extends BaseController
         if (StringUtils.isNotBlank(password)) {
             appUser.setPassword(Md5Utils.md5(Md5Utils.md5(password) + appUser.getSalt()));
         }
-        appUser.setUsername(mobile);
+        appUser.setUsername(userName);
         appUser.setAvatar(null);
         appUser.setSex(0L);
         appUser.setSignature("这家伙很懒...");
         appUser.setSalt(RandomUtil.randomString(8));
 
         // 基础信息
-        appUser.setMobile(mobile);
-        appUser.setPassword(password);
+//        appUser.setMobile(mobile);
         appUser.setRegType(0L);
         appUser.setOpenid(null);
         appUser.setRegisterIp("127.0.0.1");

+ 0 - 2
game-business/src/main/java/com/game/business/dto/AppUserAgentDTO.java

@@ -13,6 +13,4 @@ public class AppUserAgentDTO extends AppUserAgent {
     @ApiModelProperty(value = "游戏设置集合")
     private List<AppGameCommission> commissions;
 
-
-
 }

+ 2 - 2
game-business/src/main/java/com/game/business/dto/AppUserDTO.java

@@ -10,8 +10,8 @@ public class AppUserDTO {
     @ApiModelProperty(value = "操作人ID")
     private Long userId;
 
-    @ApiModelProperty(value = "手机号码")
-    private String mobile;
+    @ApiModelProperty(value = "用户名称")
+    private String userName;
 
     @ApiModelProperty(value = "密码")
     private String passWord;

+ 1 - 1
game-business/src/main/java/com/game/business/service/IAppGameBettingService.java

@@ -16,5 +16,5 @@ public interface IAppGameBettingService extends IService<AppGameBetting> {
 
     List<AppGameBettingDetailsCountVO> getCount(String strDate, Long userId);
 
-    List<AppGameBetting> selectListByGameId(Long gameId, Long userId, Integer isWinning);
+    List<AppGameBetting> selectListByGameId(Long gameId, Long userId, Integer isWinning, String strDate);
 }

+ 5 - 1
game-business/src/main/java/com/game/business/service/impl/AppGameBettingServiceImpl.java

@@ -7,6 +7,7 @@ import com.game.business.domain.AppGameBetting;
 import com.game.business.vo.AppGameBettingDetailsCountVO;
 import com.game.business.mapper.AppGameBettingMapper;
 import com.game.business.service.IAppGameBettingService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -46,13 +47,16 @@ public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper,
     }
 
     @Override
-    public List<AppGameBetting> selectListByGameId(Long gameId, Long userId, Integer isWinning) {
+    public List<AppGameBetting> selectListByGameId(Long gameId, Long userId, Integer isWinning, String strDate) {
         LambdaQueryWrapper<AppGameBetting> queryWrapper = Wrappers.lambdaQuery();;
         queryWrapper.eq(AppGameBetting::getGameId, gameId);
         queryWrapper.eq(AppGameBetting::getUserId, userId);
         if(isWinning != null && isWinning != -1){
             queryWrapper.eq(AppGameBetting::getIsWinning, isWinning);
         }
+        if(StringUtils.isNoneBlank(strDate)){
+            queryWrapper.between(AppGameBetting::getCreateTime, strDate + " 00:00:00", strDate + " 23:59:59");
+        }
         queryWrapper.orderByDesc(AppGameBetting::getCreateTime);
         return appGameBettingMapper.selectList(queryWrapper);
     }

+ 2 - 2
game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java

@@ -115,9 +115,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
     }
 
     @Override
-    public boolean getMobileCount(String mobile) {
+    public boolean getMobileCount(String userName) {
         LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AppUser::getMobile, mobile);
+        queryWrapper.eq(AppUser::getUsername, userName);
         return appUserMapper.selectCount(queryWrapper) > 0;
     }
 }

+ 3 - 0
game-business/src/main/java/com/game/business/vo/AppUserAgentVO.java

@@ -12,6 +12,9 @@ public class AppUserAgentVO extends AppUserAgent {
     @ApiModelProperty(value = "游戏设置集合")
     private List<AppGameCommissionVO> commissions;
 
+    @ApiModelProperty(value = "用户昵称")
+    private Long userId;
+
     @ApiModelProperty(value = "用户昵称")
     private String nickName;
 

+ 14 - 0
game-business/src/main/java/com/game/business/vo/AppUserPAgentVO.java

@@ -0,0 +1,14 @@
+package com.game.business.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class AppUserPAgentVO {
+
+    @ApiModelProperty(value = "当前代理信息")
+    private AppUserAgentVO appUserAgent;
+
+    @ApiModelProperty(value = "上级代理信息")
+    private AppUserAgentVO appUserPAgent;
+}