|
|
|
@ -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"=>"删除成功")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|