From f6ba3e15355e22767e69f8fc14ae22523f8db8dc Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 22 十一月 2023 19:33:58 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai

---
 cloud-server-other/src/main/java/com/dsh/other/controller/BallController.java |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/BallController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/BallController.java
index ff9fa6c..979aa00 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/BallController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/BallController.java
@@ -5,10 +5,7 @@
 import com.dsh.other.feignclient.model.AdvertisementChangeStateDTO;
 import com.dsh.other.feignclient.model.AdvertisementQuery;
 import com.dsh.other.model.BannerVo;
-import com.dsh.other.service.GameService;
-import com.dsh.other.service.IBannerService;
-import com.dsh.other.service.IRegionService;
-import com.dsh.other.service.TGameConfigService;
+import com.dsh.other.service.*;
 import com.dsh.other.util.ResultUtil;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -22,6 +19,7 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author zhibing.pu
@@ -32,12 +30,32 @@
 public class BallController {
     @Autowired
     private GameService gameService;
+    @Autowired
+    private TGameRecordService gameRecordService;
 
     @ResponseBody
     @PostMapping("/student/webStudentList")
     public List<Game> list(@RequestBody BallQueryDto ballQueryDto){
         List<Game> games =   gameService.queryAll(ballQueryDto);
         return games;
+    }
+    // 根据门店ids 获取游戏记录
+    @ResponseBody
+    @PostMapping("/game/getGameByStoreIds")
+    public List<Integer> getGameByStoreIds(@RequestBody List<Integer> storeIds){
+        // 游戏id
+        List<Integer> gamesId = gameService.list(new QueryWrapper<Game>().in("storeId", storeIds))
+                .stream().map(Game::getId).collect(Collectors.toList());
+        if (gamesId.size() == 0){
+            return new ArrayList<>();
+        }else{
+            // 根据游戏id获取游戏记录 获取用户Ids
+            List<Integer> userId = gameRecordService.list(new QueryWrapper<TGameRecord>().in("gameId", gamesId))
+                    .stream().map(TGameRecord::getUserId).collect(Collectors.toList());
+            return userId;
+        }
+
+
     }
 
     @Autowired
@@ -47,17 +65,19 @@
     @PostMapping("/save")
     public Integer save(@RequestBody Game game){
 
-        Region city = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getCityCode()));
-        game.setCity(city.getName());
+
+        if (game.getCityCode()!=null) {
+            Region city = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getCityCode()));
+            game.setCity(city.getName());
 
 
-        Region province = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getProvinceCode()));
-        game.setProvince(province.getName());
+            Region province = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getProvinceCode()));
+            game.setProvince(province.getName());
+
+        }
 
 
-
-
-        gameService.save(game);
+        gameService.saveOrUpdate(game);
          System.out.println("==========="+game);
          return  game.getId();
     }
@@ -69,7 +89,7 @@
     @PostMapping("/saveConfig")
     public void saveConfig(@RequestBody List<TGameConfig> gameConfigList){
         System.out.println("=======gameConfigList===="+gameConfigList);
-        config.saveBatch(gameConfigList);
+        config.saveOrUpdateBatch(gameConfigList);
 //        return  game.getId();
     }
 

--
Gitblit v1.7.1