/** * @param array $data * @return bool */ public static function insertProSpreadChange(array $data) { if (!$data) { return false; } return Model_House_AjkHpProSpreadChange::create($data, date('Ymd'))->save(); }
/** * 关系表数据处理. * * */ public function reletion_handle($id) { $houseList = Model_House_HouseRelation::getHouseList($id); if (empty($houseList)) { // 空数据。 $this->setLog(sprintf("[%s] : 房源关系表中没有剩余数据,处理完成.", date('Y-m-d H:i:s'))); exit; } else { foreach ($houseList as $house) { $message = []; $flagId = $house['id']; $cityId = $house['cityId']; $brokerId = $house['brokerId']; $houseId = $house['houseId']; $info = Bll_House_EsfHouse::getHouseInfo($houseId, $cityId); echo '[houseID]:', $houseId, ' [id]:', $flagId, ' [brokerId]:', $brokerId, ' [feifa]:--', $info['operateState'], "\n"; $flagInfo = array('type' => 're', 'id' => $flagId); if ($info['operateState'] == 1) { $updateTime = $info['updatedDatetime']; // 延迟5分钟处理. if (time() - strtotime($updateTime) < 300) { continue; } $filter = Bll_House_Filter::filterJob($info); if (!$filter) { // 正常房源. $this->setLog(sprintf("[%s] 房源[%s], 城市[%s], %s", date('Y-m-d H:i:s'), $houseId, $cityId, '房源信息正常.')); } else { // 虚假房源. $filter--; $message = Bll_House_Filter::$message; $log = $this->falseLog($filter, $info, $message); $this->setLog($log); $this->false_handle($info); $reasonArr = array('propId' => $houseId, 'brokerId' => $brokerId, 'type' => 2, 'reason' => '房源信息不实!', 'postTime' => time(), 'mid' => 0); Model_Log_AjkIllegalHouse::writeHouseIllegalInfo($reasonArr); $Date = date("Ymd"); $reason = '房源信息不符,房源规则' . ($filter + 1) . '违规'; $hpData = array("ProId" => $houseId, "Remark" => $reason, "BrokerId" => $brokerId, "CityId" => $cityId, "Type" => 1, "OperateId" => 0, "From" => "system"); Model_House_AjkHpProSpreadChange::insertProSpreadChange($hpData); $data = array('houseId' => $houseId, 'planId' => 0, 'brokerId' => $brokerId, 'cityId' => $cityId, 'type' => 103, 'remark' => $reason, 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 1); if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $log = sprintf("[%s]:[房源id]:%s, [房源面积]:%s,[房源户型]:%s,插入下架队列失败。", date('Y-m-d h:i:s'), $info['proId'], $info['areaNum'], $info['roomNum']); $this->setLog($log); } // 插入下架队列,actionAPI,虚假房源表。 } $this->setFlag($flagInfo); } else { // 非法房源. // log. $this->setFlag($flagInfo); continue; } } exit; } }
public static function insertProSpreadChange($SpreadId, $ProId, $BrokerId, $CityId, $Type, $Remark, $From) { return Model_House_AjkHpProSpreadChange::insertProSpreadChange(array('SpreadId' => $SpreadId, 'ProId' => $ProId, 'BrokerId' => $BrokerId, 'CityId' => $CityId, 'Type' => $Type, 'Remark' => $Remark, 'From' => $From)); }
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); }