Example #1
0
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     header("Access-Control-Allow-Origin: *");
     //获取房源 获取房源图片
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //获取房源信息
     $propId = $this->_params['propId'];
     $propInfo = Model_Weshop_Props::getWeshopProp($propId);
     if (empty($propInfo)) {
         throw new Exception_Property_NotFound(Const_APIStatus::E_PROP_INFO_FAILED);
     }
     //小区信息
     $commInfo = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($propInfo->commId, 2);
     $city_set = APF::get_instance()->get_config("city_set", "multicity");
     $cityPinYin = $city_set[$brokerInfo->cityId]['pinyin'];
     $row = array();
     $row['propId'] = $propId;
     $row['floor'] = $propInfo->floor;
     $row['totalFloor'] = $propInfo->totalFloor;
     $row['commId'] = $propInfo->commId;
     $row['commName'] = $commInfo['commName'];
     $row['commLocation'] = $commInfo['commLocal'];
     $row['sosolat'] = $commInfo['sosolat'];
     //纬度
     $row['sosolng'] = $commInfo['sosolng'];
     //经度
     //$areaId = substr($commInfo['areaCode'], 0, 8);
     //$areaInfo = Model_City_TypeCode::getTypeName($areaId);
     //$row['areaName'] = $areaInfo->typeName;
     $blockId = $commInfo['areaCode'];
     $blockInfo = Bll_Commtype_Api::getInfoByTypeCode($blockId);
     $areaInfo = Bll_Commtype_Api::getInfoByTypeId($blockInfo['parentId']);
     $row['areaName'] = $areaInfo['typeName'];
     $row['blockName'] = $blockInfo['typeName'];
     $row['room'] = $propInfo->room;
     $row['hall'] = $propInfo->hall;
     $row['toilet'] = $propInfo->toilet;
     $row['area'] = $propInfo->acreage;
     $row['areaUnit'] = '平米';
     $row['price'] = intval($propInfo->price);
     $row['priceUnit'] = '万';
     $isJson = Util_String::isJson($propInfo->description);
     $row['propDescription'] = $isJson ? json_decode($propInfo->description) : $propInfo->description;
     $row['title'] = $propInfo->title ? $propInfo->title : $row['commName'] . ' ' . $row['room'] . '室' . $row['hall'] . '厅' . ' ' . $row['area'] . '平' . ' ' . $row['price'] . '万';
     $row['cityPinYin'] = $cityPinYin;
     //从数据库取房源特色id
     $tagIds = $propInfo->tagIds;
     $tagIds = explode(',', $tagIds);
     $allTags = APF::get_instance()->get_config('weshop_tags');
     $propTags = array();
     foreach ($tagIds as $tagId) {
         $tagId = trim($tagId);
         if ($tagId) {
             $tag = array();
             $tag['tagId'] = $tagId;
             $tag['tagName'] = $allTags[$tagId];
             $propTags[] = $tag;
         }
     }
     $row['tags'] = $propTags;
     //获取房源图片
     $propImages = Model_Weshop_PropImages::getWeshopPropImages($propId);
     $row['propImages'] = $row['outdoorImage'] = array();
     foreach ($propImages as $propImage) {
         $image = array();
         $image['host'] = $propImage->imageHostId;
         $image['hash'] = $propImage->imageHash;
         $url = Util_ImageUtils::getResizeURL($propImage->imageHash, $propImage->imageHostId, 290, 240);
         $url = str_replace("display", "display/e", $url);
         //无水印格式
         $url = str_replace("240", "240c", $url);
         //图片url 加c
         $image['smallImageUrl'] = $url;
         $url = Util_ImageUtils::getResizeURL($propImage->imageHash, $propImage->imageHostId, 600, 600);
         $url = str_replace("display", "display/e", $url);
         //无水印格式
         $image['bigImageUrl'] = $url;
         //区分户型图和室内图
         if ($propImage->imageType == 1) {
             $row['propImages'][] = $image;
         } elseif ($propImage->imageType == 2) {
             $row['outdoorImage'][] = $image;
         }
     }
     $row['cityId'] = $brokerInfo->cityId;
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $row);
 }
