master
ELF 5 years ago
parent 0dc0063092
commit ab4dc74784

@ -17,16 +17,16 @@ class SpendRepository {
$isBan = $params['is_ban'] ?? false; $isBan = $params['is_ban'] ?? false;
$map = []; $map = [];
$map['pay_status']=1; $map['pay_status'] = 1;
$map['promote_id'] = ['in', $ids];
$map['pay_time'] = ['between', [$beginTime, $endTime]]; $map['pay_time'] = ['between', [$beginTime, $endTime]];
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0]; $map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
$map['promote_id'] = ['in', [1,2]];
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1']; $map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time,game_id as pay_num'; $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); $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(); $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(); // var_dump(M()->getLastSql());die();
return $data; return $data;
} }
} }

@ -0,0 +1,55 @@
<?php
namespace Base\Repository;
class UserRepository {
public function __construct()
{
}
/**
* 按照时间分组统计登录总数
*/
public function getLoginCountByDay($params) {
$beginTime = $params['begin_time'] ?? 0;
$endTime = $params['end_time'] ?? 0;
$gameId = $params['game_id'] ?? 0;
$serverId = $params['server_id'] ?? 0;
$ids = $params['promote_id'] ?? [];
$tmap = $map = [];
$tmap['lock_status'] = $map['lock_status'] = 1;
$tmap['register_time'] = $map['up.login_time'] = ['between', [$beginTime, $endTime]];
if ($gameId > 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;
}
}

@ -632,6 +632,15 @@ class QueryController extends BaseController
{ {
$this->meta_title = "ARPU统计"; $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')); $time = I('time', date('Y-m-d'));
$sdkVersion = I('sdk_version', 0); $sdkVersion = I('sdk_version', 0);
$gameId = I('game_id', 0); $gameId = I('game_id', 0);
@ -647,6 +656,7 @@ class QueryController extends BaseController
if ($sdkVersion > 0) { if ($sdkVersion > 0) {
$params['sdk_version'] = $sdkVersion; $params['sdk_version'] = $sdkVersion;
} }
$params['promote_id'] = $ids;
list($beginTime, $endTime) = $this->getBetweenTime($time); list($beginTime, $endTime) = $this->getBetweenTime($time);
$params['begin_time'] = $beginTime; $params['begin_time'] = $beginTime;
$params['end_time'] = $endTime; $params['end_time'] = $endTime;

Loading…
Cancel
Save