/** * @param $brokerId * @param $customers * @return array */ protected function buildCustomersWithExtra($brokerId, $customers) { if (empty($customers)) { return array(); } $customerParams = array(); $chatIds = array(); foreach ($customers as $k => $customer) { $customerParams[$k]['app'] = $customer['appName']; if ($customer['appName'] == 'i-ajk') { $customerParams[$k]['udid2'] = $customer['userDeviceId2']; } else { $customerParams[$k]['i'] = $customer['guid']; $customerParams[$k]['macid'] = $customer['macId']; } if ($customer['chatId']) { $chatIds[] = $customer['chatId']; } } // 批量获取打招呼开关 $appSettings = Bll_Mobile_UserList::getAppsettings($customerParams); // 批量获取账户微聊信息 $chatAccountInfos = Bll_Mobile_UserList::getChatAccountInfo($chatIds); // 获取经纪人的chatid $brokerChatInfo = Model_Mobile_BrokerChatInfo::getBrokerChatInfo($brokerId); $brokerChatId = $brokerChatInfo && isset($brokerChatInfo['chatId']) ? $brokerChatInfo['chatId'] : 0; $friendChatIds = array(); if ($brokerChatId) { // 获取经纪人好友关系 if ($brokerFriends = Bll_Mobile_UserList::getFriends($brokerChatId)) { foreach ($brokerFriends as $brokerFriend) { $friendChatIds[] = $brokerFriend['to_uid']; } } } foreach ($customers as $k => $customer) { // 如果是好友 过滤掉 // 新增逻辑,如果已抢到,无论是否好友都展示 if (in_array($customer['chatId'], $friendChatIds) && $customer['status'] != Model_Mobile_BrokerUserRelation::STATUS_LOCKED) { unset($customers[$k]); continue; } // 把开关信息append到返回列表里 foreach ($appSettings as $appSetting) { if ($appSetting['app'] == 'i-ajk') { if ($appSetting['udid2'] == $customer['userDeviceId2']) { $customers[$k]['recommendSwitch'] = $appSetting['recommend_switch']; break; } } if ($appSetting['app'] == 'a-ajk') { if ($appSetting[i] == $customer['guid'] && $appSetting['macid'] == $customer['macId']) { $customers[$k]['recommendSwitch'] = $appSetting['recommend_switch']; break; } } /*if ($appSetting['device_id'] == $customer['userDeviceId']) { $customers[$k]['recommendSwitch'] = $appSetting['recommend_switch']; break; }*/ } // 把账户微聊信息append到返回列表里 if ($chatAccountInfos) { foreach ($chatAccountInfos as $chatAccountInfo) { if ($chatAccountInfo['user_id'] == $customer['chatId']) { $customers[$k]['nickName'] = $chatAccountInfo['nick_name']; $customers[$k]['lastUpdate'] = $chatAccountInfo['last_update']; $customers[$k]['userPhoto'] = $chatAccountInfo['icon']; $customers[$k]['phone'] = isset($chatAccountInfo['phone']) ? $chatAccountInfo['phone'] : ''; break; } } } } if ($this->debug) { printf('获取打招呼开关' . PHP_EOL); echo '入参:' . PHP_EOL; print_r($customerParams); echo '结果:' . PHP_EOL; print_r($appSettings); } if ($this->debug) { printf('批量获取账户微聊信息' . PHP_EOL); echo '入参:' . PHP_EOL; print_r($chatIds); echo '结果:' . PHP_EOL; print_r($chatAccountInfos); } return $customers; }