解决冲突
commit
06bfdbca93
@ -0,0 +1,355 @@
|
||||
<?php
|
||||
namespace Base\Repository;
|
||||
|
||||
class PromoteRepository {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function assembleZero($allKeys, $records, $zeroValue) {
|
||||
$noExistKeys = array_diff($allKeys, array_keys($records));
|
||||
foreach ($noExistKeys as $key) {
|
||||
$records[$key] = $zeroValue;
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业绩公共map
|
||||
*/
|
||||
private function getPublicAchievementMap($ids, $params)
|
||||
{
|
||||
$isContainSubs = false;
|
||||
if (isset($params['isContainSubs']) && $params['isContainSubs']) {
|
||||
$isContainSubs = true;
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
if ($isContainSubs) {
|
||||
$map['promote_id'] = ['in', array_merge($ids, array_keys($params['basicPromotes']))];
|
||||
}
|
||||
if (isset($params['game_id'])) {
|
||||
$map['game_id'] = $params['game_id'];
|
||||
}
|
||||
if (isset($params['server_id'])) {
|
||||
$map['server_id'] = $params['server_id'];
|
||||
}
|
||||
if (isset($params['sdk_version'])) {
|
||||
$map['sdk_version'] = $params['sdk_version'];
|
||||
}
|
||||
if (isset($params['begin_time']) && isset($params['begin_time'])) {
|
||||
$map['create_time'] = ['between', [$params['begin_time'], $params['end_time']]];
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的角色创建数
|
||||
*/
|
||||
public function getCreateRoleCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, $records, 0);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的角色创建的用户数
|
||||
*/
|
||||
public function getCreateRoleUserCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
$items = M('user_play_info', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, $records, 0);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的新创角设备数
|
||||
*/
|
||||
public function getNewCreateRoleDeviceCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
|
||||
$subMap = $map;
|
||||
if (isset($params['begin_time']) && isset($params['begin_time'])) {
|
||||
$subMap['create_time'] = ['lt', $params['begin_time']];
|
||||
}
|
||||
|
||||
$subQuery = M('user_play_info', 'tab_')->field('create_device_number')->group('create_device_number')->where($subMap)->buildSql();
|
||||
$map['create_device_number'] = ['exp', ' not in (' . $subQuery . ')'];
|
||||
$inQuery = M('user_play_info', 'tab_')->field('create_device_number')->group('create_device_number')->where($map)->buildSql();
|
||||
|
||||
$resultMap = ['create_device_number' => ['exp', ' in (' . $inQuery . ')']];
|
||||
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, [], 0);
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的新创角IP数
|
||||
*/
|
||||
public function getNewCreateRoleIpCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
|
||||
$subMap = $map;
|
||||
if (isset($params['begin_time']) && isset($params['begin_time'])) {
|
||||
$subMap['create_time'] = ['lt', $params['begin_time']];
|
||||
}
|
||||
|
||||
$subQuery = M('user_play_info', 'tab_')->field('create_ip')->group('create_ip')->where($subMap)->buildSql();
|
||||
$map['create_ip'] = ['exp', ' not in (' . $subQuery . ')'];
|
||||
$inQuery = M('user_play_info', 'tab_')->field('create_ip')->group('create_ip')->where($map)->buildSql();
|
||||
|
||||
$resultMap = ['create_ip' => ['exp', ' in (' . $inQuery . ')']];
|
||||
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, [], 0);
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的新创角用户数
|
||||
*/
|
||||
public function getNewCreateRoleUserCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
|
||||
$subMap = $map;
|
||||
if (isset($params['begin_time']) && isset($params['begin_time'])) {
|
||||
$subMap['create_time'] = ['lt', $params['begin_time']];
|
||||
}
|
||||
|
||||
$subQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($subMap)->buildSql();
|
||||
$map['user_id'] = ['exp', ' not in (' . $subQuery . ')'];
|
||||
$inQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($map)->buildSql();
|
||||
|
||||
$resultMap = ['user_id' => ['exp', ' in (' . $inQuery . ')']];
|
||||
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, [], 0);
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的登录用户数
|
||||
*/
|
||||
public function getLoginUserCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
$items = M('user', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, $records, 0);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的充值次数
|
||||
*/
|
||||
public function getRechargeCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
|
||||
$items = M('spend', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, $records, 0);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的充值用户数
|
||||
*/
|
||||
public function getRechargeUserCountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
$items = M('spend', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select();
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$promoteId = $item['promote_id'];
|
||||
if (isset($params['basicPromotes'][$item['promote_id']])) {
|
||||
$promoteId = $params['basicPromotes'][$item['promote_id']];
|
||||
}
|
||||
if (isset($records[$promoteId])) {
|
||||
$records[$promoteId] += $item['count'];
|
||||
} else {
|
||||
$records[$promoteId] = $item['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->assembleZero($ids, $records, 0);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定推广员底下的充值金额(分类型)
|
||||
*/
|
||||
public function getRechargeAmountByIds(array $ids, array $params = [])
|
||||
{
|
||||
if (count($ids) == 0) {
|
||||
return [];
|
||||
}
|
||||
$map = $this->getPublicAchievementMap($ids, $params);
|
||||
$items = M('spend', 'tab_')->field(['sum(pay_amount) amount', 'promote_id', 'pay_way'])->where($map)->group('promote_id, pay_way')->select();
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
if ($item['pay_way'] == -1) {
|
||||
$records[$item['promote_id']]['ban_coin'] = $item['amount'];
|
||||
} elseif ($item['pay_way'] == 0) {
|
||||
$records[$item['promote_id']]['coin'] = $item['amount'];
|
||||
} else {
|
||||
if (isset($records[$item['promote_id']])) {
|
||||
$records[$item['promote_id']]['cash'] = isset($records[$item['promote_id']]['cash']) ?
|
||||
$records[$item['promote_id']]['cash'] + $item['amount'] :
|
||||
$item['amount'];
|
||||
} else {
|
||||
$records[$item['promote_id']]['cash'] = $item['amount'];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
foreach ($ids as $id) {
|
||||
if (isset($records[$id])) {
|
||||
$records[$id] = [
|
||||
'ban_coin' => isset($records[$id]['ban_coin']) ? $records[$id]['ban_coin'] : 0,
|
||||
'coin' => isset($records[$id]['coin']) ? $records[$id]['coin'] : 0,
|
||||
'cash' => isset($records[$id]['cash']) ? $records[$id]['cash'] : 0,
|
||||
];
|
||||
} else {
|
||||
$records[$id] = [
|
||||
'ban_coin' => 0,
|
||||
'coin' => 0,
|
||||
'cash' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
}
|
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace Base\Repository;
|
||||
|
||||
class SpendRepository {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function assembleDayRecords($items, $dayList, $valueColumn, $dayColumn = 'day')
|
||||
{
|
||||
$records = [];
|
||||
foreach ($dayList as $day) {
|
||||
$dayValue = 0;
|
||||
foreach ($items as $item) {
|
||||
if ($item[$dayColumn] == $day) {
|
||||
$dayValue = $item[$valueColumn];
|
||||
}
|
||||
}
|
||||
$records[$day] = $dayValue;
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 付费游戏数
|
||||
*/
|
||||
public function getPayGameCountByDay($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'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
|
||||
$map = [];
|
||||
$map['pay_status'] = 1;
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
||||
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
|
||||
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day, count(DISTINCT game_id) count';
|
||||
$items = M('spend', 'tab_')->field($field)->where($map)->group('day')->select();
|
||||
return $this->assembleDayRecords($items, $dayList, 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按天统计付款总额
|
||||
*/
|
||||
public function getPayAmountByDay($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'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
|
||||
$map['pay_status'] = 1;
|
||||
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
||||
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
|
||||
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day,sum(pay_amount) as amount';
|
||||
$items = M('spend', 'tab_')->field($field)->where($map)->group('FROM_UNIXTIME(day, "%Y-%m-%d")')->select();
|
||||
return $this->assembleDayRecords($items, $dayList, 'amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按天统计付款用户数
|
||||
*/
|
||||
public function getPayUserCountByDay($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'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
|
||||
$map['pay_status'] = 1;
|
||||
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
||||
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
|
||||
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day, count(distinct user_id) count';
|
||||
|
||||
$items = M('spend', 'tab_')->field($field)->where($map)->group('day')->select();
|
||||
return $this->assembleDayRecords($items, $dayList, 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间分组统计新增付费用户数
|
||||
*/
|
||||
public function getNewPayUserCountByDay($params) {
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
$gameId = $params['game_id'] ?? 0;
|
||||
$serverId = $params['server_id'] ?? 0;
|
||||
$ids = $params['promote_id'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
|
||||
$map = [];
|
||||
$map['pay_status']=1;
|
||||
if ($gameId > 0) {
|
||||
$map['game_id'] = $gameId;
|
||||
}
|
||||
if ($serverId > 0) {
|
||||
$map['server_id'] = $serverId;
|
||||
}
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
$oldMap = $map;
|
||||
|
||||
$records = [];
|
||||
foreach ($dayList as $day) {
|
||||
$time = strtotime($day);
|
||||
$oldMap['pay_time'] = ['lt', $time];
|
||||
$map['pay_time'] = ['between', [$time, ($time + 24 * 3600 -1)]];
|
||||
$oldQuery = M('spend', 'tab_')->field('user_id')->where($oldMap)->group('user_id')->buildSql();
|
||||
$map['user_id'] = ['exp', ' not in (' . $oldQuery . ')'];
|
||||
$result = M('spend', 'tab_')->field('count(distinct user_id) count')->where($map)->find();
|
||||
$records[$day] = $result['count'];
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间分组统计新增付费用户付费金额
|
||||
*/
|
||||
public function getNewPayAmountByDay($params) {
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
$gameId = $params['game_id'] ?? 0;
|
||||
$serverId = $params['server_id'] ?? 0;
|
||||
$ids = $params['promote_id'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
|
||||
$map = [];
|
||||
$map['pay_status']=1;
|
||||
if ($gameId > 0) {
|
||||
$map['game_id'] = $gameId;
|
||||
}
|
||||
if ($serverId > 0) {
|
||||
$map['server_id'] = $serverId;
|
||||
}
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
$oldMap = $map;
|
||||
|
||||
$records = [];
|
||||
foreach ($dayList as $day) {
|
||||
$time = strtotime($day);
|
||||
$oldMap['pay_time'] = ['lt', $time];
|
||||
$map['pay_time'] = ['between', [$time, ($time + 24 * 3600 -1)]];
|
||||
|
||||
$oldQuery = M('spend', 'tab_')->field('user_id')->where($oldMap)->group('user_id')->buildSql();
|
||||
$map['user_id'] = ['exp', ' not in (' . $oldQuery . ')'];
|
||||
$result = M('spend', 'tab_')->field('sum(pay_amount) amount')->where($map)->find();
|
||||
$records[$day] = floatval($result['amount']);
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计给定时间前的付费玩家总数
|
||||
*/
|
||||
public function getHistoryPayCountByDay($params) {
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
$gameId = $params['game_id'] ?? 0;
|
||||
$serverId = $params['server_id'] ?? 0;
|
||||
$ids = $params['promote_id'] ?? [];
|
||||
$isBan = $params['is_ban'] ?? false;
|
||||
|
||||
$map = [];
|
||||
$map['pay_status']=1;
|
||||
if ($gameId > 0) {
|
||||
$map['game_id'] = $gameId;
|
||||
}
|
||||
if ($serverId > 0) {
|
||||
$map['server_id'] = $serverId;
|
||||
}
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
||||
|
||||
$records = [];
|
||||
foreach ($dayList as $day) {
|
||||
$time = strtotime($day);
|
||||
$map['pay_time'] = ['elt', $time];
|
||||
$result = M('spend', 'tab_')->field('count(DISTINCT user_id) as count')->where($map)->find();
|
||||
$records[$day] = $result['count'];
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace Base\Repository;
|
||||
|
||||
class UserRepository {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function assembleDayRecords($items, $dayList, $valueColumn, $dayColumn = 'day')
|
||||
{
|
||||
$records = [];
|
||||
foreach ($dayList as $day) {
|
||||
$dayValue = 0;
|
||||
foreach ($items as $item) {
|
||||
if ($item[$dayColumn] == $day) {
|
||||
$dayValue = $item[$valueColumn];
|
||||
}
|
||||
}
|
||||
$records[$day] = $dayValue;
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间分组统计登录总数
|
||||
*/
|
||||
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'] ?? [];
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
|
||||
$map = [];
|
||||
$map['login_time'] = ['between', [$beginTime, $endTime]];
|
||||
|
||||
if ($gameId > 0) {
|
||||
$map['game_id'] = $gameId;
|
||||
}
|
||||
if ($serverId > 0) {
|
||||
$map['server_id'] = $serverId;
|
||||
}
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
|
||||
$items = M('user_login_record', 'tab_')->field('FROM_UNIXTIME(login_time, "%Y-%m-%d") as day, count(DISTINCT user_id) as count')
|
||||
->where($map)
|
||||
->group('day')
|
||||
->select();
|
||||
|
||||
return $this->assembleDayRecords($items, $dayList, 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间分组统计注册总数
|
||||
*/
|
||||
public function getRegisterCountByDay($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'] ?? [];
|
||||
$dayList = $params['dayList'] ?? [];
|
||||
|
||||
$dateform = '%Y-%m-%d';
|
||||
|
||||
$map = [];
|
||||
$map['register_time'] = ['between', [$beginTime, $endTime]];
|
||||
|
||||
if ($gameId > 0) {
|
||||
$map['fgame_id'] = $gameId;
|
||||
}
|
||||
|
||||
$map['promote_id'] = ['in', $ids];
|
||||
$map['puid'] = 0;
|
||||
|
||||
$items = M('user', 'tab_')->field('count(*) count, FROM_UNIXTIME(register_time,"'.$dateform.'") as day')
|
||||
->where($map)
|
||||
->group('day')
|
||||
->select();
|
||||
return $this->assembleDayRecords($items, $dayList, 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间分组统计注册编号序列
|
||||
* @param string $newslist 新玩家序列
|
||||
* @param integer $end 结束时间(时间戳)
|
||||
* @param integer $game_id 游戏编号
|
||||
* @param integer/string $promote_id 渠道编号或渠道编号列表字符串(字符串逗号分隔)
|
||||
* @param integer $flag 留存类型
|
||||
* @return array 详细数据
|
||||
* @author 鹿文学
|
||||
*/
|
||||
public function getRatentionRate($newslist,$game_id=0,$promote_id=0,$flag=1) {
|
||||
|
||||
|
||||
$map['lock_status']=1;
|
||||
if($game_id>0) {
|
||||
$map['up.game_id'] = $game_id;
|
||||
}
|
||||
$map['tab_user.promote_id'] = is_numeric($promote_id)?$promote_id:array('in',$promote_id);
|
||||
|
||||
$group = 'up.login_time';
|
||||
|
||||
$fieldname = 'retention_rate'.$flag;
|
||||
|
||||
foreach ($newslist as $value) {
|
||||
$ct1 = strtotime("+$flag day",strtotime($value['time']));
|
||||
$ct2 = strtotime("+1 day",$ct1)-1;
|
||||
|
||||
$map[$group] = array(array('egt',$ct1),array('elt',$ct2));
|
||||
|
||||
$map['user_id']=array('in',$value['id']);
|
||||
$count = count(explode(',',$value['id']));
|
||||
|
||||
|
||||
$d = $this
|
||||
->field('count(distinct up.user_id) as '.$fieldname.' ,FROM_UNIXTIME(up.login_time,"%Y-%m-%d") as play_time')
|
||||
->join('tab_user_login_record up on tab_user.id=up.user_id','right')
|
||||
->where($map)
|
||||
->group('play_time')
|
||||
->select();
|
||||
|
||||
if ($d)
|
||||
$data[]=array(
|
||||
"play_time"=>$value['time'],
|
||||
$fieldname=>($d[0][$fieldname]==0)?0:sprintf("%.2f",($d[0][$fieldname]/$count)*100)
|
||||
);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
<extend name="Public/promote_base"/>
|
||||
<block name="css">
|
||||
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
|
||||
<style>
|
||||
.form-group {
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-group label {
|
||||
line-height: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
</style>
|
||||
</block>
|
||||
<block name="body">
|
||||
<div class="page-list normal_list promote-mychlid-list">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>数据中心></span><span>团队推广业绩</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_normal_game.png">
|
||||
<span class="title_main">团队推广业绩</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-search clearfix">
|
||||
<form action="{:U('Query/achievement',array('row'=>I('get.row')))}" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group normal_space">
|
||||
<select id="game-select" name="game_id" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">请选择游戏</option>
|
||||
<volist name="games" id="game">
|
||||
<option value="{$game.game_id}" <if condition="I('game_id') eq $game['game_id']">selected</if>>{$game.game_name}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group normal_space">
|
||||
<select id="server-select" name="server_id" class="reselect select_gallery" style="width: 220px;" data-server="{:I('server_id', 0)}" >
|
||||
<option value="0">请选择区服</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group normal_space">
|
||||
<select name="sdk_version" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">请选择设备类型</option>
|
||||
<option value="1" <if condition="I('sdk_version') === '1'">selected</if>>Andriod</option>
|
||||
<option value="2" <if condition="I('sdk_version') === '2'">selected</if>>IOS</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group normal_space">
|
||||
<select name="status" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">帐号状态</option>
|
||||
<option value="1" <if condition="I('status') === '1'">selected</if>>正常</option>
|
||||
<option value="2" <if condition="I('status') === '2'">selected</if>>冻结</option>
|
||||
</select>
|
||||
</div>
|
||||
<if condition="$parent_id eq 0">
|
||||
<div class="form-group normal_space">
|
||||
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">请选择组长</option>
|
||||
<volist name="subPromotes" id="promote">
|
||||
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>{$promote.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
</if>
|
||||
<if condition="$parent_id gt 0 and $grand_id eq 0">
|
||||
<div class="form-group normal_space">
|
||||
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="0">请选择推广员</option>
|
||||
<volist name="subPromotes" id="promote">
|
||||
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>{$promote.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
</if>
|
||||
<div class="form-group normal_space fr">
|
||||
<label>起止时间:</label>
|
||||
<input type="text" class="txt range-date" name="time" placeholder="起止时间" value="{:I('time')}" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="submit normal_space" value="查询">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="trunk-list list_normal">
|
||||
<table class="table normal_table">
|
||||
<tr class="odd">
|
||||
<th>账号(姓名)</th>
|
||||
<th>创角数</th>
|
||||
<th>创角用户</th>
|
||||
<th>新创角用户</th>
|
||||
<th>新创角设备</th>
|
||||
<th>新创角IP</th>
|
||||
<th>登录用户数</th>
|
||||
<th>充值人数</th>
|
||||
<th>充值次数</th>
|
||||
<th>充值总额</th>
|
||||
<th>现金充值</th>
|
||||
<th>通用币充值</th>
|
||||
<th>绑定币充值</th>
|
||||
<?php if($level == 1):?>
|
||||
<th>操作</th>
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<empty name="records">
|
||||
<tr><td colspan="14" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
|
||||
<else />
|
||||
<volist name="records" id="record" mod="2">
|
||||
<tr data-id="{$vo.id}" class="<eq name='mod' value='1'>odd</eq>">
|
||||
<td>{$record.account}({$record.real_name})</td>
|
||||
<td>{$record.create_role_count}</td>
|
||||
<td>{$record.create_role_user_count}</td>
|
||||
<td>{$record.new_create_role_user_count}</td>
|
||||
<td>{$record.new_create_role_device_count}</td>
|
||||
<td>{$record.new_create_role_ip_count}</td>
|
||||
<td>{$record.login_user_count}</td>
|
||||
<td>{$record.recharge_count}</td>
|
||||
<td>{$record.recharge_user_count}</td>
|
||||
<td>{$record.recharge_amount}</td>
|
||||
<td>{$record.recharge_by_cash}</td>
|
||||
<td>{$record.recharge_by_coin}</td>
|
||||
<td>{$record.recharge_by_ban_coin}</td>
|
||||
<?php if($level == 1):?>
|
||||
<td><a href="{:U('Query/achievement', ['parent_id' => $record['id']])}">查看下级</a></td>
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
</volist>
|
||||
</empty>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="pagenation clearfix">
|
||||
{$pagination}
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-explain promote-mychlid-explain">
|
||||
<div class="trunk-content article border_normal">
|
||||
<!-- <table class="desccontent">
|
||||
<tr><td class="title" style="width: 100px;display: inline-block;">二级渠道说明:</td><td class="det">推广员默认为一级渠道,一级渠道可通过推广员后台新增二级渠道;二级渠道由一级渠道管理开启权限,并由一级渠道给二级渠道结算,结算可到财务管理操作。</td></tr>
|
||||
</table>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<link rel="stylesheet" href="__STATIC__/flatpickr/flatpickr.min.css">
|
||||
<script src="__STATIC__/flatpickr/flatpickr.min.js"></script>
|
||||
<script src="__STATIC__/flatpickr/l10n/zh.js"></script>
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('.range-date').flatpickr({
|
||||
mode: 'range',
|
||||
locale: 'zh',
|
||||
})
|
||||
$('.select_gallery').select2()
|
||||
var gameId = $('#game-select').val();
|
||||
var defaultServerId = $('#server-select').attr('data-server');
|
||||
getGameServers(gameId, defaultServerId)
|
||||
$('#game-select').on({
|
||||
change: function name() {
|
||||
gameId = $('#game-select').val()
|
||||
getGameServers(gameId, 0)
|
||||
}
|
||||
})
|
||||
function getGameServers(gameId, defaultServerId) {
|
||||
$.ajax({
|
||||
url: "{:U('Query/getGameServers')}",
|
||||
dataType: 'json',
|
||||
data: {game_id: gameId},
|
||||
success: function(response) {
|
||||
var options = '<option value="0">请选择区服</option>'
|
||||
for (var i in response.data.servers) {
|
||||
var server = response.data.servers[i]
|
||||
var selected = ''
|
||||
if (defaultServerId > 0 && server.id==defaultServerId) {
|
||||
selected = 'selected'
|
||||
}
|
||||
options += '<option value="' + server.id + '"' + selected + '>' + server.server_name + '</option>'
|
||||
}
|
||||
$('#server-select').html(options)
|
||||
$("#server-select").val(defaultServerId).trigger("change")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</block>
|
Loading…
Reference in New Issue