|
|
<?php
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
|
use User\Api\UserApi as UserApi;
|
|
|
use Org\UcenterSDK\Ucservice;
|
|
|
|
|
|
/**
|
|
|
* 后台首页控制器
|
|
|
* @author yyh
|
|
|
*/
|
|
|
class PlatformController extends ThinkController
|
|
|
{
|
|
|
function game_statistics($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
$user = M('User', 'tab_');
|
|
|
$map['fgame_id'] = array('egt', 0);
|
|
|
$map['puid'] = 0;
|
|
|
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
}
|
|
|
|
|
|
// var_dump($_REQUEST);exit;
|
|
|
if (isset($_REQUEST['game_id']) && $_REQUEST['game_id'] != '') {
|
|
|
$map['tab_game.relation_game_id'] = $_REQUEST['game_id'];
|
|
|
unset($_REQUEST['game_id']);
|
|
|
}
|
|
|
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
//为数据权限添加
|
|
|
setPowerPromoteIds($map);
|
|
|
$data = $user
|
|
|
->field('tab_game.relation_game_id,tab_game.relation_game_name,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count')
|
|
|
->where($map)
|
|
|
->join('tab_game on tab_game.id = fgame_id', 'left')
|
|
|
->group('tab_game.relation_game_id')
|
|
|
->order('count desc,register_time')
|
|
|
->select();
|
|
|
$map2 = array();
|
|
|
$map2['fgame_id'] = array('egt', 0);
|
|
|
$map2['puid'] = 0;
|
|
|
setPowerPromoteIds($map2);
|
|
|
|
|
|
$data2 = $user->field('tab_game.relation_game_id,count(IF(register_time ' . $today . ',1,null)) as today,
|
|
|
count(IF(register_time ' . $week . ',1,null)) as week,
|
|
|
count(IF(register_time ' . $mounth . ',1,null)) as mounth')
|
|
|
->where($map2)
|
|
|
->join('tab_game on tab_game.id = fgame_id', 'left')
|
|
|
->group('tab_game.relation_game_id')
|
|
|
->select();
|
|
|
$data2 = array_column($data2, null, 'relation_game_id');
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
|
|
|
if ($data[$key]['relation_game_id'] == 0) {
|
|
|
$data[$key]['relation_game_name'] = '其他注册';
|
|
|
}
|
|
|
$data[$key]['today'] = $data2[$value['relation_game_id']]['today'];
|
|
|
$data[$key]['week'] = $data2[$value['relation_game_id']]['week'];
|
|
|
$data[$key]['mounth'] = $data2[$value['relation_game_id']]['mounth'];
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
$this->assign('total', $total);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
//dd($data);
|
|
|
$this->meta_title = '游戏注册统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign('games', M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select());
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
|
|
|
function gamepay_statistics($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
$spend = M('Spend', 'tab_');
|
|
|
$deposit = M('Deposit', "tab_");
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
}
|
|
|
|
|
|
//为数据权限添加
|
|
|
setPowerPromoteIds($map);
|
|
|
|
|
|
$map['game_id'] = array('gt', 0);
|
|
|
// var_dump($_REQUEST);exit;
|
|
|
if (isset($_REQUEST['game_id']) && $_REQUEST['game_id'] != '') {
|
|
|
$map['tab_game.relation_game_id'] = $_REQUEST['game_id'];
|
|
|
unset($_REQUEST['game_id']);
|
|
|
}
|
|
|
$map['tab_spend.pay_status'] = 1;
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
|
|
|
$data = $spend
|
|
|
->field('tab_game.relation_game_name as game_name, tab_game.relation_game_id as game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') ->where($map)
|
|
|
->where($map)
|
|
|
->join('tab_game on tab_game.id = tab_spend.game_id', 'left')
|
|
|
->group('tab_game.relation_game_id')
|
|
|
->order('count desc,pay_time')
|
|
|
->select();
|
|
|
|
|
|
//今日、本周、本月不随搜索条件而变动
|
|
|
$map2['tab_spend.pay_status'] = 1;
|
|
|
$map2['game_id'] = array('gt', 0);
|
|
|
setPowerPromoteIds($map2);
|
|
|
$data2 = $spend
|
|
|
->field('tab_game.relation_game_id as game_id, sum(IF(pay_time ' . $today . ',pay_amount,0)) as today,
|
|
|
sum(IF(pay_time ' . $week . ',pay_amount,0)) as week,
|
|
|
sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth')
|
|
|
->join('tab_game on tab_game.id = tab_spend.game_id', 'left')
|
|
|
->where($map2)
|
|
|
->group('tab_game.relation_game_id')
|
|
|
->select();
|
|
|
$data2 = array_column($data2, null, 'game_id');
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
//加入今日、本周、本月数据
|
|
|
$data[$key]['today'] = $data2[$value['game_id']]['today'];
|
|
|
$data[$key]['week'] = $data2[$value['game_id']]['week'];
|
|
|
$data[$key]['mounth'] = $data2[$value['game_id']]['mounth'];
|
|
|
}
|
|
|
$total = $this->data_total($data);
|
|
|
$this->assign('total', $total);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
$this->meta_title = '游戏充值统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->assign('games', M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select());
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
|
|
|
function resway_statistics($p = 0)
|
|
|
{
|
|
|
// var_dump(total(2));exit;
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
|
|
|
$user = M('User', 'tab_');
|
|
|
$map['puid'] = 0;
|
|
|
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
}
|
|
|
|
|
|
// var_dump($_REQUEST);exit;
|
|
|
if (isset($_REQUEST['register_way']) && $_REQUEST['register_way'] != '') {
|
|
|
$map['register_way'] = $_REQUEST['register_way'];
|
|
|
unset($_REQUEST['register_way']);
|
|
|
}
|
|
|
|
|
|
setPowerPromoteIds($map);
|
|
|
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
$data = $user
|
|
|
->field('register_way,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count')
|
|
|
->where($map)
|
|
|
->group('register_way')
|
|
|
->order('count desc,register_time')
|
|
|
->select();
|
|
|
|
|
|
$map2 = array();
|
|
|
$map2['puid'] = 0;
|
|
|
setPowerPromoteIds($map2);
|
|
|
$data2 = $user
|
|
|
->field('register_way,
|
|
|
count(IF(register_time ' . $today . ',1,null)) as today,
|
|
|
count(IF(register_time ' . $week . ',1,null)) as week,
|
|
|
count(IF(register_time ' . $mounth . ',1,null)) as mounth')
|
|
|
->where($map2)
|
|
|
->group('register_way')
|
|
|
->select();
|
|
|
$data2 = array_column($data2, null, 'register_way');
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
$data[$key]['today'] = $data2[$value['register_way']]['today'];
|
|
|
$data[$key]['week'] = $data2[$value['register_way']]['week'];
|
|
|
$data[$key]['mounth'] = $data2[$value['register_way']]['mounth'];
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
$this->meta_title = '注册方式统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign('total', $total);
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
|
|
|
function payway_statistics($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
|
|
|
$deposit = M('Deposit', "tab_");
|
|
|
$user = M('User', 'tab_');
|
|
|
$spend = M('Spend', 'tab_');
|
|
|
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
}
|
|
|
|
|
|
// var_dump($_REQUEST);exit;
|
|
|
if (isset($_REQUEST['pay_way']) && $_REQUEST['pay_way'] != '') {
|
|
|
$map['pay_way'] = array('in', $_REQUEST['pay_way']);
|
|
|
unset($_REQUEST['pay_way']);
|
|
|
}
|
|
|
|
|
|
setPowerPromoteIds($map);
|
|
|
|
|
|
$map['pay_status'] = 1;
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
$data = $spend
|
|
|
->field('pay_way,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count')
|
|
|
->where($map)
|
|
|
->group('pay_way')
|
|
|
->order('count desc,pay_time')
|
|
|
->select();
|
|
|
|
|
|
$map2 = array();
|
|
|
$map2['pay_status'] = 1;
|
|
|
setPowerPromoteIds($map2);
|
|
|
$data2 = $spend
|
|
|
->field('pay_way,
|
|
|
sum(IF(pay_time ' . $today . ',pay_amount,0)) as today,
|
|
|
sum(IF(pay_time ' . $week . ',pay_amount,0)) as week,
|
|
|
sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth')
|
|
|
->where($map2)
|
|
|
->group('pay_way')
|
|
|
->select();
|
|
|
$data2 = array_column($data2, null, 'pay_way');
|
|
|
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
$data[$key]['today'] = $data2[$value['pay_way']]['today'];
|
|
|
$data[$key]['week'] = $data2[$value['pay_way']]['week'];
|
|
|
$data[$key]['mounth'] = $data2[$value['pay_way']]['mounth'];
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
$this->assign('total', $total);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
$this->meta_title = '充值方式统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
|
|
|
function promote_statistics($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
$user = M('User', 'tab_');
|
|
|
// $map['promote_id'] = array('egt', 0);
|
|
|
// $map['puid'] = 0;
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
}
|
|
|
//TODO:应需求,取消玩家表,只要user表的fgame有就算注册无需在play表存在
|
|
|
$play_map = false;
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
$map['fgame_name'] = ['like', "{$_REQUEST['game_name']}%"];
|
|
|
// $play_map = " and up.game_name = '{$_REQUEST['game_name']}' ";
|
|
|
}
|
|
|
$play_info_map = false;
|
|
|
if (isset($_REQUEST['server_id'])) {
|
|
|
$play_map = false; //有区服就不检索玩家表,有区服一定已经选择游戏了
|
|
|
$play_info_map = " and upi.server_id = '{$_REQUEST['server_id']}' and upi.game_name = '{$_REQUEST['game_name']}'";
|
|
|
}
|
|
|
|
|
|
if (!empty($_REQUEST['admin_id'])) {
|
|
|
$map['promote.admin_id'] = $_REQUEST['admin_id'];
|
|
|
}
|
|
|
|
|
|
if (!empty($_REQUEST['game_type'])) {
|
|
|
$map['tab_game.sdk_version'] = $_REQUEST['game_type'];
|
|
|
}
|
|
|
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
|
|
|
if (isset($_REQUEST['promote_id'])) {
|
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
|
if ($promoter_ids) {
|
|
|
$map['u.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 如果是市场专员那么只能看自己的会长信息
|
|
|
$isMarketAdmin = isMarketAdmin();
|
|
|
if ($isMarketAdmin) {
|
|
|
$map['promote.admin_id'] = is_login();
|
|
|
}
|
|
|
|
|
|
//为数据权限添加
|
|
|
setPowerPromoteIds($map, 'u.promote_id');
|
|
|
|
|
|
$data = M("User u","tab_")
|
|
|
->field("
|
|
|
count(u.id) as count,
|
|
|
tab_game.relation_game_id,
|
|
|
tab_game.relation_game_name,
|
|
|
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',
|
|
|
u.promote_id,
|
|
|
substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id")
|
|
|
->join("tab_promote promote ON u.promote_id = promote.id","left")
|
|
|
->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false)
|
|
|
// ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false)
|
|
|
->join('tab_game on u.fgame_id = tab_game.id')
|
|
|
->where($map)
|
|
|
->group('tab_game.relation_game_id, id')
|
|
|
->order('count desc, register_time')
|
|
|
->select();
|
|
|
//今日/本周/本月不变
|
|
|
$tmap = $map;
|
|
|
if(isset($tmap['register_time'])){
|
|
|
//获取最大最小
|
|
|
$tweek = total(2,false);
|
|
|
$tmonth = total(3,false);
|
|
|
//获取最小
|
|
|
$tmin = 0;
|
|
|
if($tweek[1][0] < $tmonth[1][0]){
|
|
|
$tmin = $tweek[1][0];
|
|
|
}else{
|
|
|
$tmin = $tmonth[1][0];
|
|
|
}
|
|
|
$tmap['register_time'] = ['between', array($tmin,$tmonth[1][1])];
|
|
|
}
|
|
|
|
|
|
$tdata = M("User u","tab_")
|
|
|
->field("count(IF(register_time {$today},1,null)) as today,
|
|
|
count(IF(register_time {$week},1,null)) as week,
|
|
|
count(IF(register_time {$mounth},1,null)) as mounth,
|
|
|
tab_game.relation_game_id,tab_game.relation_game_name,
|
|
|
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id")
|
|
|
->join("tab_promote promote ON u.promote_id = promote.id","left")
|
|
|
->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false)
|
|
|
->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false)
|
|
|
->join('tab_game on u.fgame_id = tab_game.id')
|
|
|
->where($tmap)
|
|
|
->group('tab_game.relation_game_id, id')
|
|
|
->order('register_time')
|
|
|
->select();
|
|
|
|
|
|
$tmdata = [];
|
|
|
foreach($data as $k=>$v){
|
|
|
$v['today'] = 0;
|
|
|
$v['week'] = 0;
|
|
|
$v['mounth'] = 0;
|
|
|
$tag = "{$v['id']}-{$v['relation_game_id']}";
|
|
|
$tmdata[$tag] = $v;
|
|
|
}
|
|
|
|
|
|
// 填入日/周/月统计
|
|
|
if(!empty($tdata)){
|
|
|
foreach ($tdata as $k => $v) {
|
|
|
$tag = "{$v['id']}-{$v['relation_game_id']}";
|
|
|
$tmdata[$tag]['today'] = $v['today'];
|
|
|
$tmdata[$tag]['week'] = $v['week'];
|
|
|
$tmdata[$tag]['mounth'] = $v['mounth'];
|
|
|
if (empty($tmdata[$tag]['relation_game_name']) && !empty($v['relation_game_name'])) {
|
|
|
$tmdata[$tag]['relation_game_name'] = $v['relation_game_name'];
|
|
|
}
|
|
|
$tmdata[$tag]['id'] = $v['id'];
|
|
|
}
|
|
|
}
|
|
|
// if(count($tmdata) >0){
|
|
|
// //获取推广员
|
|
|
// $idstr = implode(",",array_keys($tmdata));
|
|
|
// $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select();
|
|
|
// foreach($promoteRes as $k=>$v){
|
|
|
// $tmdata[$v['id']]['promote_account'] = $v['promote_account'];
|
|
|
// }
|
|
|
// }
|
|
|
// $data = [];
|
|
|
// foreach($tmdata as $k => $v){
|
|
|
// if($v['id'] == 0){
|
|
|
// $v['promote_account'] = C('OFFICIEL_CHANNEL');
|
|
|
// }
|
|
|
// $data[] = $v;
|
|
|
// }
|
|
|
$data = array_values($tmdata);
|
|
|
|
|
|
unset($map['tp1.id']);
|
|
|
unset($map['tp1.chain']);
|
|
|
unset($tmap['tp1.id']);
|
|
|
unset($tmap['tp1.chain']);
|
|
|
$map['u.promote_id'] = 0;
|
|
|
$tmap['u.promote_id'] = 0;
|
|
|
$authorityData['count'] = 0;
|
|
|
//数据排序
|
|
|
$last_names = array_column($data,'count');
|
|
|
array_multisort($last_names,SORT_DESC,$data);
|
|
|
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
$companys = !empty($data) ? M('promote', 'tab_')
|
|
|
->field('tab_promote.id, tab_promote.account as promote_account, company_name, sys_member.nickname as admin_username')
|
|
|
->join("tab_promote_company on tab_promote.company_id = tab_promote_company.id", 'left')
|
|
|
->join('sys_member on tab_promote.admin_id = sys_member.uid', 'left')
|
|
|
->where("tab_promote.id in (".implode(',', array_column($data, 'id')).")")->select() : [];
|
|
|
|
|
|
$companys = $companys ? array_column($companys, null, 'id') : [];
|
|
|
foreach ($data as &$item) {
|
|
|
$item['company_name'] = $companys[$item['id']]['company_name'] ?? '无';
|
|
|
$item['admin_username'] = $companys[$item['id']]['admin_username'] ?? '无';
|
|
|
if($item['id'] == 0){
|
|
|
$item['promote_account'] = C('OFFICIEL_CHANNEL');
|
|
|
} else {
|
|
|
$item['promote_account'] = $companys[$item['id']]['promote_account'];
|
|
|
}
|
|
|
}
|
|
|
$this->meta_title = '渠道注册统计列表';
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign('admin_users', M('member')->field('uid,nickname')->select());
|
|
|
$this->assign('total', $total);
|
|
|
$this->display();
|
|
|
}
|
|
|
//TODO:
|
|
|
public function promotepay_statistics($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
|
|
|
if(!array_key_exists("timestart",$_REQUEST)){
|
|
|
$this->redirect(ACTION_NAME, array('timestart' => date('Y-m-d',strtotime('-7 day')),"timeend"=>date('Y-m-d')));
|
|
|
}
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
$map1['promote_id'] = $map['promote_id'] = array('egt', 0);
|
|
|
$spend = M('Spend', 'tab_');
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} else {
|
|
|
$map['pay_time'] = ['between', array(0, time())];
|
|
|
// $pay_time = " between 0 and " . time();
|
|
|
}
|
|
|
$map1['s.pay_status'] = $map['s.pay_status'] = 1;
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
unset( $map['create_time']);
|
|
|
// var_dump( $promote);
|
|
|
$tweek = total(2,false);
|
|
|
$tmonth = total(3,false);
|
|
|
//获取最小
|
|
|
$tmin = 0;
|
|
|
if($tweek[1][0] < $tmonth[1][0]){
|
|
|
$tmin = $tweek[1][0];
|
|
|
}else{
|
|
|
$tmin = $tmonth[1][0];
|
|
|
}
|
|
|
|
|
|
if (isset($_REQUEST['promote_id'])) {
|
|
|
//$map['tp1.id'] = $_REQUEST['promote_id'];
|
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
|
if ($promoter_ids) {
|
|
|
$map['tp1.id'] = $_REQUEST['promote_id'];
|
|
|
$map['tp2.id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
|
}
|
|
|
} else {
|
|
|
$map['tp1.chain'] = '/';
|
|
|
}
|
|
|
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
$map['s.game_name'] = ['like', "{$_REQUEST['game_name']}%"];
|
|
|
if (isset($_REQUEST['server_id'])) {
|
|
|
$map['s.server_id'] = $_REQUEST['server_id'];
|
|
|
unset($_REQUEST['server_id']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!empty($_REQUEST['game_type'])) {
|
|
|
$map['s.sdk_version'] = $_REQUEST['game_type'];
|
|
|
}
|
|
|
|
|
|
if (isMarketAdmin()) {
|
|
|
$map['s.market_admin_id'] = is_login();
|
|
|
} else if (!empty($_REQUEST['admin_id'])) {
|
|
|
$map['s.market_admin_id'] = $_REQUEST['admin_id'];
|
|
|
} else {
|
|
|
//为数据权限添加
|
|
|
setPowerPromoteIds($map, 'tp1.id');
|
|
|
}
|
|
|
|
|
|
$data = M('promote', 'tab_')->alias('tp1')
|
|
|
->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name,
|
|
|
floor(sum(pay_amount)*100) as count')
|
|
|
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
|
|
|
->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left')
|
|
|
->join("tab_game as g on g.id = s.game_id", 'left')
|
|
|
->where($map)
|
|
|
->group('tp1.id, g.relation_game_id')
|
|
|
->order('count desc')
|
|
|
->select();
|
|
|
|
|
|
// if (isset($_REQUEST['server_id'])||isset($_REQUEST['game_name'])||isset($_REQUEST['promote_id'])||isset($_REQUEST['admin_id'])||isset($_REQUEST['admin_user_id'])) {
|
|
|
// $data = M('promote', 'tab_')->alias('tp1')
|
|
|
// ->field('tp1.account as promote_account,tp1.id,
|
|
|
// floor(sum(pay_amount)*100) as count')
|
|
|
// ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
|
|
|
// ->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left')
|
|
|
// ->join("tab_game as g on g.id = s.game_id", 'left')
|
|
|
// ->where($map)
|
|
|
// ->group('tp1.id')
|
|
|
// ->order('count desc')
|
|
|
// ->select();
|
|
|
// } else {
|
|
|
// $statisticsMap['time'] =$map['pay_time'];
|
|
|
// setPowerPromoteIds($statisticsMap, 'tab_promote.id');
|
|
|
// $data = M('promote_statistics', 'tab_')
|
|
|
// ->field("promote_account,promote_id as id,sum(count) count")
|
|
|
// ->join('tab_promote on tab_promote.id = tab_promote_statistics.promote_id', 'left')
|
|
|
// ->where($statisticsMap)
|
|
|
// ->group("promote_id")
|
|
|
// ->select();
|
|
|
// }
|
|
|
|
|
|
|
|
|
// var_dump($data);die();
|
|
|
//今日/本周/本月不变
|
|
|
$tmap = $map;
|
|
|
if(isset($map['pay_time'])){
|
|
|
$tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])];
|
|
|
}
|
|
|
$tdata = M('promote', 'tab_')->alias('tp1')
|
|
|
->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name,
|
|
|
floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today,
|
|
|
floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week,
|
|
|
floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
|
|
|
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
|
|
|
->join("tab_spend as s on tp2.id = s.promote_id", 'left')
|
|
|
->join("tab_game as g on g.id = s.game_id", 'left')
|
|
|
->where($tmap)
|
|
|
->group('tp1.id, g.relation_game_id')
|
|
|
->select();
|
|
|
|
|
|
$tmdata = [];
|
|
|
foreach($data as $k=>$v){
|
|
|
$v['today'] = 0;
|
|
|
$v['week'] = 0;
|
|
|
$v['mounth'] = 0;
|
|
|
$tag = "{$v['id']}-{$v['relation_game_id']}";
|
|
|
$tmdata[$tag] = $v;
|
|
|
}
|
|
|
//dd($data);
|
|
|
foreach ($tdata as $k => $v) {
|
|
|
|
|
|
$tag = "{$v['id']}-{$v['relation_game_id']}";
|
|
|
|
|
|
$tmdata[$tag]['today'] = $v['today'];
|
|
|
$tmdata[$tag]['week'] = $v['week'];
|
|
|
$tmdata[$tag]['mounth'] = $v['mounth'];
|
|
|
if (!$tmdata[$tag]['promote_account']) {
|
|
|
$tmdata[$tag]['promote_account'] = $v['promote_account'];
|
|
|
$tmdata[$tag]['count'] = 0;
|
|
|
}
|
|
|
|
|
|
if (empty( $tmdata[$tag]['relation_game_name']) && !empty($v['relation_game_name'])) {
|
|
|
$tmdata[$tag]['relation_game_name'] = $v['relation_game_name'];
|
|
|
}
|
|
|
|
|
|
$tmdata[$tag]['id'] = $v['id'];
|
|
|
}
|
|
|
|
|
|
$data = [];
|
|
|
foreach($tmdata as $k => $v){
|
|
|
$data[] = $v;
|
|
|
}
|
|
|
//dd($data);
|
|
|
unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id']);
|
|
|
unset($map['tp1.chain']);
|
|
|
unset($tmap['tp1.id']);
|
|
|
unset($tmap['tp1.chain'], $tmap['tp2.id']);
|
|
|
$map['s.promote_id'] = 0;
|
|
|
$tmap['s.promote_id'] = 0;
|
|
|
$authorityData['count'] = 0;
|
|
|
|
|
|
//如果有官方渠道权限
|
|
|
$user_auth_promote_ids = session('user_auth_promote_ids');
|
|
|
if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) {
|
|
|
//官方渠道数据添加
|
|
|
$authorityData = M('spend', 'tab_')->alias('s')
|
|
|
->field('floor(sum(pay_amount)*100) as count')
|
|
|
->where($map)
|
|
|
->find();
|
|
|
$tauthorityData = M('spend', 'tab_')->alias('s')
|
|
|
->field('
|
|
|
floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today,
|
|
|
floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week,
|
|
|
floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
|
|
|
->where($tmap)
|
|
|
->find();
|
|
|
$authorityData['today'] = $tauthorityData['today'];
|
|
|
$authorityData['week'] = $tauthorityData['week'];
|
|
|
$authorityData['mounth'] = $tauthorityData['mounth'];
|
|
|
}
|
|
|
$authorityData['promote_account'] = "官方渠道";
|
|
|
$authorityData['id'] = "1";
|
|
|
if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) {
|
|
|
$authorityData = [];
|
|
|
} else {
|
|
|
array_push($data, $authorityData);
|
|
|
}
|
|
|
|
|
|
//数据排序
|
|
|
$last_names = array_column($data,'count');
|
|
|
array_multisort($last_names,SORT_DESC,$data);
|
|
|
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
$value['count'] ?: 0;
|
|
|
$value['today'] ?: 0;
|
|
|
$value['week'] ?: 0;
|
|
|
$value['mounth'] ?: 0;
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
$data[$key]['count'] = $value['count'] / 100;
|
|
|
$data[$key]['today'] = $value['today'] / 100;
|
|
|
$data[$key]['week'] = $value['week'] / 100;
|
|
|
$data[$key]['mounth'] = $value['mounth'] / 100;
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
$this->assign('total', $total);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$companys = !empty($data) ? M('promote', 'tab_')
|
|
|
->field('tab_promote.id, company_name, sys_member.nickname as admin_username')
|
|
|
->join("tab_promote_company on tab_promote.company_id = tab_promote_company.id", 'left')
|
|
|
->join('sys_member on tab_promote.admin_id = sys_member.uid', 'left')
|
|
|
->where("tab_promote.id in (".implode(',', array_column($data, 'id')).")")->select() : [];
|
|
|
$companys = $companys ? array_column($companys, null, 'id') : [];
|
|
|
foreach ($data as &$item) {
|
|
|
$item['company_name'] = $companys[$item['id']]['company_name'] ?? '无';
|
|
|
$item['admin_username'] = $companys[$item['id']]['admin_username'] ?? '无';
|
|
|
}
|
|
|
|
|
|
if(isset($_REQUEST['export'])){
|
|
|
|
|
|
$GetData = $_GET;
|
|
|
unset($GetData['export']);
|
|
|
|
|
|
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出推广员充值统计','url'=>U('Platform/promotepay_statistics',$GetData),'menu'=>'统计-统计-推广员统计-推广员充值统计']);
|
|
|
|
|
|
data2csv($data,'推广员充值统计',array(
|
|
|
'company_name' => '公司',
|
|
|
"promote_account"=>"会长账号",
|
|
|
'admin_username' => '当前市场专员',
|
|
|
"count"=>"累计充值",
|
|
|
"rand"=>"排行榜",
|
|
|
"today"=>"今日充值",
|
|
|
"week"=>"本周充值",
|
|
|
"mounth"=>"本月充值",
|
|
|
));
|
|
|
}
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
|
$this->meta_title = '渠道充值统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign('admin_users', M('member')->field('uid,nickname')->select());
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->display();
|
|
|
|
|
|
}
|
|
|
public function promotepay_statistics1($p = 0)
|
|
|
{
|
|
|
$page = intval($p);
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$arraypage = $page;
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
$map1['promote_id'] = $map['promote_id'] = array('egt', 0);
|
|
|
$spend = M('Spend', 'tab_');
|
|
|
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
|
|
|
unset($_REQUEST['timestart']);
|
|
|
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
|
|
|
$map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
|
|
|
unset($_REQUEST['timeend']);
|
|
|
} else {
|
|
|
$map['pay_time'] = ['between', array(0, time())];
|
|
|
// $pay_time = " between 0 and " . time();
|
|
|
}
|
|
|
$map1['pay_status'] = $map['pay_status'] = 1;
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
unset( $map['create_time']);
|
|
|
|
|
|
//获取所有会长
|
|
|
$promote_map = "`chain` = '/'";
|
|
|
if (isset($_REQUEST['promote_id'])) {
|
|
|
$promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}";
|
|
|
}
|
|
|
//为数据权限添加
|
|
|
setPowerPromoteIds($map);
|
|
|
$promote_map2 = array();
|
|
|
setPowerPromoteIds($promote_map2, 'id');
|
|
|
$promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->where($promote_map2)->select();
|
|
|
$pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount'];
|
|
|
|
|
|
// var_dump( $promote);
|
|
|
$tweek = total(2,false);
|
|
|
$tmonth = total(3,false);
|
|
|
//获取最小
|
|
|
$tmin = 0;
|
|
|
if($tweek[1][0] < $tmonth[1][0]){
|
|
|
$tmin = $tweek[1][0];
|
|
|
}else{
|
|
|
$tmin = $tmonth[1][0];
|
|
|
}
|
|
|
|
|
|
|
|
|
$data =array();
|
|
|
for ($i=0; $i < count($promote); $i++) {
|
|
|
# code...
|
|
|
$proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select();
|
|
|
$str = '';
|
|
|
for($k=0; $k<count($proid); $k++){
|
|
|
# code...
|
|
|
$str .= ($proid[$k]['id'].",");
|
|
|
}
|
|
|
$str .= "{$promote[$i]['id']}";
|
|
|
$map['promote_id'] = array("in",$str);
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
$map['game_name'] = $_REQUEST['game_name'];
|
|
|
if (isset($_REQUEST['server_id'])) {
|
|
|
$map['server_name'] = $_REQUEST['server_id'];
|
|
|
unset($_REQUEST['server_id']);
|
|
|
}
|
|
|
}
|
|
|
$dbdata = $spend
|
|
|
->field('floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count')
|
|
|
->where($map)
|
|
|
->find();
|
|
|
$tmap = $map;
|
|
|
if(isset($map['pay_time'])){
|
|
|
$tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])];
|
|
|
}
|
|
|
$tdbdata = $spend
|
|
|
->field('
|
|
|
floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today,
|
|
|
floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week,
|
|
|
floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
|
|
|
->where($tmap)
|
|
|
->find();
|
|
|
$dbdata['today']= $tdbdata['today'];
|
|
|
$dbdata['week']= $tdbdata['week'];
|
|
|
$dbdata['mounth']= $tdbdata['mounth'];
|
|
|
|
|
|
$dbdata['promote_account'] = $promote[$i]['account'];
|
|
|
$dbdata['promote_id'] = $promote[$i]['id'];
|
|
|
|
|
|
$data[] = $dbdata;
|
|
|
}
|
|
|
$count = count($data);
|
|
|
foreach ($data as $key => $value) {
|
|
|
$value['count'] ?: 0;
|
|
|
$value['today'] ?: 0;
|
|
|
$value['week'] ?: 0;
|
|
|
$value['mounth'] ?: 0;
|
|
|
static $i = 0;
|
|
|
$i++;
|
|
|
$data[$key]['rand'] = $i;
|
|
|
$data[$key]['count'] = $value['count'] / 100;
|
|
|
$data[$key]['today'] = $value['today'] / 100;
|
|
|
$data[$key]['week'] = $value['week'] / 100;
|
|
|
$data[$key]['mounth'] = $value['mounth'] / 100;
|
|
|
}
|
|
|
|
|
|
$total = $this->data_total($data);
|
|
|
$this->assign('total', $total);
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($pcount, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
|
|
|
|
$size = $row;//每页显示的记录数
|
|
|
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
$this->meta_title = '渠道充值统计列表';
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->assign("is_admin",is_administrator());
|
|
|
$this->display();
|
|
|
|
|
|
}
|
|
|
|
|
|
public function data_total($data)
|
|
|
{
|
|
|
$total['sum_count'] = array_sum(array_column($data, 'count'));
|
|
|
$total['sum_today'] = array_sum(array_column($data, 'today'));
|
|
|
$total['sum_week'] = array_sum(array_column($data, 'week'));
|
|
|
$total['sum_mounth'] = array_sum(array_column($data, 'mounth'));
|
|
|
return $total;
|
|
|
}
|
|
|
|
|
|
function day_data($model = 'User', $column1 = array(), $column2 = 'count')
|
|
|
{
|
|
|
//今日本周本月不跟随选择的实现变动 只以当前日期为基准
|
|
|
$table = M($model, 'tab_');
|
|
|
$today = total(1);
|
|
|
$week = total(2);
|
|
|
$mounth = total(3);
|
|
|
if ($model == 'User') {
|
|
|
$data['today'] = $table->field('count(id) as count')->where($column1)->where('register_time' . $today)->select();
|
|
|
$data['week'] = $table->field('count(id) as count')->where($column1)->where('register_time' . $week)->select();
|
|
|
$data['mounth'] = $table->field('count(id) as count')->where($column1)->where('register_time' . $mounth)->select();
|
|
|
} elseif ($model == 'Spend') {
|
|
|
$data['today'] = $table->field('sum(pay_amount) as count')->where($column1)->where('pay_time' . $today)->where(array('pay_status' => 1))->select();
|
|
|
$data['week'] = $table->field('sum(pay_amount) as count')->where($column1)->where('pay_time' . $week)->where(array('pay_status' => 1))->select();
|
|
|
$data['mounth'] = $table->field('sum(pay_amount) as count')->where($column1)->where('pay_time' . $mounth)->where(array('pay_status' => 1))->select();
|
|
|
}
|
|
|
foreach ($data as $key => $value) {
|
|
|
$v = reset($value);
|
|
|
$data[$key] = $v['count'];
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
//渠道下注册详细信息
|
|
|
public function zhuce_detail($promote_id, $game_name = '', $server_name = '')
|
|
|
{
|
|
|
$map['promote_id'] = $promote_id;
|
|
|
if (!empty($game_name)) {
|
|
|
$map['fgame_name'] = $game_name;
|
|
|
}
|
|
|
if (empty($server_name)) {
|
|
|
$data = M('user', 'tab_')->field('count(id) as count,fgame_name as game_name')->where($map)->order('fgame_id')->group('game_name')->select();
|
|
|
} else {
|
|
|
$map['server_name'] = $server_name;
|
|
|
$map['game_name'] = $map['fgame_name'];
|
|
|
unset($map['fgame_name']);
|
|
|
$data = M('user_play_info', 'tab_')->field('count(user_id) as count,game_name')->where($map)->order('game_id')->group('game_name')->select();
|
|
|
}
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
//渠道下充值详细信息
|
|
|
public function chongzhi_detail($promote_id, $game_name = '', $server_name = '')
|
|
|
{
|
|
|
$map['promote_id'] = $promote_id;
|
|
|
$map['pay_status'] = 1;
|
|
|
$map['pay_way'] = array('GT', 0);
|
|
|
if ($game_name) {
|
|
|
$map['game_name'] = $game_name;
|
|
|
}
|
|
|
if ($server_name) {
|
|
|
$map['server_name'] = $server_name;
|
|
|
}
|
|
|
$data = M('spend', 'tab_')->field('sum(pay_amount) as total_amount,game_name')->where($map)->order('game_id')->group('game_name')->select();
|
|
|
$this->assign('list_data', $data);
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
public function uc_statistics($p = 1)
|
|
|
{
|
|
|
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
|
|
|
$map .= 'pay_time between ' . strtotime($_REQUEST['timestart']) . ' and ' . (strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1) . ' and ';
|
|
|
}
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
$map .= 'game_name like ' . '"' . '%' . $_REQUEST['game_name'] . '%' . '" and ';
|
|
|
$map1 .= 'game_name like ' . '"' . '%' . $_REQUEST['game_name'] . '%' . '" and ';
|
|
|
$map2 .= 'game_name like ' . '"' . '%' . $_REQUEST['game_name'] . '%' . '" and ';
|
|
|
unset($_REQUEST['game_name']);
|
|
|
}
|
|
|
$map .= " version=1 and ";
|
|
|
$map .= "platform!=1";
|
|
|
$uc = new Ucservice();
|
|
|
$page = $p;
|
|
|
$data = $uc->uc_recharge_select($page, 10, $map);
|
|
|
$map1 .= 'pay_time' . total(1) . ' and ';
|
|
|
$map1 .= " version=1 and ";
|
|
|
$map1 .= "platform!=1";
|
|
|
$map2 .= 'pay_time' . total(5) . ' and ';
|
|
|
$map2 .= " version=1 and ";
|
|
|
$map2 .= "platform!=1";
|
|
|
//今天
|
|
|
$ttotal = $uc->uc_recharge_select($page, 10, $map1)['total'] ? $uc->uc_recharge_select($page, 10, $map1)['total'] : 0;
|
|
|
//昨天
|
|
|
$ytotal = $uc->uc_recharge_select($page, 10, $map2)['total'] ? $uc->uc_recharge_select($page, 10, $map2)['total'] : 0;
|
|
|
//总共
|
|
|
$total = $data['total'] ? $data['total'] : 0;
|
|
|
//该叶
|
|
|
$pagetotal = $data['totalpage'][0]['totalpage'] ? $data['totalpage'][0]['totalpage'] : 0;
|
|
|
$this->meta_title = 'Uc充值列表';
|
|
|
$this->assign('ttotal', $ttotal);
|
|
|
$this->assign('ytotal', $ytotal);
|
|
|
$this->assign('pagetotal', $pagetotal);
|
|
|
$this->assign('total', $total);
|
|
|
$count = $data['count'];
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
unset($data['count']);
|
|
|
unset($data['total']);
|
|
|
unset($data['totalpage']);
|
|
|
$this->assign('data', $data);
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
public function getSpendServer(){
|
|
|
if(isset($_REQUEST['game_name'])){
|
|
|
$game = M('Game','tab_')->field('id')->where(['game_name'=>$_REQUEST['game_name']])->find();
|
|
|
$game_id = $game['id'];
|
|
|
|
|
|
}
|
|
|
if(isset($_REQUEST['game_id'])){
|
|
|
$game_id = $_REQUEST['game_id'];
|
|
|
}
|
|
|
$map['game_id'] = $game_id;
|
|
|
$map['server_name'] = array('neq','');
|
|
|
$data = M('server','tab_')->field('server_name,server_id')->where($map)->group('server_name')->select();
|
|
|
$this->AjaxReturn($data);
|
|
|
}
|
|
|
|
|
|
public function uc_deposit($p = 1)
|
|
|
{
|
|
|
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
|
|
|
$map .= 'create_time between ' . strtotime($_REQUEST['timestart']) . ' and ' . (strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1) . ' and ';
|
|
|
}
|
|
|
$map .= " version=1 and ";
|
|
|
$map .= "platform!=1";
|
|
|
$uc = new Ucservice();
|
|
|
$page = $p;
|
|
|
$data = $uc->uc_deposit_select($page, 10, $map);
|
|
|
$map1 .= 'create_time' . total(1) . ' and ';
|
|
|
$map1 .= " version=1 and ";
|
|
|
$map1 .= "platform!=1";
|
|
|
$map2 .= 'create_time' . total(5) . ' and ';
|
|
|
$map2 .= " version=1 and ";
|
|
|
$map2 .= "platform!=1";
|
|
|
//今天
|
|
|
$ttotal = $uc->uc_deposit_select($page, 10, $map1)['total'] ? $uc->uc_deposit_select($page, 10, $map1)['total'] : 0;
|
|
|
//昨天
|
|
|
$ytotal = $uc->uc_deposit_select($page, 10, $map2)['total'] ? $uc->uc_deposit_select($page, 10, $map2)['total'] : 0;
|
|
|
//总共
|
|
|
$total = $data['total'] ? $data['total'] : 0;
|
|
|
//该叶
|
|
|
$pagetotal = $data['totalpage'][0]['totalpage'] ? $data['totalpage'][0]['totalpage'] : 0;
|
|
|
$this->meta_title = 'Uc平台币充值列表';
|
|
|
$this->assign('ttotal', $ttotal);
|
|
|
$this->assign('ytotal', $ytotal);
|
|
|
$this->assign('pagetotal', $pagetotal);
|
|
|
$this->assign('total', $total);
|
|
|
$count = $data['count'];
|
|
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
|
$row = $_REQUEST['row'];
|
|
|
} else {
|
|
|
$row = 10;
|
|
|
}
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
unset($data['count']);
|
|
|
unset($data['total']);
|
|
|
unset($data['totalpage']);
|
|
|
$this->assign('data', $data);
|
|
|
$this->display();
|
|
|
}
|
|
|
}
|