From c137a10c8f0d5e2e27a4157968f4512bae95d0de Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 19 Aug 2020 18:38:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B7=9F=E9=9A=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/OldCountController.class.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index b9bde1856..1ba51b2b5 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -9,6 +9,24 @@ namespace Admin\Controller; */ class OldCountController extends \Think\Controller { + + public function changeCompanyGameidToPromoteGameid() + { + //默认设为 + $Promote = M("Promote","tab_"); + $PromoteCompany = M("promote_company","tab_"); + $p_res = $PromoteCompany->field("id,game_ids")->select(); + + foreach ($p_res as $k => $v) { + if(!empty($v['game_ids'])){ + $savedata =["company_id"=>$v['id'] ]; + $savedata['game_ids'] = $this->changeRelationGameidToGameid($v['game_ids']); + $Promote->save($savedata); + } + } + echo "changeCompanyGameidToPromoteGameid success"; + } + /** * 公会关系及游戏迁移 * 1. 迁移 公会company_relation到公司 @@ -50,6 +68,16 @@ class OldCountController extends \Think\Controller return implode(",",array_column($rid,'relation_game_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')); + } + + } /** * 优化旧表数值,新表需要将 开票税点及渠道费 * 100 From 3efc4daee6bd0b8e5ae305c7635d7d7d061a5904 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 19 Aug 2020 18:46:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=9F=E9=9A=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/OldCountController.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 1ba51b2b5..54c2d3f97 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -19,9 +19,8 @@ class OldCountController extends \Think\Controller foreach ($p_res as $k => $v) { if(!empty($v['game_ids'])){ - $savedata =["company_id"=>$v['id'] ]; $savedata['game_ids'] = $this->changeRelationGameidToGameid($v['game_ids']); - $Promote->save($savedata); + $Promote->where(["company_id"=>$v['id']])->save($savedata); } } echo "changeCompanyGameidToPromoteGameid success"; From e8eb963fc14a91eec59c501396ec4f87f5f5bdde Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 20 Aug 2020 10:03:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=B8=B8=E6=88=8F=E6=8E=A8=E5=B9=BF=E5=91=98?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteCompanyController.class.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 586c60fc6..abbc73e48 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -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,19 +1050,18 @@ 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(); + + $Promote = M("Promote", "tab_"); + 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); } } + } - } /** * 由于修改公司信息引起的会长信息修改 From 04ac1da1d7fcef3faf65164fb51efcf7147b7b19 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 20 Aug 2020 10:49:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E4=BC=9A=E9=95=BF=E6=B8=B8=E6=88=8F=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteCompanyController.class.php | 88 ++++++++----------- Application/Admin/Model/GameModel.class.php | 33 +++++++ 2 files changed, 70 insertions(+), 51 deletions(-) diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index abbc73e48..fb6f58fd9 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -1031,36 +1031,45 @@ class PromoteCompanyController extends ThinkController protected function changePromoteGameids($company_id,$game_ids){ $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){ - $oids = explode(',', $old_info['game_ids']); - $nids = explode(',',$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); - } - - $Promote = M("Promote", "tab_"); - 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); + 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); + } } } - } } /** @@ -1269,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])){ @@ -1349,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; } - - } - - + } } diff --git a/Application/Admin/Model/GameModel.class.php b/Application/Admin/Model/GameModel.class.php index 797ef88dd..e95fb98aa 100644 --- a/Application/Admin/Model/GameModel.class.php +++ b/Application/Admin/Model/GameModel.class.php @@ -453,6 +453,39 @@ class GameModel extends Model{ return $this->field($field)->where($where)->group("relation_game_id")->select(); } + /** + * 关联游戏id转普通游戏id + * + * @param [string/array] $ids + * @param boolean $type false:返回数组 true:返回string + * @return void + */ + public function changeRelationGameidToGameid($ids,$type=false) + { + $rid = $this->field('id')->where(["relation_game_id"=>["in",$ids]])->select(); + if($type){ + return array_column($rid,'id'); + }else{ + return implode(",",array_column($rid,'id')); + } + + } + /** + * 普通游戏id转关联游戏id + * + * @param [string/array] $ids + * @param boolean $type false:返回数组 true:返回string + * @return void + */ + public function changeGameidToRelationGameid($ids,$type=false) + { + $rid = $this->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')); + } + } } From 9f0643620760558890708383fb6a65a17877c1f3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 20 Aug 2020 10:54:44 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Model/GameModel.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Model/GameModel.class.php b/Application/Admin/Model/GameModel.class.php index e95fb98aa..fdaee470c 100644 --- a/Application/Admin/Model/GameModel.class.php +++ b/Application/Admin/Model/GameModel.class.php @@ -457,7 +457,7 @@ class GameModel extends Model{ * 关联游戏id转普通游戏id * * @param [string/array] $ids - * @param boolean $type false:返回数组 true:返回string + * @param boolean $type false:返回字符串 true:返回数组 * @return void */ public function changeRelationGameidToGameid($ids,$type=false) @@ -474,7 +474,7 @@ class GameModel extends Model{ * 普通游戏id转关联游戏id * * @param [string/array] $ids - * @param boolean $type false:返回数组 true:返回string + * @param boolean $type false:返回字符串 true:返回数组 * @return void */ public function changeGameidToRelationGameid($ids,$type=false)