/** * @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; }
/** * 获取app用户详细信息 * * @param $deviceId * @param $brokerId */ public function getAppUserDetail($deviceId, $brokerId) { $data = array('device_id' => $deviceId); if (empty($deviceId) || empty($brokerId)) { $this->errorMsg = "参数错误"; $this->errorCode = self::PARAMS_ERROR; return false; } try { $relationRecord = $this->getUserBrokerTodayRelation($deviceId, $brokerId); if (empty($relationRecord)) { $this->errorMsg = "关系不存在"; $this->errorCode = self::NO_RELATION_ERROR; return false; } //如果关系时间超过2天,直接返回已抢完 if (time() - strtotime($relationRecord->uploadDt) > Const_RobUser::RELATION_VALID_TIME) { $this->errorMsg = "关系过期"; $this->errorCode = self::RELATION_EXPIRE; return false; } //获取用户名字 $chatAccountInfos = array(); if ($relationRecord->chatId < 2000000000) { // 有效微聊ID,从2000000000开始 $data['user_name'] = Bll_Mobile_UserList::getUserName('', '', $deviceId); } else { if (($chatAccountInfos = Bll_Mobile_UserList::getChatAccountInfo(array($relationRecord->chatId))) === false) { $this->errorMsg = "获取用户名失败"; $this->errorCode = self::WEILIAO_API_FAIL; return false; } $data['user_name'] = Bll_Mobile_UserList::getUserName(isset($chatAccountInfos[0]['nick_name']) ? $chatAccountInfos[0]['nick_name'] : '', isset($chatAccountInfos[0]['phone']) ? $chatAccountInfos[0]['phone'] : '', $deviceId); } //app_name $data['app'] = $relationRecord->appName; //guid $data['i'] = $relationRecord->guid; //macid $data['macid'] = $relationRecord->macId; //udid2 $data['udid2'] = $relationRecord->userDeviceId2; //返回结果拼接用户头像 $data['user_portrait'] = $chatAccountInfos[0]['icon'] ? $chatAccountInfos[0]['icon'] : $relationRecord->userPhoto; //获取偏爱小区名字 $data['comm_preference'] = $this->getCommName($relationRecord->commPreference); //返回结果拼接偏爱户型 $data['house_type_preference'] = $relationRecord->houseTypePreference; //返回结果拼接偏爱价格段 $data['price_preference'] = $relationRecord->pricePreference; //返回结果拼接浏览房源数 $data['view_prop_num'] = $relationRecord->viewPropNum; //返回结果拼接浏览房源具体信息 $data['view_prop_info'] = array(); // $this->getProductDetail($relationRecord->viewPropList); //返回结果拼接用户状态 $data['status'] = $this->getAppUserStatus($deviceId, $brokerId, $relationRecord, true); } catch (Exception $e) { $this->errorMsg = $e->getMessage(); $this->errorCode = self::UNKNOW_ERROR; return false; } return $data; }