public function handle_request_internal() { $lng = $this->_params['lng']; $lat = $this->_params['lat']; $radius = isset($this->_params['radius']) ? $this->_params['radius'] : 3000; // 搜索半径,默认3000米 $total = isset($this->_params['total']) ? $this->_params['total'] : 500; // 最大总数,默认500 $days = isset($this->_params['days']) ? $this->_params['days'] : 3; // 查询天数,默认3天 $cache = APF_Cache_Factory::get_instance()->get_memcache(); $key = $this->generateCacheKey($lat, $lng, $days); $result = $cache->get($key); if ($result === false || $this->isDebugMode()) { // 获取近几日附近签到过的经纪人坐标 $brokerLocations = Bll_Broker_Location::getRoundBrokerLocationsInThePastFewDays($lng, $lat, $radius, $total, $days); $brokerIds = array_keys($brokerLocations); // 获取经纪人的等级 $brokerLevels = Model_Broker_AjkBrokerExtend::getMultiBrokerLevels($brokerIds); // 获取经纪人微聊状态(根据活动是否进行中,决定是否查询) if (Bll_Broker_CallAnalysis::isTalentEventOngoing()) { $brokerChatStats = Model_Chat_TalentStat::findMultiByBrokerIds($brokerIds); } // 获取经纪人明星中介状态(未判断城市是否开启等,已 BI 每日生成的最终数据为准) $brokerStarBrokerStats = Model_Broker_StarIntermediaryScore::findMultiByBrokerIds($brokerIds, date('Y-m-d')); // 拼装返回数据 $result = array(); foreach ($brokerLocations as $brokerLocation) { $row = array(); $row['id'] = $brokerLocation['id']; $row['brokerId'] = $brokerLocation['brokerId']; $row['lat'] = $brokerLocation['lat']; $row['lng'] = $brokerLocation['lng']; $row['updateTime'] = $brokerLocation['updateTime']; // 获取经纪人状态:活跃 or 非活跃(ajk_brokerextend.BrokerLevel = 'K' 为 活跃经纪人) $row['isActive'] = intval(isset($brokerLevels[$row['brokerId']]) && $brokerLevels[$row['brokerId']] == 'K'); // 微聊达人 $isChatTalent = -1; // 默认,微聊达人活动未开始或已结束 if (Bll_Broker_CallAnalysis::isTalentEventOngoing()) { $isChatTalent = 0; // 活动中,默认不是微聊达人 if (isset($brokerChatStats[$row['brokerId']])) { $isChatTalent = $brokerChatStats[$row['brokerId']]['isTalent']; } } $row['isChatTalent'] = $isChatTalent; // 明星中介 $isStarBroker = 0; if (isset($brokerStarBrokerStats[$row['brokerId']])) { $isStarBroker = $brokerStarBrokerStats[$row['brokerId']]['isMingxing']; } $row['isStarBroker'] = $isStarBroker; $result[] = $row; } $cache->set($key, $result, 0, 900); } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $result); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $app = $this->_params['app']; $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } /** 获取经纪人被关注的人数 */ $brokerChatId = Model_Mobile_BrokerChatInfo::getBrokerChatInfo($brokerId, array('chatId')); $followerNum = 0; if ($brokerChatId['chatId']) { $followerNumInfo = Bll_Mobile_ChatInfoBll::getBrokerFollowerNum($brokerChatId['chatId']); if ($followerNumInfo['data']['status'] == 'OK') { $followerNum = $followerNumInfo['data']['result']['focus_count']; } } $analysis = Bll_Broker_CallAnalysis::getBrokerAnalysis($brokerId); $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => Bll_Broker_MainBusiness::getDataByEsfId($brokerId)->memberId)); $managerInfo = Bll_Broker::getWorkerNumInfo($brokerId); // 微聊达人 $isTalent = -1; // 默认,微聊活动未开始或已结束 if (Bll_Broker_CallAnalysis::isTalentEventOngoing()) { $isTalent = 0; // 活动中,默认不是微聊达人 if ($analysis) { $isTalent = $analysis['isTalent']; } } $talentIcon = Bll_Broker_CallAnalysis::getTalentIcon($isTalent, $app); // 明星经纪人 $isStarBroker = 0; $starBrokerIcon = ''; try { $bllStarBroker = new Bll_Broker_StarIntermediary($brokerInfo['cityId']); $starBrokerInfo = $bllStarBroker->getBrokerNewestInfo($brokerId); if ($starBrokerInfo && $starBrokerInfo['broker']['isMingxing']) { $isStarBroker = 1; $starBrokerIcon = PageHelper::pure_static_url('/img/mobile/app/star_broker.png'); } } catch (Exception $e) { // do nothing } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('replyRate' => $analysis['reply5minRate'] * 100, 'responseTime' => $analysis['avgRespondTime'], 'customNum' => $analysis['accChatUser'], 'loginDays' => $analysis['accLoginDays'], 'isTalent' => $isTalent, 'talentIcon' => $talentIcon, 'isStarBroker' => $isStarBroker, 'starBrokerIcon' => $starBrokerIcon, 'ajkContact' => $managerInfo['userName'], 'balance' => empty($balanceInfo['data']['balance']) ? 0 : round($balanceInfo['data']['balance'] / 100, 2), 'tel' => $managerInfo['mobile'], 'followerNum' => $followerNum)); }