Пример #1
0
 /**
  * 获取经纪人精选房源列表
  *
  * @param $brokerId
  * @return bool
  */
 public function getBrokerPropChoiceInfo($brokerId)
 {
     try {
         //初始话返回数据
         $data = array('OnlinePropertyList' => array(), 'QueuedPropertyList' => array(), 'OfflinePropertyList' => array());
         //获取经纪人基本信息
         $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
         if (empty($brokerBaseInfo)) {
             $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG);
         }
         //判断经纪人城市是否开通精选
         if (!$this->checkChoiceOpen($brokerBaseInfo->cityId)) {
             $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG);
         }
         //获取经纪人有效精选计划
         $choicePlans = Model_Plan_EsfAjkPropSpread::getValidChoicePlanByBroker($brokerId, array('createtime', 'desc'));
         if (empty($choicePlans)) {
             return $data;
         }
         //格式化精选计划数据
         list($onSpreadList, $onQueueList, $historyList, $propList) = $this->formatPlanInfo($choicePlans);
         //获取经纪人的所有房源信息
         $propInfo = Bll_House_EsfHouse::getHouseBaseInfo($propList, $brokerBaseInfo->cityId);
         //转换房源数组key,同时添加默认totalClick的默认值
         $propInfo = $this->formatPropInfo($propInfo);
         //根据房源id获取定价总点击
         $bidBll = new bll_plan_bid_EsfBid();
         $bidClickInfo = $bidBll->getPropTotalClicksAndCost($propList, $brokerBaseInfo->cityId);
         //$fixedClickInfo = Model_Plan_EsfFixedClickInfo::getClickInfoByProps($propList, $brokerId);
         foreach ($propInfo as $key => $row) {
             $propInfo[$key]['totalClicks'] = $bidClickInfo[$row['id']]['totalClicks'];
         }
         //根据计划拼接房源信息
         $this->combinePropInfo($onSpreadList, $propInfo);
         $this->combinePropInfo($onQueueList, $propInfo);
         $this->combinePropInfo($historyList, $propInfo);
         // 排序
         $this->_sortPropByUpdateTime($onSpreadList);
         $this->_sortPropByUpdateTime($onQueueList);
         $this->_sortPropByUpdateTime($historyList);
         if (!empty($historyList)) {
             foreach ($historyList as $key => $val) {
                 $historyList[$key]['isChoice'] = 0;
             }
         }
         return array('OnlinePropertyList' => $onSpreadList, 'QueuedPropertyList' => $onQueueList, 'OfflinePropertyList' => $historyList);
     } catch (Exception $e) {
         if ($e instanceof Exception_BllErrorException) {
             $this->errorCode = $e->getCode();
         } else {
             $this->errorCode = self::UNKNOW_ERROR;
         }
         $this->errorMsg = $e->getMessage();
         return false;
     }
 }