argument('userId'); $this->info("测试财富排行榜功能"); $this->info("=================="); $this->newLine(); try { // 先检查缓存数据 $this->info("检查缓存数据:"); $houseLogic = new \App\Module\Farm\Logics\HouseLogic(); $reflection = new \ReflectionClass($houseLogic); $method = $reflection->getMethod('getWealthRankListCache'); $method->setAccessible(true); $cachedData = $method->invoke($houseLogic); $this->info("- 缓存数据总数: " . count($cachedData)); $this->newLine(); // 测试第一页 $this->info("测试第一页 (page=1, pageSize=5):"); $page1Data = HouseService::getWealthRankList($userId, 1, 5); $this->info("第一页数据:"); $this->info("- 列表数量: " . count($page1Data->list)); $this->info("- 用户排名: " . $page1Data->userRank); $this->info("- 分页信息: " . json_encode($page1Data->page, JSON_UNESCAPED_UNICODE)); // 显示第一页的前3条数据 if (!empty($page1Data->list)) { $this->info("第一页前3条数据:"); foreach (array_slice($page1Data->list, 0, 3) as $index => $item) { $this->info(" " . ($index + 1) . ". 排名: {$item->rank}, 用户ID: {$item->userId}, 昵称: {$item->nickname}, 财富: {$item->wealth}"); } } $this->newLine(); // 测试第二页 $this->info("测试第二页 (page=2, pageSize=5):"); $page2Data = HouseService::getWealthRankList($userId, 2, 5); $this->info("第二页数据:"); $this->info("- 列表数量: " . count($page2Data->list)); $this->info("- 用户排名: " . $page2Data->userRank); $this->info("- 分页信息: " . json_encode($page2Data->page, JSON_UNESCAPED_UNICODE)); $this->newLine(); // 如果第二页有数据,显示前几条 if (!empty($page2Data->list)) { $this->info("第二页前3条数据:"); foreach (array_slice($page2Data->list, 0, 3) as $index => $item) { $this->info(" " . ($index + 1) . ". 排名: {$item->rank}, 用户ID: {$item->userId}, 昵称: {$item->nickname}, 财富: {$item->wealth}"); } } else { $this->warn("第二页没有数据"); } } catch (\Exception $e) { $this->error("错误: " . $e->getMessage()); $this->error("堆栈: " . $e->getTraceAsString()); } } }