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 static function findMultiByBrokerIds(array $brokerIds) { if (empty($brokerIds)) { return array(); } // 查询 $rows = Model_Chat_TalentStat::data_access()->filter('brokerId', $brokerIds)->find_all(); // 索引 $stats = array(); foreach ($rows as $row) { $stats[$row['brokerId']] = $row; } return $stats; }
public function handle_request_internal() { $brokerIds = explode(',', $this->_params['brokerIds']); //微聊达人体系数据 $brokerChatDatas = Model_Chat_TalentStat::findMultiByBrokerIds($brokerIds); $brokerChatStatisticDatas = array(); foreach ($brokerChatDatas as $brokerChatData) { $row = array(); $row['brokerId'] = $brokerChatData['brokerId']; $row['reply5minRate'] = $brokerChatData['reply5minRate']; $row['avgRespondTime'] = $brokerChatData['avgRespondTime']; $brokerChatStatisticDatas[] = $row; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $brokerChatStatisticDatas); }
public static function getBrokerAnalysis($broker_id) { $return = Model_Chat_TalentStat::data_access()->filter('brokerId', $broker_id)->sort('calDt', 'desc')->find_only(); return $return; }