master
elf 3 years ago
parent 08016ddde7
commit 3a192b1f2b

@ -17,14 +17,22 @@ class PromoteLimitRuleController extends ThinkController
$row = I('row', 10); $row = I('row', 10);
$companyId = I('company_id', 0); $companyId = I('company_id', 0);
$promoteId = I('promote_id', 0); $promoteId = I('promote_id', 0);
$account = I('account', '');
$baseGameId = I('base_game_id', -1);
$batchNo = I('batch_no', '');
$conditions = []; $conditions = ['_string' => '1=1'];
$promoteIds = []; $promoteIds = [];
if ($promoteId !== 0) { if ($account != '') {
$promoteIds = [$promoteId]; $promote = M('promote', 'tab_')->field(['id'])->where(['account' => $account])->find();
if ($promote) {
$promoteIds = [$promote['id']];
} else {
$conditions['_string'] .= ' and 1=0';
}
} }
if ($companyId !== 0) { if ($companyId !== 0) {
$companyPromoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true); $companyPromoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId])->getField('id', true);
if (count($companyPromoteIds) > 0) { if (count($companyPromoteIds) > 0) {
$promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds; $promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds;
$promoteIds[] = 0; $promoteIds[] = 0;
@ -35,10 +43,16 @@ class PromoteLimitRuleController extends ThinkController
if (count($promoteIds)) { if (count($promoteIds)) {
$conditions['promote_id'] = ['in', $promoteIds]; $conditions['promote_id'] = ['in', $promoteIds];
} }
if ($baseGameId != -1) {
$conditions['base_game_id'] = $baseGameId;
}
if ($batchNo != '') {
$conditions['batch_no'] = $batchNo;
}
$query = M('promote_limit_rules', 'tab_')->where($conditions); $query = M('promote_limit_rules', 'tab_')->where($conditions);
$countQuery = clone $query; $countQuery = clone $query;
$rules = $query->page($page, $row)->select(); $rules = $query->order('id desc')->page($page, $row)->select();
$count = $countQuery->count(); $count = $countQuery->count();
$recordPromotes = []; $recordPromotes = [];
@ -49,8 +63,12 @@ class PromoteLimitRuleController extends ThinkController
if (count($recordCompanyIds) > 0) { if (count($recordCompanyIds) > 0) {
$recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select(); $recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select();
} }
$baseGames = M('base_game', 'tab_')->where(['id' => ['in', array_column($rules, 'base_game_id')]])->select();
$recordPromotes = index_by_column('id', $recordPromotes); $recordPromotes = index_by_column('id', $recordPromotes);
$recordCompanys = index_by_column('id', $recordCompanys); $recordCompanys = index_by_column('id', $recordCompanys);
$baseGames = index_by_column('id', $baseGames);
} }
@ -63,6 +81,9 @@ class PromoteLimitRuleController extends ThinkController
'promote_account' => $recordPromotes[$rule['promote_id']]['account'], 'promote_account' => $recordPromotes[$rule['promote_id']]['account'],
'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'], 'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'],
'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_belong']], 'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_belong']],
'base_game_name' => $rule['base_game_id'] > 0 ? $baseGames[$rule['base_game_id']]['name'] : '所有游戏',
'with_sub' => $rule['with_sub'] == 1 ? '是' : '否',
'batch_no' => $rule['batch_no'],
'limit_rule' => $this->getDisplayRule($rule), 'limit_rule' => $this->getDisplayRule($rule),
]; ];
} }
@ -72,6 +93,9 @@ class PromoteLimitRuleController extends ThinkController
if($page) { if($page) {
$this->assign('_page', $page); $this->assign('_page', $page);
} }
$baseGames = M('base_game', 'tab_')->select();
$this->assign('baseGames', $baseGames);
$this->assign('records', $records); $this->assign('records', $records);
$this->assign('companys', $companys); $this->assign('companys', $companys);
$this->display(); $this->display();
@ -102,6 +126,10 @@ class PromoteLimitRuleController extends ThinkController
$promote = M('promote', 'tab_')->where(['id' => $record['promote_id']])->field(['id', 'company_id', 'account'])->find(); $promote = M('promote', 'tab_')->where(['id' => $record['promote_id']])->field(['id', 'company_id', 'account'])->find();
$company = M('promote_company', 'tab_')->where(['id' => $promote['company_id']])->field(['id', 'company_name'])->find(); $company = M('promote_company', 'tab_')->where(['id' => $promote['company_id']])->field(['id', 'company_name'])->find();
} }
$baseGames = M('base_game', 'tab_')->select();
$this->assign('baseGames', $baseGames);
$this->assign('promote', $promote); $this->assign('promote', $promote);
$this->assign('company', $company); $this->assign('company', $company);
$this->assign('companys', $companys); $this->assign('companys', $companys);
@ -112,7 +140,11 @@ class PromoteLimitRuleController extends ThinkController
public function save() public function save()
{ {
$id = I('id', 0); $id = I('id', 0);
$promoteId = I('promote_id', 0); $baseGameId = I('base_game_id', 0);
$account = I('account', '');
$accountsStr = I('accounts', '');
$limitType = I('limit_type', 1);
$withSub = I('with_sub', 1);
$startedAt = I('started_at', ''); $startedAt = I('started_at', '');
$endedAt = I('ended_at', ''); $endedAt = I('ended_at', '');
@ -124,62 +156,122 @@ class PromoteLimitRuleController extends ThinkController
} }
$record = null; $record = null;
$promotes = [];
if ($id > 0) { if ($id > 0) {
$record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find();
if (!$record) { if (!$record) {
return $this->error('修改记录不存在'); return $this->error('修改记录不存在');
} }
} else { } else {
if (empty($promoteId)) { try {
return $this->error('请选择会长'); $accounts = [];
if ($limitType == 1) {
$accounts = [$account];
} else {
$accounts = $this->parseAccountsStr($accountsStr);
} }
$promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find(); $promotes = $this->getPromotes($accounts);
if ($promoteRecord) { } catch (\Exception $e) {
return $this->error('该会长已经设定限制规则,请前往更新'); return $this->error($e->getMessage());
} }
} }
if ($record) { if ($record) {
$promote = M('promote', 'tab_')->field(['id'])->where(['account' => $account])->find();
$data = []; $data = [];
$data['promote_id'] = $promote['id'];
$data['base_game_id'] = $baseGameId;
$data['with_sub'] = $withSub;
$data['started_at'] = $startedAt; $data['started_at'] = $startedAt;
$data['ended_at'] = $endedAt; $data['ended_at'] = $endedAt;
$data['update_time'] = time(); $data['update_time'] = time();
M('promote_limit_rules', 'tab_')->where(['id' => $id])->save($data); M('promote_limit_rules', 'tab_')->where(['id' => $id])->save($data);
addOperationLog([
'op_type' => 1,
'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt,
'op_name' => '修改推广限制',
'url' => U('PresidentDeposit/edit', ['id'=>$id]), 'menu'=>'推广员-推广员管理-推广限制-修改推广限制'
]);
} else { } else {
$data = []; $data = [];
$data['promote_id'] = $promoteId; $data['base_game_id'] = $baseGameId;
$data['with_sub'] = $withSub;
$data['started_at'] = $startedAt; $data['started_at'] = $startedAt;
$data['ended_at'] = $endedAt; $data['ended_at'] = $endedAt;
$data['batch_no'] = date('Ymdhis') . rand(1000, 9999);
$data['create_time'] = time(); $data['create_time'] = time();
$data['update_time'] = time(); $data['update_time'] = time();
M('promote_limit_rules', 'tab_')->add($data);
$records = [];
foreach ($promotes as $promote) {
$records[] = array_merge($data, ['promote_id' => $promote['id']]);
}
M('promote_limit_rules', 'tab_')->addAll($records);
}
if ($id > 0) {
addOperationLog([
'op_type' => 1,
'key'=> '',
'op_name' => '修改推广限制',
'url' => U('PromoteLimitRule/save'), 'menu'=>'推广员-推广员管理-推广限制-修改推广限制',
'content' => json_encode(I('post.'))
]);
} else {
addOperationLog([ addOperationLog([
'op_type' => 0, 'op_type' => 0,
'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, 'key'=> '',
'op_name' => '新增推广限制', 'op_name' => '新增推广限制',
'url' => U('PresidentDeposit/edit', ['promote_id'=>$promoteId]), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制' 'url' => U('PromoteLimitRule/save'), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制',
'content' => json_encode(I('post.'))
]); ]);
} }
return $this->success('保存成功', U('records')); return $this->success('保存成功', U('records'));
} }
private function parseAccountsStr($accountsStr)
{
if ($accountsStr == '') {
throw new \Exception('推广员账号数量不能为0');
}
$accountArr = json_decode($accountsStr, true);
$accounts = [];
foreach ($accountArr as $key => $item) {
$accounts[] = trim($item['推广账号']);
}
return array_unique($accounts);
}
private function getPromotes($accounts)
{
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $accounts]])->select();
if (count($accounts) != count($promotes)) {
$promotes = index_by_column('account', $promotes);
$noExistAcounts = [];
foreach ($accounts as $account) {
if (!isset($promotes[$account])) {
$noExistAcounts[] = $account;
}
}
throw new \Exception('含有不存在的推广账号: ' . implode(',', $noExistAcounts));
}
return $promotes;
}
public function delete() public function delete()
{ {
$id = I('id', 0); $id = I('id', 0);
M('promote_limit_rules', 'tab_')->where(['id' => $id])->delete(); $batchNo = I('batch_no', '');
$conditions = [];
if ($id > 0) {
$conditions['id'] = $id;
} elseif ($batchNo != '') {
$conditions['batch_no'] = $batchNo;
}
M('promote_limit_rules', 'tab_')->where($conditions)->delete();
addOperationLog([ addOperationLog([
'op_type' => 2, 'op_type' => 2,
'key' => $id, 'key' => $id,
'op_name' => '删除会长推广限制', 'op_name' => '删除会长推广限制',
'url' => U('PresidentDeposit/delete', ['id' => $id]), 'url' => U('PresidentDeposit/delete', ['id' => $id, 'batch' => $batchNo]),
'menu' => '推广员-推广员管理-推广限制-删除推广限制' 'menu' => '推广员-推广员管理-推广限制-删除推广限制'
]); ]);

@ -65,6 +65,14 @@
.iconfont-unselected:hover { .iconfont-unselected:hover {
background-color: #ababab; background-color: #ababab;
} }
.data_list table th {
line-height: 30px;
height: 30px;
}
.data_list table td {
line-height: 30px;
height: 30px;
}
</style> </style>
<div class="cf main-place top_nav_list navtab_list"> <div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3> <h3 class="page_title">{$meta_title}</h3>
@ -80,32 +88,61 @@
<div id="tab1" class="tab-pane in tab1"> <div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<tbody> <tbody>
<?php if (!$record):?>
<tr> <tr>
<td class="l"><i class="mustmark">*</i>推广公司:</td> <td class="l"><i class="mustmark">*</i>限制类型:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label >
<input type="radio" value="1" name="limit_type" checked="checked"> 单账号
</label >
<label >
<input type="radio" value="2" name="limit_type" > 多账号
</label>
</span>
</td>
</tr>
<?php endif;?>
<?php if (!$record):?>
<tr id="batch-item" style="display: none;">
<td class="l"><i class="mustmark">*</i>推广账号:</td>
<td class="r"> <td class="r">
<?php if($record):?> <div>
<span class="form_radio table_btn" style="color: red;">{$company.company_name}</span> <input id="account-list" type="hidden" name="accounts" value="">
<?php else:?> <input type="file" id="fileinput" name="file" style="display: inline-block;">
<select name="company_id" id="company-select" class="select_gallery"> <span>推广账号文件(格式见下方),暂只支持.xls .xlsx 格式文件</span>
<option value="">请选择推广公司</option> </div>
<?php foreach($companys as $company):?> </td>
<option value="<?=$company['id']?>" <?php if($company['id'] == $promote['company_id']):?>selected<?php endif;?>><?=$company['company_name']?></option> </tr>
<?php endforeach;?>
</select>
<?php endif;?> <?php endif;?>
<tr id="single-item">
<td class="l"><i class="mustmark">*</i>推广账号:</td>
<td class="r">
<input type="text" class="txt" name="account" value="<?=$promote['account']?>" placeholder="输入推广员账号" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')">
</td> </td>
</tr> </tr>
<tr> <tr id="single-item">
<td class="l"><i class="mustmark">*</i>会长:</td> <td class="l"><i class="mustmark">*</i>限制游戏</td>
<td class="r"> <td class="r">
<?php if($record):?> <select id="game_id" name="base_game_id" class="select_gallery" style="width:215px;">
<span class="form_radio table_btn" style="color: red;">{$promote.account}</span> <option value="0">所有游戏</option>
<?php else:?> <?php foreach($baseGames as $baseGame):?>
<select name="promote_id" id="promote-select" class="select_gallery"> <option value="<?=$baseGame['id']?>" <?php if($baseGame['id'] == $record['base_game_id']):?>selected<?php endif;?>><?=$baseGame['name']?></option>
<option value="">请选择会长</option> <?php endforeach;?>
</select> </select>
<?php endif;?> </td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>是否包含下级:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label >
<input type="radio" value="1" name="with_sub" checked="checked">
</label >
<label >
<input type="radio" value="0" name="with_sub" >
</label>
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -122,10 +159,29 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php if (!$record):?>
<div id="file-item" style="width: 450px; margin-left: 50px; margin-top: 20px; display: none;">
<h5 style="margin-bottom: 5px;">文件格式参考<span style="color: red;">(请严格按此格式,文件的第一行必须是字段名,且字段名不允许修改)</span></h5>
<div class="data_list">
<table>
<thead>
<tr>
<th>推广账号</th>
</tr>
</thead>
<tbody>
<tr>
<td>test1234</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php endif;?>
</div> </div>
<input type="hidden" name="id" id="id" value="{$record.id}" /> <input type="hidden" name="id" id="id" value="{$record.id}" />
<div class="form-item cf"> <div class="form-item cf">
<button class="submit_btn mlspacing" id="submit" type="submit" target-form="form-horizontal"> <button class="submit_btn mlspacing" id="submit" type="button" target-form="form-horizontal">
确认 确认
</button> </button>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" > <a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
@ -151,6 +207,7 @@
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css"> <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php> <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css"> <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/xlsx.core.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -200,10 +257,104 @@ $(function(){
}) })
} }
$('input:radio[name="limit_type"]').click(function() {
if ($('input:radio[name="limit_type"]:checked').val() == 1) {
$('#batch-item').hide()
$('#file-item').hide()
$('#single-item').show()
} else {
$('#single-item').hide()
$('#batch-item').show()
$('#file-item').show()
}
})
var isfile = false
var rABS = false; //是否将文件读取为二进制字符串
var accounts = []
$("#fileinput").change(function () {
var p = $(this).val();
var ext = p.substr(p.lastIndexOf(".")).toLowerCase();
if (ext != ".xls" && ext != ".xlsx") {
layer.msg("文件仅支持excel文件格式");
$(this).val('');
p = '';
}
if (p != '') {
isfile = true;
} else {
isfile = false;
}
})
function readFileInput(callback) {
// MSG.showmsg("读取excle中。。。");
var wb;//读取完成的数据
var f = $("#fileinput")[0].files[0];
var reader = new FileReader();
if (rABS) {
reader.readAsArrayBuffer(f);
} else {
reader.readAsBinaryString(f);
}
reader.onload = function (e) {
// MSG.showmsg("文件读取完成,比较命令初始化。。。");
var data = e.target.result;
if (rABS) {
wb = XLSX.read(btoa(fixdata(data)), {
type: 'base64'
});
} else {
wb = XLSX.read(data, {
type: 'binary'
});
}
try {
accounts = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]])
console.log(JSON.stringify(accounts))
$('#account-list').val(JSON.stringify(accounts))
callback();
} catch (error) {
// MSG.hidemsg();
isfile = false;
layer.msg('excel内容不符或不能为空');
return false;
}
// document.getElementById("demo").innerHTML= JSON.stringify( XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) );
};
}
function fixdata(data) { //文件流转BinaryString
var o = "",
l = 0,
w = 10240;
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
return o;
}
$('#submit').click(function (e) { $('#submit').click(function (e) {
if ($('input:radio[name="limit_type"]:checked').val() == 2) {
readFileInput(function () {
if (accounts.length == 0) {
layer.msg('表格中无道具');
return false;
} else {
postForm()
}
})
} else {
postForm()
}
});
function postForm() {
var target = $('form').get(0).action; var target = $('form').get(0).action;
var query = $('form').serialize(); var query = $('form').serialize();
var that = this; var that = $('#submit');
$(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true); $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
$.post(target, query).success(function(data){ $.post(target, query).success(function(data){
if(layer) {layer.closeAll('loading');} if(layer) {layer.closeAll('loading');}
@ -235,7 +386,7 @@ $(function(){
},3000); },3000);
} }
}); });
}); }
}); });
</script> </script>
</block> </block>

