Ver código fonte

Merge remote-tracking branch 'origin/master'

dos 8 meses atrás
pai
commit
d1a3fadcf8
27 arquivos alterados com 638 adições e 203 exclusões
  1. 28 0
      game-business/src/main/java/com/game/business/config/AsyncConfig.java
  2. 75 6
      game-business/src/main/java/com/game/business/controller/AppGameBettingController.java
  3. 1 1
      game-business/src/main/java/com/game/business/domain/AppGameBetting.java
  4. 77 0
      game-business/src/main/java/com/game/business/domain/AppUserCount.java
  5. 51 0
      game-business/src/main/java/com/game/business/domain/AppUserGameCount.java
  6. 24 0
      game-business/src/main/java/com/game/business/dto/AppGameBettingCountDTO.java
  7. 28 0
      game-business/src/main/java/com/game/business/dto/AppGameBettingDetailsCountDTO.java
  8. 5 0
      game-business/src/main/java/com/game/business/mapper/AppGameBettingMapper.java
  9. 7 0
      game-business/src/main/java/com/game/business/mapper/AppUserCountMapper.java
  10. 7 0
      game-business/src/main/java/com/game/business/mapper/AppUserGameCountMapper.java
  11. 5 1
      game-business/src/main/java/com/game/business/service/IAppGameBettingService.java
  12. 7 0
      game-business/src/main/java/com/game/business/service/IAppGameService.java
  13. 7 0
      game-business/src/main/java/com/game/business/service/IAppUserCountService.java
  14. 7 0
      game-business/src/main/java/com/game/business/service/IAppUserGameCountService.java
  15. 17 0
      game-business/src/main/java/com/game/business/service/impl/AppGameBettingServiceImpl.java
  16. 9 2
      game-business/src/main/java/com/game/business/service/impl/AppGameClassifyServiceImpl.java
  17. 15 2
      game-business/src/main/java/com/game/business/service/impl/AppGameServiceImpl.java
  18. 11 0
      game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java
  19. 11 0
      game-business/src/main/java/com/game/business/service/impl/AppUserGameCountServiceImpl.java
  20. 6 2
      game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java
  21. 6 2
      game-business/src/main/java/com/game/business/service/impl/AppUsersCashrecordServiceImpl.java
  22. 6 2
      game-business/src/main/java/com/game/business/service/impl/AppUsersChargeServiceImpl.java
  23. 6 2
      game-business/src/main/java/com/game/business/service/impl/FinTranRecordServiceImpl.java
  24. 195 8
      game-business/src/main/java/com/game/business/task/AppGameBettingTask.java
  25. 3 3
      game-business/src/main/java/com/game/business/websocket/WebSocketConnent.java
  26. 7 172
      game-business/src/main/java/com/game/business/websocket/client/GameOneClient.java
  27. 17 0
      game-business/src/main/resources/mapper/business/AppGameBettingMapper.xml

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

@@ -0,0 +1,28 @@
+package com.game.business.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+@Configuration
+@EnableAsync
+public class AsyncConfig {
+
+    @Bean(name = "asyncExecutor")
+    public Executor asyncExecutor() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(5); // 核心线程数
+        executor.setMaxPoolSize(10); // 最大线程数
+        executor.setQueueCapacity(25); // 队列大小
+        executor.setKeepAliveSeconds(60); // 线程空闲时的存活时间
+        executor.setThreadNamePrefix("aynTask-"); // 线程名前缀
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 拒绝策略
+        executor.initialize();
+        return executor;
+    }
+
+}

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

@@ -3,21 +3,26 @@ package com.game.business.controller;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.game.business.domain.*;
+import com.game.business.dto.AppGameBettingCountDTO;
+import com.game.business.dto.AppGameBettingDetailsCountDTO;
 import com.game.business.service.*;
 import com.game.common.core.controller.BaseController;
 import com.game.common.core.domain.AjaxResult;
