From e1c29c73af53b145544eb79223cd4978239140ea Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 3 Dec 2019 17:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E8=A7=88=E7=BB=9F=E8=AE=A1=E7=BB=93?= =?UTF-8?q?=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatisticsController.class.php | 63 +++++++++++++------ .../Admin/View/Statistics/overview.html | 6 ++ 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index 4fcc6b7a0..ca379f384 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -24,34 +24,54 @@ class StatisticsController extends ThinkController { $lastweek=$this->total(6); $lastmounth=$this->total(7); $lastyear=$this->total(8); + //昨天 + $yesterdaydate=mktime(0,0,0,date('m'),date('d')-1,date('Y')); + $promoteyesterdaydate=mktime(0,0,0,date('m'),date('d')-1,date('Y')); // 游戏排行 - $type=$_REQUEST['type']; - if($type==1 || $type==''){ - $list_data=$this->data_order($today,$yesterday,true); + $type=$_REQUEST['type']?:1; + if($type==1){ + $list_data=$this->data_order($today,$yesterday,true); + $gamedateinfo = explode(" ",$today); + $yesterdaydate=$gamedateinfo[2]; }elseif($type==2){ - $list_data=$this->data_order($thisweek,$lastweek); + $list_data=$this->data_order($thisweek,$lastweek); + $gamedateinfo = explode(" ",$thisweek); }elseif($type==3){ - $list_data=$this->data_order($thismounth,$lastmounth); + $list_data=$this->data_order($thismounth,$lastmounth); + $gamedateinfo = explode(" ",$thismounth); }elseif($type==4){ - $list_data=$this->data_order($thisyear,$lastyear); + $list_data=$this->data_order($thisyear,$lastyear); + $gamedateinfo = explode(" ",$thisyear); } + // 推广员排行 - switch($_REQUEST['category']) { - case 2:{$promote_data = $this->promote_data_order($thisweek,$lastweek);};break; - case 3:{$promote_data = $this->promote_data_order($thismounth,$lastmounth);};break; - case 4:{$promote_data = $this->promote_data_order($thisyear,$lastyear);};break; - default: - $promote_data = $this->promote_data_order($today,$yesterday,true); + $category = $_REQUEST['category']?:1; + if($category==1){ + $promote_data = $this->promote_data_order($today,$yesterday,true); + $promotedateinfo = explode(" ",$today); + $promoteyesterdaydate = $promotedateinfo[2]; + }elseif($category==2){ + $promote_data = $this->promote_data_order($thisweek,$lastweek); + $promotedateinfo = explode(" ",$thisweek); + }elseif($category==3){ + $promote_data = $this->promote_data_order($thismounth,$lastmounth); + $promotedateinfo = explode(" ",$thismounth); + }elseif($category==4){ + $promote_data = $this->promote_data_order($thisyear,$lastyear); + $promotedateinfo = explode(" ",$thisyear); } + $this->assign('zhuce',$list_data['reg']); $this->assign('active',$list_data['active']); $this->assign('pay',$list_data['pay']); $this->assign('game_chart',$list_data['chart']); + $this->assign('game_date_info',"统计[ ".date("Y/m/d",$gamedateinfo[2])." -- ".date("Y/m/d",$yesterdaydate)." ]之间数据"); $this->assign('promotereg',$promote_data['reg']); $this->assign('promoteactive',$promote_data['active']); $this->assign('promotepay',$promote_data['pay']); $this->assign('promote_chart', $promote_data['chart']); + $this->assign('promote_date_info',"统计[ ".date("Y/m/d",$promotedateinfo[2])." -- ".date("Y/m/d",$promoteyesterdaydate)." ]之间数据"); // 日历 @@ -288,7 +308,7 @@ class StatisticsController extends ThinkController { $map = ["puid"=>0,"fgame_id"=>["gt",0]];//0不是小号 $new_user_count = M("User","tab_")->field('COUNT(1) AS cg,promote_id,promote_account')->where($map)->where("register_time {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); }else{ - $new_user_count = $PromoteCount->field("promote_id,promote_account,sum(new_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_user_count = $PromoteCount->field("promote_id,promote_account,sum(new_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); } $old_user_count = $PromoteCount->field("promote_id,promote_account,sum(new_user_count) cg")->where("`date` {$endtime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); //2.设置排名 @@ -305,7 +325,7 @@ class StatisticsController extends ThinkController { ->order("cg desc") ->limit(self::COUNTLIMIT)->select(); }else{ - $new_active_count = $PromoteCount->field("promote_id,promote_account,sum(active_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_active_count = $PromoteCount->field("promote_id,promote_account,sum(active_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); if(count($new_active_count) > 0){ $listarr = array(); $promote_id_str = ''; @@ -343,7 +363,7 @@ class StatisticsController extends ThinkController { $map = ["pay_status"=>1,"promote_id"=>["gt",0]]; $new_money_count = M("Spend","tab_")->field('sum(pay_amount) AS cg,promote_id,promote_account')->where($map)->where("pay_time {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); }else{ - $new_money_count = $PromoteCount->field("promote_id,promote_account,sum(pay_money_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_money_count = $PromoteCount->field("promote_id,promote_account,sum(pay_money_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); } $old_money_count = $PromoteCount->field("promote_id,promote_account,sum(pay_money_count) cg")->where("`date` {$endtime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); @@ -527,7 +547,7 @@ class StatisticsController extends ThinkController { $map = ["puid"=>0,"fgame_id"=>["gt",0]];//0不是小号 $new_user_count = M("User","tab_")->field('COUNT(1) AS cg,fgame_id game_id,fgame_name game_name')->where($map)->where("register_time {$starttime}")->group("fgame_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); }else{ - $new_user_count = $GameCount->field("game_id,game_name,sum(new_user_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_user_count = $GameCount->field("game_id,game_name,sum(new_user_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); } $old_user_count = $GameCount->field("game_id,game_name,sum(new_user_count) cg")->where("`date` {$endtime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); //2.设置排名 @@ -539,7 +559,7 @@ class StatisticsController extends ThinkController { $map = ["game_id"=>["gt",0]]; $new_active_count = M("user_login_record","tab_")->field('COUNT(DISTINCT user_id) AS cg,game_id,game_name')->where($map)->where("login_time {$starttime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); }else{ - $new_active_count = $GameCount->field("game_id,game_name,sum(active_user_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_active_count = $GameCount->field("game_id,game_name,sum(active_user_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); if(count($new_active_count) > 0){ $listarr = array(); $promote_id_str = ''; @@ -577,7 +597,7 @@ class StatisticsController extends ThinkController { $map = ["pay_status"=>1,"game_id"=>["gt",0]]; $new_money_count = M("Spend","tab_")->field('sum(pay_amount) AS cg,game_id,game_name')->where($map)->where("pay_time {$starttime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); }else{ - $new_money_count = $GameCount->field("game_id,game_name,sum(pay_money_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); + $new_money_count = $GameCount->field("game_id,game_name,sum(pay_money_count) cg")->where("`date` {$starttime}")->group("game_id")->order("cg desc")->having("cg > 0")->limit(self::COUNTLIMIT)->select(); } $old_money_count = $GameCount->field("game_id,game_name,sum(pay_money_count) cg")->where("`date` {$endtime}")->group("game_id")->order("cg desc")->limit(self::COUNTLIMIT)->select(); @@ -1004,7 +1024,8 @@ class StatisticsController extends ThinkController { $time[]=date('Y-m-d',mktime(0,0,0,date('m'),date('d')-$i,date('Y'))); } return $time; - } + } + private function total($type) { switch ($type) { case 1: { // 今天 @@ -1064,6 +1085,10 @@ class StatisticsController extends ThinkController { case 10: { // 前30天 $start = mktime(0,0,0,date('m'),date('d')-29,date('Y')); $end=mktime(23,59,59,date('m'),date('d'),date('Y')); + };break; + case 11: { // 前天 + $start=mktime(0,0,0,date('m'),date('d')-2,date('Y')); + $end=mktime(0,0,0,date('m'),date('d')-1,date('Y'))-1; };break; default: $start='';$end=''; diff --git a/Application/Admin/View/Statistics/overview.html b/Application/Admin/View/Statistics/overview.html index d2cec8429..e7dfc08d3 100644 --- a/Application/Admin/View/Statistics/overview.html +++ b/Application/Admin/View/Statistics/overview.html @@ -403,6 +403,9 @@
  • class="active" > 年排行
  • +
  • + {$game_date_info} +
  • @@ -517,6 +520,9 @@
  • class="active" > 年排行
  • +
  • + {$promote_date_info} +