From d3417894601b74aaacb5163930a08ad0524fb122 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 16 Dec 2019 20:51:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0>=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=AE=A1=E7=90=86>=E5=85=85=E5=80=BC=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Common/function.php | 15 ++++++++ .../Home/Controller/QueryController.class.php | 38 ++++--------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index 1fb3c1774..2827ba43b 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -1197,4 +1197,19 @@ function promoteCan($promoteId, \Closure $callback) function getChildGameAddPermission($promoteId) { return D('Promote')->where(array('id' => $promoteId))->getField('child_game_permission'); +} + +function gameSearch($relationGameId, $sdkVersion) +{ + $map = '1 = 1'; + if ($relationGameId != 0) { + $map['relation_game_id'] = $relationGameId; + } + if ($sdkVersion != 0) { + $map['sdk_version'] = $sdkVersion; + } + $gameIds = M('game', 'tab_')->where($map)->getField('id', true); + $gameIds = $gameIds ?? [-1]; + + return $gameIds; } \ No newline at end of file diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 33a240b31..a5aaf12bb 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1678,16 +1678,8 @@ class QueryController extends BaseController } if ($relationGameId != 0 || $sdkVersion != 0) { - if ($relationGameId != 0) { - $gameMap['relation_game_id'] = $relationGameId; - } - if ($sdkVersion != 0) { - $gameMap['sdk_version'] = $sdkVersion; - } - $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); - $gameId = $gameId ?? [-1]; - - $map['game_id'] = ['in', $gameId]; + $gameIds = gameSearch($relationGameId, $sdkVersion); + $map['game_id'] = ['in', $gameIds]; } if ($serverId != 0) { $map['server_id'] = $serverId; @@ -1793,17 +1785,9 @@ class QueryController extends BaseController $subMap = ['promote_id' => ['in', $ids]]; if ($relationGameId != 0 || $sdkVersion != 0) { - if ($relationGameId != 0) { - $gameMap['relation_game_id'] = $relationGameId; - } - if ($sdkVersion != 0) { - $gameMap['sdk_version'] = $sdkVersion; - } - $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); - $gameId = $gameId ?? [-1]; - - $map['uc.game_id'] = ['in', $gameId]; - $subMap['game_id'] = ['in', $gameId]; + $gameIds = gameSearch($relationGameId, $sdkVersion); + $map['uc.game_id'] = ['in', $gameIds]; + $subMap['game_id'] = ['in', $gameIds]; } if ($serverId != 0) { $map['uc.server_id'] = $serverId; @@ -2081,16 +2065,8 @@ class QueryController extends BaseController 'basicPromotes' => $basicPromotes, ]; if ($relationGameId != 0 || $sdkVersion != 0) { - if ($relationGameId != 0) { - $gameMap['relation_game_id'] = $relationGameId; - } - if ($sdkVersion != 0) { - $gameMap['sdk_version'] = $sdkVersion; - } - $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); - $gameId = $gameId ?? [-1]; - - $params['game_id'] = ['in', $gameId]; + $gameIds = gameSearch($relationGameId, $sdkVersion); + $params['game_id'] = ['in', $gameIds]; } if ($serverId > 0) { $params['server_id'] = $serverId;