管理后台-游戏-游戏编辑:参数配置-新增CP游戏分成比例

master
zhengchanglong 5 years ago
parent ea140a430f
commit 326d9e5a12

@ -405,12 +405,14 @@ class GameController extends ThinkController
$data['introduction'] = str_replace("~~", "\r\n", $data['introduction']);
$this->assign('data', $data);
$this->assign('game_id', $id);
$game_ratio = M('cp_game_ratio', 'tab_')->where(array('is_del'=>"0","game_id"=>$id))->order('begin_total_amount asc')->select();
$this->meta_title = '编辑游戏';
$this->m_title = '游戏列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find());
$this->assign('game_ratio',$game_ratio);
$this->display();
}
}
@ -761,4 +763,80 @@ class GameController extends ThinkController
}
/**
* 编辑CP分成比例
*/
public function edit_ratio(){
$data = $_POST;
if($data['data_id']==0 || $data['data_id']==""){ //查询初始分成比例信息
$initial_info = M('cp_game_ratio', 'tab_')->where("game_id=%d and begin_total_amount=0 and is_del=0",$data['game_id'])->find();
}
if($data['data_type']=='initial'){ //CP初始分成比例
if($data['data_id']>0){ //修改初始CP分成比例
$where = array();
$where['is_del'] = "0";
$where['game_id'] = $data['game_id'];
$where['id'] = array("neq",$data['data_id']);
$where['ratio'] = array("elt",$data['game_ratio']);
$info = M('cp_game_ratio', 'tab_')
->where($where)
->order("ratio asc")
->find();
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();
}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();
}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();
}
}
}else{ //CP阶梯分成档位
if($data['data_id']>0) { //修改阶梯分成
$where = array();
$where['game_id']= $data['game_id'];
$where['is_del'] = "0";
$where['id']=array("neq",$data['data_id']);
$exis_info = M('cp_game_ratio', 'tab_')
->where($where)
->where("begin_total_amount='%s' or ratio = '%f'",array($data['total_amount'],$data['game_ratio']))
->find();
if($exis_info){
die(json_encode(array("result"=>"0","desc"=>"分成档位已存在")));
}
if($initial_info['game_ratio']>=$data['game_ratio']){
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();
}else{
if(!$initial_info){
die(json_encode(array("result"=>"0","desc"=>"请先设置初始CP分成比例")));
}
$exis_info = M('cp_game_ratio', 'tab_')->where("game_id=%d and (begin_total_amount='%s' or ratio = '%f') and is_del=0",array($data['game_id'],$data['total_amount'],$data['game_ratio']))->find();
if($exis_info){
die(json_encode(array("result"=>"0","desc"=>"分成档位已存在")));
}else{
$max_info = M('cp_game_ratio', 'tab_')->field("max(ratio) as max_ratio,max(begin_total_amount) as max_amount")->where("game_id=%d and is_del=0",$data['game_id'])->find();
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();
}
}
}
echo(json_encode(array("result"=>"1","desc"=>"数据保存成功")));
}
/**
* 删除CP分成比例
*/
public function delete_ratio(){
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"=>"删除成功")));
}
}

