Esempio n. 1
0
 public static function getPropHistoryComboClick($propIds)
 {
     $clickReturn = array();
     $cache = APF_Cache_Factory::get_instance()->get_memcache();
     foreach ($propIds as $propId) {
         $key = __CLASS__ . '_' . __FUNCTION__ . '_' . $propId;
         $click = $cache->get($key);
         if ($click === false) {
             $propInfo = Model_House_JpHouseIdx::data_access()->filter('id', $propId)->get_row();
             if (empty($propInfo)) {
                 continue;
             }
             $splitSuffix = date('Ym', strtotime($propInfo['createTime']));
             $clickInfo = Model_Broker_ComboPropClickAccumulate::getHouseClickInfo($propId, Model_Broker_ComboPropClickAccumulate::SITE_TYPE_JP, $splitSuffix);
             $click = intval($clickInfo[0]['vppvAccumulate']);
             $cache->set($key, $click, false, 7200);
         }
         $clickReturn[$propId] = $click;
     }
     return $clickReturn;
 }
Esempio n. 2
0
 /**
  * 获取套餐房源的累计点击量
  *
  * @param int $brokerId
  * @param array|int $houseIds
  * @param int $cityId
  * @return array
  */
 public static function getComboHouseAccumulateClick($brokerId, $houseIds, $cityId)
 {
     $noCacheHouseIds = is_array($houseIds) ? $houseIds : array($houseIds);
     /**
      * 从memcache里获取房源累计点击信息
      */
     $cache = APF_Cache_Factory::get_instance()->get_memcache();
     $cacheKey = sprintf('combo_accumulate_house_click_1_%d', $brokerId);
     /**
      * Memcache::get 的用法
      * @link http://php.net/manual/zh/memcache.get.php
      */
     $cacheHouseAccumulateClickList = $cache->get($cacheKey);
     if (is_array($cacheHouseAccumulateClickList) && !empty($cacheHouseAccumulateClickList)) {
         $houseAccumulateClickList = $cacheHouseAccumulateClickList;
         $cacheHouseIds = array_keys($cacheHouseAccumulateClickList);
         $noCacheHouseIds = array_diff($noCacheHouseIds, $cacheHouseIds);
     } else {
         $houseAccumulateClickList = array_fill_keys($noCacheHouseIds, 0);
     }
     if (count($noCacheHouseIds) == 0) {
         return $houseAccumulateClickList;
     }
     foreach ($noCacheHouseIds as $noCacheHouseId) {
         $houseAccumulateClickList[$noCacheHouseId] = 0;
     }
     $houseIds = $noCacheHouseIds;
     /**
      * 获取房源的发布时间
      */
     $houseBaseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($brokerId, $houseIds, $cityId, array('proId', 'postDate'));
     if (empty($houseBaseInfoList)) {
         return $houseAccumulateClickList;
     }
     /**
      * 根据房源的发布时间获取房源累计点击量的分表后缀
      */
     $splitSuffixes = array();
     foreach ($houseBaseInfoList as $houseBaseInfo) {
         $splitSuffix = date('Ym', $houseBaseInfo['postDate']);
         if (!isset($splitSuffixes[$splitSuffix])) {
             $splitSuffixes[$splitSuffix] = array();
         }
         $splitSuffixes[$splitSuffix][] = $houseBaseInfo['proId'];
     }
     if (empty($splitSuffixes)) {
         return $houseAccumulateClickList;
     }
     /**
      * 获取房源的累计点击量
      */
     $result = array();
     foreach ($splitSuffixes as $splitSuffix => $houseIdList) {
         $houseClickInfoList = Model_Broker_ComboPropClickAccumulate::getHouseClickInfo($houseIdList, Model_Broker_ComboPropClickAccumulate::SITE_TYPE_AJK, $splitSuffix);
         $result = array_merge($result, $houseClickInfoList);
     }
     if (empty($result)) {
         return $houseAccumulateClickList;
     }
     /**
      * 生成房源累计点击量信息
      */
     foreach ($result as $houseAccumulateClickInfo) {
         $houseId = $houseAccumulateClickInfo['propId'];
         $houseAccumulateClickList[$houseId] = $houseAccumulateClickInfo['vppvAccumulate'];
     }
     $cache->set($cacheKey, $houseAccumulateClickList, 0, 7200);
     return $houseAccumulateClickList;
 }
Esempio n. 3
0
 /**
  * 获取套餐房源的累计点击量
  * @param int $ajkBrokerId
  * @param array|int $houseIds
  * @param int $cityId
  * @return array
  */
 public static function getComboHouseAccumulateClick($ajkBrokerId, $houseIds, $cityId)
 {
     $noCacheHouseIds = is_array($houseIds) ? $houseIds : array($houseIds);
     $cache = APF_Cache_Factory::get_instance()->get_memcache();
     $cacheKey = sprintf('combo_accumulate_house_click_hz_1_%d', $ajkBrokerId);
     $cacheHouseAccumulateClickList = $cache->get($cacheKey);
     if (is_array($cacheHouseAccumulateClickList) && !empty($cacheHouseAccumulateClickList)) {
         $houseAccumulateClickList = $cacheHouseAccumulateClickList;
         $cacheHouseIds = array_keys($cacheHouseAccumulateClickList);
         $noCacheHouseIds = array_diff($noCacheHouseIds, $cacheHouseIds);
     } else {
         $houseAccumulateClickList = array_fill_keys($noCacheHouseIds, 0);
     }
     if (count($noCacheHouseIds) == 0) {
         return $houseAccumulateClickList;
     }
     foreach ($noCacheHouseIds as $noCacheHouseId) {
         $houseAccumulateClickList[$noCacheHouseId] = 0;
     }
     $houseIds = $noCacheHouseIds;
     // 获取房源的发布时间
     $houseBaseInfoList = Model_House_HzPropSearch::getPropLists($cityId, array(array('proid', 'in', $houseIds)));
     if (empty($houseBaseInfoList)) {
         return $houseAccumulateClickList;
     }
     // 根据房源的发布时间获取房源累计点击量的分表后缀
     $splitSuffixes = array();
     foreach ($houseBaseInfoList as $houseBaseInfo) {
         $splitSuffix = date('Ym', $houseBaseInfo['created']);
         if (!isset($splitSuffixes[$splitSuffix])) {
             $splitSuffixes[$splitSuffix] = array();
         }
         $splitSuffixes[$splitSuffix][] = $houseBaseInfo['proid'];
     }
     if (empty($splitSuffixes)) {
         return $houseAccumulateClickList;
     }
     /**
      * 获取房源的累计点击量
      */
     $result = array();
     foreach ($splitSuffixes as $splitSuffix => $houseIdList) {
         $houseClickInfoList = Model_Broker_ComboPropClickAccumulate::getHouseClickInfo($houseIdList, Model_Broker_ComboPropClickAccumulate::SITE_TYPE_HZ, $splitSuffix);
         $result = array_merge($result, $houseClickInfoList);
     }
     if (empty($result)) {
         return $houseAccumulateClickList;
     }
     /**
      * 生成房源累计点击量信息
      */
     foreach ($result as $houseAccumulateClickInfo) {
         $houseId = $houseAccumulateClickInfo['propId'];
         $houseAccumulateClickList[$houseId] = $houseAccumulateClickInfo['vppvAccumulate'];
     }
     $cache->set($cacheKey, $houseAccumulateClickList, 0, 7200);
     return $houseAccumulateClickList;
 }