diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php index 5b88e0a5f..934483ccb 100644 --- a/Application/Base/Repository/SpendRepository.class.php +++ b/Application/Base/Repository/SpendRepository.class.php @@ -17,16 +17,16 @@ class SpendRepository { $isBan = $params['is_ban'] ?? false; $map = []; - $map['pay_status']=1; + $map['pay_status'] = 1; + $map['promote_id'] = ['in', $ids]; $map['pay_time'] = ['between', [$beginTime, $endTime]]; $map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0]; - $map['promote_id'] = ['in', [1,2]]; $map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1']; $field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time,game_id as pay_num'; $subTable = M('spend', 'tab_')->field($field)->where($map)->group('pay_time')->select(false); - $data = M('spend', 'tab_')->field('a.pay_time,count(DISTINCT a.pay_num) as pay_num')->table('(' . $subTable . ') as a')->group('a.pay_time')->select(); - var_dump(M()->getLastSql());die(); + $data = M()->field('a.pay_time,count(DISTINCT a.pay_num) as pay_num')->table('(' . $subTable . ') as a')->group('a.pay_time')->select(); + // var_dump(M()->getLastSql());die(); return $data; } } \ No newline at end of file diff --git a/Application/Base/Repository/UserRepository.class.php b/Application/Base/Repository/UserRepository.class.php new file mode 100644 index 000000000..715e39061 --- /dev/null +++ b/Application/Base/Repository/UserRepository.class.php @@ -0,0 +1,55 @@ + 0) { + $tmap['fgame_id'] = $map['up.game_id'] = $gameId; + } + + if ($serverId > 0) { + $tmap['fgame_id'] = $map['up.game_id'] = $serverId; + } + + $tmap['promote_id'] = $map['tab_user.promote_id'] = ['in', $ids]; + + $union = M('user', 'tab_')->field('FROM_UNIXTIME(register_time,"%Y-%m-%d") as time,GROUP_CONCAT(DISTINCT id) as user_id') + ->where($tmap)->group('time')->select(false); + + $sql = M('user', 'tab_')->field('FROM_UNIXTIME(up.login_time,"%Y-%m-%d") as time,GROUP_CONCAT(DISTINCT up.user_id) as user_id') + ->join('tab_user_login_record up on up.user_id=tab_user.id','inner') + ->union($union) + ->where($map)->group('time')->select(false); + + $lists = M()->table('('.$sql.') as a')->field('a.time,GROUP_CONCAT(a.user_id) as user_id')->group('a.time')->select(); + + $data = []; + foreach($lists as $k => $v) { + $login = array_unique(explode(',', $v['user_id'])); + $data[$k] = [ + 'time' => $v['time'], + 'login_num' => count($login), + ]; + } + return $data; + } +} \ No newline at end of file diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index ea41649c2..07a8d0915 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -632,6 +632,15 @@ class QueryController extends BaseController { $this->meta_title = "ARPU统计"; + $promote = $this->getLoginPromote(); + $map = [ + '_logic' => 'or', + 'id' => $promote['id'], + 'parent_id' => $promote['id'], + 'grand_id' => $promote['id'], + ]; + $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $time = I('time', date('Y-m-d')); $sdkVersion = I('sdk_version', 0); $gameId = I('game_id', 0); @@ -647,6 +656,7 @@ class QueryController extends BaseController if ($sdkVersion > 0) { $params['sdk_version'] = $sdkVersion; } + $params['promote_id'] = $ids; list($beginTime, $endTime) = $this->getBetweenTime($time); $params['begin_time'] = $beginTime; $params['end_time'] = $endTime;