优化游戏删除

master
chenzhi 4 years ago
parent d015bce440
commit c733fc2e15

@ -363,6 +363,7 @@ class PromoteCompanyController extends ThinkController
$v['company_id'] = M("promote_company","tab_")->add($company_info);
}else{
//编辑
M("promote_company","tab_")->save($company_info);
$this->changePromote($company_info);
}
@ -1028,14 +1029,15 @@ class PromoteCompanyController extends ThinkController
}elseif(count($nids) == 0){
$diff_ids = $oids;
}else{
foreach ($nids as $k => $v) {
if(!in_array($v,$oids)){
foreach ($oids as $k => $v) {
if(!in_array($v,$nids)){
$diff_ids[] = $v;
}
}
}
if(count($diff_ids) > 0){
$is_change_game = true;
$diff_ids = $this->changeRelationGameidToGameid($diff_ids,true);
}
}
@ -1320,11 +1322,26 @@ class PromoteCompanyController extends ThinkController
return $gameinfo;
}
//普通游戏id转唯一游戏id
protected function changeGameidToRelationGameid($ids)
protected function changeGameidToRelationGameid($ids,$type=false)
{
$rid = M('game', 'tab_')->field('relation_game_id')->where(["id"=>["in",$ids]])->group("relation_game_id")->select();
return implode(",",array_column($rid,'relation_game_id'));
$rid = M('game', 'tab_')->field('relation_game_id')->where(["id"=>["in",$ids]])->group("relation_game_id")->select();
if($type){
return array_column($rid,'relation_game_id');
}else{
return implode(",",array_column($rid,'relation_game_id'));
}
}
//唯一游戏id转普通游戏id
protected function changeRelationGameidToGameid($ids,$type=false)
{
$rid = M('game', 'tab_')->field('id')->where(["relation_game_id"=>["in",$ids]])->select();
if($type){
return array_column($rid,'id');
}else{
return implode(",",array_column($rid,'id'));
}
}
protected function promoteCompanyIsCanDel($company_id){
$r = M("Promote","tab_")->where("company_id={$company_id}")->count();
if($r > 0){

Loading…
Cancel
Save