添加落地页限制规则

master
ELF 4 years ago
parent a4d86b4fdd
commit 69b09c582f

@ -0,0 +1,194 @@
<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use Base\Service\PresidentDepositService;
/**
* 推广限制
*/
class PromoteLimitRuleController extends ThinkController
{
public function records()
{
$page = I('p', 1);
$row = I('row', 10);
$companyId = I('company_id', 0);
$promoteId = I('promote_id', 0);
$query = M('promote_limit_rules', 'tab_')->where('1=1');
if ($promoteId !== 0) {
$query->where(['promote_id' => $promoteId]);
}
if ($companyId !== 0) {
$promoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true);
$query->where(['promote_id' => ['in', $promoteIds]]);
}
$countQuery = clone $query;
$rules = $query->page($page, $row)->select();
$count = $countQuery->count();
$recordPromotes = [];
$recordCompanys = [];
if (count($rules) > 0) {
$recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($rules, 'promote_id')]])->select();
$recordCompanyIds = array_column($recordPromotes, 'company_id');
if (count($recordCompanyIds) > 0) {
$recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select();
}
$recordPromotes = index_by_column('id', $recordPromotes);
$recordCompanys = index_by_column('id', $recordCompanys);
}
$companyTypes = [
0 => '内团',
1 => '外团',
2 => '外团-分发联盟',
];
$records = [];
foreach ($rules as $rule) {
$records[] = [
'id' => $rule['id'],
'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']],
'limit_rule' => $this->getDisplayRule($rule),
];
}
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select();
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('records', $records);
$this->assign('companys', $companys);
$this->display();
}
private function getDisplayRule($rule)
{
if ($rule['started_at'] === null && $rule['ended_at'] === null) {
return '永久';
} elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) {
return '从前 至 '.$rule['ended_at'];
} elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) {
return $rule['started_at'] . ' 至 永久';
} else {
return $rule['started_at'] . ' ~ ' . $rule['ended_at'];
}
}
public function edit()
{
$this->meta_title = '编辑推广限制';
$id = I('id', 0);
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select();
$record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find();
$promote = null;
$company = null;
if ($record) {
$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();
}
$this->assign('promote', $promote);
$this->assign('company', $company);
$this->assign('companys', $companys);
$this->assign('record', $record);
$this->display('form');
}
public function save()
{
$id = I('id', 0);
$promoteId = I('promote_id', 0);
$startedAt = I('started_at', '');
$endedAt = I('ended_at', '');
$startedAt = $startedAt === '' ? null : $startedAt;
$endedAt = $endedAt === '' ? null : $endedAt;
if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) {
return $this->error('开始时间不能大于结束时间');
}
$record = null;
if ($id > 0) {
$record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find();
if (!$record) {
return $this->error('修改记录不存在');
}
} else {
$promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find();
if ($promoteRecord) {
return $this->error('该会长已经设定限制规则,请前往更新');
}
}
if ($record) {
$data = [];
$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['started_at'] = $startedAt;
$data['ended_at'] = $endedAt;
$data['create_time'] = time();
$data['update_time'] = time();
M('promote_limit_rules', 'tab_')->add($data);
addOperationLog([
'op_type' => 0,
'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt,
'op_name' => '新增推广限制',
'url' => U('PresidentDeposit/edit', ['promote_id'=>$promoteId]), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制'
]);
}
return $this->success('保存成功', U('records'));
}
public function delete()
{
$id = I('id', 0);
M('promote_limit_rules', 'tab_')->where(['id' => $id])->delete();
addOperationLog([
'op_type' => 2,
'key' => $id,
'op_name' => '删除会长推广限制',
'url' => U('PresidentDeposit/records', ['id' => $id]),
'menu' => '推广员-推广员管理-推广限制-删除推广限制'
]);
$this->ajaxReturn([
'status' => 1,
'message' => '删除成功'
]);
}
public function getPromotesByCompany()
{
$companyId = I('company_id', 0);
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['level' => 1, 'company_id' => $companyId])->select();
$this->ajaxReturn([
'status' => 1,
'message' => '获取成功',
'data' => [
'promotes' => $promotes
]
]);
}
}

