|
|
|
@ -66,9 +66,11 @@ class UserRepository
|
|
|
|
|
$conditions = [];
|
|
|
|
|
$conditions['promote_id'] = ['in', $ids];
|
|
|
|
|
$conditions[$params['time_column']] = ['between', [$beginTime, $endTime]];
|
|
|
|
|
$conditions['game_id'] = ['in', $gameIds];
|
|
|
|
|
if (!empty($params['server_id'])) {
|
|
|
|
|
$conditions['server_id'] = $params['server_id'];
|
|
|
|
|
if (!empty($gameIds)) {
|
|
|
|
|
$conditions['game_id'] = ['in', $gameIds];
|
|
|
|
|
if (!empty($params['server_id'])) {
|
|
|
|
|
$conditions['server_id'] = $params['server_id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $conditions;
|
|
|
|
@ -154,12 +156,21 @@ class UserRepository
|
|
|
|
|
$gameIds = $params['game_ids'] ?? [];
|
|
|
|
|
$params['time_column'] = 'login_time';
|
|
|
|
|
$conditions = $this->getGameGroupConditions($params);
|
|
|
|
|
$items = M('user_login_record', 'tab_')->field('game_id, count(DISTINCT user_id) as count')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
$sql = M('user_login_record', 'tab_')->field('distinct game_id, user_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->fetchSql(true)
|
|
|
|
|
->select();
|
|
|
|
|
$model = new \Think\Model();
|
|
|
|
|
return $model->query("select count(*) as num from ($sql) as t")[0]['num'];
|
|
|
|
|
} else {
|
|
|
|
|
$items = M('user_login_record', 'tab_')->field('game_id, count(DISTINCT user_id) as count')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -268,11 +279,17 @@ class UserRepository
|
|
|
|
|
$params['time_column'] = 'create_time';
|
|
|
|
|
$conditions = $this->getCreateRoleByGameConditions($params);
|
|
|
|
|
|
|
|
|
|
$items = M('user_play_info', 'tab_')->field('count(*) count, game_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
return M('user_play_info', 'tab_')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->count();
|
|
|
|
|
} else {
|
|
|
|
|
$items = M('user_play_info', 'tab_')->field('count(*) count, game_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -300,11 +317,20 @@ class UserRepository
|
|
|
|
|
$params['time_column'] = 'create_time';
|
|
|
|
|
$conditions = $this->getCreateRoleByGameConditions($params);
|
|
|
|
|
|
|
|
|
|
$items = M('user_play_info', 'tab_')->field('count(distinct game_id,user_id) count, game_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
$sql = M('user_play_info', 'tab_')->field('distinct game_id, user_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->fetchSql(true)
|
|
|
|
|
->select();
|
|
|
|
|
$model = new \Think\Model();
|
|
|
|
|
return $model->query("select count(*) as num from ($sql) as t")[0]['num'];
|
|
|
|
|
} else {
|
|
|
|
|
$items = M('user_play_info', 'tab_')->field('count(distinct user_id) count, game_id')
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -356,12 +382,20 @@ class UserRepository
|
|
|
|
|
->where("ti.user_id = user_id and ti.game_id = game_id and ti.create_time < " . $params['begin_time'])
|
|
|
|
|
->fetchSql(true)
|
|
|
|
|
->count();
|
|
|
|
|
$items = $model->field("count(distinct game_id,user_id) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
return count($model->field("game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id, user_id')
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select());
|
|
|
|
|
} else {
|
|
|
|
|
$items = $model->field("count(distinct user_id) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -413,12 +447,20 @@ class UserRepository
|
|
|
|
|
->where("ti.create_device_number = create_device_number and ti.game_id = game_id and ti.create_time < " . $params['begin_time'])
|
|
|
|
|
->fetchSql(true)
|
|
|
|
|
->count();
|
|
|
|
|
$items = $model->field("count(distinct game_id,create_device_number) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
return count($model->field("game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id, create_device_number')
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select());
|
|
|
|
|
} else {
|
|
|
|
|
$items = $model->field("count(distinct game_id,create_device_number) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -470,11 +512,19 @@ class UserRepository
|
|
|
|
|
->where("ti.create_ip = create_ip and ti.game_id = game_id and ti.create_time < " . $params['begin_time'])
|
|
|
|
|
->fetchSql(true)
|
|
|
|
|
->count();
|
|
|
|
|
$items = $model->field("count(distinct game_id,create_ip) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
if (isset($params['all_data'])) {
|
|
|
|
|
return count($model->field("game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group('game_id, create_ip')
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select());
|
|
|
|
|
} else {
|
|
|
|
|
$items = $model->field("count(distinct game_id,create_ip) count, game_id, (" . $sql . ") as num")
|
|
|
|
|
->where($conditions)
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->having('num = 0')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->assembleRecords($items, $gameIds, 'count', 'game_id');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|