@ -65,13 +65,20 @@
</select> </select>
</div> </div>
<div class="input-list input-list-promote search_label_rehab"> <div class="input-list input-list-promote search_label_rehab">
<select id="promote-select" name="promote_id" class="select_gallery" style="width:120px;"> <input style="width: 200px;" type="text" name="account" class="search-input" placeholder="请输入推广账号">
<option value="">请选择会长</option> </div>
<volist name=":get_promote_list_by_id()" id="vo"> <div class="input-list input-list-promote search_label_rehab">
<option value="{$vo.id}">{$vo.account}</option> <select id="game-select" name="base_game_id" class="select_gallery" style="width:120px;">
<option value="-1">请选择游戏</option>
<option value="0">所有游戏</option>
<volist name="baseGames" id="vo">
<option value="{$vo.id}">{$vo.name}</option>
</volist> </volist>
</select> </select>
</div> </div>
<div class="input-list input-list-promote search_label_rehab">
<input style="width: 200px;" type="text" name="batch_no" class="search-input" placeholder="请输入序列号">
</div>
<div class="input-list"> <div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('PromoteLimitRule/records')}">搜索</a> <a class="sch-btn" href="javascript:;" id="search" url="{:U('PromoteLimitRule/records')}">搜索</a>
<a class="sch-btn" href="{:U('PromoteLimitRule/edit')}">添加</a> <a class="sch-btn" href="{:U('PromoteLimitRule/edit')}">添加</a>
@ -95,8 +102,11 @@
</th> </th>
<th>推广公司</th> <th>推广公司</th>
<th>会长账号</th> <th>会长账号</th>
<th>是否包含下级</th>
<th>内外团</th> <th>内外团</th>
<th>限制游戏</th>
<th>限制时间</th> <th>限制时间</th>
<th>批次号</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
@ -113,12 +123,16 @@
</td> </td>
<td>{$data.company_name}</td> <td>{$data.company_name}</td>
<td>{$data.promote_account}</td> <td>{$data.promote_account}</td>
<td>{$data.with_sub}</td>
<td>{$data.company_belong}</td> <td>{$data.company_belong}</td>
<td>{$data.base_game_name}</td>
<td>{$data.limit_rule}</td> <td>{$data.limit_rule}</td>
<td>{$data.batch_no}</td>
<td> <td>
<div class="partakebtn"> <div class="partakebtn">
<a href="<?=U('edit', ['id' => $data['id']])?>">编辑</a> <a href="<?=U('edit', ['id' => $data['id']])?>">编辑</a>
<a class="delete-btn">删除</a> <a class="delete-btn" data-type="id" data-val="{$data.id}">删除</a>
<a class="delete-btn" data-type="batch_no" data-val="{$data.batch_no}">删除批次</a>
</div> </div>
</td> </td>
</tr> </tr>
@ -183,6 +197,46 @@
$('#batch-delete-btn').on({ $('#batch-delete-btn').on({
click: function() { click: function() {
var ids = getIds(); var ids = getIds();
if (ids.length == 0) {
return layer.msg('未选中记录');
}
layer.confirm('确定要删除这些记录吗?', {
title: '删除',
btn: ['确定']
}, function(){
batchDelete(ids)
})
}
})
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
$('.delete-btn').on({
click: function() {
var val = $(this).attr('data-val')
var type = $(this).attr('data-type');
var word = '确定要删除这条记录吗?';
if (type == 'batch_no') {
word = '确定要删除批次[' + val + ']的所有记录吗?';
}
layer.confirm(word, {
title: '删除',
btn: ['确定']
}, function(){
if (type == 'batch_no') {
deleteByBachNo(val)
} else {
deleteById(val)
}
})
}
})
function batchDelete(ids) {
$.ajax({ $.ajax({
url: '{:U("batchDelete")}', url: '{:U("batchDelete")}',
type: 'post', type: 'post',
@ -200,22 +254,21 @@
} }
}) })
} }
})
function getIds() { function deleteById(id) {
var ids = []; deleteByData({id: id})
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
} }
$('.delete-btn').on({
click: function() { function deleteByBachNo(bachNo) {
var id = $(this).parents('tr').eq(0).attr('data-id'); deleteByData({batch_no: bachNo})
}
function deleteByData(data) {
$.ajax({ $.ajax({
url: '{:U("delete")}', url: '{:U("delete")}',
type: 'post', type: 'post',
dataType: 'json', dataType: 'json',
data: {id: id}, data: data,
success: function(result) { success: function(result) {
if (result.status == 1) { if (result.status == 1) {
layer.msg(result.message) layer.msg(result.message)
@ -228,7 +281,6 @@
} }
}) })
} }
})
}); });
/* $(".export-btn").on("click",function(e){ /* $(".export-btn").on("click",function(e){
e.preventDefault(); e.preventDefault();

@ -1208,22 +1208,38 @@ class PromoteService {
public function checkPromoteLimitRule($promote, $gameId = 0) public function checkPromoteLimitRule($promote, $gameId = 0)
{ {
$accountString = 'wangshuai1,ouyangtianlin,zhangjiayuan02,zhangchuang,huangjian,lixiaojie01,youjinbo01,laijiansen,liutao001,huangdonyu,huangwenlu,qiujinwei,qiucanlon,panhailang,linzilun,xuechonbiao,chenfayun01,pengjun,shenyanwei,wusiju,kechengwei,linruidong,huzhoujian,linzelong,linwei1,zhanghanying,xushiming,linxuchen,zhengchengzhi,yaokaijie,wengyongbang,liaofaqian,zhangqing,liaojunwei,zhangming,zhaoxiaoyi01,zhongkaixin,zhangkaiyu,linwei01,dukunpeng,zhengjianzhou,wengshouxiong,caizhenxing,xiuguanxin,suyuelong,guozhijie,chenzhenghao,zhongyouling,linjian,xuwenye,zhengjinhe,huangyongqing,wangqiaozhen,jiangweihao,lijianfeng01,shaowenhui,huangyuhang,lianglingui,baoxiaohui,heyuming,linwanxi,jiangnan,ouzhijie,liguangcai,lican1,caiwenxin,xianggengyu,songzhibin,jinweiyuan,chenyixing,zhangxiang,denglan,yejiehui,wangbencai,huangzhenhon,liumeifu,xuliuyang,zhengmingquan,huangshengguang,liuweihuang,lixuemeng,xurongcheng,chenzhuo,caixiaodong,linhui,luwenjie,huangyonghao,xuguojin,ningyi01,zhouchongliang,chenshigang,chenyangwen,lijiayu,lanhua,zuojingjing,zhangxingliang,huangxinyu,pujianhao,zhengdongwei,xueyiqiang,lijiawei,tongqiang,huangxirui,wangjinfu,linhao01,chenlinzhi,zengjiawei,lijunjie01,xuwei01,diaowenfeng,guoyinzhen,chenzongda,luwujun,hongye,yangdegao,hehaiwei,zhangyutao,zhengxinyao,wangjunqi,wuyuze,linzejun,yangyunfeng,huangxiaojia,linqianyun,liyao01,huangkai,aihu01,wangshuai,zhangjiayuan01,youjinbo,zhangjiayuan,wengshouxion,ningyi,qcwljunbo,nolajhr'; $baseGame = M('base_game', 'tab_')->where('android_game_id=' . $gameId . ' or ios_game_id=' . $gameId)->find();
$accounts = explode(',', $accountString); if (!$baseGame) {
if (in_array($promote['account'], $accounts)) {
return false; return false;
} }
$parentIds = $this->getIdsByChain($promote['chain']);
$ids = $parentIds;
$ids[] = $promote['id'];
$topPromote = $this->getTopPromote($promote); $access = true;
$rules = M('promote_limit_rules', 'tab_')->where(['promote_id' => ['in', $ids], 'base_game_id' => ['in', [0, $baseGame['id']]]])->order('created_at desc')->select();
foreach ($rules as $rule) {
if ($this->isLimitRuleContains($rule, $promote) && $this->isLimitRuleEeffective($rule)) {
$access = false;
}
}
return $access;
}
if (in_array($topPromote['account'], ['zhangle', 'changwanwl', 'youwan', 'youwan2022'])) { private function isLimitRuleContains($rule, $promote)
if (in_array($gameId, [293, 294])) { {
return false; if ($rule['promote_id'] == $promote['id']) {
return true;
}
$parentIds = $this->getIdsByChain($promote['chain']);
if (in_array($rule['promote_id'], $parentIds) && $rule['with_sub'] == 1) {
return true;
} }
return false;
} }
$rule = M('promote_limit_rules', 'tab_')->where(['promote_id' => $topPromote['id']])->order('created_at desc')->limit(1)->find(); private function isLimitRuleEeffective($rule)
if ($rule) { {
if ($rule['started_at'] === null && $rule['ended_at'] === null) { if ($rule['started_at'] === null && $rule['ended_at'] === null) {
return false; return false;
} elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) {
@ -1239,7 +1255,6 @@ class PromoteService {
return false; return false;
} }
} }
}
return true; return true;
} }

@ -2975,3 +2975,7 @@ CREATE TABLE `tab_rebate_times_setting` (
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '生成时间', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '生成时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='充值返利倍数设置'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='充值返利倍数设置';
alter table tab_promote_limit_rules add column with_sub tinyint(1) not null default 0 comment '是否包含下级' after promote_id;
alter table tab_promote_limit_rules add column base_game_id int(11) not null default 0 comment '限制游戏' after promote_id;
alter table tab_promote_limit_rules add column batch_no varchar(18) not null default '' comment '批次号' after with_sub;

Loading…
Cancel
Save