| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\v1\logic\center;
- use plugin\saiadmin\basic\BaseLogic;
- use app\v1\model\center\GameGroup;
- use support\think\Db;
- /**
- * 游戏分组逻辑层
- */
- class GameGroupLogic extends BaseLogic
- {
- /**
- * 构造函数
- */
- public function __construct()
- {
- $this->model = new GameGroup();
- }
-
- /**
- * 读取数据
- * @param $id
- * @return mixed
- */
- public function read($id): mixed
- {
- $data = $this->model->where('id', $id)->find();
- $gameIds = explode(',', $data['game_list']);
- $gameList = Db::connect('db_center')->table('pf_game')->where("id", $gameIds)->column('name', 'id');
- foreach ($gameList as $id => &$name) {
- $name = '[' . $id . ']' . $name;
- }
- $data['game_list_str'] = $gameList;
- return $data;
- }
- /**
- * 给游戏分组用的游戏列表,主要作用,返回可选或者可编辑的游戏列表
- * $where['game_group_id]
- */
- public function getGameListOptionsByGroup($where): array
- {
- // Todo 获取非自己的已选中
- $gameGroupId = $where['game_group_id'];
- $data = $this->model->where('id', '<>', $gameGroupId)->column("game_list");
- $gameIdList = [];
- foreach ($data as $gameIds) {
- $gameIds = explode(',', $gameIds);
- $gameIdList = array_merge($gameIdList, $gameIds);
- }
- // Todo 获取游戏分组
- $groupWhere = [
- 'status'=>1
- ];
- if (!empty($gameIdList)) {
- $groupWhere[] = [ 'id', 'notin', implode(',', $gameIdList)];
- }
- // 平台游戏
- $pfCame = Db::connect('db_center')->table('pf_game')->where($groupWhere)->select()->toArray();
- return (new GameLogic())->gameMainTree($pfCame);
- }
- }
|