Example #1
0
 public function handle_request_internal()
 {
     //组织POST参数
     $params = array();
     if (!isset($this->_params['brokerId'])) {
         return Util_MobileAPI::error(Const_APIStatus::E_BROKER_PARAM_MISS);
     } else {
         $broker_id = $this->_params["brokerId"];
     }
     if (!isset($this->_params["cityId"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_CITYID_MISS);
     }
     if (!isset($this->_params["propId"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PROP_ID_MISS);
     }
     if (!isset($this->_params["offer"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PROP_BID_PRICE_MISS);
     }
     if (!Bll_City::isBidCity($this->_params["cityId"])) {
         $error_code = Const_HzErrorInfo::NOBIDCITY;
         return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code));
     }
     $search = new Util_SearchUtil();
     $prop = Bll_HzProp::get_prop($this->_params["propId"]);
     $blockid = $prop['blockid'];
     $price = $prop['pricenum'];
     $price_block = Bll_HzBidPlan::get_price_block($this->_params["cityId"], $price);
     $ajkid = Bll_HzProp::get_subregion_id($prop['commId'], $this->_params["propId"]);
     $rank = $search->getHpRankByProp($this->_params["cityId"], $ajkid, $this->_params["propId"], $price_block['LOWER'], $price_block['UPPER'], $this->_params['offer']);
     $return = array();
     $return["status"] = "ok";
     $return["data"] = $rank;
     return $return;
 }
Example #2
0
 public function handle_request_internal()
 {
     /**
      * @var AJKRequest $request
      */
     $request = APF::get_instance()->get_request();
     $cityId = $request->getBrokerCityId();
     $keyWord = $request->get_parameter('q');
     $siteType = trim($request->get_parameter('site'));
     if (empty($keyWord)) {
         $this->response('error', array());
         return;
     }
     if ($siteType == 'hz') {
         //$this->response('ok', Util_SearchUtil::getHzSearchCommunity($cityId, $keyWord));
         // 走二手房小区solr
         $result = Util_SearchUtil::getSearchCommunity($cityId, $keyWord);
         $this->response('ok', $result ? $result : array());
     } elseif ($siteType == 'jp') {
         $pb = trim($request->get_parameter('pb'));
         $cityId = BLL_House_JpHouseManage::getMemberCityId($cityId);
         $jpMember = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId(self::$intBrokerID);
         $this->response('ok', Util_SearchUtil::getJpSearchProperty($cityId, $keyWord, $pb, intval($jpMember->id)));
     } else {
         $this->response('ok', Util_SearchUtil::getSearchCommunity($cityId, $keyWord));
     }
 }
Example #3
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 获取任务
     $tasks = Util_SearchUtil::getHzPropsListFromSolr($this->cityId, $this->lastLogId, $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->cityId => 0)));
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->dealTask($task);
         $this->lastLogId += 1;
     }
     //记录游标
     $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->cityId => $this->lastLogId)));
 }
Example #4
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     $this->setLog(sprintf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId));
     $typeArray = explode('|', $this->type);
     $houseType = $typeArray[0];
     $cityId = $typeArray[1];
     // 获取任务
     $tasks = Util_SearchUtil::getJpPropsListFromSolr($houseType, $cityId, $this->lastLogId, $this->limit);
     if ($tasks === false) {
         $this->setLog(sprintf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败'));
         exit;
     }
     if (empty($tasks)) {
         // 任务完成
         $this->setLog(sprintf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成'));
         $this->setFlag(array_merge($this->getFlag(), array($this->type => array('isFinish' => true))));
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $solrOnProId = $task['id'];
         $this->dealTask($solrOnProId);
         $this->lastLogId += 1;
     }
     //记录游标
     $this->setFlag(array_merge($this->getFlag(), array($this->type => array('lastLogId' => $this->lastLogId))));
 }
Example #5
0
 /**
  * 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))));
     */
 }
