public function dealTask($solrOnProId) { $brokerId = 0; $houseInfo = Bll_House_EsfHouse::getHouseInfoById($solrOnProId, $this->cityId); if (!empty($houseInfo)) { if ($this->isSowooHouse($houseInfo)) { printf('房源 %d 是机器抓取的不做处理' . PHP_EOL, $solrOnProId); return true; } if ($onlineComboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_AJK)) { printf('房源 %s 已经在套餐推广中, 不用通知solr下' . PHP_EOL, $solrOnProId); return true; } $brokerId = $onlineComboRelation['brokerId']; } // 房源没有或者不在线 通知solr下 //$this->addPriceQueueByAPI($onlineComboRelation['brokerId'], $this->cityId, $solrOnProId, 2, 0, 0); $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($this->cityId, $brokerId, $solrOnProId, Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_DOWN, Bll_Combo_NoticeSolrUpDown::HLSFromComboCheckNotice); printf('房源 %s 没有在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId); printf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']); return true; }
public function handle_request() { $this->setLog(sprintf('开始处理[%d - %d]的日志......', $this->_suffix, $this->_lastLogId)); $type = array(1, 2, 14, 20); $houseLogList = Model_Log_HouseLogNew::getLogInfoMoreThanIdEx($this->_lastLogId, $this->_suffix, 1, $type); $currentTimestamp = date('Y-m-d H:i:s'); if (empty($houseLogList)) { $currentDate = date('Ymd'); if ($this->_suffix != $currentDate) { $this->setFlag(array('id' => 0, 'date' => $currentDate, 'time' => $currentTimestamp)); } $this->setShCommonSleepTime(1); return; } $houseIllegalFilter = new Bll_House_Filter(); foreach ($houseLogList as $row) { $cityId = $row['cityId']; $brokerId = $row['brokerId']; $houseId = $row['houseId']; $this->setLogPrefix(sprintf('%d - %d - %d', $cityId, $brokerId, $houseId)); if (strtotime($row['addDate']) > time() - 60) { $this->setLog(sprintf('日志延时处理%s', $row['addDate'])); $this->setShCommonSleepTime(300); return; } $this->setLog(sprintf('开始处理日志:%s', json_encode($row))); $this->setFlag(array('id' => $row['id'], 'date' => $this->_suffix, 'time' => $currentTimestamp)); $houseInfo = Bll_House_EsfHouse::getHouseInfoById($houseId, $cityId); if (empty($houseInfo)) { $this->setLog('没有获取到房源的信息'); continue; } $this->setLog(sprintf('房源信息:%s', json_encode($houseInfo))); if ($houseInfo['operateState'] != 1) { $this->setLog(sprintf('房源状态[%d]无效,不处理', $houseInfo['operateState'])); continue; } if ($houseInfo['isVisible'] == 0 && $houseInfo['expireWorker'] != 'propertyReport') { $this->setLog(sprintf('房源已经违规[isVisible=%d, expireWorker=%s],不处理', $houseInfo['isVisible'], $houseInfo['expireWorker'])); continue; } $isHouseIllegal = $houseIllegalFilter->execute($houseInfo, $logContent); $this->setLog(implode(PHP_EOL, $logContent)); if ($isHouseIllegal) { $this->setLog('正常房源'); continue; } $this->setLog('房源违规'); $params = array('cityId' => $cityId, 'propId' => $houseId, 'newIsVisible' => 0, 'newModifyDate' => time(), 'newExpireDate' => 0); $apiResponse = array(); /** 调用API违规房源 */ for ($i = 0; $i < 3; $i++) { /** * @var Bll_Service_Client_HttpResponse $apiResponse */ $apiResponse = Bll_Service_House::esfUpdatePropertyInfo($params); if ($apiResponse->isSucceeded()) { break; } } if ($apiResponse->isFailed()) { $this->setLog(sprintf('调用API超时: %s', json_encode($apiResponse->getTransferInfo()))); } else { $this->setLog(sprintf('调用API的返回信息: %s', json_encode($apiResponse->getResponse()))); } if (isset($apiResponse['status']) && strcasecmp('ok', $apiResponse['status']) == 0) { $this->setLog('设置房源状态违规成功'); } else { $this->setLog('设置房源状态违规失败'); } $reasonArr = array('propId' => $houseId, 'brokerId' => $brokerId, 'type' => 2, 'reason' => '房源信息不实!', 'postTime' => time(), 'mid' => 0); Model_Log_AjkIllegalHouse::writeHouseIllegalInfo($reasonArr); $hpData = array('ProId' => $houseId, 'Remark' => '虚假房源违规', 'BrokerId' => $brokerId, 'CityId' => $cityId, 'Type' => 1, 'OperateId' => 0, 'From' => __CLASS__); Model_House_AjkHpProSpreadChange::insertProSpreadChange($hpData); $data = array('houseId' => $houseId, 'planId' => 0, 'brokerId' => $brokerId, 'cityId' => $cityId, 'type' => 103, 'remark' => '虚假房源违规', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __CLASS__, 'siteType' => 1); if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $this->setLog('上下架通知失败'); } } $this->setShCommonSleepTime(1); }