|
@@ -9,6 +9,7 @@ namespace app\v1\logic\center;
|
|
|
use plugin\saiadmin\basic\BaseLogic;
|
|
use plugin\saiadmin\basic\BaseLogic;
|
|
|
use app\v1\model\center\Game;
|
|
use app\v1\model\center\Game;
|
|
|
use plugin\saiadmin\app\logic\system\SystemDeptLogic;
|
|
use plugin\saiadmin\app\logic\system\SystemDeptLogic;
|
|
|
|
|
+use support\think\Db;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 游戏列表逻辑层
|
|
* 游戏列表逻辑层
|
|
@@ -18,6 +19,7 @@ class GameLogic extends BaseLogic
|
|
|
|
|
|
|
|
protected $gameMainLogic;
|
|
protected $gameMainLogic;
|
|
|
protected $systemDeptLogic;
|
|
protected $systemDeptLogic;
|
|
|
|
|
+ protected $gameGroupLogic;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 构造函数
|
|
* 构造函数
|
|
@@ -27,6 +29,7 @@ class GameLogic extends BaseLogic
|
|
|
$this->model = new Game();
|
|
$this->model = new Game();
|
|
|
$this->gameMainLogic = new GameMainLogic();
|
|
$this->gameMainLogic = new GameMainLogic();
|
|
|
$this->systemDeptLogic = new SystemDeptLogic();
|
|
$this->systemDeptLogic = new SystemDeptLogic();
|
|
|
|
|
+ $this->gameGroupLogic = new GameGroupLogic();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -66,7 +69,40 @@ class GameLogic extends BaseLogic
|
|
|
$query->where('id', 'in', $authGameList);
|
|
$query->where('id', 'in', $authGameList);
|
|
|
}
|
|
}
|
|
|
$list = $query->select()->toArray();
|
|
$list = $query->select()->toArray();
|
|
|
- return $list;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 携带分组信息
|
|
|
|
|
+ $gameGroupList = Db::connect('db_center')->table('game_group')->where('1=1')->select()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $gameListMap = array_column($list, null, 'id');
|
|
|
|
|
+
|
|
|
|
|
+ // 按照gameGroupList分组输出,组内携带game_list(如2,3,4),并将gameListMap中的游戏信息塞入分组,树形结构输出
|
|
|
|
|
+ $result = [];
|
|
|
|
|
+ foreach ($gameGroupList as $group) {
|
|
|
|
|
+ $groupGames = [];
|
|
|
|
|
+ if (!empty($group['game_list'])) {
|
|
|
|
|
+ $gameIds = explode(',', $group['game_list']);
|
|
|
|
|
+ foreach ($gameIds as $gid) {
|
|
|
|
|
+ $gid = trim($gid);
|
|
|
|
|
+ if (isset($gameListMap[$gid])) {
|
|
|
|
|
+ $gameInfo = $gameListMap[$gid];
|
|
|
|
|
+ // 兼容输出格式
|
|
|
|
|
+ $groupGames[] = [
|
|
|
|
|
+ 'id' => $gameInfo['id'],
|
|
|
|
|
+ 'name' =>'['.$gameInfo['id'].']'.$gameInfo['name'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $result[] = [
|
|
|
|
|
+ 'id' =>'group_id_'.$group['id'],
|
|
|
|
|
+ 'name' => $group['name'],
|
|
|
|
|
+ 'children' => $groupGames
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $result;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|