private static function searchAds(\ApiParam $params) { list($query, $category, $city, $wanted, $options, $realTime) = self::searchOption($params, 'createdTime desc'); $activeOnly = $params->activeOnly == 1; $inactiveOnly = $params->inactiveOnly == 1; $totalCount = 0; if ($inactiveOnly) { $searcher = new \InactiveSearcher($query, $options); } else { if ($activeOnly) { $query = new \AndQuery($query, new \Query('status', \Ad::STATUS_ACTIVE)); } if ($category) { $query = new \AndQuery($query, new \Query('categoryEnglishName', $category->englishName)); } if ($city) { $query = new \AndQuery($query, new \Query('cityEnglishName', $city->englishName)); } if (isset($wanted)) { $query = new \AndQuery($query, new \Query('wanted', $wanted)); } $searcher = new \ActiveSearcher($query, $options); if (!(isset($options['start']) && $options['start'] > 0)) { if ($params->isUserAd) { $searcher->prepend(new \RtSearcher($query, $options)); } else { // 修改过的很老的数据也会进rt库,只搜最近11分钟内创建的AD @zhongjiawu 2012-12-13 $rtQuery = new \AndQuery($query, new \DateFrangeQuery('createdTime', strtotime(date('Y-m-d H:i:00', time() - 660)))); $searcher->prepend(new \RtSearcher($rtQuery, $options)); } } if (!$activeOnly) { $searcher->prepend(new \InactiveSearcher($query, $options)); } } $totalCount += $searcher->totalCount(); return array($totalCount, $searcher->ads()); }