|
|
|
|
<?php
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
|
|
|
|
|
class RechargeSumController extends ThinkController{
|
|
|
|
|
|
|
|
|
|
public function summation($p=1)
|
|
|
|
|
{
|
|
|
|
|
if(!empty($_REQUEST['timeStart']) && !empty($_REQUEST['timeEnd'])){
|
|
|
|
|
$starttime = strtotime($_REQUEST['timeStart']);
|
|
|
|
|
$endtime = strtotime($_REQUEST['timeEnd']);
|
|
|
|
|
} elseif(!empty($_REQUEST['timeStart']) && empty($_REQUEST['timeEnd'])) {
|
|
|
|
|
$starttime = strtotime($_REQUEST['timeStart']);
|
|
|
|
|
$endtime = strtotime(date('Y-m-d'));
|
|
|
|
|
} elseif(empty($_REQUEST['timeStart']) && !empty($_REQUEST['timeEnd'])) {
|
|
|
|
|
|
|
|
|
|
$user = D('User')->field('register_time')->order('id asc')->find();
|
|
|
|
|
$starttime = strtotime(date('Y-m-d',$user['register_time']));
|
|
|
|
|
$endtime = strtotime($_REQUEST['timeEnd']);
|
|
|
|
|
} else {
|
|
|
|
|
$user = D('User')->field('register_time')->order('id asc')->find();
|
|
|
|
|
|
|
|
|
|
$starttime = strtotime(date('Y-m-d',$user['register_time']));
|
|
|
|
|
$endtime = strtotime(date('Y-m-d'));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = 0;
|
|
|
|
|
|
|
|
|
|
$total = ['current'=>0,'sum'=>0];
|
|
|
|
|
|
|
|
|
|
if(isset($_REQUEST['promote_id'])){
|
|
|
|
|
if ($_REQUEST['promote_id'] > 0) {
|
|
|
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
|
|
|
$promoter_ids ? $rmap['promote_id'] = $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null;
|
|
|
|
|
} else {
|
|
|
|
|
$rmap['promote_id'] = $map['promote_id'] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for($start = $endtime; $start >= $starttime;$start -= 86400)
|
|
|
|
|
{
|
|
|
|
|
$startDate = $start;
|
|
|
|
|
$endDate = $startDate + 24*60*60-1;
|
|
|
|
|
$rmap['register_time'] = $map['register_time'] = array('BETWEEN',array($startDate,$endDate));
|
|
|
|
|
$map['play_time'] = array('BETWEEN',array($startDate,$endDate));
|
|
|
|
|
$map['pay_time'] = array('BETWEEN',array($startDate,$endDate));
|
|
|
|
|
if(!empty($_REQUEST['game_type'])){
|
|
|
|
|
$map['sdk_version'] = $_REQUEST['game_type'];
|
|
|
|
|
$rmap['sdk_version'] = $_REQUEST['game_type'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($_REQUEST['game_name'])){
|
|
|
|
|
$rmap['game_id'] = $map['game_id'] = ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($_REQUEST['server_name'])) {
|
|
|
|
|
$rmap['server_name'] = $map['server_name'] = $_REQUEST['server_name'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($_REQUEST['bindcoin']==1) {
|
|
|
|
|
$map['pay_way'] = array('egt',0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//当天注册人数
|
|
|
|
|
$registerNum = D('User')->where(array_merge($rmap,array('puid'=>0)))->join("tab_user_play on tab_user.id = tab_user_play.user_id and tab_user.fgame_id = tab_user_play.game_id")->field("tab_user.id")->select();
|
|
|
|
|
$registerNum = $registerNum ? array_column($registerNum, 'id') : [];
|
|
|
|
|
|
|
|
|
|
//当天活跃人数
|
|
|
|
|
$livenNum = D('UserPlay')->where($map)->count("id");
|
|
|
|
|
|
|
|
|
|
//当天新增付费
|
|
|
|
|
if(empty($registerNum)){
|
|
|
|
|
$map['user_id'] = array('IN','0');
|
|
|
|
|
}else{
|
|
|
|
|
$map['user_id'] = array('IN',$registerNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
|
$newAddPay = D('Spend')->where(array_merge($map,array('_string'=>'( small_id = 0 or small_id = user_id)')))->sum('pay_amount');
|
|
|
|
|
|
|
|
|
|
//当天累计付费
|
|
|
|
|
unset($map['user_id']);
|
|
|
|
|
$accumulated = D('Spend')->where($map)->sum('pay_amount');
|
|
|
|
|
|
|
|
|
|
$data[$key]['date'] = date('Y-m-d',$start);
|
|
|
|
|
$data[$key]['game_id'] = empty($_REQUEST['game_id'])?"全部":get_game_name($_REQUEST['game_id']);
|
|
|
|
|
switch ($_REQUEST['promote_id']) {
|
|
|
|
|
case 'GUANFANG':
|
|
|
|
|
$data[$key]['promote_id'] = "官方渠道";
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
$data[$key]['promote_id'] = "官方渠道";
|
|
|
|
|
break;
|
|
|
|
|
case 'PROMOTE':
|
|
|
|
|
$data[$key]['promote_id'] = "推广渠道";
|
|
|
|
|
break;
|
|
|
|
|
case 'ALL':
|
|
|
|
|
$data[$key]['promote_id'] = "全部";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$data[$key]['promote_id'] = empty($_REQUEST['promote_id'])?"全部":get_promote_account($_REQUEST['promote_id']);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$data[$key]['registerNum'] = count($registerNum);
|
|
|
|
|
$data[$key]['livenNum'] = $livenNum;
|
|
|
|
|
$data[$key]['newAddPay'] = empty($newAddPay)?0:$newAddPay;
|
|
|
|
|
$data[$key]['accumulated'] = empty($accumulated)?0:$accumulated;
|
|
|
|
|
|
|
|
|
|
$total['sum'] += $data[$key]['accumulated'];
|
|
|
|
|
|
|
|
|
|
$key++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
|
|
|
|
|
|
|
|
|
|
$count = count($data);
|
|
|
|
|
|
|
|
|
|
$page = set_pagination($count,$row);
|
|
|
|
|
if($page) {$this->assign('_page', $page);}
|
|
|
|
|
|
|
|
|
|
$pnum = ceil(count($data) / $row); //总页数,ceil()函数用于求大于数字的最小整数
|
|
|
|
|
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
|
|
|
|
|
$data = array_slice($data, ($p-1)*$row, $row);
|
|
|
|
|
|
|
|
|
|
foreach($data as $k=>$v) {
|
|
|
|
|
$total['current'] += $v['accumulated'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否执行导出
|
|
|
|
|
if(I('export')==1){
|
|
|
|
|
$this->exportSum($data);
|
|
|
|
|
}
|
|
|
|
|
$this->assign('meta_title',"充值汇总");
|
|
|
|
|
$this->assign('list_data',$data);
|
|
|
|
|
$this->assign('total',$total);
|
|
|
|
|
|
|
|
|
|
$this->m_title = '充值汇总';
|
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'RechargeSum/summation','status'=>1])->find());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function exportSum($data){
|
|
|
|
|
$export = A('Export');
|
|
|
|
|
$exptitle = $_REQUEST['xlsname'];
|
|
|
|
|
$expCellName = array(
|
|
|
|
|
array('date','日期'),
|
|
|
|
|
array('promote_id','渠道来源'),
|
|
|
|
|
array('game_id','游戏名称'),
|
|
|
|
|
array('registerNum','新增人数'),
|
|
|
|
|
array('livenNum','活跃人数'),
|
|
|
|
|
array('newAddPay',"新增玩家付费"),
|
|
|
|
|
array('accumulated','本日累计'),
|
|
|
|
|
);
|
|
|
|
|
$expTableData = $data;
|
|
|
|
|
$export->exportExcel($exptitle,$expCellName,$expTableData);
|
|
|
|
|
}
|
|
|
|
|
}
|