/** * Job执行逻辑 */ public function handle_request() { printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId); // 获取任务 获取状态为4的房子 // 2014-09-01上的新套餐。 从这个时间往后取即可 $params = array(array('proid', '>', $this->lastLogId), array('updated', '>=', strtotime('2014-09-01 00:00:00')), array('status', 'in', array(Const_HzStatus::OFFLINE))); $tasks = Model_House_HzPropSearch::getPropLists($this->getCityIdByTable(), $params, $this->limit); if ($tasks === false) { printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败'); exit; } if (empty($tasks)) { // 任务完成 printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成'); $this->setStop(); $this->setShStopFlag(); $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId))); exit; } // 循环任务处理 foreach ($tasks as $task) { $this->dealTask($task); $this->lastLogId = $task['proid']; } //记录游标 $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId))); }
public static function getPropClicksByPropId($propId, $brokerId, $cityId) { if (!is_array($propId)) { $propId = array($propId); } $propSearchInfos = Model_House_HzPropSearch::getPropList($propId, $brokerId, $cityId); if (empty($propSearchInfos)) { return array(); } $newPropIds = array(); foreach ($propSearchInfos as $propSearchInfo) { $newPropIds[] = $propSearchInfo['proid']; } $propClicks = Model_Stats_PropClick::getPropBidClick($newPropIds, $brokerId, $cityId, date('Ymd')); if (empty($propClicks)) { return array(); } $result = array(); foreach ($propClicks as $propClick) { if (!isset($result[$propClick['prop_id']])) { $result[$propClick['prop_id']]['clickNum'] = $propClick['bid_cnum']; } else { $result[$propClick['prop_id']]['clickNum'] += $propClick['bid_cnum']; } } return $result; }
/** * 修复b_bj_prop_search,b_sh_prop_search,b_four_prop_search,b_other_prop_search 4张表中的ajk_brokerid 为0的数据 * * @param int $hzBrokerId * @param int $ajkBrokerId * @param int $cityId */ private function repairPropSearch($hzBrokerId, $ajkBrokerId, $cityId) { $condition = array(array('userid', '=', $hzBrokerId), array('ajkBrokerId', '=', 0), array('created', '>', strtotime('-91 day'))); $propList = Model_House_HzPropSearch::getPropLists($cityId, $condition); if (empty($propList)) { $this->setLog('没有获取到房源'); return; } foreach ($propList as $propInfo) { $this->setLog(json_encode($propInfo)); if ($propInfo['ajkBrokerId'] == 0) { $data = array('ajkBrokerId' => $ajkBrokerId); if (!Model_House_HzPropSearch::updateProp($cityId, $propInfo['proid'], $data)) { $this->setLog(sprintf('更新房源[%d]的 ajkBrokerId=%d 失败', $propInfo['proid'], $ajkBrokerId)); } else { $this->setLog(sprintf('更新房源[%d]的 ajkBrokerId=%d 成功', $propInfo['proid'], $ajkBrokerId)); } continue; } if ($propInfo['ajkBrokerId'] != $ajkBrokerId) { $this->setLog(sprintf('房源[%d]的ajkBrokerId[%d],不一致[%d]', $propInfo['proid'], $propInfo['ajkBrokerId'], $ajkBrokerId)); } else { $this->setLog(sprintf('房源[%d]的ajkBrokerId[%d],无需修复', $propInfo['proid'], $propInfo['ajkBrokerId'])); } } }
/** * Job执行逻辑 */ public function handle_request() { printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId); $expriedTime = strtotime(date("Ymd")) - Const_HzStatus::PROP_EXPIRED * 86400; // 获取任务 获取过期没有处理的房源 $params = array(array('proid', '>', $this->lastLogId), array('created', '<=', $expriedTime), array('status', '<>', Const_HzStatus::REMOVE), array('status', '<>', Const_HzStatus::EXPIRED)); $tasks = Model_House_HzPropSearch::getPropLists($this->getCityIdByTable(), $params, $this->limit); if ($tasks === false) { printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败'); exit; } if (empty($tasks)) { // 任务完成 printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成'); $this->setStop(); $this->setShStopFlag(); $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId))); exit; } // 循环任务处理 foreach ($tasks as $task) { $this->dealTask($task); $this->lastLogId = $task['proid']; } //记录游标 $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId))); }
public function handle_request() { $dealStatus = array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED); $condition = array(array('proid', '>', $this->_startId), array('updated', '>=', strtotime($this->_startTime)), array('updated', '<=', strtotime($this->_endTime))); $houseList = Model_House_HzPropSearch::getPropLists($this->_cityId, $condition, self::BATCH_LIMIT); foreach ($houseList as $houseInfo) { $houseId = $houseInfo['proid']; $this->setFlag(array('id' => $houseId, 'time' => date('Y-m-d H:i:s'))); if (!in_array($houseInfo['status'], $dealStatus)) { $this->setLog(sprintf('房源[%d]房源状态[%d]不在[%s]不处理', $houseId, $houseInfo['status'], implode(',', $dealStatus))); continue; } $houseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_HZ); if (empty($houseRelation)) { $this->setLog(sprintf('房源[%d - %d],没有获取到套餐关系', $houseId, $houseInfo['status'])); continue; } /** 如果房源关系已经不是在线的,就不修复 */ if (false == Bll_Combo_HouseRelation::isRelationOnline($houseRelation['state'])) { $this->setLog(sprintf('房源[%d - %d],已经不在线,不处理', $houseId, $houseRelation['state'])); continue; } switch ($houseInfo['status']) { case Const_HzStatus::VERIFY: $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_ILLEGAL; break; case Const_HzStatus::REMOVE: $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_DELETE; break; case Const_HzStatus::EXPIRED: $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_EXPIRE; break; default: $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_DELETE; continue; } /** 修正房源套餐推广关系 */ if (1 == Bll_Combo_HouseRelation::updateComboStatusById($houseRelation['id'], $relationState, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) { $this->setLog(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复成功', $houseId, $houseInfo['status'], $houseRelation['id'], $houseRelation['state'])); } else { $this->setLog(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复失败', $houseId, $houseInfo['status'], $houseRelation['id'], $houseRelation['state'])); } $this->noticeComboSolr($houseInfo['cityid'], $houseInfo['userid'], $houseId); } if (count($houseList) < self::BATCH_LIMIT) { $this->setLog(sprintf('[%d - %d]已经处理完成...', $this->_cityId, $this->_startId)); $this->setShStopFlag(); $this->removeFlag(); } else { $this->setShCommonSleepTime(1); } }
/** * Job执行逻辑 */ public function handle_request() { printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId); // 获取任务 获取在线房源 $params = array(array('status', '=', Const_HzStatus::ONLINE), array('proid', '>', $this->lastLogId)); $tasks = Model_House_HzPropSearch::getPropLists($this->getCityIdByTable(), $params, $this->limit); if ($tasks === false) { printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败'); exit; } if (empty($tasks)) { // 任务完成 printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成'); $this->setStop(); $this->setShStopFlag(); $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => 0))); exit; } $cityIdProIds = array(); $solrProIdsTmp = array(); $solrProIds = array(); foreach ($tasks as $task) { $cityIdProIds[$task['cityid']][] = $task['proid']; } foreach ($cityIdProIds as $cityId => $proIds) { // 获取solr $solrs = Util_SearchUtil::getHzPropsFromSolr($cityId, $proIds, $this->limit); if (!empty($solrs)) { $solrProIdsTmp[] = array_merge($solrProIdsTmp, $solrs); } } // 扁平处理 if (!empty($solrProIdsTmp)) { foreach ($solrProIdsTmp as $items) { foreach ($items as $item) { $solrProIds[] = $item['id']; } } } // 循环处理任务 foreach ($tasks as $task) { $this->dealTask($task, $solrProIds); $this->lastLogId = $task['proid']; } //记录游标 $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId))); /* if (!empty($this->errorPropIds)) Bll_House_UpDown_Worker_MailBll::getInstance()->setSubject('检查房源在线 solr却不在线')->send(array('message' => json_encode(array('error proids' => $this->errorPropIds)))); */ }
public function handle_request() { if ($this->_cityId == 0) { $this->setLog('city Id 为必须传的参数'); return; } if (!isset($this->_solrCityMapping[$this->_cityId])) { $this->setLog(sprintf('cityId[%d] 对应的solr配置不存在', $this->_cityId)); return; } $searchParams = array('__test__' => __CLASS__ . time(), 'fl' => 'id', 'q' => '*:*', 'rows' => 10000, 'wt' => 'json'); $fieldQuery = array('fq=' . urlencode('is_hp:1'), 'fq=' . urlencode(sprintf('city_id:%d', $this->_cityId))); $query = http_build_query($searchParams); $url = $this->getSolrUrl($this->_cityId) . '?' . $query . '&' . implode('&', $fieldQuery); $houseInSolrTemp = $this->httpRequest($url); if (empty($houseInSolrTemp)) { $this->setLog('在solr中的没有房源'); return; } foreach ($houseInSolrTemp as $house) { $houseId = $house['id']; $this->setLog(sprintf('开始处理房源[%d]', $houseId)); $housePlanning = Model_Plan_HzPlanning::getPropBidPlan($houseId, true); if (!empty($housePlanning)) { $ajkBrokerId = $housePlanning['ajkBrokerId']; $choicePlan = Model_Plan_HzPlanBasic::get_plan_by_id($housePlanning['plan_id'], true); $this->setLog(sprintf('房源[%d]的精选计划[%d]信息[bid_version=%d, status=%d]', $houseId, $housePlanning['plan_id'], $choicePlan['bid_version'], $choicePlan['status'])); if (!empty($choicePlan) && $choicePlan['bid_version'] == Const_HzPlan::BID_TYPE && $choicePlan['status'] == Const_HzPlan::SPREAD) { continue; } } else { $this->setLog(sprintf('没有获取到房源[%d]的计划关系信息', $houseId)); $propSearchInfo = Model_House_HzPropSearch::get_prop_by_prop_id($this->_cityId, $houseId); if (empty($propSearchInfo) || $propSearchInfo['ajkBrokerId'] == 0) { $this->setLog(sprintf('没有获取到房源[%d]的经纪人ID', $houseId)); continue; } $ajkBrokerId = $propSearchInfo['ajkBrokerId']; } $this->setLog(sprintf('需要下架房源 [%d - %d - %d]', $houseId, $ajkBrokerId, $this->_cityId)); // $res = Bll_Combo_NoticeSolrUpDown::noticeChoiceSolrZfAPI($this->_cityId, $ajkBrokerId, $houseId, 2, 2, Bll_Combo_NoticeSolrUpDown::HLSFromChoiceUpDown, time()); // $this->setLog('通知solr res: ' . json_encode($res)); } }
/** * @param $cityId * @param $propId * @param $planType 1.定价,2.竞价,3.定+竟 * @param $status * @return array */ public static function updatePropStatus($cityId, $propId, $planType, $status) { $propPlanType = self::getPropPlanType($propId); /** 记录房源下线日志 */ if ($status != 1) { //TODO } $needMap2PropStatus = false; $propUpdatedStatus = $status; switch ($planType) { case 1: if (isset($propPlanType['bid']['isValid']) && !empty($propPlanType['bid']['isValid'])) { $propUpdatedStatus = $propPlanType['bid']['isValid']; $needMap2PropStatus = true; } break; case 2: if ($status == 1) { $propUpdatedStatus = 1; } else { if (isset($propPlanType['fix']['isValid']) && !empty($propPlanType['fix']['isValid'])) { $propUpdatedStatus = $propPlanType['fix']['isValid']; $needMap2PropStatus = true; } else { $propUpdatedStatus = $status; } } break; case 3: $propUpdatedStatus = $status; break; } if ($needMap2PropStatus) { $propUpdatedStatus = self::mapPropStatus($propUpdatedStatus); } /** 更新 prop 表 */ $prop = Model_House_HzProp::get_prop_info_by_prop_id($propId); $prop['contentBasic']['status'] = $propUpdatedStatus; Model_House_HzProp::updateProp($propId, array('contentBasic' => json_encode($prop['contentBasic']))); Model_House_HzPropSearch::updatePropStatus($cityId, $propId, $propUpdatedStatus); return $propPlanType; }
public function handle_request_combo() { $ajkBrokerId = $this->brokerId; //获取经纪人套餐推广今日点击量 $comboClick = Bll_Ppc_NewPackageStatsBrokerDay::getComboClickInfo($ajkBrokerId, date('Ymd'), Model_Ppc_NewPackageStatsBrokerDay::SITE_TYPE_HZ); $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId); $propIds = array(); foreach ($comboList as $row) { $propIds[] = $row['houseId']; } $propertyList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId); foreach ($propertyList as $key => $list) { $row['publishDays'] = floor((time() - $list['created']) / 86400); if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { unset($propertyList[$key]); } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $comboClick, 'totalProps' => count($propertyList))); }
public function handle_request() { $condition = array(array('proid', '>', $this->_startId), array('cityid', '=', $this->_cityId), array('created', '<', $this->_expireTime), array('status', '<>', Const_HzStatus::EXPIRED), array('status', '<>', Const_HzStatus::REMOVE)); $houseList = Model_House_HzPropSearch::getPropLists($this->_cityId, $condition, self::BATCH_LIMIT); if (empty($houseList)) { $this->setShStopFlag(); $this->setLog('处理完成'); return; } foreach ($houseList as $house) { $houseId = $house['proid']; $this->setLog(sprintf('开始处理房源[%d], 房源发布时间[%s]: %s', $houseId, date('Y-m-d H:i:s', $house['created']), json_encode($house))); $this->setFlag(array('id' => $houseId), $this->_cursorFile); if (1 != Model_House_HzPropSearch::updatePropStatus($this->_cityId, $houseId, Const_HzStatus::EXPIRED)) { $this->setLog(sprintf('房源[%d]更新房源状态失败', $houseId)); continue; } $comboHouseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, false); if (empty($comboHouseRelation)) { $this->setLog(sprintf('房源[%d]没有获取到套餐推广关系', $houseId)); continue; } $this->setLog(sprintf('房源[%d]套餐推广关系: %s', $houseId, json_encode($comboHouseRelation))); if (!Bll_Combo_HouseRelation::isRelationOnline($comboHouseRelation['state'])) { $this->setLog(sprintf('房源[%d]套餐推广状态不在线[%d]', $houseId, $comboHouseRelation['state'])); continue; } $this->setLog(sprintf('房源[%d]套餐推广状态在线[%d]', $houseId, $comboHouseRelation['state'])); if (1 != Bll_Combo_HouseRelation::updateComboStatusById($comboHouseRelation['id'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) { $this->setLog(sprintf('更新房源[%d]套餐关系[%d : %d -> %d]失败', $houseId, $comboHouseRelation['id'], $comboHouseRelation['state'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE)); continue; } $this->setLog(sprintf('更新房源[%d]套餐关系[%d : %d -> %d]成功', $houseId, $comboHouseRelation['id'], $comboHouseRelation['state'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE)); $this->noticeComboSolr($this->_cityId, $house['userid'], $houseId, $comboHouseRelation['brokerId']); } if (count($houseList) < self::BATCH_LIMIT) { $this->setShStopFlag(); } }
/** * 组装未推广列表 取出所有-有效定价房源 * @param $out * @return array */ private static function prepareOutList(&$out) { $outList = array(); $outPropIds = array(); $fixProIds = array_keys($out['props']); // 取出经纪人所有非删除房源 (分表) $allSearchProps = Model_House_HzPropSearch::getPropLists($out['cityId'], array(array('ajkBrokerId', '=', $out['ajkBrokerId']), array('status', '<>', Const_HzStatus::DELETE), array('status', '<>', Const_HzStatus::OFFLINE), array('status', '<>', Const_HzStatus::OUTPORT), array('status', '<>', Const_HzStatus::HIBERNATE), array('status', '<>', Const_HzStatus::REMOVE), array('status', '<>', Const_HzStatus::EXPIRED)), 1000, array('created', 'desc')); if (empty($allSearchProps)) { return array(); } // 获取城市价格段 $allPrices = Model_House_HzPriceChoice::getAllPriceByCityId($out['cityId']); $out['getQualityProIds'] = array(); foreach ($allSearchProps as $allSearchProp) { $proId = $allSearchProp['proid']; $out['getQualityProIds'][] = $proId; // 过滤非删除状态定价 if (in_array($proId, $fixProIds)) { continue; } $outList[$proId] = $allSearchProp; // 获取剩余时间 $outList[$proId]['leftDays'] = Bll_House_HzHouse::getLeftDays($allSearchProp['created']); $outPropIds[] = $proId; } // 获取改经纪人所有房源质量 $out['propsQuality'] = Model_Stats_HzPropQuality::getPropsquality($out['getQualityProIds']); // 获取如是违规房源 拼接违规原因 $outList = Bll_HzProp::checkAndGetPropsIllegalInfos($outList); // 批量获取主表信息 if (empty($outPropIds)) { return array(); } $props = Model_House_HzProp::getPropsByPropIds($outPropIds); if (!$props) { return array(); } // 房源主分表信息合并 foreach ($outList as $proId => $outProp) { $outList[$proId] = array_merge($outList[$proId], $props[$proId]); // 计算点击价格 if (!empty($allPrices)) { foreach ($allPrices as $priceInfo) { if ($priceInfo['lower'] < $outList[$proId]['pricenum'] && $priceInfo['upper'] >= $outList[$proId]['pricenum']) { $outList[$proId]['unitPrice'] = $priceInfo['price']; break; } } } } return $outList; }
/** * 判断房源是否可以参加精选房源推广 * * @param $ajkBrokerId * @param $cityId * @param $propId * @return array */ public static function checkPropCanChoice($ajkBrokerId, $cityId, $propId) { $propSearch = Model_House_HzPropSearch::get_prop_by_prop_id($cityId, $propId); if (empty($propSearch)) { return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在'); } /** 判断房源是否是当前经纪人的房源 */ if ($propSearch['ajkBrokerId'] != $ajkBrokerId) { return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在(code:-10086)'); } /** 判断是否是精选开放城市 */ if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::HAOZU)) { /** 判断房源是否在套餐推广中 */ if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) { return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '房源必须套餐推广才能参与精选推广'); } } /** 判断房源是否多图 */ if ($propSearch['islabel'] == 0) { return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广'); } /** 判断房源是否是在15天内发布的 */ if (date('ymd', strtotime('-16 days')) > date('Ymd', $propSearch['created'])) { return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广'); } /** 判断房源是否已经在竞价计划中了 取master */ $propBidInfo = Model_Plan_HzPlanning::getPropBidPlan($propId, true); if (!empty($propBidInfo)) { $planBasic = Model_Plan_HzPlanBasic::get_plan_by_id($propBidInfo['plan_id'], true); if ($planBasic['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && in_array($planBasic['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING))) { return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '该房源已经处于精选状态,请先删除'); } } return array('err_no' => 0, 'err_msg' => ''); }
/** * 获取套餐房源的累计点击量 * @param int $ajkBrokerId * @param array|int $houseIds * @param int $cityId * @return array */ public static function getComboHouseAccumulateClick($ajkBrokerId, $houseIds, $cityId) { $noCacheHouseIds = is_array($houseIds) ? $houseIds : array($houseIds); $cache = APF_Cache_Factory::get_instance()->get_memcache(); $cacheKey = sprintf('combo_accumulate_house_click_hz_1_%d', $ajkBrokerId); $cacheHouseAccumulateClickList = $cache->get($cacheKey); if (is_array($cacheHouseAccumulateClickList) && !empty($cacheHouseAccumulateClickList)) { $houseAccumulateClickList = $cacheHouseAccumulateClickList; $cacheHouseIds = array_keys($cacheHouseAccumulateClickList); $noCacheHouseIds = array_diff($noCacheHouseIds, $cacheHouseIds); } else { $houseAccumulateClickList = array_fill_keys($noCacheHouseIds, 0); } if (count($noCacheHouseIds) == 0) { return $houseAccumulateClickList; } foreach ($noCacheHouseIds as $noCacheHouseId) { $houseAccumulateClickList[$noCacheHouseId] = 0; } $houseIds = $noCacheHouseIds; // 获取房源的发布时间 $houseBaseInfoList = Model_House_HzPropSearch::getPropLists($cityId, array(array('proid', 'in', $houseIds))); if (empty($houseBaseInfoList)) { return $houseAccumulateClickList; } // 根据房源的发布时间获取房源累计点击量的分表后缀 $splitSuffixes = array(); foreach ($houseBaseInfoList as $houseBaseInfo) { $splitSuffix = date('Ym', $houseBaseInfo['created']); if (!isset($splitSuffixes[$splitSuffix])) { $splitSuffixes[$splitSuffix] = array(); } $splitSuffixes[$splitSuffix][] = $houseBaseInfo['proid']; } if (empty($splitSuffixes)) { return $houseAccumulateClickList; } /** * 获取房源的累计点击量 */ $result = array(); foreach ($splitSuffixes as $splitSuffix => $houseIdList) { $houseClickInfoList = Model_Broker_ComboPropClickAccumulate::getHouseClickInfo($houseIdList, Model_Broker_ComboPropClickAccumulate::SITE_TYPE_HZ, $splitSuffix); $result = array_merge($result, $houseClickInfoList); } if (empty($result)) { return $houseAccumulateClickList; } /** * 生成房源累计点击量信息 */ foreach ($result as $houseAccumulateClickInfo) { $houseId = $houseAccumulateClickInfo['propId']; $houseAccumulateClickList[$houseId] = $houseAccumulateClickInfo['vppvAccumulate']; } $cache->set($cacheKey, $houseAccumulateClickList, 0, 7200); return $houseAccumulateClickList; }
public function push($remind, &$error) { // 订阅不存在,不推送 if (!isset($this->subscriptions[$remind['subscriptionId']])) { $error = 'subscription is not exist.'; return false; } // 订阅已取消,不推送 $subscription = $this->subscriptions[$remind['subscriptionId']]; if ($subscription['status'] == Model_Choice_Subscription::SUBSCRIPTION_CANCEL) { $error = 'subscription is canceled'; return false; } // 微聊账户不存在,不推送 $chatInfo = Model_Mobile_BrokerChatInfo::data_access()->filter('brokerId', $subscription['brokerId'])->find_only(); if (!$chatInfo) { $error = 'broker has no chat account.'; return false; } // 文案:XXX(小区)的精选推广位空出来了,快去占位吧! if ($subscription['site'] == Model_Choice_Subscription::SITE_AJK) { // 获取二手房房源小区 $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $subscription['brokerId'])->find_only(); $cityId = $broker['cityId']; $prop = Bll_House_EsfHouse::getHouseInfo($subscription['propId'], $cityId); $commName = $prop['commName']; } elseif ($subscription['site'] == Model_Choice_Subscription::SITE_RENT) { // 获取租房房源小区 $prop = Model_House_HzProp::findByPropId($subscription['propId']); $cityId = $prop->getContentBasic('cityid'); $propSearch = Model_House_HzPropSearch::data_access($cityId)->filter('proid', $prop['propId'])->find_only(); $commName = $propSearch['commname']; } else { $error = 'invalid subscription site.'; return false; } if (!$commName) { $error = 'failed to fetch community name'; return false; } // 准备待推送文案 $type = 'subscription'; $text = $commName . '的精选推广位空出来了,快去占位吧!'; $propId = strval($subscription['propId']); $tradeType = strval($subscription['site']); // 1 二手房 2租房 // 推送消息 $chatId = $chatInfo['chatId']; $api_host = APF::get_instance()->get_config('chat_api_host'); $message_url = $api_host['host'] . '/common/sendUserNotify/' . $chatId . '?from_idc=1&from=mobile-ajk-broker'; $message = json_encode(array('msgType' => 'push', 'type' => $type, 'message' => $text, 'propId' => $propId, 'tradeType' => $tradeType, 'body' => array('type' => $type, 'msg' => $text, 'propId' => $propId, 'tradeType' => $tradeType))); $result = Util_API::postData($message_url, $message); if ($result['status'] != 'OK') { $error = 'failed to call push api: ' . json_encode($result); return false; } return true; }
public function handle_request_combo() { $ajkBrokerId = $this->brokerId; $cityId = $this->cityId; $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ; //首先获取套餐关系房源列表 ---- 那房源到主表去除status 已删除的房源 -----在房源主表获取房源基本信息 $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, $siteType, 1); $surplus = $hasCombo = 0; //获取套餐信息-首先判断经纪人有无套餐 $comboInfos = Bll_Combo_Broker_BrokerComboInfo::getComboListBySite($ajkBrokerId, $siteType); if (count($comboInfos) > 0) { $index = Bll_Combo_Broker_BrokerComboInfo::getComboIndexBySiteType($siteType); $currentTime = time(); foreach ($comboInfos as $combo) { if ($combo[$index] == 0) { continue; } if (strtotime($combo['endTime']) > $currentTime && strtotime($combo['startTime']) < $currentTime) { $currentCombo = $combo; } } if (!empty($currentCombo)) { $surplus = $currentCombo['rentPropNum']; if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { //商业地产没打通 $surplus = $currentCombo['rentPropNum'] + $currentCombo['salePropNum']; } $hasCombo = 1; } } //获取当前已推广套餐数量 if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($ajkBrokerId, $siteType, true); } else { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($ajkBrokerId, $cityId, $siteType); } $oldList = $newList = array(); if (empty($comboInfos)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); } $propIds = array(); foreach ($comboList as $row) { $propIds[] = $row['houseId']; } $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId); $comboPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId); foreach ($comboPropList as $key => $list) { if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { unset($comboPropList[$key]); } } //fix bug45133 if (empty($comboPropList)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); } $propIds = array(); foreach ($comboPropList as $row) { $propIds[] = $row['proid']; } //从主表获取房源信息 $propertyList = Model_House_HzProp::getPropsByPropIds($propIds); //获取是否精选或者竞价 $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING)); if (!empty($relations)) { $planPropMap = array(); foreach ($relations as $relation) { $planIds[] = $relation['plan_id']; $planPropMap[$relation['plan_id']] = $relation['proid']; } if (!empty($planIds)) { $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds); foreach ($plans as $plan) { if ($plan->flag == 0) { continue; } if ($plan->bid_version == 2) { $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isChoice'] = 1; } else { $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isBid'] = 1; } } } } // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); if (!empty($defaultImages)) { foreach ($defaultImages as $defaultImage) { $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } krsort($propertyList); $startDate = $endDate = date('Ymd'); $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ); $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($ajkBrokerId, $propIds, $cityId); foreach ($propertyList as $list) { $row = array(); $row['id'] = $list['propId']; $row['propId'] = $list['propId']; $row['title'] = $list['title']; $row['imgUrl'] = $list['imgUrl'] ?: ''; $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $row['roomNum'] = $list['roomnum']; $row['hallNum'] = $list['hallnum']; $row['toiletNum'] = $list['toilnetnum']; $row['area'] = round($list['areanum']); $row['price'] = round($list['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $todayClicks[$list['propId']][$startDate] ?: 0; $row['totalClicks'] = $totalClicks[$list['propId']] ?: 0; $row['totalClicks'] = $row['totalClicks'] + $row['todayClicks']; $row['isBid'] = isset($list['isBid']) ? $list['isBid'] : 0; $row['isChoice'] = isset($list['isChoice']) ? $list['isChoice'] : 0; $row['isVisible'] = (int) ($list['status'] != 6); $row['isMoreImg'] = (int) $list['quality']; $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker'); $row['publishDays'] = floor((time() - $list['created']) / 86400); $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布'; $row['createTime'] = date('Y-m-d H:i:s', $list['created']); //$row['updateTime'] = date('Y-m-d H:i:s', $list['updated']); //是否委托 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $row['publishDays'] > 30 ? $oldList[] = $row : ($newList[] = $row); } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); }
/** * 获取经纪人的房源 * 会过滤掉在昨天之前就已经被删除掉的房源 * * @param int $brokerId * @param int $cityId * @return array */ public function getPropList($brokerId, $cityId) { $this->logMessage(sprintf('获取经纪人的房源信息: brokerId=%d, cityId=%d', $brokerId, $cityId)); $propList = Model_House_HzPropSearch::getPropListByUserId($brokerId, $cityId, array(array('created', '>', strtotime('-91 day')))); $validPropList = array(); foreach ($propList as $propInfo) { if (in_array($propInfo['status'], array(99, 100)) && $propInfo['updated'] < $this->yesterdayStartTimeStamp) { continue; } $validPropList[] = $propInfo; } return $validPropList; }
/** * 根据房源ID和城市ID获取好租房源信息 * @param array $proIds * @param string $cityId * @return array */ public function getBrokerHzProInfo($proIds = array(), $cityId = '') { return Model_House_HzPropSearch::getProInfo($proIds, $cityId); }
/** * 获取房源分表列表 * @param $cityId * @param array $condition * @param int $limit * @param array $sort * @return array */ public static function getPropLists($cityId, $condition = array(), $limit = 1000, $sort = array('proid', 'asc')) { try { $obj = Model_House_HzPropSearch::data_access($cityId); if (is_array($condition) && !empty($condition)) { foreach ($condition as $field => $value) { if (is_array($value) && is_numeric($field)) { list($field, $op, $val) = $value; $obj->filter_by_op($field, $op, $val); continue; } $obj->filter($field, $value); } } list($field, $order) = $sort; $obj->sort($field, $order); $obj->limit($limit); return $obj->get_all(); } catch (Exception $e) { return array(); } }
/** * 好租小区信息变更写房源日志(批量) * * @param array $queueInfo * @return array */ public static function hzCommunityInfoChangeEx($queueInfo) { if (!isset($queueInfo) || empty($queueInfo)) { return static::buildReturn(self::PROCESS_STATUS_ERROR, '小区信息变更,remark的值为空'); } $communityChangeInfo = json_decode($queueInfo['remark'], true); if (!is_array($communityChangeInfo)) { return static::buildReturn(self::PROCESS_STATUS_ERROR, '小区信息变更,remark的值不是JSON'); } $startHouseId = 0; $houseLogWriteError = array(); do { $condition = array(array('proid', '>', $startHouseId), array('cityid', '=', $communityChangeInfo['cityId']), array('commid', '=', $communityChangeInfo['commId']), array('status', '<>', Const_HzStatus::EXPIRED), array('status', '<>', Const_HzStatus::REMOVE)); $houseList = Model_House_HzPropSearch::getPropLists($communityChangeInfo['cityId'], $condition, 100); if (empty($houseList)) { break; } foreach ($houseList as $houseInfo) { $startHouseId = $houseInfo['proid']; $data = array(); $data['houseId'] = $houseInfo['proid']; $data['planId'] = 0; $data['brokerId'] = $houseInfo['ajkBrokerId']; $data['cityId'] = $queueInfo['city_id']; $data['type'] = Model_Log_HouseLogNew::TYPE_COMMUNITY_INFO_CHANGE; $data['changeType'] = $queueInfo['type']; $data['remark'] = '小区信息变更'; $data['addDate'] = date('Y-m-d H:i:s'); $data['operatorId'] = 0; $data['siteType'] = 2; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $houseLogWriteError[] = $houseInfo['proid']; } } if (count($houseList) < 100) { break; } } while (true); return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('小区信息变更,房源日志写入失败的房源Id[%s]', implode(',', $houseLogWriteError))); }
/** * 502 经纪人套餐生效 * * @param $queueInfo * @return array */ public static function comboEffect($queueInfo) { $dealRemark = array(); $currentCombo = Bll_Combo_Broker_BrokerComboInfo::getBrokerCurrentCombo($queueInfo['broker_id'], Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_AJK); $onlineHouseRelationList = Bll_Combo_HouseRelation::getOnlineHouseList($queueInfo['broker_id'], $queueInfo['city_id'], Bll_Combo_HouseRelation::SITE_TYPE_AJK); /** 当前没有生效的套餐,下掉所有的房子 */ if (empty($currentCombo)) { $dealRemark[] = sprintf('%d 经纪人当前[%s]没有生效的租售套餐', $queueInfo['id'], date('Y-m-d H:i:s')); $data = static::buildHouseLog($queueInfo, 21, '经纪人套餐生效,未获取到套餐信息房源下架', 0); if (!empty($onlineHouseRelationList)) { foreach ($onlineHouseRelationList as $onlineHouseRelation) { $data['houseId'] = $onlineHouseRelation['houseId']; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $dealRemark[] = sprintf('%d 套餐生效,未获取到套餐信息,下掉房源(%d) 失败', $queueInfo['id'], $onlineHouseRelation['houseId']); continue; } $dealRemark[] = sprintf('%d 套餐生效,未获取到套餐信息,下掉房源(%d) 成功', $queueInfo['id'], $onlineHouseRelation['houseId']); } } return static::buildReturn(self::PROCESS_STATUS_SUCCESS, $dealRemark); } /** 添加打通的套餐的逻辑 */ if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { $dealRemark[] = '当前套餐为打通套餐'; $comboSpreadHouseCount = $currentCombo['salePropNum'] + $currentCombo['rentPropNum']; $hzHouseOnlineRelationList = Bll_Combo_HouseRelation::getOnlineHouseList($queueInfo['broker_id'], $queueInfo['city_id'], Bll_Combo_HouseRelation::SITE_TYPE_HZ); $spreadHouseCount = count($hzHouseOnlineRelationList) + count($onlineHouseRelationList); if ($spreadHouseCount >= $comboSpreadHouseCount) { $dealRemark[] = sprintf('%d 经纪人当前[%s]套餐,可推广房源数小于当前在线房源数,不处理。', $queueInfo['id'], date('Y-m-d H:i:s')); return static::buildReturn(self::PROCESS_STATUS_SUCCESS, $dealRemark); } /** 上架房源 */ $needSpreadHouseCount = $comboSpreadHouseCount - $spreadHouseCount; $hzExpiredHouseRelationList = Bll_Combo_HouseRelation::getHouseRelations($queueInfo['broker_id'], Bll_Combo_HouseRelation::SITE_TYPE_HZ, Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE); $ajkExpiredHouseRelationList = Bll_Combo_HouseRelation::getHouseRelations($queueInfo['broker_id'], Bll_Combo_HouseRelation::SITE_TYPE_AJK, Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE); $rangedHouseRelation = Bll_Combo_Updown_AjkDealJob::calculateRangeByCreated($ajkExpiredHouseRelationList, $hzExpiredHouseRelationList); /** 过滤无效房源 */ $validateHouseRelation = array(); foreach ($rangedHouseRelation as $houseRelation) { $houseId = $houseRelation['houseId']; if ($houseRelation['siteType'] == Bll_Combo_HouseRelation::SITE_TYPE_HZ) { $houseInfo = Model_House_HzPropSearch::get_prop_by_prop_id($queueInfo['city_id'], $houseId); if (empty($houseInfo)) { $dealRemark[] = sprintf('好租房源[%d]不存在', $houseId); continue; } if (in_array($houseInfo['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { $dealRemark[] = sprintf('好租房源[%d]不是有效的房源', $houseId); continue; } $validateHouseRelation[] = $houseRelation; continue; } $houseInfo = Bll_House_EsfHouse::getHouseBaseInfoEx($houseId, $queueInfo['city_id']); if (empty($houseInfo)) { $dealRemark[] = sprintf('二手房房源[%d]不是有效的房源', $houseId); continue; } if ($houseInfo['isVisible'] == 0 && $houseInfo['expireWorker'] != 'propertyReport') { $dealRemark[] = sprintf('二手房房源(%d)违规,不做处理', $houseId); continue; } $validateHouseRelation[] = $houseRelation; } $houseUpRelationList = array_slice($validateHouseRelation, 0, $needSpreadHouseCount); $data = static::buildHouseLog($queueInfo, 20, '经纪人套餐生效,房源上架', 0); foreach ($houseUpRelationList as $onlineHouseRelation) { $site = $onlineHouseRelation['siteType'] == Bll_Combo_HouseRelation::SITE_TYPE_AJK ? '二手房' : '好租'; if (1 == Model_Combo_HouseRelation::updateHouseComboSpreadStateEx($queueInfo['broker_id'], $queueInfo['city_id'], $onlineHouseRelation['houseId'], Model_Combo_HouseRelation::ENUM_HOUSE_ONLINE, $onlineHouseRelation['siteType'])) { $dealRemark[] = sprintf('上架' . $site . '房源[%d]成功', $onlineHouseRelation['houseId']); } else { $dealRemark[] = sprintf('上架' . $site . '房源[%d]失败', $onlineHouseRelation['houseId']); } $data['houseId'] = $onlineHouseRelation['houseId']; $data['siteType'] = $onlineHouseRelation['siteType'] == Bll_Combo_HouseRelation::SITE_TYPE_AJK ? 1 : 2; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $dealRemark[] = sprintf('%d 套餐生效,上架' . $site . '房源(%d) 失败', $queueInfo['id'], $onlineHouseRelation['houseId']); continue; } $dealRemark[] = sprintf('%d 套餐生效,上架' . $site . '房源(%d) 成功', $queueInfo['id'], $onlineHouseRelation['houseId']); } $dealRemark[] = sprintf('%d [%s] 经纪人套餐生效,上架%d套房源。', $queueInfo['id'], date('Y-m-d H:i:s'), $spreadHouseCount); return static::buildReturn(self::PROCESS_STATUS_SUCCESS, $dealRemark); } /** * 下掉超出限制的房源 */ if (count($onlineHouseRelationList) >= $currentCombo['salePropNum']) { $data = static::buildHouseLog($queueInfo, 21, '经纪人套餐生效,下掉多余房子', 0); $offLineHouseList = array_slice($onlineHouseRelationList, $currentCombo['salePropNum']); if (empty($offLineHouseList)) { return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('%d [%s] 经纪人在线房源数已经达到套餐限制[%d]。', $queueInfo['id'], date('Y-m-d H:i:s'), $currentCombo['salePropNum'])); } foreach ($offLineHouseList as $offLineHouse) { $data['houseId'] = $offLineHouse['houseId']; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $dealRemark[] = sprintf('%d 套餐生效,未获取到套餐信息,下掉房源(%d) 失败', $queueInfo['id'], $offLineHouse['houseId']); continue; } $dealRemark[] = sprintf('%d 套餐生效,未获取到套餐信息,下掉房源(%d) 成功', $queueInfo['id'], $offLineHouse['houseId']); } return static::buildReturn(self::PROCESS_STATUS_SUCCESS, $dealRemark); } $expiredHouseRelationList = Bll_Combo_HouseRelation::getHouseRelations($queueInfo['broker_id'], Bll_Combo_HouseRelation::SITE_TYPE_AJK, Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE); if (empty($expiredHouseRelationList)) { return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('%d [%s] 没有获取到经纪人因套餐到期而下架的房源。', $queueInfo['id'], date('Y-m-d H:i:s'))); } $expiredHouseRelationIds = array(); foreach ($expiredHouseRelationList as $expiredHouseRelation) { $expiredHouseRelationIds[] = $expiredHouseRelation['houseId']; } $houseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($queueInfo['broker_id'], $expiredHouseRelationIds, $queueInfo['city_id'], array('proId', 'expireWorker', 'isVisible')); if (empty($houseInfoList)) { return static::buildReturn(self::PROCESS_STATUS_SUCCESS, sprintf('%d [%s] 没有获取到房源(%s)信息。', $queueInfo['id'], date('Y-m-d H:i:s'), implode(',', $expiredHouseRelationIds))); } /** 过滤掉违规房源 */ $validateHouseIds = array(); foreach ($houseInfoList as $houseInfo) { if ($houseInfo['isVisible'] == 0 && $houseInfo['expireWorker'] != 'propertyReport') { $dealRemark[] = sprintf('房源(%d)违规,不做处理', $houseInfo['proId']); continue; } $validateHouseIds[] = $houseInfo['proId']; } /** 按照房源ID 排序 */ sort($validateHouseIds, SORT_NUMERIC); if (count($validateHouseIds) > $currentCombo['salePropNum']) { $onlineHouseIds = array_slice($validateHouseIds, count($validateHouseIds) - $currentCombo['salePropNum']); } else { $onlineHouseIds = $validateHouseIds; } $data = static::buildHouseLog($queueInfo, 20, '经纪人套餐生效,房源上架', 0); foreach ($onlineHouseIds as $onlineHouseId) { $data['houseId'] = $onlineHouseId; if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { $dealRemark[] = sprintf('%d 套餐生效,上架房源(%d) 失败', $queueInfo['id'], $onlineHouseId); continue; } $dealRemark[] = sprintf('%d 套餐生效,上架房源(%d) 成功', $queueInfo['id'], $onlineHouseId); } $spreadHouseCount = Model_Combo_HouseRelation::updateHouseComboSpreadStateEx($queueInfo['broker_id'], $queueInfo['city_id'], $onlineHouseIds, Model_Combo_HouseRelation::ENUM_HOUSE_ONLINE, Bll_Combo_HouseRelation::SITE_TYPE_AJK); $dealRemark[] = sprintf('%d [%s] 经纪人套餐生效,上架%d套房源[%s]。', $queueInfo['id'], date('Y-m-d H:i:s'), $spreadHouseCount, implode(',', $onlineHouseIds)); return static::buildReturn(self::PROCESS_STATUS_SUCCESS, $dealRemark); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; //经纪人信息 $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $communityList = array(); $cityId = $brokerInfo->cityId; $hzBrokerId = Model_Broker_HzMapping::get_hz_broker_id($brokerId); if (Bll_Broker_HzBroker::isComboBroker($brokerId)) { /** 租房 */ $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); //套餐列表 $propIds = array(); foreach ($comboList as $combo) { $propIds[] = $combo['houseId']; } if ($propIds && $hzBrokerId) { $hzPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $cityId); //房源信息 foreach ($hzPropList as $list) { //过滤无效房源 if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { continue; } $row = array(); $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $communityList[$list['commid']] = $row; } } /** 二手房 */ $comboSpreadHouseList = Bll_Broker_Combo_ManageAjk::getComboSpreadHouseList($brokerId, $cityId); if ($comboSpreadHouseList) { //获取房源信息 $propIds = array_keys($comboSpreadHouseList); $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId); foreach ($propsInfo as $prop) { $row = array(); $row['commId'] = $prop->commId; $row['commName'] = $prop->commName; $communityList[$prop->commId] = $row; } } } else { //定价的情况 $brokerProps = Bll_Broker_HzBroker::getBrokerProps($brokerId, $cityId); // 获取房源关系列表 if ($brokerProps['status']) { /** 租房*/ $brokerProps = $brokerProps['msg']; $plans = $brokerProps['plans'][0]; //定价计划 $plannings = $brokerProps['plannings']; //计划房源关系 $propsTemp = $brokerProps['props']; //定价房源 if (empty($plans)) { $hzPropList = array(); } else { $hzPropList = array(); foreach ($propsTemp as $prop) { $hzPropList[$prop['proId']] = $prop; } foreach ($plannings as $key => $planning) { // 非有效 过滤掉 if (!Bll_HzFixPlan::isValidPlanning($planning['isValid'])) { unset($hzPropList[$planning['proId']]); } } } foreach ($hzPropList as $prop) { $row = array(); $row['commId'] = $prop['commId']; $row['commName'] = $prop['commName']; $communityList[$prop['commId']] = $row; } } /** 二手房*/ //获取经纪人有效定价计划 计划表 $fixSpreadPlanList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList($brokerId); $fixPlanId = $fixSpreadPlanList[0]['id']; //关系表中获取房源; if ($fixPlanId) { $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($fixPlanId, $cityId); $propIds = array(); foreach ($relations as $relation) { $propIds[] = $relation['proId']; } if ($propIds) { $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId); foreach ($propsInfo as $prop) { $row = array(); $row['commId'] = $prop->commId; $row['commName'] = $prop->commName; $communityList[$prop->commId] = $row; } } } } //对小区按首字母排序 $communityList = $this->communitySortByCommCode($communityList); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('communityList' => array_values($communityList))); }
public function handle_request() { //分表 $date = date('Ymd'); $id = 0; //获取游标 $dateFlag = $this->getFlag(); if (!empty($dateFlag)) { $date = $dateFlag['date']; $id = $dateFlag['id']; } //竞价队列数据获取 $ProLogList = Model_Log_HouseLogNew::getProLogList($date, $id, $this->limit); //判断当前队列是否处理完成 if (empty($ProLogList)) { //判断是否切换表 if ($date < date('Ymd')) { $date = date('Ymd', strtotime($date) + 24 * 3600); $id = 0; //记录表游标 $this->setFlag(array('date' => $date, 'id' => $id)); } //休息1秒钟 $this->setShCommonSleepTime(1); $this->setLog(date('Y-m-d H:i:s') . ' 处理完成'); exit; } //队列数据处理 foreach ($ProLogList as $list) { $id = $list['id']; $time = 0; //查询房源的发布时间 if ($list['siteType'] == 1) { //二手房 $ajkProInfo = Bll_House_EsfHouse::getHouseInfo($list['houseId'], $list['cityId']); if ($ajkProInfo->postDate) { $time = $ajkProInfo->postDate; } } elseif ($list['siteType'] == 2) { $hzProInfo = Model_House_HzPropSearch::get_prop_by_prop_id($list['cityId'], $list['houseId']); if ($hzProInfo['created']) { $time = $hzProInfo['created']; } } elseif ($list['siteType'] == 3) { $jpProInfo = Model_House_JpHouseIdx::getPropInfoByPk($list['houseId']); if ($jpProInfo['createTime']) { $time = strtotime($jpProInfo['createTime']); } } //写索引表 if (!empty($time)) { //查询数据是否存在 $ProLogIndex = Model_Log_HouseLogIndexNew::getProLogIndexByProId($list['houseId'], date('Ymd', strtotime($list['addDate'])), $list['siteType'], date('Ymd', $time)); if (!empty($ProLogIndex)) { //记录处理日志 $this->setLog(date('Y-m-d H:i:s') . ' id:' . $list['id'] . ' 城市id:' . $list['cityId'] . ' 经纪人:' . $list['brokerId'] . ' 房源:' . $list['houseId'] . ' 网站:' . $list['siteType'] . ' 房源创建时间:' . date('Y-m-d H:i:s', $time) . ' remark:索引已存在'); continue; } try { Model_Log_HouseLogIndexNew::create(array('proId' => $list['houseId'], 'datei' => date('Ymd', strtotime($list['addDate'])), 'siteType' => $list['siteType']), date('Ymd', $time))->save(); } catch (Exception $e) { print_r($e); } //记录处理日志 $this->setLog(date('Y-m-d H:i:s') . ' id:' . $list['id'] . ' 城市id:' . $list['cityId'] . ' 经纪人:' . $list['brokerId'] . ' 房源:' . $list['houseId'] . ' 网站:' . $list['siteType'] . ' 房源创建时间:' . date('Y-m-d H:i:s', $time) . ' remark:创建索引'); } else { //记录处理日志 $this->setLog(date('Y-m-d H:i:s') . ' id:' . $list['id'] . ' 城市id:' . $list['cityId'] . ' 经纪人:' . $list['brokerId'] . ' 房源:' . $list['houseId'] . ' 网站:' . $list['siteType'] . ' remark:未找到房源信息'); } } $this->setFlag(array('date' => $date, 'id' => $id)); //休息10毫秒 $this->setShCommonSleepTime(0.01); }
/** * * 获取经纪人的违规房源数 * * @param $brokerId * @param $cityId * @param $siteType * @return int */ public static function getBrokerIllegalNum($brokerId, $cityId, $siteType) { $num = 0; switch ($siteType) { case 'ajk': $propList = Bll_House_EsfHouse::getBrokerAllPropInfoList($brokerId, $cityId); foreach ($propList as $prop) { if ($prop['isVisible'] != 1) { $num += 1; } } break; case 'hz': $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId); //根据经纪人查询商铺相应 $propList = Model_House_HzPropSearch::getPropListByUserId($brokerMapping['hzBrokerid'], $cityId, array('status' => 6)); $num = count($propList); break; case 'jp': $brokerMapping = Bll_Broker_MainBusiness::getDataByEsfId($brokerId); //根据经纪人查询商铺相应 $baseInfo = Model_House_JpHouseIdx::data_access()->filter('memberId', $brokerMapping['jpBrokerid'])->filter('isDelete', Model_House_JpHouseIdx::ENUM_IS_DELETE_NO)->get_all(); if (!$baseInfo) { return $num; } $houseIds = array(); foreach ($baseInfo as $hInfo) { $houseIds[] = $hInfo['id']; } //获取房源的标签 $jpOfficeRent = Model_House_JpOfficeRent::getPropInfoByIds($houseIds); $jpOfficeSale = Model_House_JpOfficeSale::getPropInfoByIds($houseIds); $jpShopRent = Model_House_JpShopRent::getPropInfoByIds($houseIds); $jpShopSale = Model_House_JpShopSale::getPropInfoByIds($houseIds); $houseList = array_merge($jpOfficeRent, $jpOfficeSale, $jpShopRent, $jpShopSale); $num = 0; foreach ($houseList as $list) { if ($list['isIllegal'] == 1) { $num += 1; } } break; default: break; } return $num; }
/** * 竞价计划状态,更新房源状态 * * @param $cityId * @param $propId */ public static function bidStatusChangeUpdatePropStatus($cityId, $propId) { $propSearchInfo = Model_House_HzPropSearch::get_prop_by_prop_id($cityId, $propId); if (empty($propSearchInfo)) { return; } $oldStatus = $propSearchInfo['status']; $fixPropPlan = Model_Plan_HzPlanning::getPropFixPlan($propId); $newStatus = Bll_Ppc_HzProp::mapPropStatus($fixPropPlan['is_valid']); Model_House_HzPropSearch::updatePropStatus($cityId, $propId, $newStatus); Bll_HzProp::updatePropStatus($propId, $newStatus); }