diff --git a/Application/Base/Repository/PromoteRepository.class.php b/Application/Base/Repository/PromoteRepository.class.php index 176a1998c..73b628815 100644 --- a/Application/Base/Repository/PromoteRepository.class.php +++ b/Application/Base/Repository/PromoteRepository.class.php @@ -40,8 +40,8 @@ class PromoteRepository { 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']]]; + if (isset($params['begin_time']) && isset($params['begin_time']) && isset($params['time_column'])) { + $map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]]; } return $map; } @@ -54,6 +54,7 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + $params['time_column'] = 'create_time'; $map = $this->getPublicAchievementMap($ids, $params); $items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select(); $records = []; @@ -82,6 +83,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'create_time'; $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(); @@ -111,6 +114,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'create_time'; $map = $this->getPublicAchievementMap($ids, $params); $subMap = $map; @@ -150,6 +155,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'create_time'; $map = $this->getPublicAchievementMap($ids, $params); $subMap = $map; @@ -189,6 +196,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'create_time'; $map = $this->getPublicAchievementMap($ids, $params); $subMap = $map; @@ -228,8 +237,9 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + $params['time_column'] = 'login_time'; $map = $this->getPublicAchievementMap($ids, $params); - $items = M('user', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select(); + $items = M('user_login_record', 'tab_')->field(['count(DISTINCT user_id) as count', 'promote_id'])->where($map)->group('promote_id')->select(); $records = []; foreach ($items as $item) { @@ -257,6 +267,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'pay_time'; $map = $this->getPublicAchievementMap($ids, $params); $items = M('spend', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select(); @@ -287,6 +299,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'pay_time'; $map = $this->getPublicAchievementMap($ids, $params); $items = M('spend', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select(); @@ -316,6 +330,8 @@ class PromoteRepository { if (count($ids) == 0) { return []; } + + $params['time_column'] = 'pay_time'; $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 = []; diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php index 4d0d889ff..c7409113e 100644 --- a/Application/Base/Repository/SpendRepository.class.php +++ b/Application/Base/Repository/SpendRepository.class.php @@ -8,112 +8,131 @@ class SpendRepository { } - private function assembleDayRecords($items, $dayList, $valueColumn, $dayColumn = 'day') + private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day') { $records = []; - foreach ($dayList as $day) { - $dayValue = 0; + foreach ($keys as $key) { + $value = 0; foreach ($items as $item) { - if ($item[$dayColumn] == $day) { - $dayValue = $item[$valueColumn]; + if ($item[$keyColumn] == $key) { + $value = $item[$valueColumn]; } } - $records[$day] = $dayValue; + $records[$key] = $value; } return $records; } - /** - * 付费游戏数 - */ - public function getPayGameCountByDay($params) { + private function getGameGroupConditions($params) + { + $beginTime = $params['begin_time'] ?? 0; + $endTime = $params['end_time'] ?? 0; + $ids = $params['promote_ids'] ?? []; + $isBan = $params['is_ban'] ?? false; + $gameIds = $params['game_ids'] ?? []; + + $conditions = []; + $conditions['pay_status'] = 1; + $conditions['promote_id'] = ['in', $ids]; + $conditions['pay_time'] = ['between', [$beginTime, $endTime]]; + $conditions['game_id'] = ['in', $gameIds]; + $conditions['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1']; + return $conditions; + } + + private function getDayGroupConditions($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']; + $conditions = []; + $conditions['pay_status'] = 1; + $conditions['promote_id'] = ['in', $ids]; + $conditions['pay_time'] = ['between', [$beginTime, $endTime]]; + $conditions['game_id'] = $gameId > 0 ? $gameId : ['gt', 0]; + $conditions['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'); + return $conditions; } /** - * 按天统计付款总额 + * 付费游戏数 */ - 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; + public function getPayGameCountGroupByDay($params) + { $dayList = $params['dayList'] ?? []; + $conditions = $this->getDayGroupConditions($params); + $field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day, count(DISTINCT game_id) count'; + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('day')->select(); + return $this->assembleRecords($items, $dayList, 'count'); + } - $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']; + /** + * 付费游戏数 + */ + public function getPayGameCountGroupByGame($params) + { + $gameIds = $params['game_ids'] ?? []; + $conditions = $this->getGameGroupConditions($params); + $field = 'game_id, count(*) count'; + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('game_id')->select(); + return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); + } + /** + * 按天统计付款总额 + */ + public function getPayAmountGroupByDay($params) { + $dayList = $params['dayList'] ?? []; + $conditions = $this->getDayGroupConditions($params); $field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day, sum(pay_amount) as amount'; - $items = M('spend', 'tab_')->field($field)->where($map)->group('day')->select(); - return $this->assembleDayRecords($items, $dayList, 'amount'); + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('day')->select(); + return $this->assembleRecords($items, $dayList, 'amount'); + } + + /** + * 按游戏统计付款总额 + */ + public function getPayAmountGroupByGame($params) { + $gameIds = $params['game_ids'] ?? []; + $conditions = $this->getGameGroupConditions($params); + $field = 'game_id, sum(pay_amount) as amount'; + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('game_id')->select(); + return $this->assembleRecords($items, $gameIds, 'amount', 'game_id'); } /** * 按天统计付款用户数 */ - 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; + public function getPayUserCountGroupByDay($params) { $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']; - + $conditions = $this->getDayGroupConditions($params); $field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as day, count(distinct user_id) count'; + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('day')->select(); + return $this->assembleRecords($items, $dayList, 'count'); + } - $items = M('spend', 'tab_')->field($field)->where($map)->group('day')->select(); - return $this->assembleDayRecords($items, $dayList, 'count'); + /** + * 游戏统计付款用户数 + */ + public function getPayUserCountGroupByGame($params) { + $gameIds = $params['game_ids'] ?? []; + $conditions = $this->getGameGroupConditions($params); + $field = 'game_id, count(distinct user_id) count'; + $items = M('spend', 'tab_')->field($field)->where($conditions)->group('game_id')->select(); + return $this->assembleRecords($items, $dayList, 'count', 'game_id'); } /** * 按照时间分组统计新增付费用户数 */ - public function getNewPayUserCountByDay($params) { + public function getNewPayUserCountGroupByDay($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']; + $conditions = $this->getDayGroupConditions($params); $oldMap = $map; $records = []; @@ -129,26 +148,27 @@ class SpendRepository { return $records; } + /** + * 按照时间分组统计新增付费用户数 + */ + public function getNewPayUserCountGroupByGame($params) { + $beginTime = $params['begin_time'] ?? 0; + $gameIds = $params['game_ids'] ?? []; + $conditions = $this->getGameGroupConditions($params); + $oldConditions = $conditions; + $oldConditions['pay_time'] = ['lt', $beginTime]; + $oldQuery = M('spend', 'tab_')->field('user_id')->where($oldConditions)->group('user_id')->buildSql(); + $map['user_id'] = ['exp', ' not in (' . $oldQuery . ')']; + $items = M('spend', 'tab_')->field('count(distinct user_id) count, game_id')->where($conditions)->group('game_id')->find(); + return $this->assembleRecords($items, $gameIds, 'amount', 'game_id'); + } + /** * 按照时间分组统计新增付费用户付费金额 */ - public function getNewPayAmountByDay($params) { + public function getNewPayAmountGroupByDay($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']; + $conditions = $this->getDayGroupConditions($params); $oldMap = $map; $records = []; @@ -165,26 +185,28 @@ class SpendRepository { return $records; } - /** + /** + * 按照游戏统计新增付费用户付费金额 + */ + public function getNewPayAmountGroupByGame($params) { + $beginTime = $params['begin_time'] ?? 0; + $gameIds = $params['game_ids'] ?? []; + $conditions = $this->getGameGroupConditions($params); + $oldConditions = $conditions; + $oldConditions['pay_time'] = ['lt', $beginTime]; + $oldQuery = M('spend', 'tab_')->field('user_id')->where($oldConditions)->group('user_id')->buildSql(); + $map['user_id'] = ['exp', ' not in (' . $oldQuery . ')']; + $items = M('spend', 'tab_')->field('sum(pay_amount) amount, game_id')->where($conditions)->group('game_id')->find(); + return $this->assembleRecords($items, $gameIds, 'amount', 'game_id'); + } + + /** * 统计给定时间前的付费玩家总数 */ - public function getHistoryPayCountByDay($params) { + public function getHistoryPayCountGroupByDay($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']; + $conditions = $this->getDayGroupConditions($params); $records = []; foreach ($dayList as $day) { @@ -195,4 +217,16 @@ class SpendRepository { } return $records; } + + /** + * 统计给定时间前的付费玩家总数 + */ + public function getHistoryPayCountGroupByGame($params) + { + $beginTime = $params['begin_time'] ?? 0; + $conditions = $this->getGameGroupConditions($params); + $conditions['pay_time'] = ['elt', $beginTime]; + $items = M('spend', 'tab_')->field('count(DISTINCT user_id) as count, game_id')->where($conditions)->group('game_id')->find(); + return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); + } } \ No newline at end of file diff --git a/Application/Base/Repository/UserRepository.class.php b/Application/Base/Repository/UserRepository.class.php index af2b7adbf..696379bb5 100644 --- a/Application/Base/Repository/UserRepository.class.php +++ b/Application/Base/Repository/UserRepository.class.php @@ -8,79 +8,115 @@ class UserRepository { } - private function assembleDayRecords($items, $dayList, $valueColumn, $dayColumn = 'day') + private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day') { $records = []; - foreach ($dayList as $day) { - $dayValue = 0; + foreach ($keys as $key) { + $value = 0; foreach ($items as $item) { - if ($item[$dayColumn] == $day) { - $dayValue = $item[$valueColumn]; + if ($item[$keyColumn] == $key) { + $value = $item[$valueColumn]; } } - $records[$day] = $dayValue; + $records[$key] = $value; } return $records; } - /** - * 按照时间分组统计登录总数 - */ - public function getLoginCountByDay($params) { + private function getDayGroupConditions($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]]; + $conditions = []; + $conditions['promote_id'] = ['in', $ids]; + $conditions[$params['time_column']] = ['between', [$beginTime, $endTime]]; if ($gameId > 0) { - $map['game_id'] = $gameId; + $conditions['game_id'] = $gameId; } if ($serverId > 0) { - $map['server_id'] = $serverId; + $conditions['server_id'] = $serverId; } - $map['promote_id'] = ['in', $ids]; + $conditions['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1']; + + return $conditions; + } + + private function getGameGroupConditions($params) + { + $beginTime = $params['begin_time'] ?? 0; + $endTime = $params['end_time'] ?? 0; + $ids = $params['promote_ids'] ?? []; + $gameIds = $params['game_ids'] ?? []; + + $conditions = []; + $conditions['promote_id'] = ['in', $ids]; + $conditions[$params['time_column']] = ['between', [$beginTime, $endTime]]; + $conditions['game_id'] = ['in', $gameIds]; + return $conditions; + } + /** + * 按照时间分组统计登录总数 + */ + public function getLoginCountGroupByDay($params) { + $dayList = $params['dayList'] ?? []; + $params['time_column'] = 'login_time'; + $conditions = $this->getDayGroupConditions($params); $items = M('user_login_record', 'tab_')->field('FROM_UNIXTIME(login_time, "%Y-%m-%d") as day, count(DISTINCT user_id) as count') - ->where($map) + ->where($conditions) ->group('day') ->select(); - return $this->assembleDayRecords($items, $dayList, 'count'); + return $this->assembleRecords($items, $dayList, 'count'); + } + + /** + * 按照游戏分组统计登录总数 + */ + public function getLoginCountGroupByGame($params) { + $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(); + + return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); } /** * 按照时间分组统计注册总数 */ - 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'] ?? []; + public function getRegisterCountGroupByDay($params) { $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') + $params['time_column'] = 'register_time'; + $conditions = $this->getDayGroupConditions($params); + + $items = M('user', 'tab_')->field('count(*) count, FROM_UNIXTIME(register_time, "%Y-%m-%d") as day') ->where($map) ->group('day') ->select(); - return $this->assembleDayRecords($items, $dayList, 'count'); + return $this->assembleRecords($items, $dayList, 'count'); + } + + /** + * 按照游戏分分组统计注册总数 + */ + public function getRegisterCountGroupByGame($params) { + $gameIds = $params['game_ids'] ?? []; + $params['time_column'] = 'register_time'; + $conditions = $this->getGameGroupConditions($params); + + $items = M('user', 'tab_')->field('count(*) count, game_id') + ->where($conditions) + ->group('game_id') + ->select(); + return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); } /** @@ -95,7 +131,6 @@ class UserRepository { */ 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; diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php new file mode 100644 index 000000000..75511a60c --- /dev/null +++ b/Application/Base/Service/GameSourceService.class.php @@ -0,0 +1,45 @@ +getGameSourceUrl($gameSource)); + if ($zipGameSource) { + while ($zipEntry = zip_read($zipGameSource)) { + if (preg_match("/^Payload.*?\.app/", zip_entry_name($zipEntry), $matches)) { + $preUrl = $matches[0]; + break; + } + } + zip_close($zipGameSource); + } + $configUrl = $preUrl . '/_CodeSignature/TXChannel'; + } + return $configUrl; + } + + public function getGameSourceUrl($gameSource){ + $path = ''; + if($gameSource['file_type'] == '1'){ + $path = './Uploads/SourcePack/'; + }else{ + $path = './Uploads/Ios/original/'; + } + $fileUrl = $path . $gameSource['file_name']; + return ROOTTT . ltrim($fileUrl, './'); + } +} \ No newline at end of file diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index e3125c52f..b3c9cb626 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -2804,3 +2804,12 @@ function sendBrushMail($to,$content) { $mail->AltBody = $c; //邮件正文不支持HTML的备用显示 return($mail->Send()); } + +function index_by_column($column, $items) +{ + $records = []; + foreach ($items as $item) { + $records[$item[$column]] = $item; + } + return $records; +} diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index 1bf7886f3..a6007b121 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -831,24 +831,24 @@ function isParentPromote($parentId, $promoteId) } //获取所有该类型的渠道 $promoteId-渠道ID $promoteType-1:本账号 2:组长 3:推广员 -function getAllPromoteListByType($promoteType = 1, $retOne = false) +function getAllPromoteListByType($promoteType = 1, $retOne = false, $promoteId = PID) { $childPromoteData = array(); switch ($promoteType) { case 1: - $map['id'] = PID; + $map['id'] = $promoteId; break; case 2: case 3: - $promoteData = D('Promote')->where(array('id' => PID))->find(); + $promoteData = D('Promote')->where(array('id' => $promoteId))->find(); if ($promoteData['grand_id'] > 0) { return []; } elseif ($promoteData['parent_id'] > 0) { $promoteType--; } - $childPromoteIds = getAllPromoteIdsByType((string)PID, $promoteType); + $childPromoteIds = getAllPromoteIdsByType((string)$promoteId, $promoteType); break; } @@ -901,10 +901,10 @@ function getAllPromoteIdsByType($promoteIds, $level = 3, $nowLevel = 1) } //获取所有子渠道列表 $type 1-返回数组 2-返回id数组 3-返回id字符串 -function getAllChildPromoteList($type = 1) +function getAllChildPromoteList($type = 1, $promoteId = PID) { $childPromoteData = array(); - $childPromoteIds = getAllChildPromoteIds((string)PID); + $childPromoteIds = getAllChildPromoteIds((string)$promoteId); if (!empty($childPromoteIds)) { $map['id'] = ['in', $childPromoteIds]; diff --git a/Application/Home/Conf/config.php b/Application/Home/Conf/config.php index 149f96326..36b9fe1af 100644 --- a/Application/Home/Conf/config.php +++ b/Application/Home/Conf/config.php @@ -64,6 +64,8 @@ return array( '__IMG__' => __ROOT__ . '/Public/' . MODULE_NAME . '/images', '__CSS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/css', '__JS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/js', + '__LAY__' => __ROOT__ . '/Public/' . MODULE_NAME . '/layui', + ), /* SESSION 和 COOKIE 配置 */ diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index f19cc2181..ffc5136cb 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -172,7 +172,8 @@ class BaseController extends HomeController{ 'p' => $page, 'row' => $pageSize ]; - $pagination = set_pagination($count, $pageSize); + $params = array_merge($params, $_POST); + $pagination = set_pagination($count, $pageSize, $params); return [$records, $pagination, $count]; } diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 44712687c..933295615 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -44,14 +44,21 @@ class QueryController extends BaseController $map['tab_spend.promote_id'] = ['in', $childPromoteIds]; } - $teamLeaderId = I('team_leader_id');//组长账号 + $teamLeaderId = intval(I('team_leader_id'));//组长账号 if (!empty($teamLeaderId)) { $hasTeamLeaderPermission = hasPromotePermission(PID, $teamLeaderId); if ($hasTeamLeaderPermission === false) { $this->error('组长权限异常'); } - $map['tab_spend.promote_id'] = $teamLeaderId; + $childPromoteIds = getAllChildPromoteList(3, $teamLeaderId); + if (empty($childPromoteIds)) { + $map['tab_spend.promote_id'] = $teamLeaderId; + } else { + $childPromoteIds = $teamLeaderId . ',' . $childPromoteIds; + + $map['tab_spend.promote_id'] = ['in', $childPromoteIds]; + } } $promoteId = I('promote_id');//推广员账号 @@ -61,18 +68,10 @@ class QueryController extends BaseController $this->error('推广员权限异常'); } - if (!empty($map['tab_spend.promote_id'])) { - $map['_string'] = 'tab_spend.promote_id = ' . $promoteId; - } else { - $map['tab_spend.promote_id'] = $promoteId; - } + $map['tab_spend.promote_id'] = $promoteId; } if (!empty(I('own_id'))) { - if (!empty($map['_string'])) { - unset($map['_string']); - } - $map['tab_spend.promote_id'] = I('own_id');//本账号 } @@ -84,11 +83,15 @@ class QueryController extends BaseController $map['tab_spend.pay_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]]; } - if (I('pay_way') !== null && I('pay_way') !== '') { - if (I('pay_way') == 2) { - $map['tab_spend.pay_way'] = ['in', '2,3,4']; - } else { - $map['tab_spend.pay_way'] = I('pay_way'); + if (isset($_REQUEST['pay_way']) && $_REQUEST['pay_way'] !== '') { + $payWay = intval(I('pay_way')); + + if (in_array($payWay, array_keys(QueryController::$payWay))) { + if ($payWay == 2) { + $map['tab_spend.pay_way'] = ['in', '2,3,4']; + } else { + $map['tab_spend.pay_way'] = $payWay; + } } } @@ -142,6 +145,7 @@ class QueryController extends BaseController empty(I('own_id')) || $parameter['own_id'] = I('own_id'); empty(I('begtime')) || $parameter['begtime'] = I('begtime'); empty(I('endtime')) || $parameter['endtime'] = I('endtime'); + !isset($_REQUEST['pay_way']) || $parameter['pay_way'] = I('pay_way'); $serverData = $this->getServer(I('relation_game_id'), I('sdk_version')); @@ -159,6 +163,9 @@ class QueryController extends BaseController $this->assign('pID', PID); $this->assign('ownId', I('own_id')); $this->assign('payWayData', QueryController::$payWay); + if (!empty(I('team_leader_id'))) { + $this->assign('teamLeaderData', getAllPromoteListByType(1, false, intval(I('team_leader_id')))); + } $this->meta_title = "订单查询"; $this->display(); } @@ -181,14 +188,21 @@ class QueryController extends BaseController $map['tab_user.promote_id'] = ['in', $childPromoteIds]; } - $teamLeaderId = I('team_leader_id');//组长账号 + $teamLeaderId = intval(I('team_leader_id'));//组长账号 if (!empty($teamLeaderId)) { $hasTeamLeaderPermission = hasPromotePermission(PID, $teamLeaderId); if ($hasTeamLeaderPermission === false) { $this->error('组长权限异常'); } - $map['tab_user.promote_id'] = $teamLeaderId; + $childPromoteIds = getAllChildPromoteList(3, $teamLeaderId); + if (empty($childPromoteIds)) { + $map['tab_user.promote_id'] = $teamLeaderId; + } else { + $childPromoteIds = $teamLeaderId . ',' . $childPromoteIds; + + $map['tab_user.promote_id'] = ['in', $childPromoteIds]; + } } $promoteId = I('promote_id');//推广员账号 @@ -198,18 +212,10 @@ class QueryController extends BaseController $this->error('推广员权限异常'); } - if (!empty($map['tab_user.promote_id'])) { - $map['_string'] = 'tab_user.promote_id = ' . $promoteId; - } else { - $map['tab_user.promote_id'] = $promoteId; - } + $map['tab_user.promote_id'] = $promoteId; } if (!empty(I('own_id'))) { - if (!empty($map['_string'])) { - unset($map['_string']); - } - $map['tab_user.promote_id'] = I('own_id');//本账号 } @@ -272,6 +278,9 @@ class QueryController extends BaseController $this->assign('thisParentPromoteId', $thisParentPromoteId); $this->assign('pID', PID); $this->assign('ownId', I('own_id')); + if (!empty(I('team_leader_id'))) { + $this->assign('teamLeaderData', getAllPromoteListByType(1, false, intval(I('team_leader_id')))); + } $this->meta_title = '注册明细'; $this->display(); } @@ -653,10 +662,10 @@ class QueryController extends BaseController { $this->meta_title = 'ARPU统计'; - $defaultTime = date('Y-m-d', time() - 7 * 24 * 3600) . ' 至 ' . date('Y-m-d'); - $defaultTime = date('Y-m-d', time() - 7 * 24 * 3600) . ' 至 ' . date('Y-m-d'); + $defaultTime = date('Y-m-d', time() - 6 * 24 * 3600) . ' 至 ' . date('Y-m-d'); - $time = I('time', $defaultTime); + $time = I('time', ''); + $time = $time == '' ? $defaultTime : $time; $sdkVersion = I('sdk_version', 0); $gameId = I('game_id', 0); $serverId = I('server_id', 0); @@ -668,16 +677,20 @@ class QueryController extends BaseController 'grand_id' => $promote['id'], ]; $ids = M('promote', 'tab_')->where($map)->getField('id', true); - + $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select(); $games = $this->getGamesByPromote($promote); $params = []; + $searchGameName = ''; + $searchServerName = ''; if ($gameId > 0) { $params['game_id'] = $gameId; + $searchGameName = M('game', 'tab_')->where(['id' => $gameId])->getField('game_name'); } if ($serverId > 0) { $params['server_id'] = $serverId; + $searchServerName = M('server', 'tab_')->where(['server_id' => $serverId])->getField('server_name'); } if ($sdkVersion > 0) { $params['sdk_version'] = $sdkVersion; @@ -695,14 +708,14 @@ class QueryController extends BaseController if (intval($endTime - $beginTime) / (24 * 3600) <= 30) { $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - $payGameCountList = $spendRepository->getPayGameCountByDay($params); - $payUserCountList = $spendRepository->getPayUserCountByDay($params); - $newPayUserCountList = $spendRepository->getNewPayUserCountByDay($params); - $payAmountList = $spendRepository->getPayAmountByDay($params); - $newPayAmountList = $spendRepository->getNewPayAmountByDay($params); - $historyPayCountList = $spendRepository->getHistoryPayCountByDay($params); - $loginCountList = $userRepository->getLoginCountByDay($params); - $registerCountList = $userRepository->getRegisterCountByDay($params); + $payGameCountList = $spendRepository->getPayGameCountGroupByDay($params); + $payUserCountList = $spendRepository->getPayUserCountGroupByDay($params); + $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params); + $payAmountList = $spendRepository->getPayAmountGroupByDay($params); + $newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params); + $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params); + $loginCountList = $userRepository->getLoginCountGroupByDay($params); + $registerCountList = $userRepository->getRegisterCountGroupByDay($params); foreach ($dayList as $day) { $records[] = [ @@ -728,9 +741,39 @@ class QueryController extends BaseController $this->assign('subPromotes', $subPromotes); $this->assign('timeout', $timeout); $this->assign('records', $records); + $this->assign('searchGameName', $searchGameName); + $this->assign('searchServerName', $searchServerName); $this->display(); } + public function gameArpu() + { + $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')); + $applys = M('Apply', 'tab_')->field('game_id, game_name')->where(['promote_id' => $promote['id']])->order('game_id desc')->select(); + $gameIds = array_column($applys, 'game_id'); + + $params = [ + 'begin_time' => strtotime($time . ' 00:00:00'), + 'end_time' => strtotime($time . ' 23:59:59'), + 'game_ids' => $gameIds, + 'promote_ids' => $ids, + ]; + + $spendRepository = new SpendRepository(); + // $result = $spendRepository->getHistoryPayCountGroupByGame($params); + $result = $spendRepository->getPayGameCountGroupByGame($params); + var_dump($result); + } + public function arpu_analysis() { $this->meta_title = "ARPU统计"; @@ -960,16 +1003,25 @@ class QueryController extends BaseController $spendWhere['tab_spend.promote_id'] = ['in', $childPromoteIds]; } - $teamLeaderId = I('team_leader_id');//组长账号 + $teamLeaderId = intval(I('team_leader_id'));//组长账号 if (!empty($teamLeaderId)) { $hasTeamLeaderPermission = hasPromotePermission(PID, $teamLeaderId); if ($hasTeamLeaderPermission === false) { $this->error('组长权限异常'); } - $userPlayInfoWhere['tab_user_play_info.promote_id'] = $teamLeaderId; - $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $teamLeaderId; - $spendWhere['tab_spend.promote_id'] = $teamLeaderId; + $childPromoteIds = getAllChildPromoteList(3, $teamLeaderId); + if (empty($childPromoteIds)) { + $userPlayInfoWhere['tab_user_play_info.promote_id'] = $teamLeaderId; + $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $teamLeaderId; + $spendWhere['tab_spend.promote_id'] = $teamLeaderId; + } else { + $childPromoteIds = $teamLeaderId . ',' . $childPromoteIds; + + $userPlayInfoWhere['tab_user_play_info.promote_id'] = ['in', $childPromoteIds]; + $userGameLoginWhere['tab_user_game_login_record.promote_id'] = ['in', $childPromoteIds]; + $spendWhere['tab_spend.promote_id'] = ['in', $childPromoteIds]; + } } $promoteId = I('promote_id');//推广员账号 @@ -979,24 +1031,12 @@ class QueryController extends BaseController $this->error('推广员权限异常'); } - if (!empty($userPlayInfoWhere['tab_apply.promote_id'])) { - $userPlayInfoWhere['_string'] = 'tab_user_play_info.promote_id = ' . $promoteId; - $userGameLoginWhere['_string'] = 'tab_user_game_login_record.promote_id = ' . $promoteId; - $spendWhere['_string'] = 'tab_spend.promote_id = ' . $promoteId; - } else { - $userPlayInfoWhere['tab_user_play_info.promote_id'] = $promoteId; - $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $promoteId; - $spendWhere['tab_spend.promote_id'] = $promoteId; - } + $userPlayInfoWhere['tab_user_play_info.promote_id'] = $promoteId; + $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $promoteId; + $spendWhere['tab_spend.promote_id'] = $promoteId; } if (!empty(I('own_id'))) { - if (!empty($userPlayInfoWhere['_string'])) { - unset($userPlayInfoWhere['_string']); - unset($userGameLoginWhere['_string']); - unset($spendWhere['_string']); - } - $userPlayInfoWhere['tab_user_play_info.promote_id'] = I('own_id'); $userGameLoginWhere['tab_user_game_login_record.promote_id'] = I('own_id'); $spendWhere['tab_spend.promote_id'] = I('own_id'); @@ -1184,6 +1224,9 @@ class QueryController extends BaseController $this->assign('serverData', $serverData['data']); $this->assign('thisParentPromoteId', $thisParentPromoteId); $this->assign('pID', PID); + if (!empty(I('team_leader_id'))) { + $this->assign('teamLeaderData', getAllPromoteListByType(1, false, intval(I('team_leader_id')))); + } $this->display(); } @@ -1218,10 +1261,20 @@ class QueryController extends BaseController $this->error('组长权限异常'); } - $map['tab_apply.promote_id'] = $teamLeaderId; - $userPlayInfoMap['tab_user_play_info.promote_id'] = $teamLeaderId; - $userGameLoginMap['tab_user_game_login_record.promote_id'] = $teamLeaderId; - $spendMap['tab_spend.promote_id'] = $teamLeaderId; + $childPromoteIds = getAllChildPromoteList(3, $teamLeaderId); + if (empty($childPromoteIds)) { + $map['tab_apply.promote_id'] = $teamLeaderId; + $userPlayInfoMap['tab_user_play_info.promote_id'] = $teamLeaderId; + $userGameLoginMap['tab_user_game_login_record.promote_id'] = $teamLeaderId; + $spendMap['tab_spend.promote_id'] = $teamLeaderId; + } else { + $childPromoteIds = $teamLeaderId . ',' . $childPromoteIds; + + $map['tab_apply.promote_id'] = ['in', $childPromoteIds]; + $userPlayInfoMap['tab_user_play_info.promote_id'] = ['in', $childPromoteIds]; + $userGameLoginMap['tab_user_game_login_record.promote_id'] = ['in', $childPromoteIds]; + $spendMap['tab_spend.promote_id'] = ['in', $childPromoteIds]; + } } $promoteId = intval(I('promote_id'));//推广员账号 @@ -1231,21 +1284,14 @@ class QueryController extends BaseController $this->error('推广员权限异常'); } - $map['_string'] = 'tab_apply.promote_id = ' . $promoteId; - $userPlayInfoMap['_string'] = 'tab_user_play_info.promote_id = ' . $promoteId; - $userGameLoginMap['_string'] = 'tab_user_game_login_record.promote_id = ' . $promoteId; - $spendMap['_string'] = 'tab_spend.promote_id = ' . $promoteId; + $map['tab_apply.promote_id'] = $promoteId; + $userPlayInfoMap['tab_user_play_info.promote_id'] = $promoteId; + $userGameLoginMap['tab_user_game_login_record.promote_id'] = $promoteId; + $spendMap['tab_spend.promote_id'] = $promoteId; } $ownId = intval(I('own_id'));//本账号 if (!empty($ownId)) { - if (!empty($map['_string'])) { - unset($map['_string']); - unset($userPlayInfoMap['_string']); - unset($userGameLoginMap['_string']); - unset($spendMap['_string']); - } - $map['tab_apply.promote_id'] = $ownId; $userPlayInfoMap['tab_user_play_info.promote_id'] = $ownId; $userGameLoginMap['tab_user_game_login_record.promote_id'] = $ownId; @@ -1438,6 +1484,9 @@ class QueryController extends BaseController $this->assign('serverData', $serverData['data']); $this->assign('thisParentPromoteId', $thisParentPromoteId); $this->assign('pID', PID); + if (!empty(I('team_leader_id'))) { + $this->assign('teamLeaderData', getAllPromoteListByType(1, false, intval(I('team_leader_id')))); + } $this->display(); } @@ -1731,6 +1780,13 @@ class QueryController extends BaseController 'parent_id' => $promote['id'], 'grand_id' => $promote['id'], ]; + if ($headmanPromoteId > 0) { + $map['parent_id'] = $headmanPromoteId; + } + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + $ids = M('promote', 'tab_')->where($map)->getField('id', true); $promotes = []; @@ -1752,7 +1808,7 @@ class QueryController extends BaseController $map['role_name'] = ['like', '%' . $roleName . '%']; } if ($userAccount != '') { - $map['user_acount'] = ['like', '%' . $userAccount . '%']; + $map['user_account'] = ['like', '%' . $userAccount . '%']; } if ($sdkVersion != 0) { $map['sdk_version'] = $sdkVersion; @@ -1779,7 +1835,6 @@ class QueryController extends BaseController } if ($isSelf) { $map['promote_id'] = $promote['id']; - } else { if ($headmanPromoteId != 0) { $map['promote_id'] = $headmanPromoteId; } @@ -1819,6 +1874,12 @@ class QueryController extends BaseController 'parent_id' => $promote['id'], 'grand_id' => $promote['id'], ]; + if ($headmanPromoteId > 0) { + $map['parent_id'] = $headmanPromoteId; + } + if ($promoteId > 0) { + $map['id'] = $promoteId; + } $ids = M('promote', 'tab_')->where($map)->getField('id', true); $promotes = []; @@ -1838,7 +1899,7 @@ class QueryController extends BaseController $map['role_name'] = ['like', '%' . $roleName . '%']; } if ($userAccount != '') { - $map['user_acount'] = ['like', '%' . $userAccount . '%']; + $map['user_account'] = ['like', '%' . $userAccount . '%']; } if ($sdkVersion != 0) { $map['sdk_version'] = $sdkVersion; @@ -1846,11 +1907,12 @@ class QueryController extends BaseController if ($isSelf) { $map['promote_id'] = $promote['id']; $spendMap['promote_id'] = $promote['id']; - } else { + if ($headmanPromoteId != 0) { $map['promote_id'] = $headmanPromoteId; $spendMap['promote_id'] = $headmanPromoteId; } + if ($promoteId != 0) { $map['promote_id'] = $promoteId; $spendMap['promote_id'] = $promoteId; @@ -2010,6 +2072,7 @@ class QueryController extends BaseController $gameId = I('game_id', 0); $serverId = I('server_id', 0); $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); $loginPromote = $this->getLoginPromote(); @@ -2024,7 +2087,12 @@ class QueryController extends BaseController $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select(); - $query = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']]); + $map = ['parent_id' => $promote['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + + $query = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where($map); list($promotes, $pagination, $count) = $this->paginate($query); $ids = array_column($promotes, 'id'); @@ -2108,4 +2176,21 @@ class QueryController extends BaseController $this->assign('count', $count); $this->display(); } + + public function getChildPromoteList() + { + $promoteId = I('post.promote_id', 0); + if ($promoteId == 0) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + + $this->ajaxReturn($data); + } + + $promoteList = getAllPromoteListByType(3, false, $promoteId); + $data['status'] = 1; + $data['data'] = $promoteList; + + $this->ajaxReturn($data); + } } diff --git a/Application/Home/View/default/Apply/feature.html b/Application/Home/View/default/Apply/feature.html index 5899f9518..86e5dd89c 100644 --- a/Application/Home/View/default/Apply/feature.html +++ b/Application/Home/View/default/Apply/feature.html @@ -6,7 +6,7 @@ - + -