master
yulingwei 5 years ago
parent 0d258c1d8d
commit 9ebc7d3655

@ -593,17 +593,19 @@ class StatController extends ThinkController
$map['tab_user.promote_id']=$map_list['promote_id']; $map['tab_user.promote_id']=$map_list['promote_id'];
} }
unset($map['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 = strtotime("+1 day",strtotime($time));
$login_time_end = $login_time+86399; $login_time_end = $login_time+86399;
$num = M('user','tab_') $num_sql = M('user','tab_')
->field('count(DISTINCT tab_user.id) as num') ->field('tab_user.id')
->join("right join tab_user_login_record as ur on ur.user_id = 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") and ur.login_time between $login_time and $login_time_end")
->where($map) ->where($map)
->group('user_id') ->group('user_id')
->find(); ->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; $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100;
//充值 //充值
$map = $map_list; $map = $map_list;
@ -1139,9 +1141,11 @@ class StatController extends ThinkController
$mapl['tab_user.promote_id']=$mapl['promote_id']; $mapl['tab_user.promote_id']=$mapl['promote_id'];
unset($mapl['promote_id']); unset($mapl['promote_id']);
$login_time = date('Y-m-d', strtotime("+1 day",strtotime($time))); $login_time = date('Y-m-d', strtotime("+1 day",strtotime($time)));
$login_start = strtotime($login_time);
$login_end = $login_start + 86399;
$num = $user $num = $user
->field('count(DISTINCT tab_user.id) as num') ->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) ->where($mapl)
->find(); ->find();
$data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100; $data[$key]['keep_num'] = round($num['num']/$data[$key]['register_num'],4)*100;

@ -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}]} {"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}]}

@ -1959,35 +1959,45 @@ class UserModel extends Model{
*/ */
public function activeRankOnPromote($timestr,$fieldname='count',$promoteid='',$row=0,$ordermark='desc') { 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') $sql = $this->field('promote_id,tab_user.id')
->join('tab_promote on (tab_promote.id = tab_user.promote_id) ')
->where(['register_time'.$timestr,$map]) ->where(['register_time'.$timestr,$map])
->select(false); ->select(false);
$mid = $this->field('tab_user.promote_id,tab_promote.account as promote_account,tab_user.id') // $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_user_login_record as uu on tab_user.id = uu.user_id')
->join('tab_promote on(tab_user.promote_id = tab_promote.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) ->union($sql)
->group('tab_user.promote_id,tab_user.id') ->group('uu.promote_id, uu.user_id')
->where(['uu.login_time '.$timestr,$map]) ->where(['uu.login_time '.$timestr,$map])
->select(false); ->select(false);
$last = $this->table('('.$mid.') as a')->field('a.promote_id,a.promote_account,GROUP_CONCAT(a.id),count(a.id) as '.$fieldname) $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); ->group('a.promote_id')->select(false);
if($row>0) { 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 { } 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; return $data;
@ -2012,10 +2022,16 @@ class UserModel extends Model{
->where(['register_time'.$timestr,$map2]) ->where(['register_time'.$timestr,$map2])
->select(false); ->select(false);
$mid = $this->field('uu.game_id,game_name,tab_user.id') // $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') // ->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) ->union($sql)
->group('uu.game_id,tab_user.id') ->group('uu.game_id, uu.user_id')
->where(['uu.login_time '.$timestr,$map]) ->where(['uu.login_time '.$timestr,$map])
->select(false); ->select(false);
@ -2024,12 +2040,12 @@ class UserModel extends Model{
if($row>0) { 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 { } 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();
} }

Loading…
Cancel
Save