You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

893 lines
38 KiB
PHTML

5 years ago
<?php
namespace Admin\Controller;
5 years ago
use User\Api\UserApi as UserApi;
use Org\UcenterSDK\Ucservice;
5 years ago
/**
* 后台首页控制器
* @author yyh
*/
class PlatformController extends ThinkController
{
function game_statistics($p = 0)
{
5 years ago
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
5 years ago
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
5 years ago
$user = M('User', 'tab_');
$map['fgame_id'] = array('egt', 0);
$map['puid'] = 0;
5 years ago
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']);
}
5 years ago
// var_dump($_REQUEST);exit;
if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') {
$map['fgame_name'] = $_REQUEST['game_name'];
unset($_REQUEST['fgame_name']);
}
$promoteRoot = getPowerPromoteIds();
if ($promoteRoot) {
$map['promote_id'] =array('in',$promoteRoot);
}
$today = total(1);
$week = total(2);
$mounth = total(3);
$data = $user
->field('fgame_name,fgame_id,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(id) as count,
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($map)
->group('fgame_id')
->order('count desc,register_time')
->select();
$count = count($data);
foreach ($data as $key => $value) {
static $i = 0;
$i++;
$data[$key]['rand'] = $i;
5 years ago
if ($data[$key]['fgame_id'] == 0) {
$data[$key]['fgame_name'] = '其他注册';
}
}
5 years ago
$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);
}
5 years ago
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
5 years ago
}
$data = my_sort($data, $data_order_type, (int)$data_order);
$size = $row;//每页显示的记录数
5 years ago
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage - 1) * $size, $size);
5 years ago
$this->meta_title = '游戏注册统计列表';
$this->assign('list_data', $data);
5 years ago
$this->display();
}
function gamepay_statistics($p = 0)
{
$page = intval($p);
5 years ago
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
5 years ago
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
5 years ago
$spend = M('Spend', 'tab_');
$deposit = M('Deposit', "tab_");
$map['game_id'] = array('gt', 0);
5 years ago
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']);
}
5 years ago
$promoteRoot = getPowerPromoteIds();
if ($promoteRoot) {
$map['promote_id'] =array('in',$promoteRoot);
}
5 years ago
// var_dump($_REQUEST);exit;
if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') {
5 years ago
$map['game_id'] = $_REQUEST['game_name'];
unset($_REQUEST['game_name']);
}
$map['pay_status'] = 1;
$today = total(1);
$week = total(2);
$mounth = total(3);
$data = $spend
->field('game_name,game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count,
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($map)
->group('game_id')
->order('count desc,pay_time')
->select();
$count = count($data);
foreach ($data as $key => $value) {
static $i = 0;
$i++;
$data[$key]['rand'] = $i;
}
$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;//每页显示的记录数
5 years ago
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage - 1) * $size, $size);
5 years ago
$this->meta_title = '游戏充值统计列表';
$this->assign('list_data', $data);
5 years ago
$this->display();
}
function resway_statistics($p = 0)
{
5 years ago
// var_dump(total(2));exit;
$page = intval($p);
5 years ago
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
5 years ago
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
5 years ago
$user = M('User', 'tab_');
$map['puid'] = 0;
5 years ago
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']);
}
5 years ago
// var_dump($_REQUEST);exit;
if (isset($_REQUEST['register_way']) && $_REQUEST['register_way'] != '') {
$map['register_way'] = $_REQUEST['register_way'];
5 years ago
unset($_REQUEST['register_way']);
}
$promoteRoot = getPowerPromoteIds();
if ($promoteRoot) {
$map['promote_id'] =array('in',$promoteRoot);
}
$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,
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($map)
->group('register_way')
->order('count desc,register_time')
->select();
$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);
}
$data = my_sort($data, $data_order_type, (int)$data_order);
$size = $row;//每页显示的记录数
5 years ago
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage - 1) * $size, $size);
5 years ago
$this->meta_title = '注册方式统计列表';
$this->assign('list_data', $data);
$this->assign('total', $total);
5 years ago
$this->display();
}
function payway_statistics($p = 0)
{
5 years ago
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
5 years ago
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
5 years ago
$deposit = M('Deposit', "tab_");
$user = M('User', 'tab_');
$spend = M('Spend', 'tab_');
5 years ago
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']);
}
5 years ago
// var_dump($_REQUEST);exit;
if (isset($_REQUEST['pay_way']) && $_REQUEST['pay_way'] != '') {
$map['pay_way'] = array('in', $_REQUEST['pay_way']);
5 years ago
unset($_REQUEST['pay_way']);
}
$promoteRoot = getPowerPromoteIds();
if ($promoteRoot) {
$map['promote_id'] =array('in',$promoteRoot);
}
$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,
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($map)
->group('pay_way')
->order('count desc,pay_time')
->select();
$count = count($data);
foreach ($data as $key => $value) {
static $i = 0;
$i++;
$data[$key]['rand'] = $i;
}
$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;//每页显示的记录数
5 years ago
$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);
5 years ago
$this->display();
}
function promote_statistics($p = 0)
{
$page = intval($p);
5 years ago
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
5 years ago
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
5 years ago
$user = M('User', 'tab_');
5 years ago
// $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)];
5 years ago
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];
5 years ago
unset($_REQUEST['timeend']);
}
5 years ago
$play_info_map = '';
5 years ago
if (isset($_REQUEST['game_name'])) {
$map['fgame_name'] = $_REQUEST['game_name'];
5 years ago
$play_info_map .= " and upi.game_name = '{$_REQUEST['game_name']}' ";
5 years ago
unset($_REQUEST['game_name']);
}
5 years ago
if (isset($_REQUEST['server_id'])) {
$play_info_map .= " and upi.server_name = '{$_REQUEST['server_id']}' ";
}
$today = total(1);
$week = total(2);
$mounth = total(3);
5 years ago
5 years ago
if (isset($_REQUEST['promote_id'])) {
$map['tp1.id'] = $_REQUEST['promote_id'];
} else {
5 years ago
$map['tp1.chain'] = '/';
}
5 years ago
5 years ago
$data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count,
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')
5 years ago
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
5 years ago
->join("tab_user as u on tp2.id = u.promote_id", 'left')
->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false)
->where($map)
->group('tp1.id')
->order('count desc, register_time')
->select();
unset($map['tp1.id']);
unset($map['tp1.chain']);
$map['promote_id'] = 0;
//官方渠道数据添加
$authorityData = M('user', 'tab_')->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count,
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($map)
->find();
$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) {
static $i = 0;
$i++;
$data[$key]['rand'] = $i;
5 years ago
}
$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);
}
5 years ago
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
5 years ago
$data = my_sort($data, $data_order_type, (int)$data_order);
$size = $row;//每页显示的记录数
5 years ago
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage - 1) * $size, $size);
5 years ago
$this->meta_title = '渠道注册统计列表';
$this->assign('list_data', $data);
$this->assign('total', $total);
5 years ago
$this->display();
}
//TODO:
function promotepay_statistics($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['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
unset($_REQUEST['timestart']);
unset($_REQUEST['timeend']);
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
$map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " ";
unset($_REQUEST['timestart']);
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
$pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
unset($_REQUEST['timeend']);
} else {
$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']}";
}
$promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->select();
$pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->find()['acount'];
// var_dump( $promote);
$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,
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($map)
->where("pay_time".$pay_time)
->find();
$dbdata['promote_account'] = $promote[$i]['account'];
$dbdata['promote_id'] = $promote[$i]['id'];
} else {
$dbdata = $spend
->field('
floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count,
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($map)
->where("pay_time".$pay_time)
->find();
$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->display();
}
function promotepay_statistics_1($p = 0)
{
5 years ago
$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['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
unset($_REQUEST['timestart']);
unset($_REQUEST['timeend']);
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
$map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
$pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " ";
5 years ago
unset($_REQUEST['timestart']);
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
$pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " ";
5 years ago
unset($_REQUEST['timeend']);
} else {
$pay_time = " between 0 and " . time();
}
$map1['pay_status'] = $map['pay_status'] = 1;
$today = total(1);
$week = total(2);
$mounth = total(3);
5 years ago
// $map1['pay_way'] = $map['pay_way'] = array('gt', 0);
5 years ago
$bindrecharge_data = M('bind_recharge', 'tab_')
5 years ago
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time ' . $pay_time . ',real_amount,0))*100) as scount,
floor(sum(IF(create_time ' . $today . ',real_amount,0))*100) as today,
floor(sum(IF(create_time ' . $week . ',real_amount,0))*100) as week,
floor(sum(IF(create_time ' . $mounth . ',real_amount,0))*100) as mounth')
5 years ago
->where($map1)
->group('promote_id')
->select(false);
$deposit_data = M('deposit', 'tab_')
5 years ago
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time ' . $pay_time . ',pay_amount,0))*100) as scount,
floor(sum(IF(create_time ' . $today . ',pay_amount,0))*100) as today,
floor(sum(IF(create_time ' . $week . ',pay_amount,0))*100) as week,
floor(sum(IF(create_time ' . $mounth . ',pay_amount,0))*100) as mounth')
5 years ago
->where($map1)
->group('promote_id')
->select(false);
if (isset($_REQUEST['game_name'])) {
5 years ago
$map['game_name'] = $_REQUEST['game_name'];
if (isset($_REQUEST['server_id'])) {
5 years ago
$map['server_name'] = $_REQUEST['server_id'];
unset($_REQUEST['server_id']);
}
$data = $spend
5 years ago
->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time,
floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount,
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')
5 years ago
->where($map)
->group('promote_id')
->select(false);
} else {
$data = $spend
5 years ago
->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time,
floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount,
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')
5 years ago
->where($map)
5 years ago
// ->union(' (' . $bindrecharge_data . ') ')
// ->union(' (' . $deposit_data . ') ')
5 years ago
->group('promote_id')
->select(false);
}
5 years ago
$promote_map = "tp1.`chain` = '/'";
if (isset($_REQUEST['promote_id'])) {
5 years ago
$promote_map = "tp1.`id` = {$_REQUEST['promote_id']}";
5 years ago
unset($_REQUEST['promote_id']);
}
5 years ago
$data = $spend->field('t.pid as promote_id,t.promote_account,sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth')
->join("inner JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid")
->where($condition)->table('(' . $data . ') as a')->group('t.pid')->order('count desc,a.ordertime')->select();
$count = count($data);
5 years ago
foreach ($data as $key => $value) {
static $i = 0;
5 years ago
$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;
5 years ago
/* $adata=$this->day_data('Spend',array('promote_id'=>$value['promote_id']));
$data[$key]['today']=$adata['today']==''?0:$adata['today'];
$data[$key]['week']=$adata['week']==''?0:$adata['week'];
$data[$key]['mounth']=$adata['mounth']==''?0:$adata['mounth']; */
// if ($data[$key]['promote_id'] == '0') {
// unset($data[$key]);
// }
5 years ago
}
$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);
5 years ago
}
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
5 years ago
$data = my_sort($data, $data_order_type, (int)$data_order);
$size = $row;//每页显示的记录数
5 years ago
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage - 1) * $size, $size);
5 years ago
$this->meta_title = '渠道充值统计列表';
$this->assign('list_data', $data);
5 years ago
$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;
5 years ago
}
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;
5 years ago
}
5 years ago
//渠道下注册详细信息
public function zhuce_detail($promote_id, $game_name = '', $server_name = '')
{
5 years ago
$map['promote_id'] = $promote_id;
if (!empty($game_name)) {
5 years ago
$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();
5 years ago
}
$this->assign('list_data', $data);
5 years ago
$this->display();
}
5 years ago
//渠道下充值详细信息
public function chongzhi_detail($promote_id, $game_name = '', $server_name = '')
{
5 years ago
$map['promote_id'] = $promote_id;
$map['pay_status'] = 1;
$map['pay_way'] = array('GT', 0);
if ($game_name) {
5 years ago
$map['game_name'] = $game_name;
}
if ($server_name) {
5 years ago
$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);
5 years ago
$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 ';
5 years ago
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";
5 years ago
//今天
$ttotal = $uc->uc_recharge_select($page, 10, $map1)['total'] ? $uc->uc_recharge_select($page, 10, $map1)['total'] : 0;
5 years ago
//昨天
$ytotal = $uc->uc_recharge_select($page, 10, $map2)['total'] ? $uc->uc_recharge_select($page, 10, $map2)['total'] : 0;
5 years ago
//总共
$total = $data['total'] ? $data['total'] : 0;
5 years ago
//该叶
$pagetotal = $data['totalpage'][0]['totalpage'] ? $data['totalpage'][0]['totalpage'] : 0;
5 years ago
$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;
}
5 years ago
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
5 years ago
unset($data['count']);
unset($data['total']);
unset($data['totalpage']);
$this->assign('data', $data);
5 years ago
$this->display();
}
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";
5 years ago
//今天
$ttotal = $uc->uc_deposit_select($page, 10, $map1)['total'] ? $uc->uc_deposit_select($page, 10, $map1)['total'] : 0;
5 years ago
//昨天
$ytotal = $uc->uc_deposit_select($page, 10, $map2)['total'] ? $uc->uc_deposit_select($page, 10, $map2)['total'] : 0;
5 years ago
//总共
$total = $data['total'] ? $data['total'] : 0;
5 years ago
//该叶
$pagetotal = $data['totalpage'][0]['totalpage'] ? $data['totalpage'][0]['totalpage'] : 0;
5 years ago
$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;
}
5 years ago
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
5 years ago
unset($data['count']);
unset($data['total']);
unset($data['totalpage']);
$this->assign('data', $data);
5 years ago
$this->display();
}
}