From 6e405febc194cb6d3cdf8dfe96cd61289b1938a6 Mon Sep 17 00:00:00 2001 From: zhengchanglong Date: Fri, 10 Jan 2020 11:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=88=86=E6=88=90=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E5=AE=89=E5=8D=93IOS=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/GameController.class.php | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 6531fbd53..c7fbef940 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -774,9 +774,10 @@ class GameController extends ThinkController if(!is_numeric($data['game_ratio']) || $data['game_ratio']<0 || $data['game_ratio']>100){ die(json_encode(array("result"=>"0","desc"=>"分成比例为0~100之间"))); } + $game_info = M("game","tab_")->where("id=".$data['game_id'])->field("relation_game_id")->find();//根据游戏找到关联的游戏ID + $relation_game_list = M("game","tab_")->where("relation_game_id=".$game_info['relation_game_id'])->select();//根据关联ID找到游戏列表 if($data['data_type']=='initial'){ //CP初始分成比例 - if($data['data_id']>0){ //修改初始CP分成比例 $where = array(); $where['is_del'] = "0"; @@ -790,12 +791,27 @@ class GameController extends ThinkController if($info){ die(json_encode(array("result"=>"0","desc"=>"CP分成比例应小于".$info['ratio']."%"))); } - M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); + + foreach ($relation_game_list as $game){ + $map['game_id'] = $game['id']; + $map['is_del'] = 0; + $map['begin_total_amount'] = 0; + M('cp_game_ratio', 'tab_')->where($map)->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); + } + //M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); }else{ if($initial_info){ - M('cp_game_ratio', 'tab_')->where("id=%d",$initial_info['id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); + foreach ($relation_game_list as $game){ + $map['game_id'] = $game['id']; + $map['is_del'] = 0; + $map['begin_total_amount'] = 0; + M('cp_game_ratio', 'tab_')->where($map)->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); + } + //M('cp_game_ratio', 'tab_')->where("id=%d",$initial_info['id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save(); }else{ - M('cp_game_ratio', 'tab_')->data(array("game_id"=>$data['game_id'],"ratio"=>$data['game_ratio'],"begin_total_amount"=>0,"add_time"=>time(),"update_time"=>time()))->add(); + foreach ($relation_game_list as $game) { + M('cp_game_ratio', 'tab_')->data(array("game_id" => $game['id'], "ratio" => $data['game_ratio'], "begin_total_amount" => 0, "add_time" => time(), "update_time" => time()))->add(); + } } } }else{ //CP阶梯分成档位 @@ -820,7 +836,17 @@ class GameController extends ThinkController die(json_encode(array("result"=>"0","desc"=>"分成比例不得小于初始比例"))); } - M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->data(array("ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"update_time"=>time()))->save(); + $info = M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->find(); + foreach ($relation_game_list as $game) { + $map['ratio'] = $info['ratio']; + $map['begin_total_amount'] = $info['begin_total_amount']; + $map['is_del'] = 0; + $map['game_id']= $game['id']; + $updainfo = M('cp_game_ratio', 'tab_')->where($map)->find(); + if($updainfo){ + M('cp_game_ratio', 'tab_')->where("id=%d",$updainfo['id'])->data(array("ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"update_time"=>time()))->save(); + } + } }else{ if(!$initial_info){ die(json_encode(array("result"=>"0","desc"=>"请先设置初始CP分成比例"))); @@ -833,7 +859,9 @@ class GameController extends ThinkController if($max_info['max_ratio'] >= $data['game_ratio'] || $max_info['max_amount']>=$data['total_amount']){ die(json_encode(array("result"=>"0","desc"=>"新增分成档位金额或分成比例需大于现有分成档位"))); } - M('cp_game_ratio', 'tab_')->data(array("game_id"=>$data['game_id'],"ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"add_time"=>time(),"update_time"=>time()))->add(); + foreach ($relation_game_list as $game) { + M('cp_game_ratio', 'tab_')->data(array("game_id"=>$game['id'],"ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"add_time"=>time(),"update_time"=>time()))->add(); + } } } } @@ -844,7 +872,21 @@ class GameController extends ThinkController * 删除CP分成比例 */ public function delete_ratio(){ - M('cp_game_ratio', 'tab_')->where("id=".$_POST['data_id'])->data(array("is_del"=>"1","update_time"=>time()))->save(); + $info = M('cp_game_ratio', 'tab_')->where("id=%d",$_POST['data_id'])->find(); + $game_info = M("game","tab_")->where("id=".$info['game_id'])->field("relation_game_id")->find();//根据游戏找到关联的游戏ID + $relation_game_list = M("game","tab_")->where("relation_game_id=".$game_info['relation_game_id'])->select();//根据关联ID找到游戏列表 + + foreach ($relation_game_list as $game) { + $map['ratio'] = $info['ratio']; + $map['begin_total_amount'] = $info['begin_total_amount']; + $map['is_del'] = 0; + $map['game_id']= $game['id']; + $updainfo = M('cp_game_ratio', 'tab_')->where($map)->find(); + if($updainfo){ + M('cp_game_ratio', 'tab_')->where("id=".$updainfo['id'])->data(array("is_del"=>"1","update_time"=>time()))->save(); + } + } + //M('cp_game_ratio', 'tab_')->where("id=".$_POST['data_id'])->data(array("is_del"=>"1","update_time"=>time()))->save(); echo(json_encode(array("result"=>"1","desc"=>"删除成功"))); } }