/** * 获取价格区间的定价价格 * * @param int $cityId * @param float $totalMoney * @param int $areaId * @param int $communityId * @return array */ public static function getPriceInterval($cityId, $totalMoney, $areaId = 0, $communityId = 0) { $cityId = intval($cityId); if (empty($cityId) || !isset($totalMoney)) { return array(); } static $priceInterval = array(); if (empty($priceInterval)) { $cache = APF_Cache_Factory::get_instance()->get_memcache(); //实例缓存 $time = Util_MemCacheTime::getPriceInterval(); //缓存有效时间 $key = Util_MemCacheKey::getPriceInterval(); //缓存key $priceIntervalCache = $cache->get($key); if (false === $priceIntervalCache) { $tmpResult = Model_House_EsfPrice::getAllPriceIntervalEx(Model_House_EsfPrice::TRADE_TYPE_SALE); foreach ($tmpResult as $list) { $index = $list['cityId'] . '_' . $list['areaCode'] . '_' . $list['commId']; $priceInterval[$index][] = $list; } $cache->set($key, $priceInterval, 0, $time); } else { $priceInterval = $priceIntervalCache; } } $indexList = array(sprintf('%d_%d_%d', $cityId, $areaId, $communityId), sprintf('%d_%d_%d', $cityId, $areaId, 0), sprintf('%d_%d_%d', $cityId, 0, 0)); foreach ($indexList as $index) { if (!isset($priceInterval[$index])) { continue; } foreach ($priceInterval[$index] as $list) { if ($totalMoney > $list['minPrice'] && $totalMoney <= $list['maxPrice']) { return $list; } } } $errorMsg = sprintf('[%s] %d_%d_%d %d' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $areaId, $communityId, $totalMoney); file_put_contents('/data1/logs/PriceIntervalErr.log', $errorMsg, FILE_APPEND); return array(); }