1126 批量上下架

master
tping 4 years ago
parent b722175785
commit dd786dc27f

@ -232,29 +232,12 @@ class PromoteCompanyController extends ThinkController
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']}))";
$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']);
}
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']},\", ','))";
}
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,
@ -265,6 +248,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()
{
$page = intval(I('get.p', 0));

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

Loading…
Cancel
Save