From e27cdc8a389f10b7b84f6a6722f09c9f677bbf88 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 26 Nov 2019 13:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=80=E6=9C=89=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndexChartSetController.class.php | 16 +- .../Controller/StatisticsController.class.php | 289 ++++++++++-------- .../Admin/Controller/access_data_foldline.txt | 2 +- .../Admin/View/Statistics/overview.html | 46 ++- 4 files changed, 211 insertions(+), 142 deletions(-) diff --git a/Application/Admin/Controller/IndexChartSetController.class.php b/Application/Admin/Controller/IndexChartSetController.class.php index 691eff18f..624820404 100644 --- a/Application/Admin/Controller/IndexChartSetController.class.php +++ b/Application/Admin/Controller/IndexChartSetController.class.php @@ -269,11 +269,17 @@ class IndexChartSetController extends AdminController { $spend = D('Spend'); $promote = D('Promote'); $allcount = array(); - $allcount['user_count'] = $user->old(); - $allcount['active_count'] =$user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]]); - $allcount['player_count'] =$spend->player(); - $allcount['money_sum'] =$spend->totalAmount(); - $allcount['promote_sum'] =$promote->total(); + $allcount['user_count'] = $user->old();//平台累计用户 + $allcount['active_count'] =$user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]]);//七日日活 + $allcount['player_count'] =$spend->player();//累计付费用户 + $allcount['money_sum'] =$spend->totalAmount();//累计充值 + $allcount['promote_sum'] =$promote->total();//推广员总数 + $allcount['game_count'] = M("game","tab_")->where("game_status = 1")->field("count(1) game_count")->find()['game_count'];//游戏接入数量 + $allcount['android_gamesource_count'] = M("GameSource","tab_")->where("file_type = 1 and apply_status = 1")->field("count(1) game_count")->find()['game_count'];//安卓游戏原包 + $allcount['ios_gamesource_count'] = M("GameSource","tab_")->where("file_type = 2 and apply_status = 1")->field("count(1) game_count")->find()['game_count'];//IOS游戏原包 + $allcount['promote_user_count'] = $user->where("promote_id > 0 and puid = 0")->field("count(1) user_count")->find()['user_count'];//推广员注册用户 + $allcount['promote_spend_sum'] = $spend->where("promote_id > 0 and pay_status = 1")->field("sum(pay_amount) pay_amount")->find()['pay_amount'];//推广员总充值 + $this->adddata["all_count"] = serialize($allcount); } public function createDb() diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index 4dd30404b..03b2b8546 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -9,7 +9,7 @@ use User\Api\UserApi as UserApi; */ class StatisticsController extends ThinkController { public function overview(){ - $shuju = M('Data','tab_')->order('create_time desc')->find(); + $shuju = unserialize(M('IndexChart','tab_')->field("all_count")->order('`date` desc')->find()["all_count"]); $this->assign('shuju',$shuju); $this->assign('openegretmain','openegretmain');//模板还样式使用 @@ -58,148 +58,183 @@ class StatisticsController extends ThinkController { R('Index/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']); + } + // $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); $this->display(); - } - - /* - * 折线图 - * @param integer $start 开始时间 - * @param integer $end 结束时间 - * @param boolean $flag 是否ajax返回 - * @author 鹿文学 - */ - public function foldLineDiagram($start='',$end='',$num='',$flag=false) { + } + /* + * 今日折线图 + */ + public function nowday($num) + { + $starttime = mktime(0,0,0,date('m'),date('d'),date('Y')); - $starttime = $start?strtotime($start):mktime(0,0,0,date('m'),date('d')-1,date('Y')); - - $endtime = $end?strtotime($end)+86399:$starttime+86399; + $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 == $end) { - - 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; + 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; + } } - // 新增用户 - $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($hoursactive as $h) { - foreach($hoursmoney as $h) { - $time = explode(' ',$h['time']); - if ($time[1] == $v){ - $data['money'][$v] = $h['money'];break; - } + if ($h['time'] == $v){ + $data['active'][$v] = (integer)$h['active'];break; } - } - } else { - $datelist = get_date_list($starttime,$endtime,$num==7?4:1); - - $data['date'] = $datelist; - - $data['hours'] = 0; - foreach($datelist as $k => $v) { - $data['news'][$v] = 0; - $data['active'][$v] = 0; - $data['player'][$v] = 0; - $data['money'][$v] = 0; + foreach($hoursplayer as $h) { + $time = explode(' ',$h['time']); + if ($time[1] == $v){ + $data['player'][$v] = (integer)$h['player'];break; + } } - // 新增用户 - $news = $user->newsAdd(['register_time'=>['between',[$starttime,$endtime]]],'news','time',$num==7?2:1); - - // 活跃用户 - $active = $user->totalPlayerByGroup($datelist,['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]],'active','time',$num==7?2:1); - - // 付费用户 - //$player = $spend->totalPlayerByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'player','time',$num==7?2:1); - $player = $spend->totalPlayerByTime($starttime,$endtime,'player','time',$num==7?2:1); - - // 充值金额 - $money = $spend->totalAmountByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'money','time',$num==7?2:1); - - foreach($datelist as $v) { - foreach($news as $h) { - if ($v == $h['time']) { - $data['news'][$v] = (integer)$h['news'];break; - } - } - - foreach($active as $h) { - if ($v == $h['time']) { - $data['active'][$v] = (integer)$h['active'];break; - } - } - - foreach($player as $h) { - if ($v == $h['time']) { - $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; } - - foreach($money as $h) { - if ($v == $h['time']) { - $data['money'][$v] = $h['money'];break; + } + + } + foreach($data as $k => $v) { + if (is_array($v)) { + if($data['hours']!=1){$table[$k] = $v;} + if ($k == 'date'){ + $data[$k] = '"'.implode('","',$v).'"'; + }else{ + $sum = 0;$x='';$y=0;$tempexport=[]; + foreach($v as $t => $s){ + $sum += $s; + if($data['hours']==1){ + if ($t%2==1) {$tab[$x.'~'.$t] = $y+$s;$x='';$y=0;}else{$x .= $t;$y += $s;} + $tempexport[]=['time'=>((integer)substr($t,0,2)).':00','count'=>$s]; + }else{ + $tempexport[]=['time'=>$t,'count'=>$s]; } } - + $table['sum'][$k]=$sum; + if($data['hours']==1)$table[$k]=$tab; + $export[$k]=$tempexport; + $export['sum'][$k]=$sum; + $data[$k] = implode(',',$v); } - } + } + if ($flag) { + echo json_encode($data); - foreach($data as $k => $v) { + } else { + + $this->assign('foldline',$data); + $this->assign('table',$table); + $this->assign('num',$num); + + } + # code... + } + /* + * 折线图 + * @param integer $start 开始时间 + * @param integer $end 结束时间 + * @param boolean $flag 是否ajax返回 + * @author 鹿文学 + */ + public function foldLineDiagram($start='',$end='',$num='',$flag=false) + { + $starttime = $start?strtotime($start):mktime(0,0,0,date('m'),date('d')-1,date('Y')); + + $endtime = $end?strtotime($end)+86399:$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 == $end) { // 单天 + + if ($start == date('Y-m-d',strtotime('-1 day'))) {$num = 2;} + $data['date'] = [$start]; + $data['hours'] = 1; + $tm = strtotime($start); + $dbdata = M("IndexChart","tab_")->field("new_user_count,new_user_hours,active_user_count,active_user_hours,pay_user_count,pay_user_hours,pay_money_count,pay_money_hours,promote_new_count")->where("`date` = '{$tm}'")->find(); + $data['news'] = unserialize($dbdata["new_user_hours"]); + $data['active'] = unserialize($dbdata["active_user_hours"]); + $data['player']=unserialize($dbdata["pay_user_hours"]); + $data['money']=unserialize($dbdata["pay_money_hours"]); + } else { + $datelist = get_date_list($starttime,$endtime,$num==7?4:1); + $data['date'] = $datelist; + $data['hours'] = 0; + $map = array( + "date"=>['between',[$starttime,$endtime]] + ); + //获取记录 + $count1 = array(); + $active_user_list = []; + $pay_user_list = []; + $dbdata = M("IndexChart","tab_")->field("new_user_count,active_user_count,pay_user_count,pay_money_count,promote_new_count") + ->where($map)->select(); + + foreach($dbdata as $k => $v) { + $data['news'][$k] = $v['new_user_count']; + $data['active'][$k] = $v['active_user_count']; + $data['player'][$k] = $v['pay_user_count']; + $data['money'][$k] = $v['pay_money_count']; + } + } + foreach($data as $k => $v) { + // dump($k); if (is_array($v)) { if($data['hours']!=1){$table[$k] = $v;} if ($k == 'date'){ @@ -224,26 +259,30 @@ class StatisticsController extends ThinkController { } } - file_put_contents(dirname(__FILE__).'/access_data_foldline.txt',json_encode($export)); - if ($flag) { - $data['table'] = $table; - echo json_encode($data); } else { $this->assign('foldline',$data); - $this->assign('table',$table); - $this->assign('num',$num); } - - } + # code... + } + private function promote_data_order($starttime,$endtime){ + //注册排行 + $IndexChart = M("IndexChart","tab_"); + // + $map = array( + "date"=>['between',[$starttime,$endtime]] + ); + + + } /** * 排行榜(推广员) * @param string $nowtime 现在时间段(between 开始时间戳 and 结束时间戳) @@ -251,7 +290,7 @@ class StatisticsController extends ThinkController { * @return array 结果集 * @author lwx */ - private function promote_data_order($nowtime,$othertime){ + private function promote_data_order2($nowtime,$othertime){ $user = M("User","tab_"); $spend = M('Spend',"tab_"); @@ -369,7 +408,7 @@ if ($payids) { else $data['chart'][$k] = implode(',',$v); } - + echo "
";dump($data);die();
         return $data;
     }
 		
diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt
index 248024757..f2bc7fb38 100644
--- a/Application/Admin/Controller/access_data_foldline.txt
+++ b/Application/Admin/Controller/access_data_foldline.txt
@@ -1 +1 @@
-{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":2},{"time":"20:00","count":1},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":3,"active":4,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":3},{"time":"20:00","count":1},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]}
\ No newline at end of file
+{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":0,"active":0,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]}
\ No newline at end of file
diff --git a/Application/Admin/View/Statistics/overview.html b/Application/Admin/View/Statistics/overview.html
index 1c8b930e5..d2cec8429 100644
--- a/Application/Admin/View/Statistics/overview.html
+++ b/Application/Admin/View/Statistics/overview.html
@@ -55,17 +55,17 @@
 			
- {$shuju.player_regist_all|default=0} 平台累计用户 + {:set_number_short($shuju['user_count'])} 平台累计用户
- {$shuju.payer_all|default=0} 累计付费用户 + {:set_number_short($shuju['player_count'])} 累计付费用户
- {$shuju.pay_all|default=0} 累计充值 + {:set_number_short($shuju['money_sum'])} 累计充值
@@ -75,32 +75,32 @@
- {$shuju.pro_complete|default=0} 开通推广员数 + {:set_number_short($shuju['promote_sum'])} 开通推广员数
- {$shuju.game_add_all|default=0} 游戏接入数量 + {$shuju.game_count|default=0} 游戏接入数量
- {$shuju.game_and_all|default=0} 安卓游戏原包 + {$shuju.android_gamesource_count|default=0} 安卓游戏原包
- {$shuju.game_ios_all|default=0} IOS游戏原包 + {$shuju.ios_gamesource_count|default=0} IOS游戏原包
- {$shuju.pro_player_all|default=0} 推广员注册用户 + {:set_number_short($shuju['promote_user_count'])} 推广员注册用户
- {$shuju.pro_pay_all|default=0} 推广员总充值 + {:set_number_short($shuju['promote_spend_sum'])} 推广员总充值
@@ -123,7 +123,7 @@
  • 过去整月
  • 过去7天
  • 过去30天
  • -
  • 过去一年
  • +
    @@ -762,6 +762,30 @@ } function chartdata(start,end,parent) { + + var starttime = new Date(start).getTime(); + if(end){ + var endtime = new Date(end).getTime(); + }else{ + var endtime = new Date(start).getTime(); + } + if(starttime > endtime){ + var temp = start; + start = end; + end = temp; + } + + if(end && (start != end)){ + var endtime = (new Date(end).getTime()) + 86399000; + var now = new Date().getTime(); + if(endtime > now){ + layer.msg('历史时间选择不能包含今日'); + return false; + } + }; + var index = layer.load(1, { + shade: [0.3,'#000'] //0.1透明度的白色背景 + }); var href = '{:U("overview",array("type"=>I("type"),"category"=>I("category")))}'; end = end?end:start; @@ -1164,7 +1188,7 @@ - +