protected function getAreaCodeNames($areaCodes) { if (empty($areaCodes)) { return array(); } // 去重 $areaCodes = array_flip(array_flip($areaCodes)); // 获取区域的编码 foreach ($areaCodes as $areaCode) { if (strlen($areaCode) > 8) { $areaCodes[] = substr($areaCode, 0, 8); } } // 再次去重 $areaCodes = array_flip(array_flip($areaCodes)); $typeCodes = Model_City_TypeCode::data_access()->filter('typeCode', $areaCodes)->find_all(); $result = array(); foreach ($typeCodes as $typeCode) { $result[$typeCode->typeCode] = $typeCode->typeName; } return $result; }
public static function getArrayAreaInfoByParentIdEx($parentId) { try { $result = Model_City_TypeCode::data_access()->load_field("typeId")->load_field("typeName")->filter('parentId', $parentId)->filter('typeFlag', 0)->get_all(); } catch (Exception $e) { $result = array(''); } return $result; }
/** * 获取房源 Solr 文档信息 * * @param Model_Fyk_QueuePropToSolr $task * * @return array */ protected function propDoc($task) { $propDoc = array(); $prop = $task->prop(); if (!$prop) { throw new Exception(sprintf('Task %d prop %d not found.', $task->id, $task->propId)); } $propDoc['id'] = $prop->id; $propDoc['status'] = $prop->status; $propDoc['city_id'] = $prop->cityId; $propDoc['housing_type_id'] = $prop->housingType; $propDoc['housing_type_name'] = ''; // TODO // TODO 待优化 $housingType = Model_Community_UseType::data_access()->filter('typeId', $prop->housingType)->find_only(); if ($housingType) { $propDoc['housing_type_name'] = $housingType['typeName']; // TODO } $propDoc['build_year'] = $prop->buildYear; $propDoc['is_only'] = $prop->isOnly; $propDoc['is_real'] = $prop->isReal; $propDoc['is_certificate'] = $prop->certificate; $propDoc['fitment_id'] = $prop->fitment; $propDoc['fitment_name'] = ''; // TODO $fitmentType = Model_House_FitmentType::data_access()->filter('fitmentId', $prop->fitment)->find_only(); if ($fitmentType) { $propDoc['fitment_name'] = $fitmentType->fitmentValue; } $propDoc['area_num'] = $prop->acreage; $propDoc['room_num'] = $prop->cell; $propDoc['hall_num'] = $prop->hall; $propDoc['toilet_num'] = $prop->toilet; $propDoc['floor'] = $prop->floor; $propDoc['floor_total'] = $prop->totalFloor; $propDoc['price'] = $prop->totalPrices * 10000; // 单位:元 $propDoc['price_unit'] = $prop->acreage ? intval($prop->totalPrices * 10000 / $prop->acreage) : 0; $propDoc['comm_id'] = $prop->commId; $propDoc['comm_name'] = ''; $propDoc['comm_location'] = ''; // TODO 待优化 $comm = Bll_Community_APIComm::getInstance()->getInfoById($prop->commId, 2); $commLat = $comm['geolocation']['soso'] ? $comm['geolocation']['soso']['lat'] : null; $commLng = $comm['geolocation']['soso'] ? $comm['geolocation']['soso']['lng'] : null; if ($comm) { $propDoc['comm_name'] = $comm['name']; $propDoc['comm_location'] = $commLat . ',' . $commLng; } $propDoc['block_id'] = $prop->blockId; $propDoc['block_name'] = ''; $propDoc['district_id'] = $prop->areaId; $propDoc['district_name'] = ''; // TODO 待优化 $zones = Model_City_TypeCode::data_access()->filter('typeId', array($prop->blockId, $prop->areaId))->find_all(); foreach ($zones as $zone) { if ($zone->typeId == $propDoc['block_id']) { $propDoc['block_name'] = $zone->typeName; } if ($zone->typeId == $propDoc['district_id']) { $propDoc['district_name'] = $zone->typeName; } } $propDoc['onsell_time'] = $prop->onsellTime; $propDoc['create_time'] = $prop->createTime; $propDoc['update_time'] = strtotime($prop->updateTime); return $propDoc; }
public function handle_request_internal() { $propLists = array(); $hasNextPage = 0; $userId = $this->_params['userId']; $sinceId = isset($this->_params['sinceId']) ? intval($this->_params['sinceId']) : 0; $per = isset($this->_params['per']) ? $this->_params['per'] : 20; $propIds = Model_Broker_FykPushProps::data_access()->load_field('propId')->filter('userId', $userId)->sort('id', 'desc')->limit($per + 1)->offset($sinceId)->get_all(); if (!empty($propIds)) { $hasNextPage = count($propIds) > $per ? 1 : 0; if ($hasNextPage) { array_pop($propIds); $sinceId = $sinceId + $per; } else { $sinceId = 0; } $propIds = self::getArrayColumn($propIds, 'propId'); $props = Model_Fyk_PropLibrary::data_access()->filter('id', array_unique($propIds))->get_all(); //获取小区、板块名称 start $commNames = $typeNames = array(); $commIds = self::getArrayColumn($props, 'commId'); /*$commInfos = Model_Community_AjkCommunity::data_access() ->filter('commId', $commIds) ->get_all();*/ $commInfos = Bll_Community_APIComm::getInstance()->getInfoById($commIds); foreach ($commInfos as $info) { $commNames[$info['comm_id']] = $info['name']; } //———————————————————————————————————————————————— $districtIds = self::getArrayColumn($props, 'areaId'); $blockIds = self::getArrayColumn($props, 'blockId'); $typeIds = array_merge($districtIds, $blockIds); $typeInfos = Model_City_TypeCode::data_access()->load_field('typeId')->load_field('typeName')->filter('typeId', $typeIds)->get_all(); foreach ($typeInfos as $info) { $typeNames[$info['typeId']] = $info['typeName']; } //获取小区、板块名称 end foreach ($props as $prop) { //计算发布时间 $publishDate = strtotime(date('Y-m-d', $prop['createTime'])); $nowDate = strtotime(date('Y-m-d', time())); $publishDays = intval(($nowDate - $publishDate) / 86400); $propId = $prop['id']; $propList['fPropId'] = $propId; $propList['isOnly'] = $prop['isOnly']; $propList['isReal'] = $prop['isReal']; $propList['certificate'] = $prop['certificate']; $propList['commId'] = $prop['commId']; $propList['commName'] = $commNames[$prop['commId']]; $propList['districtId'] = $prop['areaId']; $propList['districtName'] = $typeNames[$prop['areaId']]; $propList['blockId'] = $prop['blockId']; $propList['blockName'] = $typeNames[$prop['blockId']]; $propList['roomNum'] = $prop['cell']; $propList['hallNum'] = $prop['hall']; $propList['toiletNum'] = $prop['toilet']; $propList['area'] = $prop['acreage']; $propList['areaUnit'] = '平'; $propList['price'] = intval($prop['totalPrices']); $propList['priceUnit'] = '万'; $propList['publishDays'] = $publishDays; $propList['publishDaysMsg'] = $propList['publishDays'] > 0 ? "{$propList['publishDays']}天前发布" : '今天发布'; $propLists[$propId] = $propList; } } $propListFormat = array(); foreach ($propIds as $id) { $propListFormat[] = $propLists[$id]; } unset($propLists); //更新为0 Model_Fyk_PushPropsLatestCount::data_access()->set_field('count', 0)->filter('userId', $userId)->update(); $data['props'] = $propListFormat; $data['sinceId'] = $sinceId; $data['hasNextPage'] = $hasNextPage; return API_Result::create()->ok()->data($data)->toArray(); }