|
|
@ -231,31 +231,14 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
public function displayOnShelves() {
|
|
|
|
public function displayOnShelves() {
|
|
|
|
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();
|
|
|
|
$where = [];
|
|
|
|
$relationGames = M('game', 'tab_')->where(['relation_game_id' => $game['relation_game_id']])->select();
|
|
|
|
if ($post['batch_company_type'] == 1) {
|
|
|
|
foreach ($relationGames as $relationGame) {
|
|
|
|
$where['company_belong'] = array('exp', " IN (1,2)");
|
|
|
|
$gameId = $relationGame['id'];
|
|
|
|
} else {
|
|
|
|
$this->doDisplayOnShelves($gameId, $post['batch_company_type'], $post['batch_type']);
|
|
|
|
$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']},\", ','))";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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([
|
|
|
|
echo $this->ajaxReturn([
|
|
|
|
'code' => 1,
|
|
|
|
'code' => 1,
|
|
|
|
'msg' => '成功',
|
|
|
|
'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()
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
{
|
|
|
|