|
|
|
@ -890,9 +890,9 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
|
} else {
|
|
|
|
|
$game_ids = '';
|
|
|
|
|
}
|
|
|
|
|
$this->changePromoteGameids($id,$game_ids);
|
|
|
|
|
$res = M('promote_company', 'tab_')->where(['id'=>$id])->save(['game_ids'=>$game_ids]);
|
|
|
|
|
if ($res) {
|
|
|
|
|
$this->changePromoteGameids($id,$game_ids);
|
|
|
|
|
$this->ajaxReturn(['code'=>1,'msg'=>'更新成功']);
|
|
|
|
|
} else {
|
|
|
|
|
$this->ajaxReturn(['code'=>0,'msg'=>'数据未发生变化']);
|
|
|
|
@ -1029,41 +1029,48 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
|
$save['last_up_time'] = $time;
|
|
|
|
|
}
|
|
|
|
|
protected function changePromoteGameids($company_id,$game_ids){
|
|
|
|
|
$is_change_game = false;
|
|
|
|
|
$old_info = M("PromoteCompany","tab_")->field("company_belong,develop_type,game_ids")->where("id = {$company_id}")->find();
|
|
|
|
|
$is_change_game = false;
|
|
|
|
|
$Promote = M("Promote", "tab_");
|
|
|
|
|
if($old_info['game_ids'] != $game_ids){
|
|
|
|
|
// $is_change_game = true;
|
|
|
|
|
$oids = explode(',', $old_info['game_ids']);
|
|
|
|
|
$nids = explode(',', $save['game_ids']);
|
|
|
|
|
$diff_ids = [];
|
|
|
|
|
if(count($oids) == 0){
|
|
|
|
|
$is_change_game = false;
|
|
|
|
|
}elseif(count($nids) == 0){
|
|
|
|
|
$diff_ids = $oids;
|
|
|
|
|
if($old_info['company_belong'] == 1 || $old_info['company_belong'] == 2){
|
|
|
|
|
//外团跟随公司
|
|
|
|
|
$new_game_ids = D("Game")->changeRelationGameidToGameid($game_ids,true);
|
|
|
|
|
$new_game_ids = implode(',',$new_game_ids);
|
|
|
|
|
$save = [
|
|
|
|
|
"game_ids"=>$new_game_ids
|
|
|
|
|
];
|
|
|
|
|
$dbres = $Promote->where("company_id = '{$company_id}'")->save($save);
|
|
|
|
|
}else{
|
|
|
|
|
foreach ($oids as $k => $v) {
|
|
|
|
|
if(!in_array($v,$nids)){
|
|
|
|
|
$diff_ids[] = $v;
|
|
|
|
|
$oids = explode(',', $old_info['game_ids']);
|
|
|
|
|
$nids = explode(',',$game_ids);
|
|
|
|
|
$diff_ids = [];
|
|
|
|
|
if(empty($old_info['game_ids'])){
|
|
|
|
|
$is_change_game = false;
|
|
|
|
|
}elseif(empty($game_ids)){
|
|
|
|
|
$is_change_game = true;
|
|
|
|
|
$diff_ids = $oids;
|
|
|
|
|
}else{
|
|
|
|
|
$is_change_game = true;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
if ($is_change_game) {
|
|
|
|
|
$Promote = M("Promote", "tab_");
|
|
|
|
|
$dbres = $Promote->field("id,game_ids,company_belong,company_relation")->where("company_id = '{$company_id}'")->select();
|
|
|
|
|
foreach ($dbres as $k=>&$v) {
|
|
|
|
|
$temp_ids = explode(',', $v['game_ids']);
|
|
|
|
|
$v['game_ids'] = implode(',', array_diff($temp_ids, $diff_ids));
|
|
|
|
|
$v['company_belong'] = $save['company_belong'];
|
|
|
|
|
$v['company_relation'] = $save['develop_type'];
|
|
|
|
|
$Promote->save($v);
|
|
|
|
|
if(count($diff_ids) > 0){
|
|
|
|
|
$diff_ids = D("Game")->changeRelationGameidToGameid($diff_ids,true);
|
|
|
|
|
}
|
|
|
|
|
if($is_change_game){
|
|
|
|
|
$dbres = $Promote->field("id,game_ids")->where("company_id = '{$company_id}'")->select();
|
|
|
|
|
foreach ($dbres as $k=>&$v) {
|
|
|
|
|
$temp_ids = explode(',', $v['game_ids']);
|
|
|
|
|
$v['game_ids'] = implode(',', array_diff($temp_ids, $diff_ids));
|
|
|
|
|
$Promote->save($v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 由于修改公司信息引起的会长信息修改
|
|
|
|
@ -1271,7 +1278,7 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
|
}else{
|
|
|
|
|
$v['list'] = [];
|
|
|
|
|
$v['row']=0;
|
|
|
|
|
$v['game_ids'] = $this->changeGameidToRelationGameid($v['game_ids']);
|
|
|
|
|
$v['game_ids'] = D("Game")->changeGameidToRelationGameid($v['game_ids']);
|
|
|
|
|
$game_arr = array_flip(explode(",",$v['game_ids']));
|
|
|
|
|
foreach($game_arr as $ke=>$va){
|
|
|
|
|
if(isset($ratio[$ke])){
|
|
|
|
@ -1351,37 +1358,14 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
return $gameinfo;
|
|
|
|
|
}
|
|
|
|
|
//普通游戏id转唯一游戏id
|
|
|
|
|
protected function changeGameidToRelationGameid($ids,$type=false)
|
|
|
|
|
{
|
|
|
|
|
$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){
|
|
|
|
|
//判断公司是否能被删除
|
|
|
|
|
protected function promoteCompanyIsCanDel($company_id){
|
|
|
|
|
$r = M("Promote","tab_")->where("company_id={$company_id}")->count();
|
|
|
|
|
if($r > 0){
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|