Beispiel #1
0
 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);
 }