/** * 关系表数据处理. * * */ 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 function handle_request() { $accountBalanceZeroList = Model_Log_AccountBalanceZeroLog::getLogList($this->_startId, self::LOG_LIMIT); if (empty($accountBalanceZeroList)) { $this->logMsg(sprintf('Id: %d 处理完成', $this->_startId)); return; } foreach ($accountBalanceZeroList as $accountBalanceZero) { $this->setCursor($accountBalanceZero['id']); /** 根据 AccountId 获取UserId */ $accountId = $accountBalanceZero['accountId']; $accountMapping = Model_Payment_AccountMapping::getAccountMappingByAccountId($accountId, Model_Payment_AccountMapping::SITE_TYPE_AJK); if (empty($accountMapping)) { $this->logMsg(sprintf('没有获取到AccountMapping accountId:%d', $accountId)); continue; } $userId = $accountMapping['userId']; $brokerInfo = Model_Broker_AjkBrokerExtend::getBrokerInfoByUserIdEx($userId, array('cityId', 'brokerId', 'userId', 'trueName', 'payType')); if (empty($brokerInfo)) { $this->logMsg(sprintf('没有获取到经纪人信息 accountId:%d userId:%d', $accountId, $userId)); continue; } $brokerId = $brokerInfo['brokerId']; if ($brokerInfo['payType'] != 10000) { $this->logMsg(sprintf('经纪人:%s AccountId:%d UserId:%d BrokerId:%d PayType=%d不是PPC经纪人 ', $brokerInfo['trueName'], $accountId, $userId, $brokerId, $brokerInfo['payType'])); continue; } $cityId = $brokerInfo['cityId']; $data = array('brokerId' => $brokerId, 'cityId' => $cityId, 'type' => 301, 'remark' => '账户余额不足', 'flag' => 0, 'addDate' => time(), 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 4); try { Model_House_UpDown_Task::create($data, date('Ymd'))->save(); } catch (Exception $e) { $this->logMsg(sprintf('经纪人:%s CityId:%d AccountId:%d UserId:%d BrokerId:%d 通知账户没钱失败', $brokerInfo['trueName'], $cityId, $accountId, $userId, $brokerId)); } $this->logMsg(sprintf('经纪人:%s CityId:%d AccountId:%d UserId:%d BrokerId:%d 通知账户没钱成功', $brokerInfo['trueName'], $cityId, $accountId, $userId, $brokerId)); } if (count($accountBalanceZeroList) < self::LOG_LIMIT) { $this->logMsg(sprintf('Id: %d 处理完成', $this->_startId)); return; } }
/** * 手动暂停金铺经纪人的定价计划 * * @param int $jpBrokerId * @param int $cityId * @param array $fixPlan */ private function stopJpFixPlan($jpBrokerId, $cityId, $fixPlan) { try { $ajkBrokerId = Bll_Broker_User::getAjkBrokerIdByJpBrokerId($jpBrokerId); } catch (Exception $e) { $this->logMsg($e->getMessage()); return; } $this->logMsg(sprintf('经纪人[%d - %d - %d]金铺的定价计划,处理开始。', $cityId, $ajkBrokerId, $jpBrokerId)); $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d - %d]状态。', $cityId, $ajkBrokerId, $jpBrokerId, $fixPlan['id'], $fixPlan['status'], $fixPlan['stopReason'])); $data = array('houseId' => 0, 'planId' => 0, 'brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'type' => 207, 'remark' => '切新端口,暂停定价计划', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 3); $this->logMsg(json_encode($fixPlan)); if (false == Bll_Plan_Fix_JpPlan::stopPlanByHand($fixPlan['id'])) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停失败。', $cityId, $ajkBrokerId, $jpBrokerId, $fixPlan['id'], $fixPlan['stopReason'])); return; } $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停成功。', $cityId, $ajkBrokerId, $jpBrokerId, $fixPlan['id'], $fixPlan['stopReason'])); if ($fixPlan['status'] == 4) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]已经停止,不通知上下架。', $cityId, $ajkBrokerId, $jpBrokerId, $fixPlan['id'], $fixPlan['stopReason'])); return; } /** * 记录上下架队列 */ $data['planId'] = $fixPlan['id']; if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $this->logMsg(sprintf('%s 记录上下架队列失败。', json_encode($data))); } else { $this->logMsg(sprintf('%s 记录上下架队列成功。', json_encode($data))); } $this->logMsg(sprintf('经纪人[%d - %d - %d]金铺的定价计划,处理结束。', $cityId, $ajkBrokerId, $jpBrokerId)); }
/** * 手动暂停好租经纪人的定价计划 * * @param int $hzBrokerId * @param int $cityId * @param array $fixPlan */ private function stopHzFixPlan($hzBrokerId, $cityId, $fixPlan) { $ajkBrokerId = Model_Broker_HzMapping::get_ajk_broker_id($hzBrokerId); if ($ajkBrokerId == 0) { $this->logMsg(sprintf('经纪人[%d - %d - %d]获取经纪人ajkBrokerId失败。', $cityId, $hzBrokerId, $fixPlan['id'])); } $this->logMsg(sprintf('经纪人[%d - %d - %d]的好租定价计划,处理开始。', $cityId, $ajkBrokerId, $hzBrokerId)); $data = array('houseId' => 0, 'planId' => 0, 'brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'type' => 207, 'remark' => '切新端口,暂停定价计划', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 2); $this->logMsg(json_encode($fixPlan)); if ($fixPlan['status'] == Const_HzPlan::MANUALLY_PAUSE) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d]已经手动暂停,不做处理。', $cityId, $hzBrokerId, $ajkBrokerId, $fixPlan['id'])); return; } if (false == Bll_HzFixPlan::stopPlanByHand($fixPlan['id'])) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停失败。', $cityId, $hzBrokerId, $ajkBrokerId, $fixPlan['id'], $fixPlan['status'])); return; } $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停成功。', $cityId, $hzBrokerId, $ajkBrokerId, $fixPlan['id'], $fixPlan['status'])); if ($fixPlan['status'] != Const_HzPlan::SPREAD) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d]已经暂停,不通知上下架。', $cityId, $hzBrokerId, $ajkBrokerId, $fixPlan['id'])); return; } /** * 记录上下架队列 */ $data['planId'] = $fixPlan['id']; if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $this->logMsg(sprintf('%s 记录上下架队列失败。', json_encode($data))); } else { $this->logMsg(sprintf('%s 记录上下架队列成功。', json_encode($data))); } $this->logMsg(sprintf('经纪人[%d - %d - %d]的好租定价计划,处理结束。', $cityId, $hzBrokerId, $hzBrokerId)); }
/** * 手动暂停二手房经纪人的定价计划 * * @param int $brokerId * @param int $cityId * @param array $fixPlan */ private function stopAjkFixPlan($brokerId, $cityId, $fixPlan) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的定价计划,处理开始。', $cityId, $brokerId)); $currentTimestamp = time(); $data = array('houseId' => 0, 'planId' => 0, 'brokerId' => $brokerId, 'cityId' => $cityId, 'type' => 207, 'remark' => '切新端口,暂停定价计划', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 1); $this->logMsg(json_encode($fixPlan)); /** * 经纪人的计划,已经被手动停止 */ if ($fixPlan['viewTime'] == 1861891200) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]已经手动停止,不处理。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); return; } /** * 经纪人的计划,在推广中 */ if ($fixPlan['viewTime'] <= $currentTimestamp) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]推广中。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); } /** * 经纪人的计划,因账户没钱停止 */ if ($fixPlan['viewTime'] == 1893427200) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]因账户没钱停止。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); } if (false == BLL_Plan_EsfPropFixedPlanRelation::stopFixPlanByHand($fixPlan['id'])) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]手动暂停失败。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); return; } $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]手动暂停成功。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); if ($fixPlan['viewTime'] > $currentTimestamp) { $this->logMsg(sprintf('二手房经纪人[%d - %d]的计划[%d - %d]已经停止,不通知上下架。', $cityId, $brokerId, $fixPlan['id'], $fixPlan['viewTime'])); return; } /** * 记录上下架队列 */ $data['planId'] = $fixPlan['id']; if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $this->logMsg(sprintf('%s 记录上下架队列失败。', json_encode($data))); } else { $this->logMsg(sprintf('%s 记录上下架队列成功。', json_encode($data))); } $this->logMsg(sprintf('二手房经纪人[%d - %d]的定价计划,处理结束。', $cityId, $brokerId)); }
/** * 手动暂停好租经纪人的定价计划 * * @param int $ajkBrokerId * @param int $cityId */ private function stopHzFixPlan($ajkBrokerId, $cityId) { $hzBrokerId = Bll_Broker_HzBroker::getBrokerIdByAjkBrokerId($ajkBrokerId); if ($hzBrokerId == 0) { $this->logMsg(sprintf('经纪人[%d - %d]没有获取到好租经纪人ID。', $cityId, $ajkBrokerId)); return; } $this->logMsg(sprintf('经纪人[%d - %d - %d]的好租定价计划,处理开始。', $cityId, $ajkBrokerId, $hzBrokerId)); $fixPlanList = Bll_HzFixPlan::getBrokerPlan($hzBrokerId); if (empty($fixPlanList)) { $this->logMsg(sprintf('经纪人[%d - %d - %d]没有获取到好租定价计划。', $cityId, $ajkBrokerId, $hzBrokerId)); return; } $data = array('houseId' => 0, 'planId' => 0, 'brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'type' => 207, 'remark' => '切新端口,暂停定价计划', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __METHOD__, 'siteType' => 2); foreach ($fixPlanList as $fixPlan) { $this->logMsg(json_encode($fixPlan)); if ($fixPlan['status'] == Const_HzPlan::MANUALLY_PAUSE) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d]已经手动暂停,不做处理。', $cityId, $ajkBrokerId, $hzBrokerId, $fixPlan['id'])); continue; } if (false == Bll_HzFixPlan::stopPlanByHand($fixPlan['id'])) { $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停失败。', $cityId, $ajkBrokerId, $hzBrokerId, $fixPlan['id'], $fixPlan['status'])); continue; } $this->logMsg(sprintf('经纪人[%d - %d - %d]定价计划[%d - %d]手动暂停成功。', $cityId, $ajkBrokerId, $hzBrokerId, $fixPlan['id'], $fixPlan['status'])); /** * 记录上下架队列 */ $data['planId'] = $fixPlan['id']; if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) { $this->logMsg(sprintf('%s 记录上下架队列失败。', json_encode($data))); } else { $this->logMsg(sprintf('%s 记录上下架队列成功。', json_encode($data))); } } $this->logMsg(sprintf('经纪人[%d - %d - %d]的好租定价计划,处理结束。', $cityId, $ajkBrokerId, $hzBrokerId)); }
/** * 通知上下架队列 * * @param int $brokerId * @param int|array $houseIds * @param int $cityId * @param int $site * @param int $type * @param string $remark * @param string $from * @param int $operateId * @return int */ public static function notifyHouseUpDownTask($brokerId, $houseIds, $cityId, $site, $type, $remark, $from, $operateId) { if ($site == self::SITE_TYPE_AJK) { $siteType = Model_House_UpDown_Task::SITE_TYPE_AJK; } elseif ($site == self::SITE_TYPE_HZ) { $siteType = Model_House_UpDown_Task::SITE_TYPE_HZ; } elseif ($site == self::SITE_TYPE_JP) { $siteType = Model_House_UpDown_Task::SITE_TYPE_JP; } else { $siteType = Model_House_UpDown_Task::SITE_TYPE_ALL; } if (!is_array($houseIds)) { $houseIds = array($houseIds); } $backtrace = debug_backtrace(); foreach ($backtrace as $part) { // 获取入口Controller if (isset($part['class']) && substr($part['class'], -10) === 'Controller') { $from = sprintf('%s::%s|%s', $part['class'], $part['function'], $from); break; } } $data = array('houseId' => 0, 'planId' => 0, 'brokerId' => $brokerId, 'cityId' => $cityId, 'type' => $type, 'remark' => $remark, 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => $operateId, 'from' => $from . "|ipfrom" . $_SERVER["SERVER_ADDR"], 'siteType' => $siteType); foreach ($houseIds as $houseId) { $data['houseId'] = $houseId; Model_House_UpDown_Task::create($data, date('Ymd'))->save(); } }
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); }