Example #2
0
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $sinceId = isset($this->_params['sinceId']) ? intval($this->_params['sinceId']) : 0;
     //从$sinceId 行开始读
     $per = isset($this->_params['per']) ? $this->_params['per'] : 10;
     //每页显示的条数
     //获取经纪人房源
     $brokerProps = Model_Weshop_Props::getWeshopPropsByBrokerId($brokerId, $per + 1, $sinceId);
     $totalProps = Model_Weshop_Props::getWeshopPropsCount($brokerId);
     $propList = array();
     $hasNextPage = 0;
     if (!empty($brokerProps)) {
         $hasNextPage = count($brokerProps) > $per ? 1 : 0;
         if ($hasNextPage) {
             array_pop($brokerProps);
             $sinceId += $per;
         } else {
             $sinceId = 0;
         }
         $propIds = array();
         $commIds = array();
         foreach ($brokerProps as $prop) {
             $propIds[] = $prop->id;
             $commIds[] = $prop->commId;
         }
         //批量获取小区信息
         list($commInfos, $areaIds, $blockIds) = $this->getCommInfos($commIds);
         $araNames = $this->getCommTypeInfo($areaIds);
         $blockIdNames = $this->getCommTypeInfo($blockIds);
         //批量获取房源默认图片
         $defaultImages = $this->getPropDefaultImage($propIds);
         foreach ($brokerProps as $brokerProp) {
             $row = array();
             $row['propId'] = $brokerProp->id;
             $row['commId'] = $brokerProp->commId;
             $row['commName'] = $commInfos[$brokerProp->commId]['commName'];
             //批量获取小区信息  commIds propIds
             $areaId = substr($commInfos[$brokerProp->commId]['areaCode'], 0, 8);
             $blockId = $commInfos[$brokerProp->commId]['areaCode'];
             $row['areaName'] = $araNames[$areaId];
             //批量获取区域 板块
             $row['blockName'] = $blockIdNames[$blockId];
             //批量获取区域 板块
             $row['room'] = $brokerProp->room;
             $row['hall'] = $brokerProp->hall;
             $row['toilet'] = $brokerProp->toilet;
             $row['area'] = $brokerProp->acreage;
             $row['areaUnit'] = '平米';
             $row['price'] = intval($brokerProp->price);
             $row['priceUnit'] = '万';
             $isJson = Util_String::isJson($brokerProp->description);
             $row['propDescription'] = $isJson ? json_decode($brokerProp->description) : $brokerProp->description;
             $row['title'] = $brokerProp->title ? $brokerProp->title : $row['commName'] . ' ' . $row['room'] . '室' . $row['hall'] . '厅' . ' ' . $row['area'] . '平' . ' ' . $row['price'] . '万';
             $imageUrl = PageHelper::pure_static_url(APF::get_instance()->get_config('prop_image_url_default', 'weshop', 'img/mobile/app/weshop_prop_default.jpg'));
             $url = Util_ImageUtils::getResizeURL($defaultImages[$brokerProp->id]['imageHash'], $defaultImages[$brokerProp->id]['imageHostId'], 290, 240);
             $url = str_replace("display", "display/e", $url);
             //无水印格式
             $url = str_replace("240", "240c", $url);
             $row['imageUrl'] = $defaultImages[$brokerProp->id] ? $url : $imageUrl;
             $row['previewUrl'] = Bll_Weshop::getPropPreviewUrl(array('brokerId' => $brokerId, 'propId' => $brokerProp->id));
             $propList[] = $row;
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propList' => $propList, 'sinceId' => $sinceId, 'hasNextPage' => $hasNextPage, 'totalProps' => $totalProps));
 }