+import com.game.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-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 java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RestController
-@RequestMapping("/game/betting")
+@RequestMapping("/business/betting")
 @Api(value = "AppGameBettingController", description = "游戏投注接口", tags = {"游戏投注、查询记录等"})
 public class AppGameBettingController extends BaseController{
 
@@ -43,6 +48,7 @@ public class AppGameBettingController extends BaseController{
      * 下注
      */
     @PostMapping(value = "/create")
+    @ApiOperation(value = "游戏下注", notes = "游戏下注")
     public AjaxResult betting(@RequestBody AppGameBetting gameBetting)
     {
 
@@ -73,7 +79,7 @@ public class AppGameBettingController extends BaseController{
         }
 
         if(StringUtils.isBlank(appGame.getGameTime())){
-            return error("游戏倒计时不存在,无法下单。");
+            return error("游戏已封盘,无法下单。");
         }
 
         if(!appGame.getGameTime().contains(":")){
@@ -169,4 +175,67 @@ public class AppGameBettingController extends BaseController{
 
         return success();
     }
+
+    /**
+     * 游戏输赢统计
+     */
+    @GetMapping(value = "/count")
+    public AjaxResult getCount(@RequestParam(name = "strDate") String strDate)
+    {
+        AppGameBettingCountDTO appGameBettingCountDTO = new AppGameBettingCountDTO();
+        List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
+
+        if(gameList == null || gameList.isEmpty()){
+            return success(appGameBettingCountDTO);
+        }
+
+        List<AppGameBettingDetailsCountDTO> countList = appGameBettingService.getCount(strDate);
+        if(countList == null){
+            countList = new ArrayList<>();
+        }
+        Map<Long, List<AppGameBettingDetailsCountDTO>> idGameMap = countList.stream().collect(Collectors.groupingBy(AppGameBettingDetailsCountDTO::getGameId));
+
+        List<AppGameBettingDetailsCountDTO> newList = new ArrayList<>();
+        double orderAmount = 0.00;
+        double winAmount = 0.00;
+        double loseAmount = 0.00;
+        for (int i = 0; i < gameList.size(); i++) {
+            AppGame appGame = gameList.get(i);
+            AppGameBettingDetailsCountDTO appGameBettingDetailsCountDTO = new AppGameBettingDetailsCountDTO();
+            appGameBettingDetailsCountDTO.setGameId(appGame.getId());
+            appGameBettingDetailsCountDTO.setGameName(appGame.getName());
+            if(idGameMap.containsKey(appGame.getId())){
+                AppGameBettingDetailsCountDTO dbAppGameBettingDetailsCount = idGameMap.get(appGame.getId()).get(0);
+                appGameBettingDetailsCountDTO.setBettingCount(dbAppGameBettingDetailsCount.getBettingCount());
+                appGameBettingDetailsCountDTO.setOrderAmount(dbAppGameBettingDetailsCount.getOrderAmount());
+                appGameBettingDetailsCountDTO.setWinAmount(dbAppGameBettingDetailsCount.getWinAmount());
+                appGameBettingDetailsCountDTO.setLoseAmount(dbAppGameBettingDetailsCount.getLoseAmount());
+                orderAmount += dbAppGameBettingDetailsCount.getOrderAmount();
+                winAmount += dbAppGameBettingDetailsCount.getWinAmount();
+                loseAmount += dbAppGameBettingDetailsCount.getLoseAmount();
+            }else{
+                appGameBettingDetailsCountDTO.setBettingCount(0);
+                appGameBettingDetailsCountDTO.setOrderAmount(0.00);
+                appGameBettingDetailsCountDTO.setWinAmount(0.00);
+                appGameBettingDetailsCountDTO.setLoseAmount(0.00);
+            }
+            newList.add(appGameBettingDetailsCountDTO);
+        }
+        appGameBettingCountDTO.setOrderAmount(orderAmount);
+        appGameBettingCountDTO.setWinAmount(winAmount);
+        appGameBettingCountDTO.setLoseAmount(loseAmount);
+        appGameBettingCountDTO.setList(newList);
+        return success(appGameBettingCountDTO);
+    }
+
+    /**
+     * 游戏输赢详情列表
+     */
+    @GetMapping(value = "/listByGameId")
+    public TableDataInfo getListByGameId(@RequestParam(name = "gameId") Long gameId)
+    {
+        startPage();
+        List<AppGameBetting> list = appGameBettingService.selectListByGameId(gameId);
+        return getDataTable(list);
+    }
 }

+ 1 - 1
game-business/src/main/java/com/game/business/domain/AppGameBetting.java

@@ -66,7 +66,7 @@ public class AppGameBetting {
 
     @Excel(name = "开奖时间")
     @TableField(value = "update_time")
-    @ApiModelProperty(value = "投注时间")
+    @ApiModelProperty(value = "开奖时间")
     private Date updateTime;
 
 }

+ 77 - 0
game-business/src/main/java/com/game/business/domain/AppUserCount.java

@@ -0,0 +1,77 @@
+package com.game.business.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.game.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+@Data
+@TableName(value= "app_user_count")
+@ApiModel(value = "app_user_count", description = "app用户统计")
+public class AppUserCount {
+
+    /** $column.columnComment */
+    @ApiModelProperty(value = "主键ID")
+    @TableId(value = "id" , type = IdType.AUTO)
+    private Long id;
+
+    @Excel(name = "时间")
+    @TableField(value = "str_date")
+    @ApiModelProperty(value = "时间(2000-01-01)")
+    private String strDate;
+
+    @Excel(name = "用户ID")
+    @TableField(value = "user_id")
+    @ApiModelProperty(value = "用户ID")
+    private Long userId;
+
+    @Excel(name = "充值金额")
+    @TableField(value = "recharge_amount")
+    @ApiModelProperty(value = "充值金额")
+    private double rechargeAmount;
+
+    @Excel(name = "充值手续费")
+    @TableField(value = "recharge_commission")
+    @ApiModelProperty(value = "充值手续费")
+    private double rechargeCommission;
+
+    @Excel(name = "提现金额")
+    @TableField(value = "withdrawal_amount")
+    @ApiModelProperty(value = "提现金额")
+    private double withdrawalAmount;
+
+    @Excel(name = "提现手续费")
+    @TableField(value = "withdrawal_commission")
+    @ApiModelProperty(value = "提现手续费")
+    private double withdrawalCommission;
+
+    @Excel(name = "直播消费金额")
+    @TableField(value = "live_use_amount")
+    @ApiModelProperty(value = "直播消费金额")
+    private double liveUseAmount;
+
+    @Excel(name = "直播佣金")
+    @TableField(value = "live_commission")
+    @ApiModelProperty(value = "直播佣金")
+    private double liveCommission;
+
+    @Excel(name = "游戏-赢")
+    @TableField(value = "game_win_amount")
+    @ApiModelProperty(value = "游戏-赢")
+    private double gameWinAmount;
+
+    @Excel(name = "游戏-输")
+    @TableField(value = "game_lose_amount")
+    @ApiModelProperty(value = "游戏-赢")
+    private double gameLoseAmount;
+
+    @Excel(name = "游戏佣金")
+    @TableField(value = "game_commission")
+    @ApiModelProperty(value = "游戏佣金")
+    private double gameCommission;
+}

+ 51 - 0
game-business/src/main/java/com/game/business/domain/AppUserGameCount.java

@@ -0,0 +1,51 @@
+package com.game.business.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.game.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@TableName(value= "app_user_game_count")
+@ApiModel(value = "app_user_game_count", description = "app用户游戏统计")
+public class AppUserGameCount {
+
+    /** $column.columnComment */
+    @ApiModelProperty(value = "主键ID")
+    @TableId(value = "id" , type = IdType.AUTO)
+    private Long id;
+
+    @Excel(name = "时间")
+    @TableField(value = "str_date")
+    @ApiModelProperty(value = "时间(2000-01-01)")
+    private String strDate;
+
+    @Excel(name = "用户ID")
+    @TableField(value = "user_id")
+    @ApiModelProperty(value = "用户ID")
+    private Long userId;
+
+    @Excel(name = "游戏ID")
+    @TableField(value = "game_id")
+    @ApiModelProperty(value = "游戏ID")
+    private Long gameId;
+
+    @Excel(name = "游戏-赢")
+    @TableField(value = "game_win_amount")
+    @ApiModelProperty(value = "游戏-赢")
+    private double gameWinAmount;
+
+    @Excel(name = "游戏-输")
+    @TableField(value = "game_lose_amount")
+    @ApiModelProperty(value = "游戏-赢")
+    private double gameLoseAmount;
+
+    @Excel(name = "游戏佣金")
+    @TableField(value = "game_commission")
+    @ApiModelProperty(value = "游戏佣金")
+    private double gameCommission;
+}

+ 24 - 0
game-business/src/main/java/com/game/business/dto/AppGameBettingCountDTO.java

@@ -0,0 +1,24 @@
+package com.game.business.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@ApiModel(description = "游戏输赢汇总")
+public class AppGameBettingCountDTO {
+
+    @ApiModelProperty(value = "下单金额")
+    private double orderAmount;
+
+    @ApiModelProperty(value = "赢")
+    private double winAmount;
+
+    @ApiModelProperty(value = "输")
+    private double loseAmount;
+
+    @ApiModelProperty(value = "游戏列表统计")
+    private List<AppGameBettingDetailsCountDTO> list;
+}

+ 28 - 0
game-business/src/main/java/com/game/business/dto/AppGameBettingDetailsCountDTO.java

@@ -0,0 +1,28 @@
+package com.game.business.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "游戏输赢详情")
+public class AppGameBettingDetailsCountDTO {
+
+    @ApiModelProperty(value = "游戏ID")
+    private Long gameId;
+
+    @ApiModelProperty(value = "游戏名称")
+    private String gameName;
+
+    @ApiModelProperty(value = "数量")
+    private long bettingCount;
+
+    @ApiModelProperty(value = "下单金额")
+    private double orderAmount;
+
+    @ApiModelProperty(value = "赢")
+    private double winAmount;
+
+    @ApiModelProperty(value = "输")
+    private double loseAmount;
+}

+ 5 - 0
game-business/src/main/java/com/game/business/mapper/AppGameBettingMapper.java

@@ -3,6 +3,11 @@ package com.game.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.game.business.domain.AppGameBetting;
+import com.game.business.dto.AppGameBettingDetailsCountDTO;
+
+import java.util.List;
 
 public interface AppGameBettingMapper extends BaseMapper<AppGameBetting> {
+
+    List<AppGameBettingDetailsCountDTO> getCount(String strDate);
 }

+ 7 - 0
game-business/src/main/java/com/game/business/mapper/AppUserCountMapper.java

@@ -0,0 +1,7 @@
+package com.game.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.game.business.domain.AppUserCount;
+
+public interface AppUserCountMapper extends BaseMapper<AppUserCount> {
+}

+ 7 - 0
game-business/src/main/java/com/game/business/mapper/AppUserGameCountMapper.java

@@ -0,0 +1,7 @@
+package com.game.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.game.business.domain.AppUserGameCount;
+
+public interface AppUserGameCountMapper extends BaseMapper<AppUserGameCount> {
+}

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

@@ -2,15 +2,19 @@ package com.game.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.game.business.domain.AppGameBetting;
+import com.game.business.dto.AppGameBettingDetailsCountDTO;
 
 import java.util.List;
 
 public interface IAppGameBettingService extends IService<AppGameBetting> {
 
-
     List<AppGameBetting> getIsWinning(Long classId, Long gameId, String gameDate, Integer isWinning);
 
     boolean updateById(AppGameBetting appGameBetting);
 
     boolean save(AppGameBetting appGameBetting);
+
+    List<AppGameBettingDetailsCountDTO> getCount(String strDate);
+
+    List<AppGameBetting> selectListByGameId(Long gameId);
 }

+ 7 - 0
game-business/src/main/java/com/game/business/service/IAppGameService.java

@@ -59,6 +59,13 @@ public interface IAppGameService extends IService<AppGame> {
      */
     public int deleteAppGameById(Long id);
 
+    /**
+     * 根据类型查询游戏
+     * @param classId
+     * @return
+     */
+    List<AppGame> selectAppGameByClassId(Long classId);
+
     /**
      * 根据编码查询游戏
      * @param classId

+ 7 - 0
game-business/src/main/java/com/game/business/service/IAppUserCountService.java

@@ -0,0 +1,7 @@
+package com.game.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.game.business.domain.AppUserCount;
+
+public interface IAppUserCountService extends IService<AppUserCount> {
+}

+ 7 - 0
game-business/src/main/java/com/game/business/service/IAppUserGameCountService.java

@@ -0,0 +1,7 @@
+package com.game.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.game.business.domain.AppUserGameCount;
+
+public interface IAppUserGameCountService extends IService<AppUserGameCount> {
+}

+ 17 - 0
game-business/src/main/java/com/game/business/service/impl/AppGameBettingServiceImpl.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.game.business.domain.AppGameBetting;
+import com.game.business.dto.AppGameBettingDetailsCountDTO;
 import com.game.business.mapper.AppGameBettingMapper;
 import com.game.business.service.IAppGameBettingService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -13,6 +15,7 @@ import java.util.List;
 @Service
 public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper, AppGameBetting> implements IAppGameBettingService {
 
+    @Autowired
     private AppGameBettingMapper appGameBettingMapper;
 
     @Override
@@ -36,4 +39,18 @@ public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper,
     public boolean save(AppGameBetting appGameBetting) {
         return appGameBettingMapper.insert(appGameBetting) > 0;
     }
+
+    @Override
+    public List<AppGameBettingDetailsCountDTO> getCount(String strDate) {
+        return appGameBettingMapper.getCount(strDate);
+    }
+
+    @Override
+    public List<AppGameBetting> selectListByGameId(Long gameId) {
+        LambdaQueryWrapper<AppGameBetting> queryWrapper = Wrappers.lambdaQuery();;
+        queryWrapper.eq(AppGameBetting::getGameId, gameId);
+        queryWrapper.ne(AppGameBetting::getIsWinning, 0);
+        queryWrapper.orderByDesc(AppGameBetting::getCreateTime);
+        return appGameBettingMapper.selectList(queryWrapper);
+    }
 }

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

@@ -1,11 +1,12 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
 
+import com.game.common.annotation.DataSource;
+import com.game.common.enums.DataSourceType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.game.business.mapper.AppGameClassifyMapper;
@@ -19,7 +20,6 @@ import com.game.business.service.IAppGameClassifyService;
  * @date 2024-06-14
  */
 @Service
-@DS("slave")
 public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMapper, AppGameClassify> implements IAppGameClassifyService {
     @Autowired
     private AppGameClassifyMapper appGameClassifyMapper;
@@ -31,6 +31,7 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 游戏分类
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppGameClassify selectAppGameClassifyById(Long id) {
         return appGameClassifyMapper.selectAppGameClassifyById(id);
     }
@@ -42,6 +43,7 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 游戏分类
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<AppGameClassify> selectAppGameClassifyList(AppGameClassify appGameClassify) {
         return appGameClassifyMapper.selectAppGameClassifyList(appGameClassify);
     }
@@ -53,6 +55,7 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertAppGameClassify(AppGameClassify appGameClassify) {
             return appGameClassifyMapper.insertAppGameClassify(appGameClassify);
     }
@@ -64,6 +67,7 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateAppGameClassify(AppGameClassify appGameClassify) {
         return appGameClassifyMapper.updateAppGameClassify(appGameClassify);
     }
@@ -75,6 +79,7 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppGameClassifyByIds(Long[] ids) {
         return appGameClassifyMapper.deleteAppGameClassifyByIds(ids);
     }
@@ -86,11 +91,13 @@ public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMappe
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppGameClassifyById(Long id) {
         return appGameClassifyMapper.deleteAppGameClassifyById(id);
     }
 
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppGameClassify getByCode(String code) {
         LambdaQueryWrapper<AppGameClassify> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(AppGameClassify::getCode, code);

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

@@ -1,6 +1,5 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -22,7 +21,6 @@ import com.game.business.service.IAppGameService;
  * @date 2024-06-14
  */
 @Service
-@DS("slave")
 public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> implements IAppGameService {
     @Autowired
     private AppGameMapper appGameMapper;
@@ -34,6 +32,7 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 游戏配置
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppGame selectAppGameById(Long id) {
         return appGameMapper.selectAppGameById(id);
     }
@@ -45,6 +44,7 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 游戏配置
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<AppGame> selectAppGameList(AppGame appGame) {
         return appGameMapper.selectAppGameList(appGame);
     }
@@ -56,6 +56,7 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertAppGame(AppGame appGame) {
                 appGame.setCreateTime(DateUtils.getNowDate());
             return appGameMapper.insertAppGame(appGame);
@@ -68,6 +69,7 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateAppGame(AppGame appGame) {
         return appGameMapper.updateAppGame(appGame);
     }
@@ -79,6 +81,7 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppGameByIds(Long[] ids) {
         return appGameMapper.deleteAppGameByIds(ids);
     }
@@ -90,11 +93,21 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppGameById(Long id) {
         return appGameMapper.deleteAppGameById(id);
     }
 
     @Override
+    @DataSource(DataSourceType.SLAVE)
+    public List<AppGame> selectAppGameByClassId(Long classId) {
+        LambdaQueryWrapper<AppGame> queryGameWrapper = Wrappers.lambdaQuery();;
+        queryGameWrapper.eq(AppGame::getClassifyId, classId);
+        return appGameMapper.selectList(queryGameWrapper);
+    }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppGame selectAppGameByClassIdAndCode(Long classId, String code) {
         LambdaQueryWrapper<AppGame> queryGameWrapper = Wrappers.lambdaQuery();;
         queryGameWrapper.eq(AppGame::getCode, code);

+ 11 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java

@@ -0,0 +1,11 @@
+package com.game.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.game.business.domain.AppUserCount;
+import com.game.business.mapper.AppUserCountMapper;
+import com.game.business.service.IAppUserCountService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, AppUserCount> implements IAppUserCountService {
+}

+ 11 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserGameCountServiceImpl.java

@@ -0,0 +1,11 @@
+package com.game.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.game.business.domain.AppUserGameCount;
+import com.game.business.mapper.AppUserGameCountMapper;
+import com.game.business.service.IAppUserGameCountService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AppUserGameCountServiceImpl extends ServiceImpl<AppUserGameCountMapper, AppUserGameCount> implements IAppUserGameCountService {
+}

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

@@ -1,6 +1,5 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
 
@@ -20,7 +19,6 @@ import com.game.business.service.IAppUserService;
  * @date 2024-06-18
  */
 @Service
-@DS("slave")
 public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements IAppUserService {
     @Autowired
     private AppUserMapper appUserMapper;
@@ -32,6 +30,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return app用户
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppUser selectAppUserByUserid(Long userid) {
         return appUserMapper.selectAppUserByUserid(userid);
     }
@@ -43,6 +42,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return app用户
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<AppUser> selectAppUserList(AppUser appUser) {
         return appUserMapper.selectAppUserList(appUser);
     }
@@ -54,6 +54,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertAppUser(AppUser appUser) {
                 appUser.setCreateTime(DateUtils.getNowDate());
             return appUserMapper.insertAppUser(appUser);
@@ -66,6 +67,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateAppUser(AppUser appUser) {
         return appUserMapper.updateAppUser(appUser);
     }
@@ -77,6 +79,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUserByUserids(Long[] userids) {
         return appUserMapper.deleteAppUserByUserids(userids);
     }
@@ -88,6 +91,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUserByUserid(Long userid) {
         return appUserMapper.deleteAppUserByUserid(userid);
     }

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

@@ -1,6 +1,5 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
 
@@ -19,7 +18,6 @@ import com.game.business.service.IAppUsersCashrecordService;
  * @date 2024-06-18
  */
 @Service
-@DS("slave")
 public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecordMapper, AppUsersCashrecord> implements IAppUsersCashrecordService {
     @Autowired
     private AppUsersCashrecordMapper appUsersCashrecordMapper;
@@ -31,6 +29,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 提现记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppUsersCashrecord selectAppUsersCashrecordById(Long id) {
         return appUsersCashrecordMapper.selectAppUsersCashrecordById(id);
     }
@@ -42,6 +41,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 提现记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<AppUsersCashrecord> selectAppUsersCashrecordList(AppUsersCashrecord appUsersCashrecord) {
         return appUsersCashrecordMapper.selectAppUsersCashrecordList(appUsersCashrecord);
     }
@@ -53,6 +53,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertAppUsersCashrecord(AppUsersCashrecord appUsersCashrecord) {
             return appUsersCashrecordMapper.insertAppUsersCashrecord(appUsersCashrecord);
     }
@@ -64,6 +65,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateAppUsersCashrecord(AppUsersCashrecord appUsersCashrecord) {
         return appUsersCashrecordMapper.updateAppUsersCashrecord(appUsersCashrecord);
     }
@@ -75,6 +77,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUsersCashrecordByIds(Long[] ids) {
         return appUsersCashrecordMapper.deleteAppUsersCashrecordByIds(ids);
     }
@@ -86,6 +89,7 @@ public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecor
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUsersCashrecordById(Long id) {
         return appUsersCashrecordMapper.deleteAppUsersCashrecordById(id);
     }

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

@@ -1,6 +1,5 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
 
@@ -19,7 +18,6 @@ import com.game.business.service.IAppUsersChargeService;
  * @date 2024-06-18
  */
 @Service
-@DS("slave")
 public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper, AppUsersCharge> implements IAppUsersChargeService {
     @Autowired
     private AppUsersChargeMapper appUsersChargeMapper;
@@ -31,6 +29,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 充值记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public AppUsersCharge selectAppUsersChargeById(Long id) {
         return appUsersChargeMapper.selectAppUsersChargeById(id);
     }
@@ -42,6 +41,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 充值记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<AppUsersCharge> selectAppUsersChargeList(AppUsersCharge appUsersCharge) {
         return appUsersChargeMapper.selectAppUsersChargeList(appUsersCharge);
     }
@@ -53,6 +53,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertAppUsersCharge(AppUsersCharge appUsersCharge) {
             return appUsersChargeMapper.insertAppUsersCharge(appUsersCharge);
     }
@@ -64,6 +65,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateAppUsersCharge(AppUsersCharge appUsersCharge) {
         return appUsersChargeMapper.updateAppUsersCharge(appUsersCharge);
     }
@@ -75,6 +77,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUsersChargeByIds(Long[] ids) {
         return appUsersChargeMapper.deleteAppUsersChargeByIds(ids);
     }
@@ -86,6 +89,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteAppUsersChargeById(Long id) {
         return appUsersChargeMapper.deleteAppUsersChargeById(id);
     }

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

@@ -1,6 +1,5 @@
 package com.game.business.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import java.util.List;
 
@@ -20,7 +19,6 @@ import com.game.business.service.IFinTranRecordService;
  * @date 2024-06-18
  */
 @Service
-@DS("slave")
 public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, FinTranRecord> implements IFinTranRecordService {
 
     @Autowired
@@ -33,6 +31,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 消费记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public FinTranRecord selectFinTranRecordById(Long id) {
         return finTranRecordMapper.selectFinTranRecordById(id);
     }
@@ -44,6 +43,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 消费记录
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public List<FinTranRecord> selectFinTranRecordList(FinTranRecord finTranRecord) {
         return finTranRecordMapper.selectFinTranRecordList(finTranRecord);
     }
@@ -55,6 +55,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int insertFinTranRecord(FinTranRecord finTranRecord) {
                 finTranRecord.setCreateTime(DateUtils.getNowDate());
             return finTranRecordMapper.insertFinTranRecord(finTranRecord);
@@ -67,6 +68,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int updateFinTranRecord(FinTranRecord finTranRecord) {
         return finTranRecordMapper.updateFinTranRecord(finTranRecord);
     }
@@ -78,6 +80,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteFinTranRecordByIds(Long[] ids) {
         return finTranRecordMapper.deleteFinTranRecordByIds(ids);
     }
@@ -89,6 +92,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
      * @return 结果
      */
     @Override
+    @DataSource(DataSourceType.SLAVE)
     public int deleteFinTranRecordById(Long id) {
         return finTranRecordMapper.deleteFinTranRecordById(id);
     }

+ 195 - 8
game-business/src/main/java/com/game/business/task/AppGameBettingTask.java

@@ -1,18 +1,17 @@
 package com.game.business.task;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.game.business.domain.AppGameBetting;
-import com.game.business.domain.AppUser;
-import com.game.business.domain.FinTranRecord;
-import com.game.business.service.IAppGameBettingService;
-import com.game.business.service.IAppUserService;
-import com.game.business.service.IFinTranRecordService;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.game.business.domain.*;
+import com.game.business.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Component
 public class AppGameBettingTask {
@@ -26,6 +25,194 @@ public class AppGameBettingTask {
     @Autowired
     private IFinTranRecordService finTranRecordService;
 
+    @Autowired
+    private IAppGameLotteryService appGameLotteryService;
+
+    @Autowired
+    private IAppGameService appGameService;
+
+    @Autowired
+    private IAppGameClassifyService appGameClassifyService;
+
+    @Async("asyncExecutor")
+    public void gameDataTask(String message){
+
+        JSONArray dataArry = JSONArray.parseArray(message);
+
+        Integer type = null;
+
+        for (int i = 0; i < dataArry.size(); i++) {
+            JSONObject jsonObject = dataArry.getJSONObject(i);
+            if(jsonObject.containsKey("type")){
+                type = jsonObject.getInteger("type");
+                break;
+            }
+        }
+
+        if(type == null){
+            System.out.println("游戏socket推送类型为空。");
+            return;
+        }
+
+        // 更新倒计时
+        if(type == 1){
+
+            JSONArray gameDataArry = null;
+            String time = null;
+            String classCode = null;
+            for (int i = 0; i < dataArry.size(); i++) {
+                JSONObject jsonObject = dataArry.getJSONObject(i);
+                if(jsonObject.containsKey("data")){
+                    gameDataArry = jsonObject.getJSONArray("data");
+                }
+                if(jsonObject.containsKey("time")){
+                    time = jsonObject.getString("time");
+                }
+                if(jsonObject.containsKey("id")){
+                    classCode = jsonObject.getString("id");
+                }
+            }
+
+            if(classCode == null){
+                System.out.println("游戏socket推送倒计时,平台ID为空。");
+                return;
+            }
+
+            if(gameDataArry == null){
+                System.out.println("游戏socket推送倒计时,data对象为空。");
+                return;
+            }
+
+            if(time == null || time.trim().isEmpty()){
+                System.out.println("游戏socket推送倒计时,time为空。");
+                return;
+            }
+
+            AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
+            if(appGameClassify == null){
+                System.out.println("开奖游戏平台不存在:" + classCode);
+                return;
+            }
+
+            List<AppGame> appGameList = appGameService.selectAppGameByClassId(appGameClassify.getId());
+            if(appGameList == null || appGameList.isEmpty()){
+                System.out.println("开奖游戏平台没有游戏:" + classCode);
+                return;
+            }
+            Map<String, List<AppGame>> codeGameMap = appGameList.stream().collect(Collectors.groupingBy(AppGame::getCode));
+
+            for (int i = 0; i < gameDataArry.size(); i++) {
+                JSONObject jsonObject = gameDataArry.getJSONObject(i);
+                String gameCode = jsonObject.getString("id");
+                if(gameCode == null){
+                    System.out.println("游戏socket推送倒计时,游戏id为空。");
+                    continue;
+                }
+                if(!codeGameMap.containsKey(gameCode)){
+                    System.out.println("开奖游戏不存在:" + gameCode);
+                    continue;
+                }
+                AppGame appGame = codeGameMap.get(gameCode).get(0);
+                appGame.setGameTime(time);
+                appGameService.updateAppGame(appGame);
+            }
+            return;
+        }
+
+        if(type != 2 && type != 3){
+            return;
+        }
+
+        JSONArray gameArry = null;
+        String classCode = null;
+        for (int i = 0; i < dataArry.size(); i++) {
+            JSONObject jsonObject = dataArry.getJSONObject(i);
+            if(jsonObject.containsKey("gameTypeSortArrayVOS")){
+                gameArry = jsonObject.getJSONArray("gameTypeSortArrayVOS");
+            }
+            if(jsonObject.containsKey("id")){
+                classCode = jsonObject.getString("id");
+            }
+        }
+
+        if(gameArry == null){
+            System.out.println("游戏socket推送期号或开奖,gameTypeSortArrayVOS对象为空。");
+            return;
+        }
+
+        if(classCode == null){
+            System.out.println("游戏socket推送期号或开奖,平台ID为空。");
+            return;
+        }
+
+        AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
+        if(appGameClassify == null){
+            System.out.println("开奖游戏平台不存在:" + classCode);
+        }
+
+        List<AppGame> appGameList = appGameService.selectAppGameByClassId(appGameClassify.getId());
+        if(appGameList == null || appGameList.isEmpty()){
+            System.out.println("开奖游戏平台没有游戏:" + classCode);
+            return;
+        }
+        Map<String, List<AppGame>> codeGameMap = appGameList.stream().collect(Collectors.groupingBy(AppGame::getCode));
+
+        for (int i = 0; i < gameArry.size(); i++) {
+            JSONObject gameLotteryObject = gameArry.getJSONObject(i);
+            String gameCode = gameLotteryObject.getString("id");
+
+            if(gameCode == null){
+                System.out.println("游戏socket推送期号或开奖,游戏ID为空。");
+                return;
+            }
+
+            if(!codeGameMap.containsKey(gameCode)){
+                System.out.println("开奖游戏不存在:" + gameCode);
+                continue;
+            }
+            AppGame appGame = codeGameMap.get(gameCode).get(0);
+
+            String gameDate = gameLotteryObject.getString("gameDate");
+            if(gameDate == null){
+                System.out.println("游戏socket推送期号或开奖,期号为空。");
+                return;
+            }
+
+            if(type == 3){
+                appGame.setGameDate(gameDate);
+                appGameService.updateAppGame(appGame);
+                continue;
+            }
+
+            long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), gameDate);
+
+            if(count > 0){
+                System.out.println("游戏socket推送开奖,当前期已开过将,游戏编码:" + gameCode + ",期号:" + gameDate);
+                continue;
+            }
+
+            Integer isLottery = gameLotteryObject.getInteger("isLottery");
+            String gameLotterySucc = gameLotteryObject.getString("gameLotterySucc");
+
+            // 保存开奖记录
+            AppGameLottery appGameLottery = new AppGameLottery();
+            appGameLottery.setGameId(appGame.getId());
+            appGameLottery.setClassId(appGame.getClassifyId());
+            appGameLottery.setGameDate(gameDate);
+            appGameLottery.setIsLottery(isLottery);
+            appGameLottery.setGameRecordDate(new Date());
+            appGameLottery.setGameLotterySucc(gameLotterySucc);
+            appGameLotteryService.save(appGameLottery);
+
+            if(isLottery != 1){
+                continue;
+            }
+
+            this.gameBettingTask(appGameClassify.getId(), appGame.getId(), gameDate, gameLotterySucc);
+        }
+
+    }
+
     public void gameBettingTask(Long classId, Long gameId, String gameDate, String bettingItem){
 
         List<AppGameBetting> list = appGameBettingService.getIsWinning(classId, gameId, gameDate, 0);

+ 3 - 3
game-business/src/main/java/com/game/business/websocket/WebSocketConnent.java

@@ -23,20 +23,20 @@ public class WebSocketConnent {
     public void connect() throws Exception{
         while (true){
             try {
-                System.out.printf("正在" + (this.WS_CONNENT_NUM == 0 ? "" : ("第" + this.WS_CONNENT_NUM + "次")) + "连接WebSocket[" + this.WS_URL_NAME + "]......");
+                System.out.println("正在" + (this.WS_CONNENT_NUM == 0 ? "" : ("第" + this.WS_CONNENT_NUM + "次")) + "连接WebSocket[" + this.WS_URL_NAME + "]......");
                 if(Common.GANME_ONE_NAME.equals(this.WS_URL_NAME)){
                     GameOneClient client = SpringContextSetting.getBean(GameOneClient.class);
                     ContainerProvider.getWebSocketContainer().connectToServer(client, new URI(this.WS_URL));
                 }
 
-                System.out.printf(this.WS_URL_NAME + " 已成功连接Websocket[" + this.WS_URL + "]");
+                System.out.println(this.WS_URL_NAME + " 已成功连接Websocket[" + this.WS_URL + "]");
                 this.WS_CONNENT_NUM = 0;
                 break;
             }catch (Exception e){
                 if(this.WS_CONNENT_MAX_NUM > this.WS_CONNENT_NUM){
                     this.WS_CONNENT_NUM ++;
                 }
-                System.out.printf("连接[" + this.WS_URL_NAME + "]异常," + this.WS_CONNENT_NUM + "秒后尝试重新连接:" + e.getMessage());
+                System.out.println("连接[" + this.WS_URL_NAME + "]异常," + this.WS_CONNENT_NUM + "秒后尝试重新连接:" + e.getMessage());
                 Thread.sleep(this.WS_CONNENT_NUM * 1000);
             }
         }

+ 7 - 172
game-business/src/main/java/com/game/business/websocket/client/GameOneClient.java

@@ -19,40 +19,31 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.websocket.*;
-import java.util.Date;
+
 
 @Component
 @ClientEndpoint
 public class GameOneClient {
 
-    @Autowired
-    private IAppGameLotteryService appGameLotteryService;
-
-    @Autowired
-    private IAppGameService appGameService;
-
-    @Autowired
-    private IAppGameClassifyService appGameClassifyService;
-
     @Autowired
     private AppGameBettingTask appGameBettingTask;
 
     @OnOpen
     public void onOpen(Session session) throws Exception{
-        System.out.printf("game one 游戏已连接 server");
+        System.out.println("game one 游戏已连接 server");
         // 发送游戏编码
         session.getBasicRemote().sendText("{\"code\":\"" + Common.GAME_ONE_CODE + "\"}");
     }
 
     @OnClose
     public void onClose(Session session) throws Exception{
-        System.out.printf("game on 游戏已断开 server");
+        System.out.println("game on 游戏已断开 server");
         connect();
     }
 
     @OnError
     public void onError(Session session, Throwable throwable) throws Exception{
-        System.out.printf("game one 连接异常 [" + throwable.getMessage() + "]");
+        System.out.println("game one 连接异常 [" + throwable.getMessage() + "]");
         connect();
     }
 
@@ -61,7 +52,7 @@ public class GameOneClient {
             try {
                 GameOneConfig.webSocketConnent.connect();
             }catch (Exception e){
-                System.out.printf("连接 game on [socket] 异常" + e.getMessage());
+                System.out.println("连接 game on [socket] 异常" + e.getMessage());
             }
         }
     }
@@ -75,166 +66,10 @@ public class GameOneClient {
             }
 
             System.out.println("game one 接收数据" + message);
-            JSONArray dataArry = JSONArray.parseArray(message);
-
-            Integer type = null;
-
-            for (int i = 0; i < dataArry.size(); i++) {
-                JSONObject jsonObject = dataArry.getJSONObject(i);
-                if(jsonObject.containsKey("type")){
-                    type = jsonObject.getInteger("type");
-                    break;
-                }
-            }
-
-            if(type == null){
-                System.out.println("游戏socket推送类型为空。");
-                return;
-            }
-
-            // 更新倒计时
-            if(type == 1){
-
-                JSONArray gameDataArry = null;
-                String time = null;
-                String classCode = null;
-                for (int i = 0; i < dataArry.size(); i++) {
-                    JSONObject jsonObject = dataArry.getJSONObject(i);
-                    if(jsonObject.containsKey("data")){
-                        gameDataArry = jsonObject.getJSONArray("data");
-                    }
-                    if(jsonObject.containsKey("time")){
-                        time = jsonObject.getString("time");
-                    }
-                    if(jsonObject.containsKey("id")){
-                        classCode = jsonObject.getString("id");
-                    }
-                }
-
-                if(classCode == null){
-                    System.out.println("游戏socket推送倒计时,平台ID为空。");
-                    return;
-                }
-
-                if(gameDataArry == null){
-                    System.out.println("游戏socket推送倒计时,data对象为空。");
-                    return;
-                }
-
-                if(time == null){
-                    System.out.println("游戏socket推送倒计时,time为空。");
-                    return;
-                }
-
-                AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
-                if(appGameClassify == null){
-                    System.out.println("开奖游戏平台不存在:" + classCode);
-                }
-
-                for (int i = 0; i < gameDataArry.size(); i++) {
-                    JSONObject jsonObject = gameDataArry.getJSONObject(i);
-                    String gameCode = jsonObject.getString("id");
-                    if(gameCode == null){
-                        System.out.println("游戏socket推送倒计时,游戏id为空。");
-                        continue;
-                    }
-
-                    AppGame appGame = appGameService.selectAppGameByClassIdAndCode(appGameClassify.getId(), gameCode);
-                    if(appGame == null){
-                        System.out.println("开奖游戏不存在:" + gameCode);
-                    }
-                    appGame.setGameTime(time);
-                    appGameService.updateAppGame(appGame);
-                }
-                return;
-            }
-
-            if(type != 2 && type != 3){
-                return;
-            }
-
-            JSONArray gameArry = null;
-            String classCode = null;
-            for (int i = 0; i < dataArry.size(); i++) {
-                JSONObject jsonObject = dataArry.getJSONObject(i);
-                if(jsonObject.containsKey("gameTypeSortArrayVOS")){
-                    gameArry = jsonObject.getJSONArray("data");
-                }
-                if(jsonObject.containsKey("id")){
-                    classCode = jsonObject.getString("id");
-                }
-            }
-
-            if(gameArry == null){
-                System.out.println("游戏socket推送期号或开奖,gameTypeSortArrayVOS对象为空。");
-                return;
-            }
-
-            if(classCode == null){
-                System.out.println("游戏socket推送期号或开奖,平台ID为空。");
-                return;
-            }
-
-            AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
-            if(appGameClassify == null){
-                System.out.println("开奖游戏平台不存在:" + classCode);
-            }
-
-            for (int i = 0; i < gameArry.size(); i++) {
-                JSONObject gameLotteryObject = gameArry.getJSONObject(i);
-                String gameCode = gameLotteryObject.getString("id");
-
-                if(gameCode == null){
-                    System.out.println("游戏socket推送期号或开奖,游戏ID为空。");
-                    return;
-                }
-
-                AppGame appGame = appGameService.selectAppGameByClassIdAndCode(appGameClassify.getId(), gameCode);
-                if(appGame == null){
-                    System.out.println("开奖游戏不存在:" + gameCode);
-                }
-
-                String gameDate = gameLotteryObject.getString("gameDate");
-
-                if(gameDate == null){
-                    System.out.println("游戏socket推送期号或开奖,期号为空。");
-                    return;
-                }
-
-                if(type == 3){
-                    appGame.setGameDate(gameDate);
-                    appGameService.updateAppGame(appGame);
-                    continue;
-                }
-
-                long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), gameDate);
-
-                if(count > 0){
-                    System.out.println("游戏socket推送开奖,当前期已开过将,游戏编码:" + gameCode + ",期号:" + gameDate);
-                    continue;
-                }
-
-                Integer isLottery = gameLotteryObject.getInteger("isLottery");
-                String gameLotterySucc = gameLotteryObject.getString("gameLotterySucc");
-
-                // 保存开奖记录
-                AppGameLottery appGameLottery = new AppGameLottery();
-                appGameLottery.setGameId(appGame.getId());
-                appGameLottery.setGameDate(gameDate);
-                appGameLottery.setIsLottery(isLottery);
-                appGameLottery.setGameRecordDate(new Date());
-                appGameLottery.setGameLotterySucc(gameLotterySucc);
-                appGameLotteryService.save(appGameLottery);
-
-                if(isLottery != 1){
-                    continue;
-                }
-
-                appGameBettingTask.gameBettingTask(appGameClassify.getId(), appGame.getId(), gameDate, gameLotterySucc);
-            }
+            appGameBettingTask.gameDataTask(message);
         }catch (Exception e){
             e.printStackTrace();
-            System.out.printf("game one 接收数据异常[" + e.getMessage() + "]");
+            System.out.println("game one 接收数据异常[" + e.getMessage() + "]");
         }
     }
 }

+ 17 - 0
game-business/src/main/resources/mapper/business/AppGameBettingMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.game.business.mapper.AppGameBettingMapper">
+
+    <select id="getCount" resultType="com.game.business.dto.AppGameBettingDetailsCountDTO">
+        select
+        game_id as gameId,
+        count(id) as bettingCount,
+        sum(betting_amount) as orderAmount,
+        sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
+        sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
+        from app_game_betting  where date_format(create_time, '%Y-%m-%d') = #{strDate}
+        group by game_id
+    </select>
+</mapper>