修正公司取消游戏推广员无效

master
chenzhi 4 years ago
parent 3efc4daee6
commit e8eb963fc1

@ -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,12 +1029,11 @@ 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;
if($old_info['game_ids'] != $game_ids){
// $is_change_game = true;
$oids = explode(',', $old_info['game_ids']);
$nids = explode(',', $save['game_ids']);
$nids = explode(',',$game_ids);
$diff_ids = [];
if(count($oids) == 0){
$is_change_game = false;
@ -1051,20 +1050,19 @@ class PromoteCompanyController extends ThinkController
$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();
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));
$v['company_belong'] = $save['company_belong'];
$v['company_relation'] = $save['develop_type'];
$Promote->save($v);
}
}
}
}
}
/**
* 由于修改公司信息引起的会长信息修改
* @param [type] $save

Loading…
Cancel
Save