diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 9eb94a6b1..554761b17 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -231,31 +231,14 @@ class PromoteCompanyController extends ThinkController public function displayOnShelves() { if (IS_AJAX) { $post = I("post."); - -// var_dump(time()); - $where = []; - if ($post['batch_company_type'] == 1) { - $where['company_belong'] = array('exp', " IN (1,2)"); - } else { - $where['company_belong'] = $post['batch_company_type']; - } - if ($post['batch_type'] == 1) { // 批量增加 - $where['_string'] = "concat(',', game_ids, ',') not like \"%,{$post['batch_game']},%\""; - $exp = "trim(BOTH ',' FROM concat(game_ids, ',', {$post['batch_game']}))"; - } - if ($post['batch_type'] == 2) { // 批量删除 - $where['_string'] = "concat(',', game_ids, ',') like \"%,{$post['batch_game']},%\""; - $exp = "trim(BOTH ',' FROM replace(concat(',', game_ids, ','), \",{$post['batch_game']},\", ','))"; + + $game = M('game', 'tab_')->where(['id' => $post['batch_game']])->find(); + $relationGames = M('game', 'tab_')->where(['relation_game_id' => $game['relation_game_id']])->select(); + foreach ($relationGames as $relationGame) { + $gameId = $relationGame['id']; + $this->doDisplayOnShelves($gameId, $post['batch_company_type'], $post['batch_type']); } - M('promote', 'tab_')->where($where)->save([ - 'game_ids' => ['exp', $exp] - ]); - - M('promote_company', 'tab_')->where($where)->save([ - 'game_ids' => ['exp', $exp] - ]); -// var_dump(M('promote', 'tab_')->_sql(),time());die; - + echo $this->ajaxReturn([ 'code' => 1, 'msg' => '成功', @@ -264,6 +247,32 @@ class PromoteCompanyController extends ThinkController } } + + private function doDisplayOnShelves($gameId, $batchCompanyType, $batchType) { + $where = []; + $exp = ''; + if ($batchCompanyType == 1) { + $where['company_belong'] = array('exp', " IN (1,2)"); + } else { + $where['company_belong'] = $batchCompanyType; + } + + if ($batchType == 1) { // 批量增加 + $where['_string'] = "concat(',', game_ids, ',') not like \"%,{$gameId},%\""; + $exp = "trim(BOTH ',' FROM concat(game_ids, ',', {$gameId}))"; + } + if ($batchType == 2) { // 批量删除 + $where['_string'] = "concat(',', game_ids, ',') like \"%,{$gameId},%\""; + $exp = "trim(BOTH ',' FROM replace(concat(',', game_ids, ','), \",{$gameId},\", ','))"; + } + M('promote', 'tab_')->where($where)->save([ + 'game_ids' => ['exp', $exp] + ]); + + M('promote_company', 'tab_')->where($where)->save([ + 'game_ids' => ['exp', $exp] + ]); + } public function index() { diff --git a/Application/Admin/View/PromoteCompany/lists.html b/Application/Admin/View/PromoteCompany/lists.html index 813d29ead..587c57f8e 100644 --- a/Application/Admin/View/PromoteCompany/lists.html +++ b/Application/Admin/View/PromoteCompany/lists.html @@ -694,6 +694,7 @@ } $(".batch_page").hide(); $(".modal").hide(); + window.location.reload(); } });