Example #1
0
 /**
  * 获取房源 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;
 }