master
elf@home 4 years ago
parent 3f92608468
commit f13f3f7744

@ -9,6 +9,7 @@ use Base\Repository\SpendRepository;
use Base\Repository\UserRepository;
use Base\Service\PromoteService;
use GuzzleHttp\Client;
use Base\Repository\GameRepository;
/**
* 前台首页控制器
@ -2818,7 +2819,10 @@ class QueryController extends BaseController
$baseGameId = I('game_id', 0);
$deviceType = I('device_type', '');
$timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d'));
$lastSortName = trim(I('last_sort_name', ''));
$sortName = trim(I('sort_name', ''));
$sort = intval(I('sort', 1));
$start = '';
$end = '';
$timeRangeRow = explode(' 至 ', $timeRange);
@ -2834,13 +2838,11 @@ class QueryController extends BaseController
$levelPromote = $this->getLevelPromote();
$queryPromote = $this->getQueryPromote($levelPromote);
$orderType = 'asc';
$orderColumn = 'date';
if ($dataOrder != '')
{
$dataOrder = explode(',', $dataOrder);
$orderType = $dataOrder[1];
$orderColumn = $dataOrder[0];
$orderColumn = $sortName;
$orderType = ($sort == 1) ? 'desc' : 'asc';
if (!empty($sortName)) {
$orderColumn = $sortName;
$orderType = ($sort == 1) ? 'desc' : 'asc';
}
$status = true;
@ -2918,8 +2920,8 @@ class QueryController extends BaseController
$this->assign('baseGames', $baseGames);
// $this->checkListOrCountAuthRestMap($map,[]);
$this->assign('order_type', $orderType);
$this->assign('order_column', $orderColumn);
$this->assign('sortName', $sortName);
$this->assign('sort', $sort);
$this->assign('data', $data);
$this->assign('start', $start);
$this->assign('end', $end);
@ -2928,9 +2930,12 @@ class QueryController extends BaseController
public function gameData()
{
$baseGameId = I('game_id', 0);
$deviceType = I('device_type', '');
$gameId = I('game_id', 0);
$serverId = I('server_id', '');
$timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d'));
$lastSortName = trim(I('last_sort_name', ''));
$sortName = trim(I('sort_name', ''));
$sort = intval(I('sort', 1));
$start = '';
$end = '';
@ -2942,12 +2947,66 @@ class QueryController extends BaseController
$start = $timeRangeRow[0];
$end = $timeRangeRow[0];
}
$spendMap = ['pay_status' => 1];
$roleMap = [];
$map = [];
$betweenTime = [strtotime($start . ' 00:00:00'), strtotime($start . ' 23:59:59')];
$spendMap['pay_time'] = ['between', $betweenTime];
$spendMap['create_time'] = ['between', $betweenTime];
if ($gameId > 0) {
$spendMap['game_id'] = $gameId;
$roleMap['game_id'] = $gameId;
$map['game_id'] = $gameId;
}
if ($serverId == '') {
$spendMap['server_id'] = $serverId;
$roleMap['server_id'] = $serverId;
$map['server_id'] = $serverId;
}
$query = M('game', 'tab_')->where();
list($games, $pagination, $count) = $this->paginate($query);
$spendSubSql = M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where($spendMap)->groupBy('game_id, server_id')->select(false);
$roleSubSql = M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where($roleMap)->groupBy('game_id, server_id')->select(false);
M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where()->groupBy('game_id, server_id')->select();
M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where()->groupBy('game_id, server_id')->select();
$query = M('server', 'tab_')->alias('a')
->field(['a.game_id', 'a.game_name', 'a.server_id', 'a.server_name', 'b.amount', 'c.count'])
->join('left join (' . $spendSubSql . ') b on a.game_id = b.game_id and a.server_id = b.server_id')
->join('left join (' . $roleSubSql . ') c on a.game_id = c.game_id and a.server_id = c.server_id')
->where($map);
$orderBy = '';
$sortNameData = ['amount', 'count'];
if (!empty($sortName)) {
if (in_array($sortName, $sortNameData)) {
$desc = ' desc';
$asc = ' asc';
if ($lastSortName != $sortName) {
$sortString = $desc;
$sort = 1;
} else {
$sortString = ($sort == 1) ? $desc : $asc;
}
$orderBy = $sortName . $sortString;
}
}
if ($orderBy) {
$query->order($orderBy);
}
list($records, $pagination, $count) = $this->paginate($query);
$gameRepository = new GameRepository();
$this->assign('games', $gameRepository->getChoiceGames());
$this->assign('servers', $gameRepository->getServersByGameId($gameId));
$this->assign('sort', $sort);
$this->assign('sortName', $sortName);
$this->assign('records', $records);
$this->assign('start', $start);
$this->assign('end', $end);
$this->display();
}
}

@ -0,0 +1,227 @@
<extend name="Public/promote_base"/>
<block name="css">
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
<link href="__STATIC__/icons_alibaba/iconfont.css?v=1.3" rel="stylesheet">
<style>
.form-group {
float: left;
margin-bottom: 10px;
}
.form-group label {
line-height: 34px;
height: 34px;
}
.iconsort {
font-size: 1rem;
}
.normal_table tr .sort {
color: #145ccd;
cursor: pointer;
}
.trunk-search .select-time .txt {
width: 100px;
}
.title-cursor-pointer {
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 jssearch">
<div class="form-group normal_space fr">
<span id="server_js">
<select id="server_id" name="server_id" class="reselect select_gallery" style="width:101px" data-default="<?=I('server_id', '')?>">
<option server-id="0" value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['server_id']?>" <?php if($server['server_id'] == I('server_id')):?>selected="selected"<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</span>
</div>
<div class="form-group normal_space fr">
<select id="game_id" name="game_id" class="reselect select_gallery">
<option game-id="0" value="">请选择游戏</option>
<?php foreach($games as $game):?>
<option game-id="<?=$game['id']?>" value="<?=$game['id']?>" <?php if($game['id'] == I('game_id')):?>selected="selected"<?php endif;?>>
<?=$game['game_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<include file="Public/promote_select" />
<div class="form-group normal_space fr">
<label>起止时间:</label>
<input type="text" class="txt range-date" name="time_range" placeholder="创建时间" value="{$start} 至 {$end}" >
</div>
<div class="form-group normal_space">
<input type="hidden" name="last_sort_name" id="last_sort_name" value="{:I('sort_name', '')}">
<input type="hidden" name="sort_name" id="sort_name" value="{:I('sort_name', '')}">
<input type="hidden" name="sort" id="sort" value="{$sort}">
<input type="submit" class="submit" id='submit' url="{:U('Query/userretention','model='.$model['name'],false)}"
value="查询">
</div>
</div>
<div class="trunk-list list_normal">
<table class="table normal_table">
<tr class="odd">
<th>游戏名称</th>
<th>区服名称</th>
<th class="sort" sort-name="register_count" class="title-cursor-pointer">创角数
<if condition="'register_count' == I('sort_name', '')">
<if condition="1 == $sort">
<i class="iconfont iconsort-down"></i>
<else/>
<i class="iconfont iconsort-up"></i>
</if>
<else/>
<i class="iconfont iconsort"></i>
</if>
</th>
<th class="sort" sort-name="retention_day1" class="title-cursor-pointer">消费金额
<if condition="'retention_day1' == I('sort_name', '')">
<if condition="1 == $sort">
<i class="iconfont iconsort-down"></i>
<else/>
<i class="iconfont iconsort-up"></i>
</if>
<else/>
<i class="iconfont iconsort"></i>
</if>
</th>
</tr>
<empty name="records">
<tr><td colspan="13" class="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="vo">
<tr>
<td>{$vo.game_name}</td>
<td>{$vo.server_name}</td>
<td>{$vo.count}</td>
<td>{$vo.amount}</td>
</tr>
</volist>
</empty>
</table>
</div>
<div class="pagenation clearfix">
<?php if ($loginer['level'] !== 4) :?>
<a id="sch-btn" data-href="{:U('download/userRoles_data_export',array_merge(['xlsname'=>'ceshi'],I('get.')))}" 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>
<script type="text/javascript" src="__JS__/common.js"></script>
<script type="text/javascript">
$(function() {
setValue('row', '{:I("get.row",10)}');
var defaultDate = $('.range-date').val()
defaultDate = defaultDate == '' ? [] : defaultDate.split(' 至 ')
$('.range-date').flatpickr({
mode: 'range',
locale: 'zh',
dateFormat: "Y-m-d",
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);
}
});
$("#game_id").change(function () {
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: $("#game_id option:selected").attr('game-id') },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
var servers = result.data.servers
var str = "<option value=''>请选择区服</option>"
for (var i in servers){
str += "<option value='"+servers[i].server_id+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
$("#server_js").click(function (event) {
var game_id = $("#game_id").val();
if (game_id == 0) {
layer.msg('请先选择游戏');
}
});
var promoteUrl = "{:U('Query/getSubPromotes')}"
initPromoteSelect(promoteUrl)
$('.sort').click(function () {
var element = $(this);
var sortName = element.attr('sort-name');
var sort = parseInt($('#sort').val());
sort = (sort === 1) ? 2 : 1;
$('#sort').val(sort);
$('#sort_name').val(sortName);
$('#submit').trigger('click');
});
$('#submit').click(function () {
var url = $(this).attr('url');
console.log(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;
});
})
</script>
</block>
Loading…
Cancel
Save