private function dealFailureHouse() { $houseIdList = file($this->_failureHouseIdFile); if (empty($houseIdList)) { $this->logMsg('没有需要处理的房源。'); return; } foreach ($houseIdList as $houseId) { /** 再判断一下房源是否应该在线,预防将该下的房源通知上了 */ $onlineHouseRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK); if (empty($onlineHouseRelation)) { $this->logMsg(sprintf('房源[%d]已经下线, 不予处理。', $houseId)); continue; } $this->logMsg(sprintf('调用参数:cityId=%d, brokerId=%d, houseId=%d', $onlineHouseRelation['cityId'], $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId'])); $apiResponse = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($onlineHouseRelation['cityId'], $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId'], Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_UP, Bll_Combo_NoticeSolrUpDown::NOTICE_FROM_TYPE_CHECK_HOUSE_FOR_SOLR); if (is_null($apiResponse) || !isset($apiResponse['status']) || strcasecmp('ok', $apiResponse['status']) != 0) { $this->logMsg(sprintf('调用API失败。res: %s', json_encode($apiResponse))); continue; } $this->logMsg(sprintf('调用API成功。res: %s', json_encode($apiResponse))); } file_put_contents($this->_doneFile, 'DONE'); }
/** * 通知solr下架房源 * * @param array $record * @return bool */ public function noticeDownSolrAjk($record) { $downType = array(3, 8, 9); $this->setLog('二手房房源删除、到期、违规,通知solr 下架房源'); if (!in_array($record['type'], $downType)) { $this->setLog(sprintf('通知solr 下架房源,日志类型不是[%s]', implode(',', $downType))); return false; } $resArr = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($record['cityId'], $record['brokerId'], $record['houseId'], 2, Bll_Combo_NoticeSolrUpDown::HLS_FROM_DELETE_HOUSE, strtotime($record['addDate']), date('Ymd', strtotime($record['addDate'])) . $record['id']); if ($resArr['status'] != 'ok') { $this->setLog(sprintf('solr处理失败 res:%s', json_encode($resArr))); return false; } $this->setLog(sprintf('solr处理成功 res:%s', $record['id'], json_encode($resArr))); return true; }
public function handle_request() { $cityIds = $this->getOption('city', array()); if (empty($cityIds)) { $this->logMsg('Usage: launcher.php Combo_AjkCheckHouseIsValidate --cityId=... [--release=...] '); return; } $cityIdList = explode(',', $cityIds); $dealCityIdList = array(); foreach ($cityIdList as $cityId) { if (false == Bll_City::isComboCity($cityId)) { $this->logMsg(sprintf('城市:%d 不是套餐城市,不予处理。', $cityId)); continue; } $dealCityIdList[] = $cityId; } $this->logMsg(sprintf('开始处理城市[%s]........', implode(',', $dealCityIdList))); $brokerList = Bll_Broker::scanComboBrokerByCityId($dealCityIdList, $this->_startId, self::BROKER_LIMIT); if (empty($brokerList)) { $this->logMsg(sprintf('startId: %d 没有获取到经纪人。', $this->_startId)); file_put_contents($this->_doneFile, 'YES'); return; } foreach ($brokerList as $broker) { $this->setCursor($broker['brokerId']); $onlineHouseRelationList = Bll_Combo_HouseRelation::getOnlineHouseList($broker['brokerId'], $broker['cityId'], Bll_Combo_HouseRelation::SITE_TYPE_AJK); /** 经纪人没有在线房源 */ if (empty($onlineHouseRelationList)) { $this->logMsg(sprintf('经纪人[%d]没有在线房源', $broker['brokerId'])); continue; } /** 获取在线房源ID */ $onlineHouseList = array(); foreach ($onlineHouseRelationList as $onlineHouseRelation) { $onlineHouseList[] = $onlineHouseRelation['houseId']; } $houseList = static::getInvalidateHouse($broker['cityId'], $broker['brokerId'], $onlineHouseList); /** 没有获取无效的房源信息 */ if (empty($houseList)) { $this->logMsg(sprintf('经纪人[%d]没有获取无效的房源[%s]信息', $broker['brokerId'], implode(',', $onlineHouseList))); continue; } foreach ($houseList as $house) { $this->logMsg(sprintf('房源[%d] brokerId=%d operateState=%d isVisible=%d expireWorker=%s updatedDatetime=%s', $house['proId'], $house['brokerId'], $house['operateState'], $house['isVisible'], $house['expireWorker'], $house['updatedDatetime'])); $effectRowCount = Bll_Combo_HouseRelation::updateHouseComboSpreadState($house['brokerId'], $house['proId'], Bll_Combo_HouseRelation::SITE_TYPE_AJK, Model_Combo_HouseRelation::ENUM_HOUSE_DELETE); if ($effectRowCount != 1) { $this->logMsg(sprintf('房源[%d] 更新关系失败', $house['proId'])); continue; } /** 通知用户端下架房源 */ $apiResponse = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($broker['cityId'], $house['brokerId'], $house['proId'], Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_DOWN); if ($apiResponse['status'] == 'ok') { $this->logMsg(sprintf('房源[%d] 通知下架成功', $house['proId'])); } else { $this->logMsg(sprintf('房源[%d] 通知下架失败, apiResponse:%s', $house['proId'], json_encode($apiResponse))); } } } if (count($brokerList) < self::BROKER_LIMIT) { $this->logMsg(sprintf('startId: %d 经纪人已经处理完成', $this->_startId)); file_put_contents($this->_doneFile, 'YES'); } }
/** * 通知中间件上下架房源 * * @param int $houseId * @param int $flag */ private function notifyMiddleWare($houseId, $flag) { $resArr = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($this->_cityId, $this->_brokerId, $houseId, $flag, Bll_Combo_NoticeSolrUpDown::HLS_FROM_HOUSE_STATE_CHECK_REPAIR, time(), date('Ymd') . $houseId); if ($resArr['status'] != 'ok') { $this->logMsg(sprintf('通知中间件失败 res:%s', json_encode($resArr))); return; } $this->logMsg(sprintf('通知中间件成功 res:%s', json_encode($resArr))); }
public function handle_request() { $dealCityList = $this->getOption('city', array()); if (!is_array($dealCityList)) { $dealCityList = explode(',', $dealCityList); } if (empty($dealCityList)) { $this->logMsg('请传需要处理城市ID'); file_put_contents($this->_doneFile, 'YES'); return; } file_put_contents($this->_doneFile, 'NO'); $brokerList = $this->getBrokerList($dealCityList, $this->_startId); if (empty($brokerList)) { $this->logMsg(sprintf('startId: %d 没有获取到经纪人。', $this->_startId)); file_put_contents($this->_doneFile, 'YES'); return; } foreach ($brokerList as $broker) { $brokerId = $broker['brokerId']; $cityId = $broker['cityId']; $this->logMsg(sprintf('开始处理城市 %d 经纪人 %d', $cityId, $brokerId)); $houseList = Bll_House_EsfHouse::getBrokerAllPropInfoList($brokerId, $cityId); $houseIds = array(); foreach ($houseList as $house) { $houseIds[] = $house['proId']; } $this->logMsg(sprintf('经纪人 %d 共有 %d 套房源[%s]', $brokerId, count($houseIds), implode(',', $houseIds))); $spreadHouseList = Bll_Combo_HouseRelation::getOnlineHouseList($brokerId, $cityId, Bll_Combo_HouseRelation::SITE_TYPE_AJK); $spreadHouseIds = array(); foreach ($spreadHouseList as $spreadHouse) { $spreadHouseIds[] = $spreadHouse['houseId']; } $this->logMsg(sprintf('经纪人 %d 共有推广 %d 套房源[%s]', $brokerId, count($spreadHouseIds), implode(',', $spreadHouseIds))); $houseIds = array_diff($houseIds, $spreadHouseIds); $this->logMsg(sprintf('经纪人 %d 需要下掉 %d 套房源[%s]', $brokerId, count($houseIds), implode(',', $houseIds))); foreach ($houseIds as $houseId) { /** 通知用户端下架房源 */ $apiResponse = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($cityId, $brokerId, $houseId, Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_DOWN); if ($apiResponse['status'] == 'ok') { $this->logMsg(sprintf('房源[%d] 通知下架成功', $houseId)); } else { $this->logMsg(sprintf('房源[%d] 通知下架失败, apiResponse:%s', $houseId, json_encode($apiResponse))); } } $this->setCursor($brokerId); } if (count($brokerList) < self::BROKER_LIMIT) { $this->logMsg(sprintf('startId: %d 经纪人已经处理完成', $this->_startId)); file_put_contents($this->_doneFile, 'YES'); } }
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; }