Example #6
0
 public static function beforePostInjectAfter($ctx)
 {
     // 委托房源
     $ctx['commission'] = null;
     if (isset($ctx['commission']) && (int) $ctx['commission'] > 0) {
         $commissionId = (int) $ctx['commission'];
         unset($ctx['commission']);
         // 获取委托房源信息
         $commission = Bll_House_HzHouse::getCommissionHouse($commissionId, $ctx['ajkBrokerId']);
         if ($commission) {
             // 如果委托房源已经发布,跳转至房源详情页面
             if ($commission['brokerHouseId']) {
                 APF::get_instance()->get_response()->redirect('/ajkbroker/user/house/propview/hz/' . $commission['brokerHouseId']);
             }
             // 委托信息
             $ctx['isCommission'] = 1;
             $ctx['commissionId'] = $commission['id'];
             // 默认值(如果经纪人修改过,忽略这些值)
             if (APF::get_instance()->get_request()->is_get_method()) {
                 $ctx['renttype'] = $commission['house']['rentType'];
                 $ctx['roomnum'] = $commission['house']['roomNum'];
                 $ctx['hallnum'] = $commission['house']['hallNum'];
                 $ctx['toilnetnum'] = $commission['house']['toiletNum'];
                 $ctx['areanum'] = $commission['house']['areaNum'];
             }
             // 获取委托房源的小区信息
             $arrMatchComm = Util_SearchUtil::getHzSearchCommunity($ctx['cityId'], $commission['house']['commName']);
             if ($arrMatchComm) {
                 $arrMatchComm['commname'] = $commission['house']['commName'];
                 $ctx['areaid'] = $arrMatchComm['areaid'];
                 $ctx['blockid'] = $arrMatchComm['blockid'];
                 $ctx['commid'] = $arrMatchComm['commid'];
                 $ctx['commname'] = $commission['house']['commName'];
                 $ctx['address'] = $arrMatchComm['address'];
                 $ctx['block_name'] = $arrMatchComm['blockname'];
                 $ctx['area_name'] = $arrMatchComm['areaname'];
             }
             $commission['community'] = $arrMatchComm;
             $ctx['commission'] = $commission;
         }
         // 委托end
     }
     // others
     return $ctx;
 }
 protected function dealScan($dealCityIdList)
 {
     $this->logMsg(sprintf('开始扫描处理城市[%s]........', implode(',', $dealCityIdList)));
     $onlineHouseRelationList = Bll_Combo_HouseRelation::ajkGetOnlineHouseListByCityId($dealCityIdList, $this->_startId, self::COMMUNITY_LIMIT);
     foreach ($onlineHouseRelationList as $onlineHouseRelation) {
         /**
          * 查询Solr,判断房源是否在线
          */
         if (Util_SearchUtil::checkHouseIsOnline($onlineHouseRelation['cityId'], $onlineHouseRelation['houseId'])) {
             $this->logMsg(sprintf('经纪人[%d]房源[%d]在线,不予处理。', $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId']));
             continue;
         }
         $this->saveFailureHouseId($onlineHouseRelation['houseId']);
         $this->logMsg(sprintf('经纪人[%d]房源[%d]不在线。', $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId']));
         $this->setCursor($onlineHouseRelation['id']);
     }
     if (count($onlineHouseRelationList) < self::COMMUNITY_LIMIT) {
         $this->logMsg(sprintf('startId: %d 处理结束。', $this->_startId));
         file_put_contents($this->_doneFile, 'SLEEP');
         return;
     }
 }
Example #8
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 获取任务
     // TODO传入对应城市列表
     $tasks = Util_SearchUtil::getHzPropsListFromSolr(self::getCityIdByTable(), $this->lastLogId, $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;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->proceLog = date('Y-m-d H:i:s') . ' solrId:' . $this->lastLogId . ' proId:' . $task['id'] . ' ';
         $this->dealTask($task);
         //记录日志
         $this->setLog($this->proceLog);
         $this->lastLogId += 1;
     }
     //记录游标
     $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId)));
     /*
             // 发邮件获取记录日志
             if (!empty($this->errorPropIds) || !empty($this->emptyPropIds)) {
                 Bll_House_UpDown_Worker_MailBll::getInstance()->setSubject('房源不在线 solr却在线')->send(array('message' => json_encode(array(
                     array('error prop' => $this->errorPropIds),
                     array('prop not found in db' => $this->emptyPropIds)
                 ))));
             }*/
 }
Example #9
0
 /**
  * 从slor获取竞价排名
  */
 public static function get_bid_rank($prop, $city_id)
 {
     $price_block = self::get_price_block($city_id, $prop['pricenum']);
     $ajkid = Bll_HzProp::get_subregion_id($prop['commid'], $prop['proid']);
     $rank = Util_SearchUtil::getHpCurrentRank($city_id, $ajkid, $prop['proid'], $price_block['LOWER'], $price_block['UPPER'], $prop['unit_price']);
     return $rank;
 }
