master
elf 3 years ago
parent 08016ddde7
commit 3a192b1f2b

@ -17,14 +17,22 @@ class PromoteLimitRuleController extends ThinkController
$row = I('row', 10);
$companyId = I('company_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 = [];
if ($promoteId !== 0) {
$promoteIds = [$promoteId];
if ($account != '') {
$promote = M('promote', 'tab_')->field(['id'])->where(['account' => $account])->find();
if ($promote) {
$promoteIds = [$promote['id']];
} else {
$conditions['_string'] .= ' and 1=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) {
$promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds;
$promoteIds[] = 0;
@ -35,10 +43,16 @@ class PromoteLimitRuleController extends ThinkController
if (count($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);
$countQuery = clone $query;
$rules = $query->page($page, $row)->select();
$rules = $query->order('id desc')->page($page, $row)->select();
$count = $countQuery->count();
$recordPromotes = [];
@ -49,8 +63,12 @@ class PromoteLimitRuleController extends ThinkController
if (count($recordCompanyIds) > 0) {
$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);
$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'],
'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'],
'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),
];
}
@ -72,6 +93,9 @@ class PromoteLimitRuleController extends ThinkController
if($page) {
$this->assign('_page', $page);
}
$baseGames = M('base_game', 'tab_')->select();
$this->assign('baseGames', $baseGames);
$this->assign('records', $records);
$this->assign('companys', $companys);
$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();
$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('company', $company);
$this->assign('companys', $companys);
@ -112,7 +140,11 @@ class PromoteLimitRuleController extends ThinkController
public function save()
{
$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', '');
$endedAt = I('ended_at', '');
@ -124,62 +156,122 @@ class PromoteLimitRuleController extends ThinkController
}
$record = null;
$promotes = [];
if ($id > 0) {
$record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find();
if (!$record) {
return $this->error('修改记录不存在');
}
} else {
if (empty($promoteId)) {
return $this->error('请选择会长');
}
$promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find();
if ($promoteRecord) {
return $this->error('该会长已经设定限制规则,请前往更新');
try {
$accounts = [];
if ($limitType == 1) {
$accounts = [$account];
} else {
$accounts = $this->parseAccountsStr($accountsStr);
}
$promotes = $this->getPromotes($accounts);
} catch (\Exception $e) {
return $this->error($e->getMessage());
}
}
if ($record) {
$promote = M('promote', 'tab_')->field(['id'])->where(['account' => $account])->find();
$data = [];
$data['promote_id'] = $promote['id'];
$data['base_game_id'] = $baseGameId;
$data['with_sub'] = $withSub;
$data['started_at'] = $startedAt;
$data['ended_at'] = $endedAt;
$data['update_time'] = time();
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 {
$data = [];
$data['promote_id'] = $promoteId;
$data['base_game_id'] = $baseGameId;
$data['with_sub'] = $withSub;
$data['started_at'] = $startedAt;
$data['ended_at'] = $endedAt;
$data['batch_no'] = date('Ymdhis') . rand(1000, 9999);
$data['create_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([
'op_type' => 0,
'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt,
'key'=> '',
'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'));
}
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()
{
$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([
'op_type' => 2,
'key' => $id,
'op_name' => '删除会长推广限制',
'url' => U('PresidentDeposit/delete', ['id' => $id]),
'url' => U('PresidentDeposit/delete', ['id' => $id, 'batch' => $batchNo]),
'menu' => '推广员-推广员管理-推广限制-删除推广限制'
]);

@ -65,6 +65,14 @@
.iconfont-unselected:hover {
background-color: #ababab;
}
.data_list table th {
line-height: 30px;
height: 30px;
}
.data_list table td {
line-height: 30px;
height: 30px;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
@ -80,52 +88,100 @@
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark">*</i>推广公司:</td>
<td class="r">
<?php if($record):?>
<span class="form_radio table_btn" style="color: red;">{$company.company_name}</span>
<?php else:?>
<select name="company_id" id="company-select" class="select_gallery">
<option value="">请选择推广公司</option>
<?php foreach($companys as $company):?>
<option value="<?=$company['id']?>" <?php if($company['id'] == $promote['company_id']):?>selected<?php endif;?>><?=$company['company_name']?></option>
<?php endforeach;?>
<?php if (!$record):?>
<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="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">
<div>
<input id="account-list" type="hidden" name="accounts" value="">
<input type="file" id="fileinput" name="file" style="display: inline-block;">
<span>推广账号文件(格式见下方),暂只支持.xls .xlsx 格式文件</span>
</div>
</td>
</tr>
<?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>
</tr>
<tr id="single-item">
<td class="l"><i class="mustmark">*</i>限制游戏:</td>
<td class="r">
<select id="game_id" name="base_game_id" class="select_gallery" style="width:215px;">
<option value="0">所有游戏</option>
<?php foreach($baseGames as $baseGame):?>
<option value="<?=$baseGame['id']?>" <?php if($baseGame['id'] == $record['base_game_id']):?>selected<?php endif;?>><?=$baseGame['name']?></option>
<?php endforeach;?>
</select>
<?php endif;?>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>会长:</td>
<td class="r">
<?php if($record):?>
<span class="form_radio table_btn" style="color: red;">{$promote.account}</span>
<?php else:?>
<select name="promote_id" id="promote-select" class="select_gallery">
<option value="">请选择会长</option>
</select>
<?php endif;?>
</td>
</tr>
<tr>
<td class="l">开始时间:</td>
<td class="r">
<input type="text" name="started_at" class="time" value="<?=$record['started_at']?>" placeholder="请选择开始时间" style="width: 200px"/>
</td>
</tr>
<tr>
<td class="l">结束时间:</td>
<td class="r">
<input type="text" name="ended_at" class="time" value="<?=$record['ended_at']?>" placeholder="请选择结束时间" style="width: 200px" />
</td>
</tr>
</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>
</tr>
<tr>
<td class="l">开始时间:</td>
<td class="r">
<input type="text" name="started_at" class="time" value="<?=$record['started_at']?>" placeholder="请选择开始时间" style="width: 200px"/>
</td>
</tr>
<tr>
<td class="l">结束时间:</td>
<td class="r">
<input type="text" name="ended_at" class="time" value="<?=$record['ended_at']?>" placeholder="请选择结束时间" style="width: 200px" />
</td>
</tr>
</tbody>
</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>
<input type="hidden" name="id" id="id" value="{$record.id}" />
<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>
<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">
<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">
<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/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
@ -200,42 +257,136 @@ $(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) {
var target = $('form').get(0).action;
var query = $('form').serialize();
var that = this;
$(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
$.post(target,query).success(function(data){
if(layer) {layer.closeAll('loading');}
if (data.status==1) {
if (data.url) {
updateAlert(data.info + ' 页面即将自动跳转~');
}else{
updateAlert(data.info);
}
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
} else if( $(that).hasClass('no-refresh')) {
$('#tip').find('.tipclose').click();
} else {
location.reload();
}
}, 1500);
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 query = $('form').serialize();
var that = $('#submit');
$(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
$.post(target, query).success(function(data){
if(layer) {layer.closeAll('loading');}
if (data.status==1) {
if (data.url) {
updateAlert(data.info + ' 页面即将自动跳转~');
}else{
updateAlert(data.info);
}
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
} else if( $(that).hasClass('no-refresh')) {
$('#tip').find('.tipclose').click();
} else {
location.reload();
}
}, 1500);
}else{
updateAlert(data.info,'tip_error');
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
}else{
updateAlert(data.info,'tip_error');
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
}else{
$('#tip').find('.tipclose').click();
}
},3000);
$('#tip').find('.tipclose').click();
}
});
});
},3000);
}
});
}
});
</script>
</block>

