public function handle_request() { $houseRelationList = $this->getComboSpreadHouseList(); foreach ($houseRelationList as $houseRelation) { $this->setCursor($houseRelation['id']); $this->logMsg(sprintf('处理房源[%d] %s', $houseRelation['houseId'], json_encode($houseRelation))); $houseRank = Model_Jinpu_HouseRank::getHouseRankById($houseRelation['houseId']); if (empty($houseRank)) { $this->logMsg(sprintf('房源[%d]没有获取到rank信息', $houseRelation['houseId'])); continue; } $rankUpdateTime = strtotime($houseRank['update_time']); $spreadTime = strtotime($houseRelation['updateTime']); /** 如果rank的更新时间 大于 房源做推广的时间,就通知solr更新房源信息 */ if ($rankUpdateTime >= $spreadTime) { $houseInfo = $this->getHouseInfo($houseRelation['houseId']); if (empty($houseInfo)) { $this->logMsg('获取房源[%d]信息失败', $houseRelation['houseId']); continue; } $this->logMsg(sprintf('房源信息 %s', json_encode($houseInfo))); if ($houseInfo['houseType'] < 1 || $houseInfo['houseType'] > 4) { $this->logMsg(sprintf('房源[%d]信息错误', $houseRelation['houseId'])); continue; } $requestId = date('Ymd', $rankUpdateTime) . $houseRelation['id']; $from = Bll_Combo_NoticeSolrUpDown::HLS_FROM_REPAIR_UPDATE_RANK_NOTIFY_SOLR; // $action = Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_UP; // $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($houseRelation['cityId'], $houseRelation['brokerId'], $houseRelation['houseId'], $houseInfo['houseType'], $action, $from, $rankUpdateTime, $requestId); $result = Bll_Combo_NoticeSolrUpDown::noticeUpdateJpAPI($houseRelation['cityId'], $houseRelation['houseId'], $houseInfo['houseType'], $from, $rankUpdateTime, $requestId); if (is_array($result) && $result['status'] == 'ok') { $this->logMsg(sprintf('房源[%d]通知solr成功 %s', $houseRelation['houseId'], json_encode($result))); continue; } $this->logMsg(sprintf('房源[%d]通知solr失败 %s', $houseRelation['houseId'], json_encode($result))); } } if (count($houseRelationList) < self::BATCH_LIMIT) { file_put_contents($this->_doneFile, 'DONE'); } }
/** * 金铺更新 * @param $record * @return bool */ public function updateSolrJp($record) { $type = $record['type']; if ($type != 2 && $type != 4) { //记录处理日志 $this->setLog('不需要做更新处理 ' . __METHOD__); return true; } $houseIdx = Model_House_JpHouseIdx::data_access()->filter('id', $record['houseId'])->find_only(); if (intval($houseIdx->houseType) <= 0) { $this->setLog('金铺房源房源类型为空,无法处理 '); return false; } $resArr = Bll_Combo_NoticeSolrUpDown::noticeUpdateJpAPI($record['cityId'], $record['houseId'], $houseIdx->houseType, Bll_Combo_NoticeSolrUpDown::HLSFromPropUpdate, strtotime($record['addDate']), date('Ymd', strtotime($record['addDate'])) . $record['id']); if ($resArr['status'] == 'ok') { //记录处理日志 $this->setLog('solr处理成功 '); } else { //记录处理日志 $this->setLog('solr处理失败 '); } return true; }