kk 9 месяцев назад
Родитель
Сommit
02f2d26372

+ 12 - 6
game-business/src/main/java/com/game/business/controller/GameController.java → game-business/src/main/java/com/game/business/controller/AppGameBettingController.java

@@ -1,21 +1,28 @@
 package com.game.business.controller;
 
 import com.game.business.domain.AppGameBetting;
+import com.game.business.service.IAppGameBettingService;
 import com.game.common.core.controller.BaseController;
 import com.game.common.core.domain.AjaxResult;
+import io.swagger.annotations.Api;
+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;
 
 @RestController
-@RequestMapping("/game/record")
-public class GameController extends BaseController{
+@RequestMapping("/game/betting")
+@Api(value = "AppGameBettingController", description = "游戏投注接口", tags = {"游戏投注、查询记录等"})
+public class AppGameBettingController extends BaseController{
+
+    @Autowired
+    private IAppGameBettingService appGameBettingService;
 
     /**
      * 下注
      */
-    @PostMapping(value = "/betting")
+    @PostMapping(value = "/create")
     public AjaxResult betting(@RequestBody AppGameBetting gameBetting)
     {
         // 获取用户金额,判断投注金额是否大于余额
@@ -28,9 +35,8 @@ public class GameController extends BaseController{
             return error("已超过投注下单时间");
         }
 
-        return success();
-
         // 插入投注记录
+        appGameBettingService.save(gameBetting);
+        return success();
     }
-
 }

+ 46 - 0
game-business/src/main/java/com/game/business/domain/AppGameLottery.java

@@ -0,0 +1,46 @@
+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.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName(value = "app_game_lottery")
+public class AppGameLottery {
+
+    @ApiModelProperty(value = "游戏开奖Id")
+    @TableId(value = "id" , type = IdType.AUTO)
+    @Excel(name = "游戏开奖Id", cellType = Excel.ColumnType.NUMERIC, prompt = "游戏开奖Id")
+    private Long id;
+
+    @Excel(name = "游戏Id")
+    @TableField(value = "game_id")
+    @ApiModelProperty(value = "游戏Id")
+    private Long gameId;
+
+    @Excel(name = "游戏期号")
+    @TableField(value = "game_date")
+    @ApiModelProperty(value = "游戏期号")
+    private String gameDate;
+
+    @Excel(name = "是否开奖:0 否;1是")
+    @TableField(value = "is_lottery")
+    @ApiModelProperty(value = "是否开奖:0 否;1是")
+    private Integer isLottery;
+
+    @Excel(name = "开奖选项")
+    @TableField(value = "game_lottery_succ")
+    @ApiModelProperty(value = "开奖选项")
+    private String gameLotterySucc;
+
+    @Excel(name = "记录时间")
+    @TableField(value = "game_record_date")
+    @ApiModelProperty(value = "记录时间")
+    private Date gameRecordDate;
+}

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

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

+ 10 - 0
game-business/src/main/java/com/game/business/service/IAppGameLotteryService.java

@@ -0,0 +1,10 @@
+package com.game.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.game.business.domain.AppGameLottery;
+
+/**
+ * 游戏开奖记录业务接口
+ */
+public interface IAppGameLotteryService extends IService<AppGameLottery> {
+}

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

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

+ 34 - 27
game-business/src/main/java/com/game/business/websocket/client/GameOneClient.java

@@ -2,7 +2,12 @@ package com.game.business.websocket.client;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.game.business.config.GameOneConfig;
+import com.game.business.domain.AppGame;
+import com.game.business.domain.AppGameLottery;
+import com.game.business.service.IAppGameLotteryService;
+import com.game.business.service.IAppGameService;
 import com.game.business.util.Common;
+import com.game.common.utils.DateUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -13,6 +18,12 @@ import javax.websocket.*;
 @ClientEndpoint
 public class GameOneClient {
 
+    @Autowired
+    private IAppGameLotteryService appGameLotteryService;
+
+    @Autowired
+    private IAppGameService appGameService;
+
     @OnOpen
     public void onOpen(Session session) throws Exception{
         System.out.printf("game one 游戏已连接 server");
@@ -60,33 +71,29 @@ public class GameOneClient {
                 return;
             }
 
-//            GameType gameType = new GameType();
-//            gameType.setGameTypeCode(code);
-//            GameType dbGameType = gameTypeService.selectGameType(gameType);
-//            if(dbGameType == null){
-//                System.out.printf("game one 游戏类型数据库不匹配");
-//                return;
-//            }
-//
-//            GameRecord record = JSONObject.parseObject(message, GameRecord.class);
-//            record.setGameTypeId(dbGameType.getGameTypeId());
-//            gameRecordService.insertGameRecord(record);
-//
-//            GameLottery gameLottery = new GameLottery();
-//            gameLottery.setGameTypeId(dbGameType.getGameTypeId());
-//            gameLottery.setGameDate(record.getGameDate());
-//
-//            GameLottery dbGameLottery = gameLotteryService.selectGameLottery(gameLottery);
-//
-//            if(dbGameLottery == null){
-//                gameLotteryService.insertGameLottery(gameLottery);
-//            }else{
-//                if(record.getIsLottery() == 1) {
-//                    dbGameLottery.setGameLotteryDate(record.getGameRecordDate());
-//                    dbGameLottery.setGameLotterySucc(record.getGameLotterySucc());
-//                    gameLotteryService.updateGameLottery(dbGameLottery);
-//                }
-//            }
+            // 是否为开奖
+            Integer isLottery = jsonObject.getInteger("isLottery");
+            if(isLottery == 0){
+                return;
+            }
+
+            AppGame appGame = appGameService.selectAppGameById(0L);
+
+            String gameDate = jsonObject.getString("gameDate");
+            String gameRecordDate = jsonObject.getString("gameRecordDate");
+            String gameLotterySucc = jsonObject.getString("gameLotterySucc");
+
+            AppGameLottery appGameLottery = new AppGameLottery();
+            appGameLottery.setGameId(appGame.getId());
+            appGameLottery.setGameDate(gameDate);
+            appGameLottery.setIsLottery(isLottery);
+            appGameLottery.setGameRecordDate(DateUtils.parseDate(gameRecordDate));
+            appGameLottery.setGameLotterySucc(gameLotterySucc);
+
+            appGameLotteryService.save(appGameLottery);
+
+            // 开奖结算
+
         }catch (Exception e){
             e.printStackTrace();
             System.out.printf("game one 接收数据异常[" + e.getMessage() + "]");