资源审核配置列表、新增、编辑、删除、锁定、解锁
parent
0d4ca0840b
commit
02920aab8a
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
/**
|
||||
* 资源审核配置控制器
|
||||
* @author lww
|
||||
*/
|
||||
class ResourceVerifyConfigController extends ThinkController
|
||||
{
|
||||
private $modelName = 'ResourceVerifyConfig';
|
||||
|
||||
//列表
|
||||
public function lists()
|
||||
{
|
||||
$model = M($this->modelName, 'tab_');
|
||||
$map = [];
|
||||
if (!empty(I('game_name'))) {
|
||||
$map['game_name'] = I('game_name');
|
||||
}
|
||||
|
||||
$page = intval(I('get.p', 0));
|
||||
$page = $page ? $page : 1; //默认显示第一页数据
|
||||
$row = intval(I('row', 0));
|
||||
$row = empty($row) ? 10 : $row;//每页条数
|
||||
|
||||
$is_export= false;
|
||||
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
|
||||
$is_export = true;
|
||||
}
|
||||
|
||||
//获取分页数据
|
||||
$query = $model
|
||||
->field("id,game_id,game_name,sdk_version,new_apply_count,new_low_value,new_high_value,
|
||||
old_value_ratio,status,update_time")
|
||||
->where($map)
|
||||
->order("id desc");
|
||||
$data = $query
|
||||
->page($page,$row)
|
||||
->select();
|
||||
foreach ($data as $key => $value) {
|
||||
$data[$key]['sdk_version'] = getSDKTypeName($value['sdk_version'], true);
|
||||
$data[$key]['new_low_value'] = floatval($value['new_low_value']);
|
||||
$data[$key]['new_high_value'] = floatval($value['new_high_value']);
|
||||
$data[$key]['status'] = $value['status'] ? '正常' : '锁定';
|
||||
$data[$key]['update_time'] = $value['update_time'] ? set_show_time($value['update_time']) : '-';
|
||||
}
|
||||
|
||||
/* 查询记录总数 */
|
||||
$count = $model
|
||||
->where($map)
|
||||
->count();
|
||||
//分页
|
||||
$parameter['p'] = $page;
|
||||
$parameter['row'] = $row;
|
||||
$page = set_pagination($count, $row, $parameter);
|
||||
if ($page) {
|
||||
$this->assign('_page', $page);
|
||||
}
|
||||
|
||||
$this->assign('listData', $data);
|
||||
$this->assign('count', $count);
|
||||
$this->meta_title = '资源审核配置';
|
||||
$this->display();
|
||||
}
|
||||
|
||||
//根据游戏与终端判断该资源审核配置是否已存在
|
||||
private function check($game_name, $sdk_version)
|
||||
{
|
||||
$check['status'] = 1;
|
||||
$check['errmsg'] = 'success';
|
||||
if ($sdk_version == 1 || $sdk_version == 2) {
|
||||
$res = DM('resource_verify_config')
|
||||
->where(['game_name' => $game_name, 'sdk_version' => $sdk_version])
|
||||
->count();
|
||||
if ($res) {
|
||||
$check['errmsg'] = '该终端已存在';
|
||||
$check['status'] = 0;
|
||||
}
|
||||
} else {
|
||||
$res = DM('resource_verify_config')
|
||||
->where(['game_name' => $game_name])
|
||||
->count();
|
||||
if ($res) {
|
||||
$check['errmsg'] = '已存在该游戏的资源审核配置';
|
||||
$check['status'] = 0;
|
||||
}
|
||||
}
|
||||
return $check;
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
if ($_POST) {
|
||||
// dd($_REQUEST);
|
||||
if (empty(I('game_name'))) {
|
||||
$this->error('请选择游戏');
|
||||
}
|
||||
if (!strlen(I('sdk_version'))) {
|
||||
$this->error('请选择终端');
|
||||
}
|
||||
$check = $this->check(I('game_name'), I('sdk_version'));
|
||||
if ($check['status'] == 0) {
|
||||
$this->error($check['errmsg']);
|
||||
}
|
||||
if (I('new_apply_count') < 0) {
|
||||
$this->error('新用户判断标准不能小于0');
|
||||
}
|
||||
if (I('new_low_value') >= I('new_high_value')) {
|
||||
$this->error('最低申请额度不能高于或等于最高申请额度');
|
||||
}
|
||||
if (I('old_value_ratio')<0 || I('old_value_ratio') > 100) {
|
||||
$this->error('可申请额度占总充值量的比例必须在0-100之间');
|
||||
}
|
||||
$model = M($this->modelName, 'tab_');
|
||||
$save['game_id'] = I('game_id');
|
||||
$save['game_name'] = trim(I('game_name'));
|
||||
$save['sdk_version'] = I('sdk_version');
|
||||
$save['new_apply_count'] = I('new_apply_count');
|
||||
$save['new_low_value'] = I('new_low_value');
|
||||
$save['new_high_value'] = I('new_high_value');
|
||||
$save['old_value_ratio'] = I('old_value_ratio')/100;
|
||||
|
||||
$save['status'] = 0;
|
||||
$save['add_time'] = time();
|
||||
$save['update_time'] = time();
|
||||
$save['uid'] = UID;
|
||||
if ($save['sdk_version'] == 0) {
|
||||
$game_ids = DM('game')->where(['relation_game_name' => I('game_name')])->field('id,sdk_version')->select();
|
||||
$saveAll = array();
|
||||
foreach ($game_ids as $item) {
|
||||
$save['game_id'] = $item['id'];
|
||||
$save['sdk_version'] = $item['sdk_version'];
|
||||
$saveAll[] = $save;
|
||||
}
|
||||
} else {
|
||||
$game_id = DM('game')->where(['relation_game_name' => I('game_name')])->getField('id');
|
||||
$save['game_id'] = $game_id;
|
||||
$saveAll[] = $save;
|
||||
}
|
||||
$res = $model->addAll($saveAll);
|
||||
if ($res) {
|
||||
$this->success('保存成功', U('lists'));
|
||||
} else {
|
||||
$this->error('保存失败');
|
||||
}
|
||||
} else {
|
||||
$this->meta_title = '新增资源审核配置';
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit()
|
||||
{
|
||||
$model = M($this->modelName, 'tab_');
|
||||
|
||||
if ($_POST) {
|
||||
/* if (empty(I('game_name'))) {
|
||||
$this->error('请选择游戏');
|
||||
}
|
||||
if (!strlen(I('sdk_version'))) {
|
||||
$this->error('请选择终端');
|
||||
}
|
||||
$check = $this->check(I('game_name'), I('sdk_version'));
|
||||
if ($check['status'] == 0) {
|
||||
$this->error($check['errmsg']);
|
||||
}*/
|
||||
if (I('new_apply_count') < 0) {
|
||||
$this->error('新用户判断标准不能小于0');
|
||||
}
|
||||
if (I('new_low_value') >= I('new_high_value')) {
|
||||
$this->error('最低申请额度不能高于或等于最高申请额度');
|
||||
}
|
||||
if (I('old_value_ratio')<0 || I('old_value_ratio') > 100) {
|
||||
$this->error('可申请额度占总充值量的比例必须在0-100之间');
|
||||
}
|
||||
$model = M($this->modelName, 'tab_');
|
||||
// $save['game_id'] = I('game_id');
|
||||
// $save['game_name'] = trim(I('game_name'));
|
||||
// $save['sdk_version'] = I('sdk_version');
|
||||
$save['new_apply_count'] = I('new_apply_count');
|
||||
$save['new_low_value'] = I('new_low_value');
|
||||
$save['new_high_value'] = I('new_high_value');
|
||||
$save['old_value_ratio'] = I('old_value_ratio')/100;
|
||||
|
||||
$save['status'] = 0;
|
||||
$save['add_time'] = time();
|
||||
$save['update_time'] = time();
|
||||
$save['uid'] = UID;
|
||||
$save['id'] = I('id');
|
||||
$res = $model->save($save);
|
||||
if ($res) {
|
||||
$this->success('保存成功', U('lists'));
|
||||
} else {
|
||||
$this->error('保存失败');
|
||||
}
|
||||
} else {
|
||||
$id = intval(I('get.id', 0));
|
||||
$map['id'] = $id;
|
||||
$data = $model
|
||||
->find($id);
|
||||
$data['old_value_ratio'] *= 100;//存的是小数,显示百分比
|
||||
$data['game_name'] = trim($data['game_name']);
|
||||
// dd($data);
|
||||
$this->assign('data', $data);
|
||||
$action = I('action');
|
||||
$this->assign('action', $action);
|
||||
$this->meta_title = '编辑资源审核配置';
|
||||
$this->display($action);
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function del()
|
||||
{
|
||||
if (!empty($_POST['ids'])) {
|
||||
if (!is_array($_POST['ids'])) {
|
||||
$this->error('参数异常');
|
||||
}
|
||||
|
||||
$id = implode(',', $_POST['ids']);
|
||||
} else {
|
||||
$id = intval(I('get.id', 0));
|
||||
if ($id == 0) {
|
||||
$this->error('参数异常');
|
||||
}
|
||||
}
|
||||
|
||||
$res = M($this->modelName, 'tab_')->delete($id);
|
||||
if ($res === false) {
|
||||
$this->error('删除失败');
|
||||
}
|
||||
|
||||
$this->success('删除成功', U('lists'));
|
||||
}
|
||||
|
||||
public function updateStatus()
|
||||
{
|
||||
$save['status'] = I('status');
|
||||
$save['id']= I('id');
|
||||
$res = M($this->modelName, 'tab_')->save($save);
|
||||
if ($res === false) {
|
||||
$this->error('操作失败');
|
||||
}
|
||||
$this->success('操作成功', U('lists'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
<extend name="Public/base"/>
|
||||
|
||||
<block name="body">
|
||||
|
||||
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
|
||||
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="__JS__/select2.min.js"></script>
|
||||
<style>
|
||||
.select2-container--default .select2-selection--single {
|
||||
color: #000;
|
||||
resize: none;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
|
||||
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
|
||||
height:28px;border-radius:3px;font-size:12px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||
line-height:35px;
|
||||
line-height:28px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
||||
height:26px;
|
||||
}
|
||||
.select2-container--default .select2-search--dropdown .select2-search__field {
|
||||
height:26px;line-height:26px;font-size:12px;
|
||||
}
|
||||
.select2-results__option[aria-selected] {font-size:12px;}
|
||||
.data_list table td{
|
||||
text-indent:0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="cf main-place top_nav_list navtab_list">
|
||||
<h3 class="page_title">{$meta_title}</h3>
|
||||
</div>
|
||||
|
||||
<div class="cf top_nav_list">
|
||||
<div class="fl button_list">
|
||||
<div class="tools">
|
||||
<a class="" href="{:U('add')}"><span class="button_icon button_icon1"></span>新增</a>
|
||||
<a class="ajax-post confirm " target-form="ids" url="{:U('del')}"><span class="button_icon button_icon2"></span>删除</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jssearch fl cf search_list" >
|
||||
<div class="input-list search-title-box">
|
||||
<label>搜索:</label>
|
||||
</div>
|
||||
|
||||
<div class="input-list input-list-game search_label_rehab">
|
||||
<select id="game_name" name="game_name" class="select_gallery" >
|
||||
<option value="">请选择游戏</option>
|
||||
<volist name=":getAllGame()" id="vo">
|
||||
<option value="{$vo.game_name}" <if condition="$vo.game_name eq I('game_name')">selected</if>
|
||||
>{$vo.game_name}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="input-list">
|
||||
<a class="sch-btn" href="javascript:;" id="search" url="{:U('lists','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据列表 -->
|
||||
<div class="data_list data_game_list">
|
||||
<div class="">
|
||||
<table>
|
||||
<!-- 表头 -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<input class="check-all" type="checkbox">
|
||||
</th>
|
||||
<th>序号</th>
|
||||
<th>游戏名</th>
|
||||
|
||||
<th>终端</th>
|
||||
<th>新用户判断标准(说明第几次之前为新用户)(次)</th>
|
||||
<th>新用户资源最低申请额度(/个)</th>
|
||||
<th>新用户资源最高申请额度(/个)</th>
|
||||
<th>非新用户可申请额度占总充值量的比例(%)</th>
|
||||
<th>状态</th>
|
||||
<th>更新时间</th>
|
||||
<th style="width:10%;min-width:150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- 列表 -->
|
||||
<tbody>
|
||||
<empty name ="listData">
|
||||
<td colspan="11" class="text-center">aOh! 暂时还没有内容!</td>
|
||||
<else />
|
||||
<volist name="listData" id="data">
|
||||
<tr>
|
||||
<td><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
|
||||
<td>{$data.id}</td>
|
||||
<td>{$data.game_name}</td>
|
||||
<td>{$data.sdk_version}</td>
|
||||
<td>{$data.new_apply_count}</td>
|
||||
<td>{$data.new_low_value}</td>
|
||||
<td>{$data.new_high_value}</td>
|
||||
<td>{$data.old_value_ratio}</td>
|
||||
<td>{$data.status}</td>
|
||||
<td>{$data.update_time}</td>
|
||||
<td>
|
||||
<a href="{:U('edit',array('id'=>$data['id']))}">编辑</a>
|
||||
<if condition="$data.status eq '正常'">
|
||||
<a data-url="{:U('lock',array('id'=>$data['id']))}" data-id="{$data['id']}" href="javascript:void(0)" style="width:100%;" class="lockRow">锁定</a>
|
||||
<else />
|
||||
<a data-url="{:U('lock',array('id'=>$data['id']))}" data-id="{$data['id']}" href="javascript:void(0)" style="width:100%;" class="open">解锁</a>
|
||||
</if>
|
||||
<a href="{:U('del',array('id'=>$data['id']))}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</volist>
|
||||
</empty>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page">
|
||||
{$_page|default=''}
|
||||
</div>
|
||||
|
||||
<div class="common_settings">
|
||||
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
|
||||
<form class="addShortcutIcon">
|
||||
<input type="hidden" name="title" value="{$meta_title}">
|
||||
<input type="hidden" name="url" value="Partner/lists">
|
||||
</form>
|
||||
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
|
||||
</div>
|
||||
|
||||
</block>
|
||||
|
||||
<block name="script">
|
||||
<script src="__STATIC__/layer/layer.js"></script>
|
||||
<script src="__STATIC__/layer/extend/layer.ext.js"></script>
|
||||
<style>
|
||||
.layui-layer-demo .layui-layer-title {background:#F0F5F7;font-weight:bold;}
|
||||
.layui-layer-demo .layui-layer-content {}
|
||||
.layui-layer-demo .layui-layer-content table{width:100%;border:0;border-spacing:0;padding:0;}
|
||||
.layui-layer-demo .layui-layer-content td {height:42px;padding-left:20px;}
|
||||
.layui-layer-demo .layui-layer-content tr:hover {background:#F0F5F7;}
|
||||
.layui-layer-demo .layui-layer-content tr~tr {border-top:1px solid #ccc;}
|
||||
.layui-layer-demo .layui-layer-content td~td {border-left:1px solid #ccc;}
|
||||
.layui-layer-demo .layui-layer-content tr:last-child td {}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
<volist name=":I('get.')" id="vo">
|
||||
Think.setValue('{$key}',"{$vo}");
|
||||
</volist>
|
||||
$(".select_gallery").select2();
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
//导航高亮
|
||||
highlight_subnav("{:U('ResourceVerifyConfig/lists')}");
|
||||
$(function(){
|
||||
$('.lockRow').click(function () {
|
||||
var id = $(this).attr('data-id');
|
||||
layer.confirm('确认锁定该规则?', {
|
||||
icon:0,
|
||||
btn: ['锁定','取消'] //按钮
|
||||
}, function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{:U('updateStatus')}",
|
||||
dataType: 'json',
|
||||
async: false,
|
||||
data: {id:id, status:0},
|
||||
success:function(data){
|
||||
if(data.status==1){
|
||||
layer.msg(data.info);
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
},1500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function(){
|
||||
layer.close();
|
||||
});
|
||||
});
|
||||
$('.open').click(function () {
|
||||
var id = $(this).attr('data-id');
|
||||
layer.confirm('确认解锁该规则?', {
|
||||
icon:0,
|
||||
btn: ['解锁','取消'] //按钮
|
||||
}, function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{:U('updateStatus')}",
|
||||
dataType: 'json',
|
||||
async: false,
|
||||
data: {id:id, status:1},
|
||||
success:function(data){
|
||||
if(data.status==1){
|
||||
layer.msg(data.info);
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
},1500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function(){
|
||||
layer.close();
|
||||
});
|
||||
});
|
||||
//搜索功能
|
||||
$("#search").click(function(){
|
||||
var url = $(this).attr('url');
|
||||
var query = $('.jssearch').find('input').serialize();
|
||||
query += "&"+$('.jssearch').find('select').serialize();
|
||||
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
|
||||
query = query.replace(/^&/g,'');
|
||||
|
||||
if( url.indexOf('?')>0 ){
|
||||
url += '&' + query;
|
||||
}else{
|
||||
url += '?' + query;
|
||||
}
|
||||
|
||||
window.location.href = url;
|
||||
});
|
||||
|
||||
//回车自动提交
|
||||
$('.jssearch').find('input').keyup(function(event){
|
||||
if(event.keyCode===13){
|
||||
$("#search").click();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</block>
|
Loading…
Reference in New Issue