Esempio n. 1
0
 /**
  * @param AJKRequest $request
  * @param array $out
  * @throws Exception
  */
 public static function initEnv($request, &$out)
 {
     $out['debug'] = isset($_GET['debug']) ? true : false;
     $out['cityId'] = $request->getBrokerCityId();
     $out['ajkBrokerId'] = $request->getBrokerId();
     $brokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerIdEx($out['ajkBrokerId']);
     if (empty($brokerInfo)) {
         throw new Exception('获取金铺经纪人信息失败:ajkBrokerId [' . $out['ajkBrokerId'] . ']');
     }
     $out['brokerInfo'] = $brokerInfo;
     // 获取金铺brokerId
     $out['jpBrokerId'] = $brokerInfo['id'];
     // 是否精选
     $out['isChoiceCity'] = Bll_City::isChoiceCity($out['cityId'], Const_Site::JINPU);
     $out['isBidCity'] = false;
     $out['isShowCaseCity'] = Bll_City::isShowCaseCity($out['cityId'], Const_Site::JINPU);
     $out['bidTip'] = '精选';
     //经纪人全部有效房源
     $out['houses'] = Bll_House_JpHouseInfo::getAllHouseInfoEx($out['ajkBrokerId']);
     $out['houseIds'] = array();
     foreach ($out['houses'] as $infoP) {
         $base = $infoP['base'];
         $info = $infoP['info'];
         $type = $infoP['houseType'];
         $propertyId = in_array($type, array(1, 2)) ? $info['buildingId'] : $info['propertyId'];
         $out['houseIds'][$type][$base['id']] = array('houseId' => $base['id'], 'propertyId' => $propertyId);
     }
     $out['publishUrl'] = Bll_Broker_Combo_ManageJp::buildHousePublishUrl();
 }
 public function handle_request()
 {
     if ($this->_brokerId == 0) {
         echo sprintf('Usage: launcher.php Monitor_JpHouseSpreadState --broker=[:number:] [--release=...]'), PHP_EOL;
         return;
     }
     $loadFields = array('id', 'cityId', 'ajkMemberId');
     $brokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerIdEx($this->_brokerId, $loadFields);
     if (empty($brokerInfo)) {
         $this->logMsg(sprintf('没有获取到经纪人[%d]的金铺经纪人信息', $this->_brokerId));
         return;
     }
     $this->logMsg(sprintf('经纪人[%d]的金铺经纪人信息: %s', $this->_brokerId, json_encode($brokerInfo)));
     $searchParams = array('fl' => 'id,is_auction,is_combo', 'q' => '*:*', 'version' => '2.2', 'indent' => 'on', 'rows' => 1000, 'wt' => 'json');
     $fieldQuery = array('fq=' . urlencode(sprintf('list_time:[0 TO %d]', time())), 'fq=' . urlencode(sprintf('member_id:%d', $brokerInfo['id'])), 'fq=' . urlencode(sprintf('city_id:%d', $brokerInfo['cityId'])));
     $query = http_build_query($searchParams);
     $houseInInSolr = array();
     /** 查询在Solr中的房源 */
     foreach ($this->_hosts as $houseType => $host) {
         $url = $host . '?' . $query . '&' . implode('&', $fieldQuery);
         $this->logMsg('URL: ' . $url);
         $temp = $this->httpRequest($url);
         foreach ($temp as $tmp) {
             $tmp['houseType'] = $houseType;
             $houseInInSolr[$tmp['id']] = $tmp;
         }
     }
     /** 获取推广中的房源 */
     $houseComboRelationList = Bll_Combo_HouseRelation::getHouseRelations($this->_brokerId, Bll_Combo_HouseRelation::SITE_TYPE_JP, 1);
     if (empty($houseInInSolr) && empty($houseComboRelationList)) {
         $this->logMsg(sprintf('经纪人[%d]没有在solr和在线的房源', $this->_brokerId));
         return;
     }
     $comboSpreadHouseIds = array();
     foreach ($houseComboRelationList as $houseComboRelation) {
         $comboSpreadHouseIds[] = $houseComboRelation['houseId'];
     }
     /** 判断solr中的房源是否都在套餐推广中 该下没下 */
     foreach ($houseInInSolr as $houseId => $houseSpreadState) {
         if (!in_array($houseId, $comboSpreadHouseIds)) {
             $this->logMsg(sprintf('房源[%d]在solr中,但是不在套餐推广中', $houseId));
             file_put_contents($this->_houseInSolrNotSpread, sprintf('%d-%d' . PHP_EOL, $houseId, $houseSpreadState['houseType']), FILE_APPEND);
         }
     }
     /** 判断套餐推广中的房源是否在solr中 该上没上 */
     foreach ($comboSpreadHouseIds as $houseId) {
         if (!isset($houseInInSolr[$houseId])) {
             $this->logMsg(sprintf('房源[%d]在套餐推广中,但是不在solr中', $houseId));
             file_put_contents($this->_comboSpreadHouseNotInSolr, $houseId . PHP_EOL, FILE_APPEND);
         }
     }
 }