ith5 před 6 měsíci
rodič
revize
c8cb316b4a

+ 5 - 2
app/v1/controller/CommonController.php

@@ -186,9 +186,12 @@ class CommonController extends BaseController
      */
     public function getGameListOptionsByGroup(Request $request): Response
     {
-        $data = $this->gameGroupLogic->getGameListOptionsByGroup();
+        $where = $request->more([
+            ['game_group_id', '']
+        ]);
+        $data = $this->gameGroupLogic->getGameListOptionsByGroup($where);
         return $this->success($data);
     }
 
 
-}
+}

+ 0 - 4
app/v1/controller/center/GameGroupController.php

@@ -43,10 +43,6 @@ class GameGroupController extends BaseController
         $query->order('sort', 'desc');
         $data = $this->logic->getList($query);
 
-        $allGameList =  Db::connect('db_center')->table('pf_game')->field('id,name')->select()->toArray();
-        $allGameList = array_column($allGameList, 'name', 'id');
-
-
         return $this->success($data);
     }
 

+ 22 - 9
app/v1/logic/center/GameGroupLogic.php

@@ -49,31 +49,44 @@ class GameGroupLogic extends BaseLogic
 
     /**
      * 给游戏分组用的游戏列表
+     * $where['game_group_id]
      */
-    public function getGameListOptionsByGroup()
+    public function getGameListOptionsByGroup($where)
     {
+
+        // 获取gameGroupId, 如果存在,则返回的游戏需要加上这个分组的game_list
+        $gameGroupId = $where['game_group_id'];
+
+
+        // 游戏分组数据
         $data = $this->model->where('1=1')->order('sort', 'desc')->order('id', 'desc')->select()->toArray();
 
         // 已经存在分组的game_list
         $gameIdList = [];
-
         foreach ($data as $item) {
-            $temGameListArray = explode(',', $item['game_list']);
-            $gameIdList = array_merge($gameIdList, $temGameListArray);
+            // 传入的分组,不加入筛选去除筛选,用于编辑回显示
+            if($item['id']!=$gameGroupId){
+                $temGameListArray = explode(',', $item['game_list']);
+                $gameIdList = array_merge($gameIdList, $temGameListArray);
+            }
         }
 
-        $where = [];
-        $where[] = ['status', 1];
+        $groupWhere = [];
+        $groupWhere[] = ['status', '=', 1];
+
+
 
         if (!empty($gameIdList)) {
-            $where[] = ['id', 'notin', implode(',', $gameIdList)];
+            $groupWhere[] = [ 'id', 'notin', implode(',', $gameIdList)];
         }
 
-        $game = Db::connect('db_center')->table('pf_game')->where($where)->select()->toArray();
+        // 平台游戏
+        $pfCame = Db::connect('db_center')->table('pf_game')->where($groupWhere)->select()->toArray();
+
 
         $mainGameMap = $this->gameMainLogic->getMainGameMap();
         $groupedGames = [];
-        foreach ($game as $item) {
+        foreach ($pfCame as $item) {
             $mainId = $item['main_id'];
             $groupedGames[$mainId]['id'] = 'main_id_'.$mainId;
             $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId;

+ 2 - 2
app/v1/logic/center/GameLogic.php

@@ -168,10 +168,10 @@ class GameLogic extends BaseLogic
     public function getGameListTreeNoAuth($where)
     {
  
-        $game_list = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
+        $pfGame = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
         $mainGameMap = $this->gameMainLogic->getMainGameMap();
         $groupedGames = [];
-        foreach ($game_list as $game) {
+        foreach ($pfGame as $game) {
             $mainId = $game['main_id'];
             $groupedGames[$mainId]['id'] = 'main_id_'.$mainId;
             $groupedGames[$mainId]['disabled'] = ($where['single'] ?? false);