@ -65,13 +65,20 @@
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote-select" name="promote_id" class="select_gallery" style="width:120px;">
<option value="">请选择会长</option>
<volist name=":get_promote_list_by_id()" id="vo">
<option value="{$vo.id}">{$vo.account}</option>
<input style="width: 200px;" type="text" name="account" class="search-input" placeholder="请输入推广账号">
</div>
<div class="input-list input-list-promote search_label_rehab">
<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>
</select>
</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">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('PromoteLimitRule/records')}">搜索</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>
</tr>
</thead>
@ -113,12 +123,16 @@
</td>
<td>{$data.company_name}</td>
<td>{$data.promote_account}</td>
<td>{$data.with_sub}</td>
<td>{$data.company_belong}</td>
<td>{$data.base_game_name}</td>
<td>{$data.limit_rule}</td>
<td>{$data.batch_no}</td>
<td>
<div class="partakebtn">
<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>
</td>
</tr>
@ -183,21 +197,14 @@
$('#batch-delete-btn').on({
click: function() {
var ids = getIds();
$.ajax({
url: '{:U("batchDelete")}',
type: 'post',
dataType: 'json',
data: {ids: ids},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
if (ids.length == 0) {
return layer.msg('未选中记录');
}
layer.confirm('确定要删除这些记录吗?', {
title: '删除',
btn: ['确定']
}, function(){
batchDelete(ids)
})
}
})
@ -210,25 +217,70 @@
}
$('.delete-btn').on({
click: function() {
var id = $(this).parents('tr').eq(0).attr('data-id');
$.ajax({
url: '{:U("delete")}',
type: 'post',
dataType: 'json',
data: {id: id},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
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({
url: '{:U("batchDelete")}',
type: 'post',
dataType: 'json',
data: {ids: ids},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
function deleteById(id) {
deleteByData({id: id})
}
function deleteByBachNo(bachNo) {
deleteByData({batch_no: bachNo})
}
function deleteByData(data) {
$.ajax({
url: '{:U("delete")}',
type: 'post',
dataType: 'json',
data: data,
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
});
/* $(".export-btn").on("click",function(e){
e.preventDefault();

@ -1208,36 +1208,51 @@ class PromoteService {
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';
$accounts = explode(',', $accountString);
if (in_array($promote['account'], $accounts)) {
$baseGame = M('base_game', 'tab_')->where('android_game_id=' . $gameId . ' or ios_game_id=' . $gameId)->find();
if (!$baseGame) {
return false;
}
$parentIds = $this->getIdsByChain($promote['chain']);
$ids = $parentIds;
$ids[] = $promote['id'];
$topPromote = $this->getTopPromote($promote);
if (in_array($topPromote['account'], ['zhangle', 'changwanwl', 'youwan', 'youwan2022'])) {
if (in_array($gameId, [293, 294])) {
return false;
$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;
}
private function isLimitRuleContains($rule, $promote)
{
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();
if ($rule) {
if ($rule['started_at'] === null && $rule['ended_at'] === null) {
private function isLimitRuleEeffective($rule)
{
if ($rule['started_at'] === null && $rule['ended_at'] === null) {
return false;
} elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) {
if (time() < strtotime($rule['ended_at'] . ' 23:59:59')) {
return false;
}
} elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) {
if (time() >= strtotime($rule['started_at'] . ' 00:00:00')) {
return false;
}
} else {
if (time() >= strtotime($rule['started_at'] . ' 00:00:00') && time() < strtotime($rule['ended_at'] . ' 23:59:59')) {
return false;
} elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) {
if (time() < strtotime($rule['ended_at'] . ' 23:59:59')) {
return false;
}
} elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) {
if (time() >= strtotime($rule['started_at'] . ' 00:00:00')) {
return false;
}
} else {
if (time() >= strtotime($rule['started_at'] . ' 00:00:00') && time() < strtotime($rule['ended_at'] . ' 23:59:59')) {
return false;
}
}
}
return true;

@ -2974,4 +2974,8 @@ CREATE TABLE `tab_rebate_times_setting` (
`max_times` int(11) NOT NULL DEFAULT '0' COMMENT '上限倍数',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '生成时间',
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