游戏比例模板导出删除

master
chenzhi 5 years ago
parent adbc76c3ae
commit c1283ebfeb

@ -33,12 +33,19 @@ class GameRatioMouldController extends AdminController
if(isset($params['company_belong'])){
$where['m.company_belong'] = $params['company_belong'];
}
$gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false);
$dbres = $this->DBModel->alias('m')->join("LEFT JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id")->where($where)->order('create_time desc, id desc')->page($page, $row)->select();
$this->checkListOrCountAuthRestMap($where);
$gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false);
$dbres = $this->DBModel->alias('m')->join("LEFT JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id")->where($where)->order('create_time desc, id desc');
if(isset($params['export'])){
$dbres = $dbres->select();
}else{
$dbres = $dbres->page($page, $row)->select();
}
foreach($dbres as $k=>&$v){
$v['create_time'] = date("Y-m-d H:i:s",$v['create_time']);
$v['company_belong'] = getCompanyBlong($v['company_belong']);
$v['company_belong'] ="下游".getCompanyBlong($v['company_belong']);
$thisTurnoverRatios = $v['turnover_ratio'] ? json_decode($v['turnover_ratio'], true) : [];
$thisRatioDtl = "默认:{$v['ratio']}%";
@ -55,6 +62,23 @@ class GameRatioMouldController extends AdminController
}
$v['turnover_ratio_str'] = $thisRatioDtl;
}
//判断导出
if(isset($_REQUEST['export'])){
$GetData = $_GET;
unset($GetData['export']);
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$GetData),'menu'=>"推广员-推广员管理-游戏分成比例模板-导出"]);
data2csv($dbres,'游戏分成比例模板',array(
"game_type_name"=>"游戏类型",
"relation_game_name"=>"现包名",
"original_package_name"=>"原包名",
"company_belong"=>"公司类型",
"turnover_ratio_str"=>"比例分成",
"create_time"=>"时间",
"admin_name"=>"操作人"
));
}
$count = $this->DBModel->alias('m')->field("count(id) count")->join("LEFT JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id")->where($where)->find()['count'];
$this->assign('data', $dbres);
$page = set_pagination($count, $row);
@ -94,7 +118,7 @@ class GameRatioMouldController extends AdminController
}
//保存
$id = $this->DBModel->add($save);
addOperationLog(['op_type'=>1,'key'=>$id,'op_name'=>'新增游戏分成比例模板','url'=>U('GameRatioMould/index')]);
addOperationLog(['op_type'=>0,'key'=>$id,'op_name'=>'新增游戏分成比例模板','url'=>U('GameRatioMould/index')]);
$this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("index")]);
} else {
$game_type = M("game_type","tab_")->field("id,type_name")->where("status=1")->select();
@ -117,7 +141,7 @@ class GameRatioMouldController extends AdminController
$save['turnover_ratio'] = $this->setTurnoverRatio($params);
$this->DBModel->save($save);
addOperationLog(['op_type'=>2,'key'=>$save['id'],'op_name'=>'修改游戏分成比例模板','url'=>U('PromoteGameRatio/index')]);
addOperationLog(['op_type'=>1,'key'=>$save['id'],'op_name'=>'修改游戏分成比例模板','url'=>U('PromoteGameRatio/index')]);
$this->ajaxReturn(["msg"=>"修改成功","code"=>1,"url"=>U("index")]);
} else {
$params = I('get.');
@ -132,6 +156,21 @@ class GameRatioMouldController extends AdminController
$this->display();
}
}
public function del()
{
if(!isset($_REQUEST['id'])){
$this->error('参数错误');
}
$id = $_REQUEST['id'];
$res = $this->DBModel->where("id='{$id}'")->delete();
if($res !== false){
addOperationLog(['op_type'=>2,'key'=>$id,'op_name'=>'删除游戏分成模板','url'=>U('PromoteGameRatio/index')]);
$this->ajaxReturn(["msg"=>"删除成功","code"=>1,"url"=>U("index")]);
}else{
$this->error('删除错误');
}
}
//基础信息获取
public function getGames()
{

@ -70,7 +70,7 @@
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="relation_game_id" name="relation_game_id" class="select_gallery" >
<option value="">游戏名称</option>
<option value="">现包名</option>
<volist name="gameList" id="vo">
<option value="{$vo.relation_game_id}" <if condition="$vo.relation_game_id eq I('relation_game_id')">selected</if> >{$vo.relation_game_name}</option>
</volist>
@ -102,19 +102,12 @@
<input class="check-all" type="checkbox">
</th>
<th>游戏类型</th>
<th>现包名</th>
<th>原包名</th>
<th>公司类型</th>
<th>比例分成</th>
<th>时间</th>
<th>操作人</th>
<th>操作</th>
</tr>
</thead>
@ -138,22 +131,17 @@
<td>{$data.game_type_name}</td>
<td>{$data.relation_game_name}</td>
<td>{$data.original_package_name}</td>
<td>下游{$data.company_belong}</td>
<td>{$data.company_belong}</td>
<td style="line-height: 16px;text-indent: 0;">
<div style="text-align: left;width: 90%;margin-left: 5%;margin-top: 10px;margin-bottom: 10px;">
{$data.turnover_ratio_str}
</div>
</td>
<td>{$data.create_time}</td>
<td>{$data.admin_name}</td>
<td>
<a href="{:U('edit', array('id'=>$data['id']))}" class="">修改</a>
<a href="{:U('del', array('id'=>$data['id']))}" class="">删除</a>
<a data-url="{:U('del', array('id'=>$data['id']))}" class="ratio_del">删除</a>
</td>
</tr>
</volist>
@ -218,124 +206,28 @@ $(function(){
$("#search").click();
}
});
})
function refuse() {
if ($('.ids[type=checkbox]:checked').length > 0) {
layer.open({
type: 1,
title: '审核拒绝',
shadeClose: true,
shade: 0.8,
area: ['387px', '500px'],
content: $('.promote-layer')
});
$('#deny').addClass('promote-show');
$('#remark').addClass('ids');
} else {
updateAlert('请选择需要操作的数据','tip_error');
setTimeout(function(){
$('#tip').find('.tipclose').click();
},1500);
}
}
</script>
<script type="text/javascript">
//点击字母按照条件按钮筛选
$(".pro_promot_select_list_con").click(function(){
//选中高亮样式
$(this).addClass('active');
$(this).siblings().removeClass('active');
var that = $(this);
var index = $(this).attr("data-index");
$("#game_list li").each(function(index,ele){
var short = $(this).attr('data-short');
$(this).show();
if(that.attr('data-index')){
if(that.attr('data-index')!=short.charAt(0)){
$(this).hide();
$(".ratio_del").on("click",function(){
var url = $(this).data("url");
layer.confirm('删除后将无法恢复,请慎重选择', {
btn: ['取消','删除'] //按钮
}, function(index){
layer.close(index);
}, function(){
$.get(url,function(data){
if(data.code == 1){
layer.msg('<span style="color:white">'+data.msg+'<span>',{time: 1000},function(){
window.location.reload();
});
}else{
layer.msg(data.msg,{icon: 2});
}
}
})
});
//打开弹窗
$(".ajax-view").click(function(){
//获取游戏列表
var url = "{:U('Promote/getPromoteGame')}";
var id = $(this).attr('data-id');
$.post(url,{id:id},function(res){
if(res.code==1){
$(".pro_promot_select_list a").eq(0).addClass('active');
$(".pro_promot_select_list a").eq(0).siblings().removeClass('active');
var game_list = res.data.game_list;
var promote_info = res.data.promote_info;
var lis = [];
$.each(game_list,function(index,ele){
if(ele.game_name.length>6){
ele.game_name = ele.game_name .substring(0,6)+"..."
}
lis.push('<li class="fl pro_promot_game_con" data-short="'+ele.short+'">');
if(promote_info['game_ids']==''){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
if(promote_info['game_ids'].indexOf(ele.id)>-1){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" id="gameCheck'+index+'" />');
}
}
lis.push('<label for="gameCheck'+index+'" class="fl"></label>');
lis.push('<span class="fl pro_promot_game_name">'+ele.game_name+'</span>');
lis.push('</li>');
});
$("#game_list").html(lis.join(''));
$(".pro_promot_number").text(res.data.promote_info.account);
$("#se_promote_id").val(res.data.promote_info.id);
$(".pro_promot").css("display","block");
jsgameid();
}else{
alert('请求失败');
}
});
});
//保存修改
$(".pro_promot_btn_confirm").click(function(){
$("#ajaxForm").ajaxSubmit(function(res){
layer.msg(res.msg);
$(".pro_promot").hide();
});
});
return false;
});
//关闭弹窗
$(".pro_promot_close").click(function(){
$(".pro_promot").css("display","none");
});
//取消修改
$(".pro_promot_btn_cancel").click(function(){
$(".pro_promot").css("display","none");
layer.msg('修改已取消');
});
})
})
$(".jsgamecheckall").click(function(){
$(this).closest('.jsgamecheckallbox').siblings("#game_list").find(".jsgameid").prop("checked", this.checked);
});
$(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
})
</script>
</block>

Loading…
Cancel
Save