1126 批量上下架

master
tping 4 years ago
parent b722175785
commit dd786dc27f

@ -232,20 +232,38 @@ class PromoteCompanyController extends ThinkController
if (IS_AJAX) { if (IS_AJAX) {
$post = I("post."); $post = I("post.");
// var_dump(time()); $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']);
}
echo $this->ajaxReturn([
'code' => 1,
'msg' => '成功',
'data' => []
]);
}
}
private function doDisplayOnShelves($gameId, $batchCompanyType, $batchType) {
$where = []; $where = [];
if ($post['batch_company_type'] == 1) { $exp = '';
if ($batchCompanyType == 1) {
$where['company_belong'] = array('exp', " IN (1,2)"); $where['company_belong'] = array('exp', " IN (1,2)");
} else { } else {
$where['company_belong'] = $post['batch_company_type']; $where['company_belong'] = $batchCompanyType;
} }
if ($post['batch_type'] == 1) { // 批量增加
$where['_string'] = "concat(',', game_ids, ',') not like \"%,{$post['batch_game']},%\""; if ($batchType == 1) { // 批量增加
$exp = "trim(BOTH ',' FROM concat(game_ids, ',', {$post['batch_game']}))"; $where['_string'] = "concat(',', game_ids, ',') not like \"%,{$gameId},%\"";
$exp = "trim(BOTH ',' FROM concat(game_ids, ',', {$gameId}))";
} }
if ($post['batch_type'] == 2) { // 批量删除 if ($batchType == 2) { // 批量删除
$where['_string'] = "concat(',', game_ids, ',') like \"%,{$post['batch_game']},%\""; $where['_string'] = "concat(',', game_ids, ',') like \"%,{$gameId},%\"";
$exp = "trim(BOTH ',' FROM replace(concat(',', game_ids, ','), \",{$post['batch_game']},\", ','))"; $exp = "trim(BOTH ',' FROM replace(concat(',', game_ids, ','), \",{$gameId},\", ','))";
} }
M('promote', 'tab_')->where($where)->save([ M('promote', 'tab_')->where($where)->save([
'game_ids' => ['exp', $exp] 'game_ids' => ['exp', $exp]
@ -254,15 +272,6 @@ class PromoteCompanyController extends ThinkController
M('promote_company', 'tab_')->where($where)->save([ M('promote_company', 'tab_')->where($where)->save([
'game_ids' => ['exp', $exp] 'game_ids' => ['exp', $exp]
]); ]);
// var_dump(M('promote', 'tab_')->_sql(),time());die;
echo $this->ajaxReturn([
'code' => 1,
'msg' => '成功',
'data' => []
]);
}
} }
public function index() public function index()

@ -694,6 +694,7 @@
} }
$(".batch_page").hide(); $(".batch_page").hide();
$(".modal").hide(); $(".modal").hide();
window.location.reload();
} }
}); });

Loading…
Cancel
Save