diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php index f6fe4b649..b9b483087 100644 --- a/Application/Base/Repository/SpendRepository.class.php +++ b/Application/Base/Repository/SpendRepository.class.php @@ -374,175 +374,4 @@ class SpendRepository { // return M('spend', 'tab_')->field($columns)->where($map); } - - public function achievement() - { - $time = I('time', date('Y-m-d')); - if (!empty($time)) { - $defaultTime = $time; - } else { - $defaultTime = date('Y-m-d', time()); - } - $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); - $status = I('status', 0); - $searchLevel = 0; - $searchLevelName = ''; - $currentDisplay = ''; - $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', 'group_remark'])->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', 'chain'])->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; - } - if ($status > 0) { - $params['lock_status'] = $status; - } - list($beginTime, $endTime) = $this->getBetweenTime($time); - $params['begin_time'] = $beginTime; - $params['end_time'] = $endTime; - - $timeout = 0; - $records = []; - if (intval($endTime - $beginTime) / (24 * 3600) <= 7) { - $promoteRepository = new PromoteRepository(); - $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); - $createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params); - $newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params); - // $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params); - $newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params); - $loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params); - - $rechargeCountList = []; - $rechargeUserCountList = []; - $rechargeAmountList = []; - if ($this->canViewUserRecharge) { - $rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params); - $rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params); - $rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params); - } - - $promoteService = new PromoteService(); - - if (I('p', 1) == 1) { - $selfParams = $params; - $selfParams['isContainSubs'] = false; - $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams); - $selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$parent['id']], $selfParams); - $selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$parent['id']], $selfParams); - // $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams); - $selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams); - $selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams); - $record = [ - 'id' => $parent['id'], - 'account' => $parent['account'], - 'promote_group' => $promoteService->getGroupNameByChain($parent['chain'], $parent['id']), - 'real_name' => hideRealName($parent['real_name']), - 'level' => $parent['level'], - 'create_role_count' => $selfCreateRoleCountList[$parent['id']], - 'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']], - 'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$parent['id']], - // 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']], - 'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']], - 'login_user_count' => $selfLoginUserCountList[$parent['id']], - 'current_display' => $currentDisplay, - ]; - if ($this->canViewUserRecharge) { - $selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams); - $selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams); - $selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams); - $record['recharge_count'] = $selfRechargeCountList[$parent['id']]; - $record['recharge_user_count'] = $selfRechargeUserCountList[$parent['id']]; - $record['recharge_amount'] = $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash']; - $record['recharge_by_ban_coin'] = $selfRechargeAmountList[$parent['id']]['ban_coin']; - $record['recharge_by_coin'] = $selfRechargeAmountList[$parent['id']]['coin']; - $record['recharge_by_cash'] = $selfRechargeAmountList[$parent['id']]['cash']; - } - $records[] = $record; - } - foreach ($promotes as $promote) { - $id = $promote['id']; - $record = [ - 'id' => $id, - 'account' => $promote['account'], - 'promote_group' => $promoteService->getGroupNameByChain($promote['chain'], $promote['id']), - 'real_name' => hideRealName($promote['real_name']), - 'level' => $promote['level'], - 'create_role_count' => $createRoleCountList[$id], - 'create_role_user_count' => $createRoleUserCountList[$id], - 'new_create_role_user_count' => $newCreateRoleUserCountList[$id], - // 'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id], - 'new_create_role_ip_count' => $newCreateRoleIpCountList[$id], - 'login_user_count' => $loginUserCountList[$id], - 'current_display' => '', - ]; - if ($this->canViewUserRecharge) { - $record['recharge_count'] = $rechargeCountList[$id]; - $record['recharge_user_count'] = $rechargeUserCountList[$id]; - $record['recharge_amount'] = $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash']; - $record['recharge_by_ban_coin'] = $rechargeAmountList[$id]['ban_coin']; - $record['recharge_by_coin'] = $rechargeAmountList[$id]['coin']; - $record['recharge_by_cash'] = $rechargeAmountList[$id]['cash']; - } - $records[] = $record; - } - } else { - $timeout = 1; - } } \ No newline at end of file