|
|
|
@ -42,8 +42,12 @@ class IndexController extends AdminController {
|
|
|
|
|
|
|
|
|
|
// 日历
|
|
|
|
|
$this->calendar();
|
|
|
|
|
$this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']);
|
|
|
|
|
|
|
|
|
|
if(strtotime($_REQUEST['start']) == mktime(0,0,0,date('m'),date('d'),date('Y'))){
|
|
|
|
|
//今日时时
|
|
|
|
|
$this->nowday($_REQUEST['num']);
|
|
|
|
|
}else{
|
|
|
|
|
$this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']);
|
|
|
|
|
}
|
|
|
|
|
$tm =strtotime(date("Y-m-d",strtotime("-1 day")));
|
|
|
|
|
$allcount = M("IndexChart","tab_")->field("all_count")->where("`date` = '{$tm}'")->find();
|
|
|
|
|
$allcount = unserialize($allcount['all_count']);
|
|
|
|
@ -56,6 +60,142 @@ class IndexController extends AdminController {
|
|
|
|
|
//累计统计
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* 今日折线图
|
|
|
|
|
*/
|
|
|
|
|
public function nowday($num)
|
|
|
|
|
{
|
|
|
|
|
$starttime = mktime(0,0,0,date('m'),date('d'),date('Y'));
|
|
|
|
|
|
|
|
|
|
$endtime = $starttime+86399;
|
|
|
|
|
|
|
|
|
|
$start = date('Y-m-d',$starttime);
|
|
|
|
|
$end = date('Y-m-d',$endtime);
|
|
|
|
|
|
|
|
|
|
$user = D('User');
|
|
|
|
|
$spend = D('Spend');
|
|
|
|
|
$promote = D('Promote');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($start == date('Y-m-d',strtotime('-1 day'))) {$num = 2;}
|
|
|
|
|
|
|
|
|
|
$hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'];
|
|
|
|
|
|
|
|
|
|
$data['date'] = [$start];
|
|
|
|
|
|
|
|
|
|
$data['hours'] = 1;
|
|
|
|
|
|
|
|
|
|
foreach($hours as $v) {
|
|
|
|
|
$data['news'][$v] = 0;
|
|
|
|
|
$data['active'][$v] = 0;
|
|
|
|
|
$data['player'][$v] = 0;
|
|
|
|
|
$data['money'][$v] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 新增用户
|
|
|
|
|
$hoursnews = $user->newsAdd(['register_time'=>['between',[$starttime,$endtime]]],'news','time',5);
|
|
|
|
|
|
|
|
|
|
// 活跃用户
|
|
|
|
|
$hoursactive = $user->totalPlayerByGroup($hours,['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]],'active','time',5);
|
|
|
|
|
|
|
|
|
|
// 付费用户
|
|
|
|
|
$hoursplayer = $spend->totalPlayerByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'player','time',5);
|
|
|
|
|
|
|
|
|
|
// 充值金额
|
|
|
|
|
$hoursmoney = $spend->totalAmountByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'money','time',5);
|
|
|
|
|
|
|
|
|
|
foreach($hours as $v) {
|
|
|
|
|
foreach($hoursnews as $h) {
|
|
|
|
|
$time = explode(' ',$h['time']);
|
|
|
|
|
if ($time[1] == $v){
|
|
|
|
|
$data['news'][$v] = (integer)$h['news'];break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($hoursactive as $h) {
|
|
|
|
|
|
|
|
|
|
if ($h['time'] == $v){
|
|
|
|
|
$data['active'][$v] = (integer)$h['active'];break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($hoursplayer as $h) {
|
|
|
|
|
$time = explode(' ',$h['time']);
|
|
|
|
|
if ($time[1] == $v){
|
|
|
|
|
$data['player'][$v] = (integer)$h['player'];break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($hoursmoney as $h) {
|
|
|
|
|
$time = explode(' ',$h['time']);
|
|
|
|
|
if ($time[1] == $v){
|
|
|
|
|
$data['money'][$v] = $h['money'];break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 新
|
|
|
|
|
$between = ['between',[$starttime-86400,$endtime]];
|
|
|
|
|
|
|
|
|
|
$cnewslist = $user->newsAdd(['register_time'=>$between],'count','time',1,'time desc');
|
|
|
|
|
$cnews['count'] = $cnewslist[0]['count']?$cnewslist[0]['count']:0;
|
|
|
|
|
$cnews['rate'] = $cnewslist[0] && $cnewslist[1]? round(($cnewslist[0]['count']/$cnewslist[1]['count']-1)*100,2):($cnewslist[0]&&!$cnewslist[1]?(100):(!$cnewslist[0]&&$cnewslist[1]?(-100):0));
|
|
|
|
|
|
|
|
|
|
// 活
|
|
|
|
|
$cactivelist = $user->totalPlayerByGroup([date('Y-m-d',$starttime-86400),$end],['tab_user_login_record.login_time'=>$between],'count','time',1,'time desc');
|
|
|
|
|
$cactive['count'] = $cactivelist[0]['count']?$cactivelist[0]['count']:0;
|
|
|
|
|
$cactive['rate'] = $cactivelist[0] && $cactivelist[1]? round(($cactivelist[0]['count']/$cactivelist[1]['count']-1)*100,2):($cactivelist[0]&&!$cactivelist[1]?(100):(!$cactivelist[0]&&$cactivelist[1]?(-100):0));
|
|
|
|
|
|
|
|
|
|
// 付
|
|
|
|
|
$cplayerlist = $spend->totalPlayerByGroup(['pay_time'=>$between],'count','time',1,'time desc');
|
|
|
|
|
$cplayer['count'] = $cplayerlist[0]['count']?$cplayerlist[0]['count']:0;
|
|
|
|
|
$cplayer['rate'] = $cplayerlist[0] && $cplayerlist[1]? round(($cplayerlist[0]['count']/$cplayerlist[1]['count']-1)*100,2):($cplayerlist[0]&&!$cplayerlist[1]?(100):(!$cplayerlist[0]&&$cplayerlist[1]?(-100):0));
|
|
|
|
|
|
|
|
|
|
// 充
|
|
|
|
|
$cmoneylist = $spend->totalAmountByGroup(['pay_time'=>$between],'count','time',1,'time desc');
|
|
|
|
|
$cmoney['count'] = $cmoneylist[0]['count']?$cmoneylist[0]['count']:0;
|
|
|
|
|
$cmoney['rate'] = $cmoneylist[0] && $cmoneylist[1]? round(($cmoneylist[0]['count']/$cmoneylist[1]['count']-1)*100,2):($cmoneylist[0]&&!$cmoneylist[1]?(100):(!$cmoneylist[0]&&$cmoneylist[1]?(-100):0));
|
|
|
|
|
|
|
|
|
|
// 渠
|
|
|
|
|
$cpromotelist = $promote->newsAdd(['create_time'=>$between],'count','time',1,'time desc');
|
|
|
|
|
$cpromote['count'] = $cpromotelist[0]['count']?$cpromotelist[0]['count']:0;
|
|
|
|
|
$cpromote['rate'] = $cpromotelist[0] && $cpromotelist[1]? round(($cpromotelist[0]['count']/$cpromotelist[1]['count']-1)*100,2):($cpromotelist[0]&&!$cpromotelist[1]?(100):(!$cpromotelist[0]&&$cpromotelist[1]?(-100):0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data as $k => $v) {
|
|
|
|
|
|
|
|
|
|
if (is_array($v)) {
|
|
|
|
|
if ($k == 'date')
|
|
|
|
|
$data[$k] = '"'.implode('","',$v).'"';
|
|
|
|
|
else
|
|
|
|
|
$data[$k] = implode(',',$v);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data['compare']['news'] = $cnews;
|
|
|
|
|
$data['compare']['active'] = $cactive;
|
|
|
|
|
$data['compare']['player'] = $cplayer;
|
|
|
|
|
$data['compare']['money'] = $cmoney;
|
|
|
|
|
$data['compare']['promote'] = $cpromote;
|
|
|
|
|
|
|
|
|
|
if ($flag) {
|
|
|
|
|
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$this->assign('foldline',$data);
|
|
|
|
|
|
|
|
|
|
$this->assign('num',$num);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 折线图
|
|
|
|
|