Example #10
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     $this->setLog(sprintf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId));
     // 获取非删除的房子
     $params = array(array('isDelete', '=', 0), array('id', '>', $this->lastLogId));
     if ($this->cityIds) {
         $params = array(array('isDelete', '=', 0), array('cityId', 'in', $this->cityIds), array('id', '>', $this->lastLogId));
     }
     $tasks = Model_House_JpHouseIdx::getPropLists($params, $this->limit);
     if ($tasks === false) {
         $this->setLog(sprintf('[%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('lastLogId' => 0));
         exit;
     }
     $doProps = array();
     /** 本次处理的房子 */
     $doTmpProIds = array();
     $solrProIdsTmp = array();
     $solrProIds = array();
     foreach ($tasks as $task) {
         $this->lastLogId = $task['id'];
         $doProps[$task['id']] = $task;
         $doTmpProIds[$task['houseType']][] = $task['id'];
     }
     foreach ($doTmpProIds as $type => $proIds) {
         printf('[%s] 获取solr, type: %s, proId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $type, json_encode($proIds));
         // 获取solr
         $solrs = Util_SearchUtil::getJpPropsFromSolr($this->getTypeByHouseType($type), $proIds, $this->limit);
         if (!empty($solrs)) {
             $solrProIdsTmp[$type] = $solrs;
         }
     }
     // 扁平处理
     if (!empty($solrProIdsTmp)) {
         foreach ($solrProIdsTmp as $items) {
             foreach ($items as $item) {
                 $solrProIds[] = $item['id'];
             }
         }
     }
     // 拿出不在线的进行处理
     $willDealProIds = array_diff(array_keys($doProps), $solrProIds);
     if (empty($willDealProIds)) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '本轮取的房子都在线,不需要处理');
         //记录游标
         $this->setFlag(array('lastLogId' => $this->lastLogId));
         die;
     }
     // 循环处理任务
     foreach ($willDealProIds as $willDealProId) {
         $this->dealTask($doProps[$willDealProId]);
     }
     //记录游标
     $this->setFlag(array('lastLogId' => $this->lastLogId));
 }
Example #11
0
 /**
  * 计算竞价房源排名
  * @param $proId
  * @param $commId
  * @param $priceNum
  * @param $unitPrice
  * @param $cityId
  * @return int
  */
 public static function getBidRank($proId, $commId, $priceNum, $unitPrice, $cityId)
 {
     // 获取价格段
     $priceBlock = Bll_HzBidPlan::get_price_block($cityId, $priceNum);
     // 板块id
     $ajkid = Bll_HzProp::get_subregion_id($commId, $proId);
     $rank = Util_SearchUtil::getHpCurrentRank($cityId, $ajkid, $proId, $priceBlock['LOWER'], $priceBlock['UPPER'], $unitPrice);
     if ($rank > 5) {
         $rank = '排队中';
     }
     return $rank;
 }
Example #12
0
 /**
  * 获取小区在板块中的排名和小区房源数
  * @param $commId
  * @return array|bool|string
  */
 public static function getVppvOrderAndPropNum($commId)
 {
     if (!$commId) {
         return false;
     }
     $yesterday = date('Ymd', strtotime("-1 day"));
     $cacheTime = strtotime(date("Y-m-d 09:00:00"));
     //每天9点之后的数据开始缓存
     $key = sprintf('%s_%s_%d', __CLASS__, __METHOD__, $commId);
     $cacheObj = APF_Cache_Factory::get_instance()->get_memcache();
     $result = $cacheObj->get($key);
     if ($result && time() > $cacheTime) {
         return $result;
     }
     $result = array();
     // 当前小区的vppv
     $commVppcInfo = Model_Stats_HzCommVppvDaily::getCommVppvInfo($commId, $yesterday);
     $vppv = $commVppcInfo ? $commVppcInfo['vppv'] : 0;
     $result['propNum'] = $commVppcInfo ? $commVppcInfo['propNum'] : 0;
     // 小区对应的板块id
     $solrCommInfo = Util_SearchUtil::getHzCommInfo($commId);
     $blockId = $solrCommInfo ? $solrCommInfo['block_id'] : 0;
     $result['order'] = 0;
     if ($blockId) {
         //取板块下vppv当大于当前小区的总数
         $total = Model_Stats_HzCommVppvDaily::getCommCntGtVppvByBlockId($blockId, $yesterday, $vppv);
         $result['order'] = $total ? $total + 1 : ($vppv ? 1 : 0);
     }
     $cacheObj->set($key, $result, 0, self::EXPIRE_TIME);
     return $result;
 }