@ -0,0 +1,241 @@
<extend name="Public/base" />
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link href="__STATIC__/icons_alibaba/iconfont.css" rel="stylesheet">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="__STATIC__/provincecityarea/AreaData_min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.tabcon1711 input.time {
width: 150px;
}
#form .txt_area {
width: 300px;
height: 150px;
}
.tabcon1711 .form_unit {
margin-left: 2px;
}
.tabcon1711 .mustmark {
margin-left:-7px;
}
.list-ratio {
display: table;
}
.list-ratio .li-ratio {
display: flex;
margin-bottom: 20px;
align-items: center;
}
.list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
position: relative;
}
.list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
color: red;
position: absolute;
left: 0;
top: 30px;
white-space: nowrap;
display: none;
}
.iconfont-btn {
cursor: pointer;
}
.iconfont-style {
font-size: 18px;
color: #fff;
border-radius: 4px;
border: 0;
padding: 5px;
margin-left: 10px;
}
.iconfont-selected {
background-color: #0A9AF2;
}
.iconfont-selected:hover {
background-color: #03a9f4;
}
.iconfont-unselected {
background-color: #999;
}
.iconfont-unselected:hover {
background-color: #ababab;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<!-- <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
</div>
<!-- 标签页导航 -->
<div class="tab-wrap">
<div class="tab-content tabcon1711">
<!-- 表单 -->
<form id="form" action="{:U('save')}" method="post" class="form-horizontal">
<!-- 基础文档模型 -->
<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;?>
</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>
</tbody>
</table>
</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>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
返回
</a>
</div>
</form>
</div>
</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="{$m_title}">
<input type="hidden" name="url" value="Promote/lists/type/1">
</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">
<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__/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">
//导航高亮
highlight_subnav("{:U('PromoteLimitRule/records')}");
$(".select_gallery").select2();
$(function(){
$('.time').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
autoclose: true,
scrollMonth: false,
scrollTime: false,
scrollInput: false,
startView: 'month',
minView:'month',
maxView:'month',
});
showTab();
$('#company-select').on({
change: function() {
var companyId = $(this).val()
getPromotesByCompany(companyId, function(promotes) {
var html = '<option value="">请选择会长</option>'
for (var key in promotes) {
html += '<option value="' + promotes[key].id + '">' + promotes[key].account + '</option>'
}
$('#promote-select').html(html)
$('#promote-select').select2()
})
}
})
function getPromotesByCompany(companyId, callback) {
$.ajax({
url: '{:U("getPromotesByCompany")}',
type: 'get',
dataType: 'json',
data: {company_id: companyId},
success: function(result) {
if (result.status == 1) {
callback(result.data.promotes)
} else {
layer.msg(result.message)
}
}
})
}
$('#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);
}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);
}
});
});
});
</script>
</block>

@ -0,0 +1,216 @@
<extend name="Public/base"/>
<block name="css">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<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;}
.textarea-style {
width: 200px;
height: 80px;
border-radius: 5px;
padding: 5px;
}
.mustmark {
color: #FF0000;
font-style: normal;
margin: 0 3px;
}
</style>
</block>
<block name="body">
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.form.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">推广限制</h3>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_select" name="company_id" class="select_gallery" style="width:200px;">
<option value="">请选择公司</option>
<?php foreach($companys as $company):?>
<option value="<?=$company['id']?>"><?=$company['company_name']?></option>
<?php endforeach;?>
</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>
</volist>
</select>
</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>
</div>
<!-- <div class="input-list">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,),I('get.')))}">导出</a>
</div> -->
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>
<input class="check-all" type="checkbox">
</th>
<th>推广公司</th>
<th>会长账号</th>
<th>内外团</th>
<th>限制时间</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name ="records">
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="records" id="data">
<tr data-id="<?=$data['id']?>">
<td>
<input class="ids" type="checkbox" value="{$data['id']}" name="ids[]">
</td>
<td>{$data.company_name}</td>
<td>{$data.promote_account}</td>
<td>{$data.company_belong}</td>
<td>{$data.limit_rule}</td>
<td>
<div class="partakebtn">
<a href="<?=U('edit', ['id' => $data['id']])?>">编辑</a>
<a class="delete-btn">删除</a>
</div>
</td>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<!-- <a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a> -->
</if>
{$_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="{$m_title}">
<input type="hidden" name="url" value="Query/withdraw">
</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" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script src="__STATIC__/jquery.cookie.js" charset="utf-8"></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('PromoteLimitRule/records')}");
$(function(){
//搜索功能
$("#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();
}
})
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
$('.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)
}
}
})
}
})
});
/* $(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
}) */
</script>
</block>

@ -1125,4 +1125,28 @@ class PromoteService {
return $selfGameIds;
}
}
public function checkPromoteLimitRule($promote)
{
$topPromote = $this->getTopPromote($promote);
$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) {
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;
}
}

@ -5,6 +5,7 @@ use Think\Controller;
use User\Api\MemberApi;
use Base\Facade\Request;
use Base\Service\ApplyService;
use Base\Service\PromoteService;
use Base\Service\PackageDownloadLogService;
use Base\Tool\MobileDetect;
@ -170,6 +171,16 @@ class HomeController extends Controller
$promoteId = $data['promote_id'];
}
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
if (!$promote) {
$this->error('该链接已失效');
}
$promoteService = new PromoteService();
if (!$promoteService->checkPromoteLimitRule($promote)) {
$this->error('链接已失效');
}
$isWechat = Request::isWechat();
$isIOS = Request::isIOS() || Request::isIPadOS();
$isAndroid = Request::isAndroid();
@ -208,8 +219,6 @@ class HomeController extends Controller
$map = ['id' => intval($gameId)];
$game = M('game', 'tab_')->field($columns)->where($map)->find();
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
if ($game['sdk_version'] == 1 && $isIOS) {
$map = [];
$map['relation_game_id'] = $game['relation_game_id'];

@ -54,6 +54,16 @@ class PackageController extends Controller
$promoteId = $data['promote_id'];
}
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
if (!$promote) {
$this->error('该链接已失效');
}
$promoteService = new PromoteService();
if (!$promoteService->checkPromoteLimitRule($promote)) {
$this->error('链接已失效');
}
$map = [];
$map['status'] = 1;
$map['enable_status'] = 1;
@ -65,7 +75,6 @@ class PackageController extends Controller
$this->redirect("package/downloadError", ['message' => '该链接已经停止使用']);
}
$promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find();
$game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find();
if (Request::isMobile() || Request::isTablet()) {

Loading…
Cancel
Save