diff --git a/Application/Base/Repository/PromoteRepository.class.php b/Application/Base/Repository/PromoteRepository.class.php index 518d2cc5e..253b2b392 100644 --- a/Application/Base/Repository/PromoteRepository.class.php +++ b/Application/Base/Repository/PromoteRepository.class.php @@ -45,7 +45,10 @@ class PromoteRepository { if (isset($params['sdk_version'])) { $map['sdk_version'] = $params['sdk_version']; } - if (isset($params['begin_time']) && isset($params['begin_time']) && isset($params['time_column'])) { + if (isset($params['role_level'])) { + $map['role_level'] = $params['role_level']; + } + if (isset($params['begin_time']) && isset($params['end_time']) && isset($params['time_column'])) { $map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]]; } if (isset($params['lock_status'])) { diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index aa5387634..c7777c09b 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -2210,4 +2210,206 @@ class QueryController extends BaseController $this->ajaxReturn($data); } + + //推广员指标管理 + public function promoteQuota() + { + $time = I('time', date('Y-m-d')); + if (!empty($time)) { + $defaultTime = $time; + } else { + $nowTime = date('Y-m-d', time()); + $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; + $time = $defaultTime; + } + $sdkVersion = I('sdk_version', 0); + $relationGameId = I('relation_game_id', 0); + $serverId = I('server_id', 0); + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $levelBegin = I('level_begin', ''); + $levelEnd = I('level_end', ''); + $prevParentId = 0; + + $promoteService = new PromoteService(); + $loginPromote = $this->getLoginPromote(); + + $parent = null; + if ($parentId > 0) { + $parent = M('promote', 'tab_')->where(['id' => $parentId])->find(); + $currentDisplay = $promoteService->getLevelName($parent['level']) . '推广'; + $prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id']; + } else { + $parent = $loginPromote; + $currentDisplay = '自己'; + } + $searchLevel = $parent['level'] + 1; + $searchLevelName = $promoteService->getLevelName($searchLevel); + + $games = get_promote_serach_game(); + + $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $parent['id']])->select(); + + $map = ['parent_id' => $parent['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + + $query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level'])->where($map); + list($promotes, $pagination, $count) = $this->paginate($query); + $ids = array_column($promotes, 'id'); + + $rows = []; + if (count($ids) > 0) { + $rows = M('promote', 'tab_') + ->field(['id', 'chain']) + ->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]]) + ->select(); + } + + $basicPromotes = []; + foreach ($ids as $id) { + foreach ($rows as $row) { + $needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/'; + if (strpos($row['chain'], $needChain) !== false) { + $basicPromotes[$row['id']] = $id; + } + } + } + $params = [ + 'isContainSubs' => true, + 'basicPromotes' => $basicPromotes, + ]; + if ($relationGameId != 0 || $sdkVersion != 0) { + $gameIds = gameSearch($relationGameId, $sdkVersion); + $params['game_id'] = ['in', $gameIds]; + } + if ($serverId > 0) { + $params['server_id'] = $serverId; + } + $where = $params; + if ($sdkVersion != 0) { + $where['sdk_version'] = $sdkVersion; + } + $game = $this->getGame($where); + + if ($levelBegin !== '' || $levelEnd !== '') { + if ($levelBegin !== '' && $levelEnd !== '') { + $levelBegin = intval($levelBegin); + $levelEnd = intval($levelEnd); + if ($levelBegin > $levelEnd) { + $this->error('角色等级范围错误'); + } + $params['role_level'] = ['between', [$levelBegin, $levelEnd]]; + } elseif ($levelBegin !== '' && $levelEnd === '') { + $levelBegin = intval($levelBegin); + $params['role_level'] = ['egt', $levelBegin]; + } elseif ($levelBegin === '' && $levelEnd !== '') { + $levelEnd = intval($levelEnd); + $params['role_level'] = ['elt', $levelEnd]; + } + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $params['begin_time'] = $beginTime; + $params['end_time'] = $endTime; + + $records = []; + $promoteRepository = new PromoteRepository(); + $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); + + if (I('p', 1) == 1) { + $selfParams = $params; + $selfParams['isContainSubs'] = false; + $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams); + $record = [ + 'id' => $parent['id'], + 'account' => $parent['account'], + 'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**', + 'level' => $parent['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $selfCreateRoleCountList[$parent['id']], + 'current_display' => $currentDisplay, + ]; + $records[] = $record; + } + foreach ($promotes as $promote) { + $id = $promote['id']; + $record = [ + 'id' => $id, + 'account' => $promote['account'], + 'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**', + 'level' => $promote['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $createRoleCountList[$id], + 'current_display' => '', + ]; + $records[] = $record; + } + + $this->assign('prevParentId', $prevParentId); + $this->assign('searchLevelName', $searchLevelName); + $this->assign('games', $games); + $this->assign('parent', $parent); + $this->assign('subPromotes', $subPromotes); + $this->assign('records', $records); + $this->assign('pagination', $pagination); + $this->assign('parentId', $parentId); + $this->assign('count', $count); + $this->assign('time', $defaultTime); + $this->assign('meta_title', '推广员指标管理'); + $this->display(); + } + + private function getGame($map = []) + { + $gameName = '全部游戏'; + $sdkVersionText = getSDKTypeName(0, true); + $serverName = '--'; + if (isset($map['game_id']) || isset($map['sdk_version'])) { + $where = []; + if (!isset($map['game_id'])) { + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + } elseif (!isset($map['sdk_version'])) { + $where['id'] = $map['game_id']; + $gameName = M('game', 'tab_')->where($where)->getField('relation_game_name'); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], 0, $map['server_id']); + } + } else { + $where['id'] = $map['game_id']; + $where['sdk_version'] = $map['sdk_version']; + $gameName = M('game', 'tab_')->where($where)->getField('game_name'); + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], $map['sdk_version'], $map['server_id']); + } + } + } + + $game = [ + 'game_name' => $gameName, + 'sdk_version_text' => $sdkVersionText, + 'server_name' => $serverName, + ]; + return $game; + } + + private function getServerName($gameIds, $serverVersion, $serverId) + { + $map['_string'] = '1 = 1'; + if ($gameIds) { + $map['game_id'] = $gameIds; + } + if ($serverVersion) { + $map['server_version'] = $serverVersion; + } + if ($serverId) { + $map['server_id'] = $serverId; + } + return M('server', 'tab_')->where($map)->getField('server_name'); + } } diff --git a/Application/Home/View/default/Query/promoteQuota.html b/Application/Home/View/default/Query/promoteQuota.html new file mode 100644 index 000000000..a941f9c6e --- /dev/null +++ b/Application/Home/View/default/Query/promoteQuota.html @@ -0,0 +1,184 @@ + + + + + + +
+
+
+
当前位置:数据管理>{$meta_title}
+
+ + {$meta_title} +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
推广员游戏名称平台游戏区服角色数量操作

暂无数据

{$record.account}({$record.real_name}) + + [{$record['current_display']}] + + {$record.game_name}{$record.sdk_version_text}{$record.server_name}{$record.role_num} + + 查看下级 + +
+ +
+
+ + 导出 + + {$pagination} +
+
+
+
+ +
+
+
+
+ + + + + + + + + + \ No newline at end of file