commit
c3ff827b69
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
namespace Base\Service;
|
||||
|
||||
use Base\Facade\Request;
|
||||
use Base\Tool\GameCatClient;
|
||||
|
||||
class PromoteGradeService
|
||||
{
|
||||
public static $symbols = [
|
||||
1 => '>=',
|
||||
2 => '>',
|
||||
];
|
||||
|
||||
/**
|
||||
* @config
|
||||
* reach_level
|
||||
* grades
|
||||
* - name
|
||||
* - value
|
||||
*/
|
||||
public function saveSetting($params, $promote)
|
||||
{
|
||||
$id = $params['id'] ?? 0;
|
||||
|
||||
$setting = null;
|
||||
if ($id > 0) {
|
||||
$setting = M('promote_grade_setting', 'tab_')->where(['id' => $id])->find();
|
||||
if (is_null($setting)) {
|
||||
throw new \Exception('记录不存在');
|
||||
}
|
||||
if ($setting['company_id'] != $promote['company_id']) {
|
||||
throw new \Exception('不允许修改其他公司的配置');
|
||||
}
|
||||
} else {
|
||||
$setting = M('promote_grade_setting', 'tab_')->where(['company_id' => $promote['company_id']])->find();
|
||||
if ($setting) {
|
||||
throw new \Exception('您已经设置过了');
|
||||
}
|
||||
}
|
||||
|
||||
$config = [];
|
||||
$config['reach_level'] = $params['level'];
|
||||
$config['grades'] = $this->sortGrades($params['grades']);
|
||||
$config['default_grade_name'] = $params['default_grade_name'];
|
||||
|
||||
$data = [];
|
||||
$data['status'] = 1;
|
||||
$data['name'] = $params['name'];
|
||||
$data['config'] = json_encode($config);
|
||||
|
||||
if ($setting) {
|
||||
$data['create_time'] = time();
|
||||
M('promote_grade_setting', 'tab_')->where(['id' => $id])->save($data);
|
||||
} else {
|
||||
$data['company_id'] = $promote['company_id'];
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
M('promote_grade_setting', 'tab_')->add($data);
|
||||
}
|
||||
}
|
||||
|
||||
private function sortGrades($grades)
|
||||
{
|
||||
if (count($grades) == 0) {
|
||||
return $grades;
|
||||
}
|
||||
$values = [];
|
||||
$symbols = [];
|
||||
foreach ($grades as $key => $row) {
|
||||
$values[$key] = $row['value'];
|
||||
$symbols[$key] = $row['symbol'];
|
||||
}
|
||||
|
||||
array_multisort($values, SORT_ASC, $symbols, SORT_ASC, $grades);
|
||||
return $grades;
|
||||
}
|
||||
|
||||
public function getCurrentSetting($promote)
|
||||
{
|
||||
return M('promote_grade_setting', 'tab_')->where(['status' => 1, 'company_id' => $promote['company_id']])->find();
|
||||
}
|
||||
|
||||
public function searchGradeByPromotes($promotes, $params, $setting)
|
||||
{
|
||||
$config = json_decode($setting['config'], true);
|
||||
$settingLevel = $config['reach_level'];
|
||||
$month = $params['month'] ?? date('Y-m');
|
||||
$promoteIds = array_column($promotes, 'id');
|
||||
$beginTime = strtotime($month . '-01 00:00:00');
|
||||
$endDate = date('Y-m-01 00:00:00', strtotime($month . '-01' . ' +1 month'));
|
||||
$endTime = strtotime($endDate) - 1;
|
||||
|
||||
$betweenTime = [$beginTime, $endTime];
|
||||
|
||||
$userSubSql = M('user', 'tab_')
|
||||
->field(['id'])
|
||||
->where(['register_time' => ['between', $betweenTime], 'promote_id' => ['in', $promoteIds]])
|
||||
->group('promote_id')
|
||||
->select(false);
|
||||
|
||||
$accountItems = M('user_play_info', 'tab_')
|
||||
->field(['promote_id', 'count(DISTINCT user_id) num'])
|
||||
->where([
|
||||
'role_level' => ['egt', $settingLevel],
|
||||
'create_time' => ['between', $betweenTime],
|
||||
'promote_id' => ['in', $promoteIds],
|
||||
'_string' => 'user_id in (' . $userSubSql . ')'
|
||||
])
|
||||
->group('promote_id')
|
||||
->select();
|
||||
$accountItems = index_by_column('promote_id', $accountItems);
|
||||
|
||||
$amountItems = M('spend', 'tab_')
|
||||
->field(['promote_id', 'sum(pay_amount) amount'])
|
||||
->where([
|
||||
'pay_time' => ['between', $betweenTime],
|
||||
'pay_status' => 1, 'promote_id' => ['in', $promoteIds],
|
||||
'_string' => 'user_id in (' . $userSubSql . ')'
|
||||
])
|
||||
->group('promote_id')
|
||||
->select();
|
||||
$amountItems = index_by_column('promote_id', $amountItems);
|
||||
|
||||
$promoteService = new PromoteService();
|
||||
|
||||
$records = [];
|
||||
foreach ($promotes as $promote) {
|
||||
$amountItem = $amountItems[$promote['id']] ?? null;
|
||||
$accountItem = $accountItems[$promote['id']] ?? null;
|
||||
$amount = $amountItem ? $amountItem['amount'] : 0;
|
||||
$num = $accountItem ? $accountItem['num'] : 0;
|
||||
$value = $num == 0 ? 0 : round($amount / $num, 2);
|
||||
$records[] = [
|
||||
'id' => $promote['id'],
|
||||
'level' => $promote['level'],
|
||||
'amount' => $amount,
|
||||
'num' => $num,
|
||||
'real_name' => hideRealName($promote['real_name']),
|
||||
'account' => $promote['account'],
|
||||
'promote_group' => $promoteService->getGroupNameByChain($promote['chain'], $promote['id']),
|
||||
'value' => $value,
|
||||
'grade_name' => $this->getGradeByValue($value, $setting),
|
||||
'current_display' => ''
|
||||
];
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
public function getGradeByValue($value, $setting)
|
||||
{
|
||||
$config = json_decode($setting['config'], true);
|
||||
$grades = $config['grades'];
|
||||
$gradeName = $config['default_grade_name'];
|
||||
foreach ($grades as $key => $grade) {
|
||||
if ($key == 0 && !$this->isBigger($value, $grade)) {
|
||||
$gradeName = $config['default_grade_name'];
|
||||
break;
|
||||
}
|
||||
$nextGrade = $grades[$key + 1] ?? null;
|
||||
if ($this->isBigger($value, $grade) && !$this->isBigger($value, $nextGrade)) {
|
||||
$gradeName = $grade['name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $gradeName;
|
||||
}
|
||||
|
||||
private function isBigger($value, $grade)
|
||||
{
|
||||
if (is_null($grade)) {
|
||||
return false;
|
||||
}
|
||||
if ($grade['symbol'] == 1 && $value >= $grade['value']) {
|
||||
return true;
|
||||
} elseif ($grade['symbol'] == 2 && $value > $grade['value']) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Base\Model\PromoteModel;
|
||||
use Base\Service\PromoteService;
|
||||
use Base\Service\PromoteGradeService;
|
||||
|
||||
class PromoteGradeController extends BaseController
|
||||
{
|
||||
protected function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
$loginPromote = $this->getLoginPromote();
|
||||
if((C('APP_ENV') == 'dev' || $loginPromote['company_id'] == 334) && $loginPromote['level'] <= 2) {
|
||||
|
||||
} else {
|
||||
return $this->error('您没有权限');
|
||||
}
|
||||
}
|
||||
|
||||
public function index($p = 1)
|
||||
{
|
||||
$month = I('month', date('Y-m'));
|
||||
$loginPromote = $this->getLoginPromote();
|
||||
|
||||
$promoteGradeService = new PromoteGradeService();
|
||||
$setting = $promoteGradeService->getCurrentSetting($loginPromote);
|
||||
if (is_null($setting)) {
|
||||
return $this->error('未设置评级规则');
|
||||
}
|
||||
|
||||
$parentId = I('parent_id', 0);
|
||||
$promoteId = I('promote_id', 0);
|
||||
$searchLevel = 0;
|
||||
$searchLevelName = '';
|
||||
$currentDisplay = '';
|
||||
$prevParentId = 0;
|
||||
|
||||
$promoteService = new PromoteService();
|
||||
|
||||
$parent = null;
|
||||
if ($parentId > 0) {
|
||||
$parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
|
||||
$currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
|
||||
$prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
|
||||
} else {
|
||||
$parent = $loginPromote;
|
||||
$currentDisplay = '自己';
|
||||
}
|
||||
|
||||
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select();
|
||||
|
||||
$map = ['parent_id' => $parent['id']];
|
||||
if ($promoteId > 0) {
|
||||
$map['id'] = $promoteId;
|
||||
}
|
||||
|
||||
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
|
||||
list($promotes, $pagination, $count) = $this->paginate($query);
|
||||
|
||||
if (I('p', 1) == 1) {
|
||||
array_unshift($promotes, $parent);
|
||||
}
|
||||
|
||||
$records = $promoteGradeService->searchGradeByPromotes($promotes, [
|
||||
'month' => $month,
|
||||
], $setting);
|
||||
|
||||
if (I('p', 1) == 1) {
|
||||
$records[0]['current_display'] = $currentDisplay;
|
||||
}
|
||||
|
||||
$this->meta_title = '团队评级';
|
||||
|
||||
$this->assign('month', $month);
|
||||
$this->assign('prevParentId', $prevParentId);
|
||||
$this->assign('searchLevelName', $searchLevelName);
|
||||
$this->assign('subPromotes', $subPromotes);
|
||||
$this->assign('parentId', $parentId);
|
||||
$this->assign('records', $records);
|
||||
$this->assign('pagination', $pagination);
|
||||
$this->display();
|
||||
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
$loginPromote = $this->getLoginPromote();
|
||||
$items = M('promote_grade_setting', 'tab_')->where(['company_id' => $loginPromote['company_id']])->select();
|
||||
|
||||
$symbols = PromoteGradeService::$symbols;
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$i = 0;
|
||||
$config = json_decode($item['config'], true);
|
||||
$gradeCount = count($config['grades']) + 1;
|
||||
if ($gradeCount == 1) {
|
||||
$records[] = [
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'grade_count' => $gradeCount,
|
||||
'reach_level' => $config['reach_level'],
|
||||
'grade_name' => $config['default_grade_name'],
|
||||
'grade_value' => '全部'
|
||||
];
|
||||
} else {
|
||||
$firstGrade = $config['grades'][0];
|
||||
$records[] = [
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'grade_count' => $gradeCount,
|
||||
'reach_level' => $config['reach_level'],
|
||||
'grade_name' => $config['default_grade_name'],
|
||||
'grade_value' => ($firstGrade['symbol'] == 1 ? '<' : '<=') . $firstGrade['value']
|
||||
];
|
||||
foreach ($config['grades'] as $key => $grade) {
|
||||
$records[] = [
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'grade_count' => 0,
|
||||
'reach_level' => $config['reach_level'],
|
||||
'grade_name' => $grade['name'],
|
||||
'grade_value' => $symbols[$grade['symbol']] . $grade['value']
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('records', $records);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function setting()
|
||||
{
|
||||
$id = I('id', 0);
|
||||
|
||||
$setting = null;
|
||||
if ($id > 0) {
|
||||
$setting = M('promote_grade_setting', 'tab_')->where(['id' => $id])->find();
|
||||
if (is_null($setting)) {
|
||||
return $this->error('记录不存在');
|
||||
} else {
|
||||
$setting['config'] = json_decode($setting['config'], true);
|
||||
}
|
||||
}
|
||||
$this->assign('setting', $setting);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$id = I('id', 0);
|
||||
if ($id == 0) {
|
||||
return $this->error('记录不存在');
|
||||
}
|
||||
$setting = M('promote_grade_setting', 'tab_')->field(['id'])->where(['id' => $id])->find();
|
||||
if (is_null($setting)) {
|
||||
return $this->error('记录不存在');
|
||||
}
|
||||
|
||||
M('promote_grade_setting', 'tab_')->where(['id' => $id])->delete();
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
public function saveSetting()
|
||||
{
|
||||
$params = I('post.');
|
||||
$loginPromote = $this->getLoginPromote();
|
||||
$promoteGradeService = new PromoteGradeService();
|
||||
try {
|
||||
$promoteGradeService->saveSetting($params, $loginPromote);
|
||||
return $this->success('保存成功');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
<extend name="Public/promote_base"/>
|
||||
<block name="css">
|
||||
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
|
||||
<style>
|
||||
.form-group {
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-group label {
|
||||
line-height: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
.pointer-hand {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</block>
|
||||
<block name="body">
|
||||
<div class="page-list normal_list promote-mychlid-list">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>评级管理></span><span>团队评级</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_normal_game.png">
|
||||
<span class="title_main">团队评级</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-search clearfix">
|
||||
<form action="{:U('PromoteGrade/index',['row'=>I('get.row')])}" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="parent_id" value="{:I('parent_id', 0)}">
|
||||
<div class="form-group normal_space">
|
||||
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">请选择{$searchLevelName}</option>
|
||||
<volist name="subPromotes" id="promote">
|
||||
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>
|
||||
{$promote.account}({$promote.real_name})
|
||||
<?=$promote['group_remark'] ? ' - ' . $promote['group_remark'] : '' ?>
|
||||
</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group normal_space fr">
|
||||
<input type="text" class="txt month-date" name="month" placeholder="月份" value="{$month}" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="submit normal_space" value="查询">
|
||||
</div>
|
||||
<?php if ($prevParentId > 0):?>
|
||||
<div class="form-group">
|
||||
<a class="submit normal_space" href="{:U('PromoteGrade/index', ['row'=>I('get.row'), 'parent_id' => $prevParentId, 'month'=>$month])}" style="line-height: 36px; display: inline-block; text-align: center; background: #E5E5E5; color: #2bd8ed; cursor: pointer;">返回上级</a>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<div class="trunk-list list_normal">
|
||||
<table class="table normal_table">
|
||||
<tr class="odd">
|
||||
<th>账号(姓名)</th>
|
||||
<th>等级</th>
|
||||
<th>系数值</th>
|
||||
<th>当月玩家达标个数</th>
|
||||
<th>当月注册充值总额</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
<empty name="records">
|
||||
<tr><td colspan="14" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
|
||||
<else />
|
||||
<volist name="records" id="record" mod="2">
|
||||
<tr data-id="{$record.id}" class="<eq name='mod' value='1'>odd</eq>">
|
||||
<td>{$record.account}({$record.real_name}
|
||||
<?php if($record['promote_group'] != ''):?>
|
||||
/{$record.promote_group}
|
||||
<?php endif;?>
|
||||
)
|
||||
<?php if($record['current_display'] != ''):?>
|
||||
<span style="color: #06C;">[{$record['current_display']}]</span>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
<td>{$record.grade_name}</td>
|
||||
<td>{$record.value}</td>
|
||||
<td>{$record.num}</td>
|
||||
<td>{$record.amount}</td>
|
||||
<td>
|
||||
<?php if($record['current_display'] == '' && $record['level'] < 4):?>
|
||||
<a href="{:U('PromoteGrade/index', ['parent_id' => $record['id'], 'month' => I('month', '')])}">查看下级</a>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
</volist>
|
||||
</empty>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="pagenation clearfix">
|
||||
<?php if ($loginer['level'] !== 4) :?>
|
||||
<a id="sch-btn" href="{:U('download/promote_grade_export',array_merge(['parent_id'=>$parentId,'month'=>$month],I('post.')))}" class="ajax-get">导出</a>
|
||||
<?php endif ;?>
|
||||
{$pagination}
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-explain promote-mychlid-explain">
|
||||
<div class="trunk-content article border_normal">
|
||||
<!-- <table class="desccontent">
|
||||
<tr><td class="title" style="width: 100px;display: inline-block;">二级渠道说明:</td><td class="det">推广员默认为一级渠道,一级渠道可通过推广员后台新增二级渠道;二级渠道由一级渠道管理开启权限,并由一级渠道给二级渠道结算,结算可到财务管理操作。</td></tr>
|
||||
</table>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<link rel="stylesheet" href="__STATIC__/flatpickr/flatpickr.min.css">
|
||||
<script src="__STATIC__/flatpickr/flatpickr.min.js"></script>
|
||||
<script src="__STATIC__/flatpickr/l10n/zh.js"></script>
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
<eq name='timeout' value='1'>
|
||||
<script>
|
||||
layer.msg('时间间隔不能超过31天');
|
||||
</script>
|
||||
</eq>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var defaultDate = $('.month-date').val()
|
||||
$('.month-date').flatpickr({
|
||||
locale: 'zh',
|
||||
dateFormat: "Y-m",
|
||||
defaultDate: defaultDate,
|
||||
})
|
||||
$('.select_gallery').select2()
|
||||
var gameId = $('#game-select').val();
|
||||
var sdkVersion = $('#sdk_version').val();
|
||||
var defaultServerId = $('#server-select').attr('data-server');
|
||||
getGameServers(gameId, sdkVersion, defaultServerId)
|
||||
$('#game-select,#sdk_version').on({
|
||||
change: function name() {
|
||||
gameId = $('#game-select').val();
|
||||
sdkVersion = $('#sdk_version').val();
|
||||
getGameServers(gameId, sdkVersion, 0);
|
||||
}
|
||||
});
|
||||
function getGameServers(gameId, sdkVersion, defaultServerId) {
|
||||
$.ajax({
|
||||
url: "{:U('Query/getGameServers')}",
|
||||
dataType: 'json',
|
||||
data: {game_id: gameId, sdk_version: sdkVersion},
|
||||
success: function(response) {
|
||||
var options = '<option value="0">请选择区服</option>'
|
||||
for (var i in response.data.servers) {
|
||||
var server = response.data.servers[i]
|
||||
var selected = ''
|
||||
if (defaultServerId > 0 && server.id==defaultServerId) {
|
||||
selected = 'selected'
|
||||
}
|
||||
options += '<option value="' + server.server_id + '"' + selected + '>' + server.server_name + '</option>'
|
||||
}
|
||||
$('#server-select').html(options)
|
||||
$("#server-select").val(defaultServerId).trigger("change")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</block>
|
@ -0,0 +1,249 @@
|
||||
<extend name="Public/promote_base"/>
|
||||
<block name="css">
|
||||
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
|
||||
<style>
|
||||
.add-rule {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 15px;
|
||||
width: 80px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
background: #409eff;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.delete-rule {
|
||||
margin-left: 10px;
|
||||
width: 60px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
background: rgb(249,104,104);
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rule-list {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.rule-list .rule-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.rule-list .rule-item .select2 {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.trunk-list .table2 .l {
|
||||
width: 140px;
|
||||
}
|
||||
</style>
|
||||
</block>
|
||||
<block name="body">
|
||||
<div class="page-list normal_list promote-add_chlid-form">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>评级管理></span><span>评级设定</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_normal_ziqudao.png">
|
||||
<span class="title_main">评级设定</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-list list_normal">
|
||||
<form action="{:U('PromoteGrade/saveSetting')}" novalidate="novalidate" method="post" class="base_info" id="rule-form">
|
||||
<table class="table2">
|
||||
<input type="hidden" name="id" value="<?= $setting['id'] ?? 0 ?>">
|
||||
<tr>
|
||||
<td class="l">* 评级规则名称:</td>
|
||||
<td class="r">
|
||||
<input type="text" class="name input-txt txt" name="name" value="<?= $setting['name'] ?? '' ?>" placeholder="请输入评级规则名称">
|
||||
</td>
|
||||
</tr>
|
||||
<?php $settingConfig = $setting ? $setting['config'] : null ?>
|
||||
<tr>
|
||||
<td class="l">* 玩家角色达标等级:</td>
|
||||
<td class="r">
|
||||
<input type="text" class="name input-txt txt" name="level" value="<?= $settingConfig['reach_level'] ?? '' ?>" maxlength="4" minlength="1" placeholder="玩家角色达标等级">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l" style="vertical-align: top; padding-top: 15px;"><span class="req">*</span>等级设定:</td>
|
||||
<td class="r" style="padding-top: 15px;">
|
||||
<div style="margin-bottom: 10px">
|
||||
<input type="text" class="name input-txt txt" name="default_grade_name" id="default_grade_name" value="<?= $settingConfig['default_grade_name'] ?? '' ?>" placeholder="默认等级名称">
|
||||
<span style="font-size: 12px; color: #F8AC59">默认等级名称</span>
|
||||
</div>
|
||||
<button id="add-rule" type="button" class="add-rule">添加等级</button>
|
||||
<div id="rule-list" class="rule-list">
|
||||
<?php if($setting):?>
|
||||
<?php foreach($settingConfig['grades'] as $grade):?>
|
||||
<div class="rule-item">
|
||||
系数值:
|
||||
<select class="symbol-item reselect select_gallery" style="width: 60px;" >
|
||||
<option value="1" <?php if($grade['symbol'] == 1):?>selected<?php endif;?> >>=</option>
|
||||
<option value="2" <?php if($grade['symbol'] == 2):?>selected<?php endif;?> >></option>
|
||||
</select>
|
||||
<input type="text" class="value-item name input-txt txt" value="<?=$grade['value']?>" maxlength="8" minlength="1" placeholder="系数值">
|
||||
|
||||
等级名称:
|
||||
<input type="text" class="name-item name input-txt txt" value="<?=$grade['name']?>" placeholder="等级名称">
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"></td>
|
||||
<td class="r">
|
||||
<input type="button" onclick="check()" class="tj btn" value="保存" title="" style="cursor: pointer;">
|
||||
<a class="back_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();">返回</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(".select_gallery").select2();
|
||||
|
||||
$('#add-rule').on({
|
||||
click: function () {
|
||||
var html = '<div class="rule-item">'
|
||||
+ '系数值:' + "\n"
|
||||
+ '<select class="symbol-item reselect select_gallery" style="width: 60px;" >'
|
||||
+ '<option value="1">>=</option>'
|
||||
+ '<option value="2">></option>'
|
||||
+ '</select>' + "\n"
|
||||
+ '<input type="text" class="value-item name input-txt txt" maxlength="4" minlength="1" placeholder="系数值">' + "\n"
|
||||
+ ' ' + "\n"
|
||||
+ '等级名称:' + "\n"
|
||||
+ '<input type="text" class="name-item name input-txt txt" placeholder="等级名称">'
|
||||
+ '<button type="button" class="delete-rule">删除</button>'
|
||||
+ '</div>';
|
||||
$('#rule-list').append(html)
|
||||
$(".select_gallery").select2();
|
||||
}
|
||||
})
|
||||
|
||||
function check() {
|
||||
if (!validation()) {
|
||||
return
|
||||
}
|
||||
var form = $('#rule-form');
|
||||
var id = form.find('input[name=id]').val()
|
||||
var name = form.find('input[name=name]').val()
|
||||
var level = form.find('input[name=level]').val()
|
||||
var defaultGradeName = form.find('input[name=default_grade_name]').val()
|
||||
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"{:U('saveSetting')}",
|
||||
data:{
|
||||
id: id,
|
||||
name: name,
|
||||
level: level,
|
||||
default_grade_name: defaultGradeName,
|
||||
grades: getGrades()
|
||||
},
|
||||
success:function(res){
|
||||
if(res.status == 1){
|
||||
layer.msg(res.info);
|
||||
setTimeout(function(){
|
||||
window.location.href="{:U('settings')}";
|
||||
},1000);
|
||||
}else{
|
||||
layer.msg(res.info);
|
||||
}
|
||||
}
|
||||
});
|
||||
// $('#form_reg').submit();
|
||||
}
|
||||
|
||||
$('#rule-list').on('click', '.delete-rule', function() {
|
||||
$(this).parents('.rule-item').eq(0).remove()
|
||||
})
|
||||
|
||||
function getGrades() {
|
||||
var grades = []
|
||||
$('#rule-list').children('.rule-item').each(function(index, elem) {
|
||||
var item = $(elem)
|
||||
var symbol = item.find('.symbol-item').val()
|
||||
var value = item.find('.value-item').val()
|
||||
var name = item.find('.name-item').val()
|
||||
grades.push({
|
||||
name: name,
|
||||
value: value,
|
||||
symbol: symbol
|
||||
})
|
||||
})
|
||||
return grades
|
||||
}
|
||||
|
||||
function validation() {
|
||||
var form = $('#rule-form');
|
||||
var name = form.find('input[name=name]').val()
|
||||
var level = form.find('input[name=level]').val()
|
||||
var defaultGradeName = form.find('input[name=default_grade_name]').val()
|
||||
if (name == '') {
|
||||
layer.msg('请输入评级规则名称');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (level == '') {
|
||||
layer.msg('玩家角色达标等级');
|
||||
return false;
|
||||
}
|
||||
var levelReg = /^\d+$/;
|
||||
|
||||
if(!levelReg.test(level)){
|
||||
layer.msg('玩家角色达标等级必须为数字');
|
||||
return false;
|
||||
}
|
||||
if (level > 10000) {
|
||||
layer.msg('玩家角色达标等级不能超过10000');
|
||||
return false;
|
||||
}
|
||||
if (level < 0) {
|
||||
layer.msg('玩家角色不能小于0');
|
||||
return false;
|
||||
}
|
||||
if (defaultGradeName == '') {
|
||||
layer.msg('默认等级名称不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
var grades = getGrades()
|
||||
for(var i in grades) {
|
||||
if (grades[i].name == '') {
|
||||
layer.msg('请输入等级名称');
|
||||
return false;
|
||||
}
|
||||
if (grades[i].value == '') {
|
||||
layer.msg('请输入系数值');
|
||||
return false;
|
||||
}
|
||||
if (grades[i].value < 0) {
|
||||
layer.msg('系数值不能小于0');
|
||||
return false;
|
||||
}
|
||||
|
||||
/* var numReg = /([+]\d+[.]\d+|[-]\d+[.]\d+|\d+[.]\d+|[+]\d+|[-]\d+|\d+)/ig;
|
||||
if(!numReg.test(grades[i].value)){
|
||||
layer.msg('系数值必须为整数或浮点数');
|
||||
return false;
|
||||
} */
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
</block>
|
||||
|
@ -0,0 +1,104 @@
|
||||
<extend name="Public/promote_base"/>
|
||||
<block name="css">
|
||||
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
|
||||
<style>
|
||||
.form-group {
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-group label {
|
||||
line-height: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
.pointer-hand {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</block>
|
||||
<block name="body">
|
||||
<div class="page-list normal_list promote-mychlid-list">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>评级管理></span><span>评级设定</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_normal_game.png">
|
||||
<span class="title_main">评级设定</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-search clearfix">
|
||||
<div class="form-group">
|
||||
<a class="submit normal_space" href="{:U('PromoteGrade/setting')}" style="line-height: 36px; display: inline-block; text-align: center; background: #409eff; color: #ffffff; cursor: pointer;">新增评级规则</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="trunk-list list_normal">
|
||||
<table class="table normal_table">
|
||||
<tr class="odd">
|
||||
<th>ID</th>
|
||||
<th style="width: 200px;">规则名称</th>
|
||||
<th style="width: 200px;">当月注册玩家角色达标等级</th>
|
||||
<th>系数值</th>
|
||||
<th>等级名称</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
<empty name="records">
|
||||
<tr><td colspan="6" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
|
||||
<else />
|
||||
<?php foreach($records as $record):?>
|
||||
<tr data-id="<?=$record['id']?>">
|
||||
<?php if($record['grade_count'] > 0):?>
|
||||
<td rowspan="<?=$record['grade_count']?>"><?=$record['id']?></td>
|
||||
<td rowspan="<?=$record['grade_count']?>"><?=$record['name']?></td>
|
||||
<td rowspan="<?=$record['grade_count']?>"><?=$record['reach_level']?></td>
|
||||
<?php endif;?>
|
||||
<td><?=$record['grade_value']?></td>
|
||||
<td><?=$record['grade_name']?></td>
|
||||
<?php if($record['grade_count'] > 0):?>
|
||||
<td rowspan="<?=$record['grade_count']?>">
|
||||
<a href="{:U('PromoteGrade/setting',['id'=>$record['id']])}" class="editbtn">编辑</a>
|
||||
|
||||
<a href="javascript:;" style="color: red;" class="delete-btn editbtn">删除</a>
|
||||
</td>
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</empty>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-explain promote-mychlid-explain">
|
||||
<div class="trunk-content article border_normal">
|
||||
<!-- <table class="desccontent">
|
||||
<tr><td class="title" style="width: 100px;display: inline-block;">二级渠道说明:</td><td class="det">推广员默认为一级渠道,一级渠道可通过推广员后台新增二级渠道;二级渠道由一级渠道管理开启权限,并由一级渠道给二级渠道结算,结算可到财务管理操作。</td></tr>
|
||||
</table>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<link rel="stylesheet" href="__STATIC__/flatpickr/flatpickr.min.css">
|
||||
<script src="__STATIC__/flatpickr/flatpickr.min.js"></script>
|
||||
<script src="__STATIC__/flatpickr/l10n/zh.js"></script>
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.delete-btn').on({
|
||||
click: function() {
|
||||
var tr = $(this).parents('tr').eq(0)
|
||||
var id = tr.attr('data-id')
|
||||
layer.confirm('是否要删除该设置?', {icon: 3, title:'提示'}, function(index){
|
||||
$.ajax({
|
||||
url: "{:U('PromoteGrade/delete')}",
|
||||
data: {id: id},
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
layer.msg(response.info, {time: 1000}, function() {
|
||||
window.location.href = window.location.href
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</block>
|
Loading…
Reference in New Issue