@ -5,6 +5,23 @@
<style>
#form .txt_area.download_url {width:400px;}
.tabcon1711 .table_radio2 .table_btn {width:215px;}
.bnt_add,.bnt_remove,.bnt_save{
height: 30px;
width: 20px;
font-size: 20px;
line-height: 10px;
color: #3399ff;
background: none;
border: none;
margin-left: 20px;
cursor: pointer;
}
.bnt_remove{
color: #F70909;
}
.bnt_save{
color: #4DB361;
}
</style>
</block>
<block name="body">
@ -451,8 +468,6 @@
</td>
</tr>
<notempty name="data.accredit_img">
<tr class="picbox">
<td class="l noticeinfo">知识产权</td>
@ -614,6 +629,46 @@
<span class="notice-text">此处数值为推广结算时CPA模式的注册单价</span>
</td>
</tr>
<tr class="bns">
<td class="l noticeinfo">CP分成比例</td>
<td class="r">
<input type="hidden" class="txt table_text_input" name="game_amount" value="0" >
<input type="text" class="txt table_text_input" name="game_ratio" value="{$game_ratio[0]['ratio']}" placeholder="输入0-100之间的数字">
<span class="form_unit">% <button type="button" class="bnt_save" data-id ="{$game_ratio[0]['id']}" data-type="initial"></button> </span>
<span class="notice-text">CP游戏分成比例</span>
</td>
</tr>
<empty name="game_ratio[1]">
<tr class="bns">
<td class="l noticeinfo">CP流水大于等于</td>
<td class="r">
<input type="text" class="txt table_text_input" name="game_amount" value="" placeholder="" style="width: 55px">
<span class="form_unit" style="margin: 0 10px">分成比例</span>
<input type="text" class="txt table_text_input" name="game_ratio" value="" placeholder="" style="width: 50px">
<span class="form_unit">% </span>
<button type="button" class="bnt_add"></button><button type="button" class="bnt_save" data-id="0" data-type="ladder"></button>
</td>
</tr>
<else />
<foreach name="game_ratio" item="vo" key="k">
<if condition="$k gt 0">
<tr class="bns">
<td class="l noticeinfo">CP流水大于等于</td>
<td class="r">
<input type="text" class="txt table_text_input" name="game_amount" value="{$vo['begin_total_amount']}" placeholder="" style="width: 55px"><span class="form_unit" style="margin: 0 10px">分成比例</span>
<input type="text" class="txt table_text_input" name="game_ratio" value="{$vo['ratio']}" placeholder="" style="width: 50px"><span class="form_unit">%</span>
<if condition="$k eq 1">
<button type="button" class="bnt_add"></button>
<button type="button" class="bnt_remove" data-id="{$vo['id']}"></button>
<else/>
<button type="button" class="bnt_remove" data-id="{$vo['id']}"></button>
</if>
<button type="button" class="bnt_save" data-id="{$vo['id']}" data-type="ladder"></button>
</td>
</tr>
</if>
</foreach>
</empty>
<tr>
<td class="l noticeinfo">开发者分成比例</td>
<td class="r">
@ -2097,7 +2152,6 @@
<?php foreach ($data['icon_data'] as $value3) { ?>
<?php $value3 = (int)$value3; ?>
imgListIconData.push(<?=$value3?>);
html += '<div id="' + <?=$value3?> + '" class="item flooring_page_img_box" style="margin-right: 10px;">';
html += '<a href="javascript:;"><img src="<?=get_cover($value3,"path")?>" style="width: 100px;height: 100px;cursor: move;"></a>';
html += '<h4 class="info" style="text-align: center;">';
@ -2205,4 +2259,93 @@
}
</script>
<script>
$(".bnt_add").bind("click",function(){
var a= '<tr class="bns" data-id="0">'+
'<td class="l noticeinfo">CP流水大于等于</td>' +
'<td class="r">'+
'<input type="text" class="txt table_text_input" name="game_amount" value="" placeholder="" style="width: 55px">' +
'<span class="form_unit" style="margin: 0 10px">分成比例</span>'+
'<input type="text" class="txt table_text_input" name="game_ratio" value="" placeholder="" style="width: 50px">' +
'<span class="form_unit">% </span>' +
'<button type="button" class="bnt_remove" data-id="0"></button>' +
'<button type="button" class="bnt_save" data-id="0" data-type="ladder"></button>'+
'</td>'+
'</tr>';
$(".bns:last").after(a);
})
$(document).on('click', '.bnt_remove', function(){
var that = $(this).parents("tr.bns");
var data_id = $(this).attr("data-id");
layer.confirm('你确定要删除本档分成比例吗?', {icon: 3, title:'提示'}, function(index){
layer.close(index);
$.ajax({
//请求方式
type : "POST",
dataType: "json",
url : "{:U('delete_ratio')}",
data : {
data_id :data_id,
game_id:'{$game_id}'
},
//请求成功
success : function(result) {
if(result.result==1){
$(that).remove();
layer.msg(result.desc);
setTimeout(function(){
location.reload();
},1500);
}else{
layer.msg(result.desc);
}
},
//请求失败,包含具体的错误信息
error : function(e){
console.log(e.status);
console.log(e.responseText);
}
});
});
});
$(document).on('click', '.bnt_save', function(){
var data_id = $(this).attr("data-id");
var data_type =$(this).attr("data-type");
var that = $(this).parents("tr.bns");
var total_amount = $(that).find("input[name=game_amount]").val();
var game_ratio = $(that).find("input[name=game_ratio]").val();
$.ajax({
//请求方式
type : "POST",
dataType: "json",
url : "{:U('edit_ratio')}",
data : {
data_type:data_type,
data_id :data_id,
total_amount:total_amount,
game_ratio:game_ratio,
game_id:'{$game_id}'
},
//请求成功
success : function(result) {
if(result.result==1){
layer.msg(result.desc);
setTimeout(function(){
location.reload();
},1500);
}else{
layer.msg(result.desc);
}
},
//请求失败,包含具体的错误信息
error : function(e){
console.log(e.status);
console.log(e.responseText);
}
});
});
</script>
</block>

Loading…
Cancel
Save