diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index fad630ebd..96a7e4557 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -593,17 +593,19 @@ class StatController extends ThinkController $map['tab_user.promote_id']=$map_list['promote_id']; } unset($map['promote_id']); - $map["FROM_UNIXTIME(register_time,'%Y-%m-%d')"] = $time; + //$map["FROM_UNIXTIME(,'%Y-%m-%d')"] = $time; + $map["register_time"] = ['between', [strtotime($time), strtotime($time)+86399]]; $login_time = strtotime("+1 day",strtotime($time)); $login_time_end = $login_time+86399; - $num = M('user','tab_') - ->field('count(DISTINCT tab_user.id) as num') + $num_sql = M('user','tab_') + ->field('tab_user.id') ->join("right join tab_user_login_record as ur on ur.user_id = tab_user.id - and ur.login_time between $login_time and $login_time_end") - ->where($map) - ->group('user_id') - ->find(); + and ur.login_time between $login_time and $login_time_end") + ->where($map) + ->group('user_id') + ->select(false); + $num = M()->query("select count(*) as total from ({$num_sql}) t limit 1")[0]['total']; $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; //充值 $map = $map_list; @@ -1139,9 +1141,11 @@ class StatController extends ThinkController $mapl['tab_user.promote_id']=$mapl['promote_id']; unset($mapl['promote_id']); $login_time = date('Y-m-d', strtotime("+1 day",strtotime($time))); + $login_start = strtotime($login_time); + $login_end = $login_start + 86399; $num = $user ->field('count(DISTINCT tab_user.id) as num') - ->join("right join tab_user_login_record as ur on ur.user_id = tab_user.id and FROM_UNIXTIME(ur.login_time,'%Y-%m-%d') = '{$login_time}'") + ->join("right join tab_user_login_record as ur on ur.user_id = tab_user.id and ur.login_time between {$login_start} and {$login_end}") ->where($mapl) ->find(); $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt index f2bc7fb38..06372c756 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":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 +{"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":2,"player":0,"money":0},"active":[{"time":"0:00","count":1},{"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":1},{"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/Model/UserModel.class.php b/Application/Admin/Model/UserModel.class.php index e5529b227..b97b16d3c 100644 --- a/Application/Admin/Model/UserModel.class.php +++ b/Application/Admin/Model/UserModel.class.php @@ -1959,36 +1959,46 @@ class UserModel extends Model{ */ public function activeRankOnPromote($timestr,$fieldname='count',$promoteid='',$row=0,$ordermark='desc') { - $map['tab_user.promote_id']=array('gt',0); + $map['promote_id']=array('gt',0); - if ($promoteid[0]) {$map['tab_user.promote_id']=array('in',$promoteid);} + if ($promoteid[0]) {$map['promote_id']=array('in',$promoteid);} - $sql = $this->field('tab_user.promote_id,tab_promote.account as promote_account,tab_user.id') - ->join('tab_promote on (tab_promote.id = tab_user.promote_id) ') + $sql = $this->field('promote_id,tab_user.id') ->where(['register_time'.$timestr,$map]) ->select(false); - $mid = $this->field('tab_user.promote_id,tab_promote.account as promote_account,tab_user.id') - ->join('tab_user_login_record as uu on tab_user.id = uu.user_id') - ->join('tab_promote on(tab_user.promote_id = tab_promote.id)') - ->union($sql) - ->group('tab_user.promote_id,tab_user.id') - ->where(['uu.login_time '.$timestr,$map]) - ->select(false); - - $last = $this->table('('.$mid.') as a')->field('a.promote_id,a.promote_account,GROUP_CONCAT(a.id),count(a.id) as '.$fieldname) - ->group('a.promote_id')->select(false); - + // $mid = $this->field('tab_user.promote_id,tab_promote.account as promote_account,tab_user.id') + // ->join('tab_user_login_record as uu on tab_user.id = uu.user_id') + // ->join('tab_promote on(tab_user.promote_id = tab_promote.id)') + // ->union($sql) + // ->group('tab_user.promote_id,tab_user.id') + // ->where(['uu.login_time '.$timestr,$map]) + // ->select(false); + + $mid = M('user_login_record', 'tab_')->alias("uu")->field('uu.promote_id, uu.user_id as id') + ->union($sql) + ->group('uu.promote_id, uu.user_id') + ->where(['uu.login_time '.$timestr,$map]) + ->select(false); + + $last = $this->table('('.$mid.') as a')->field('a.promote_id,GROUP_CONCAT(a.id),count(a.id) as '.$fieldname) + ->group('a.promote_id')->select(false); if($row>0) { - $data = $this->table('('.$last.') as b')->limit($row)->order('b.'.$fieldname.' '.$ordermark)->select(); - + $data = $this->table('('.$last.') as b')->limit($row)->order('b.'.$fieldname.' '.$ordermark)->limit(10)->select(); } else { - $data = $this->table('('.$last.') as b')->order('b.'.$fieldname.' '.$ordermark)->select(); + $data = $this->table('('.$last.') as b')->order('b.'.$fieldname.' '.$ordermark)->limit(10)->select(); - } + } + if (!empty($data)) { + $promoters = M('promote', 'tab_')->field('id, account')->where(['id'=>['in', array_column($data, 'promote_id')]])->select(); + $promoter_names = array_column($promoters, 'account', 'id'); + foreach ($data as &$item) { + $item['promote_account'] = isset($promoter_names[$item['promote_id']]) ? $promoter_names[$item['promote_id']] : ''; + } + } return $data; } @@ -2012,27 +2022,33 @@ class UserModel extends Model{ ->where(['register_time'.$timestr,$map2]) ->select(false); - $mid = $this->field('uu.game_id,game_name,tab_user.id') - ->join('tab_user_login_record as uu on tab_user.id = uu.user_id') - ->union($sql) - ->group('uu.game_id,tab_user.id') - ->where(['uu.login_time '.$timestr,$map]) - ->select(false); + // $mid = $this->field('uu.game_id,game_name,tab_user.id') + // ->join('tab_user_login_record as uu on tab_user.id = uu.user_id') + // ->union($sql) + // ->group('uu.game_id,tab_user.id') + // ->where(['uu.login_time '.$timestr,$map]) + // ->select(false); + + $mid = M('user_login_record', 'tab_')->alias("uu")->field('game_id,game_name,user_id as id') + ->union($sql) + ->group('uu.game_id, uu.user_id') + ->where(['uu.login_time '.$timestr,$map]) + ->select(false); $last = $this->table('('.$mid.') as a')->field('a.game_id,a.game_name,GROUP_CONCAT(a.id),count(a.id) as '.$fieldname) ->group('a.game_id')->select(false); if($row>0) { - $data = $this->table('('.$last.') as b')->limit($row)->order('b.'.$fieldname.' '.$ordermark)->select(); + $data = $this->table('('.$last.') as b')->limit($row)->order('b.'.$fieldname.' '.$ordermark)->limit(10)->select(); } else { - $data = $this->table('('.$last.') as b')->order('b.'.$fieldname.' '.$ordermark)->select(); - - } + $data = $this->table('('.$last.') as b')->order('b.'.$fieldname.' '.$ordermark)->limit(10)->select(); + } + return $data; }