예제 #1
0
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     //更新房源数据库
     //header('Content-Type: application/json; charset=utf-8');
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $data = $this->_params;
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //获取房源信息
     $imageUrl = 'http://pages.anjukestatic.com/img/mobile/app/weshop_prop_default.jpg';
     $propId = $data['propId'];
     $oldPropInfo = Model_Weshop_Props::getWeshopProp($propId);
     if (empty($oldPropInfo)) {
         throw new Exception_Property_NotFound();
     }
     if ($oldPropInfo->brokerId != $brokerId) {
         throw new Exception_Prop_PropNotBelongBroker('brokerId' . $oldPropInfo->brokerId);
     }
     $images = json_decode($data['imageJson'], true);
     $outdoorImage = json_decode($data['outdoorImageJson'], true);
     if (count($images) > 8) {
         throw new Exception_Prop_PropImageBeyondLimit();
     }
     if (mb_strlen($data['propDescription'], 'utf-8') > 500) {
         throw new Exception_Prop_PropDescriptionBeyondLimit();
     }
     $tagIds = explode(',', $data['tagIds']);
     if (count($tagIds) > 4) {
         throw new Exception_Prop_PropTagsBeyondLimit();
     }
     //小区信息
     $commInfo = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($data['commId']);
     if (empty($commInfo)) {
         throw new Exception_Property_CommNotFound(Const_APIStatus::E_COMM_NOT_EXISTS);
     }
     $propInfo = array();
     $propInfo['cityId'] = $brokerInfo->cityId;
     $propInfo['commId'] = $data['commId'];
     $propInfo['brokerId'] = $brokerId;
     $propInfo['areaId'] = substr($commInfo['areaCode'], 0, 8);
     $propInfo['blockId'] = $commInfo['areaCode'];
     $propInfo['price'] = $data['price'] > 0 ? $data['price'] : 0;
     $propInfo['acreage'] = $data['area'];
     $propInfo['room'] = $data['room'];
     $propInfo['hall'] = $data['hall'];
     $propInfo['toilet'] = $data['toilet'];
     $propInfo['description'] = json_encode($data['propDescription']);
     if (!empty($data['title'])) {
         $propInfo['title'] = trim($data['title']);
     }
     if (!empty($data['floor'])) {
         $propInfo['floor'] = intval($data['floor']);
     }
     if (!empty($data['totalFloor'])) {
         $propInfo['totalFloor'] = intval($data['totalFloor']);
     }
     $propInfo['tagIds'] = $data['tagIds'];
     $propInfo['status'] = 1;
     $res = Model_Weshop_Props::updateWeshopProps($propId, $propInfo);
     if (!$res) {
         throw new Exception_Property_NotFound();
     } else {
         //比较图片是否有修改
         $oldImages = Model_Weshop_PropImages::getWeshopPropImages($propId);
         $oldImageHashAndHost = $oldOutImageHashAndHost = array();
         foreach ($oldImages as $img) {
             if ($img->imageType == 1) {
                 $oldImageHashAndHost[] = $img->imageHash;
                 $oldImageHashAndHost[] = $img->imageHostId;
             } elseif ($img->imageType == 2) {
                 $oldOutImageHashAndHost[] = $img->imageHash;
                 $oldOutImageHashAndHost[] = $img->imageHostId;
             }
         }
         $newImageHashAndHost = $newOutImageHashAndHost = array();
         foreach ($images as $img) {
             $newImageHashAndHost[] = $img['hash'];
             $newImageHashAndHost[] = $img['host'];
         }
         $newOutImageHashAndHost[] = $outdoorImage['hash'];
         $newOutImageHashAndHost[] = $outdoorImage['host'];
         $compareImages = $this->compareImages($oldImageHashAndHost, $newImageHashAndHost);
         //无论是否有图片的变化 一定返回室内图片的第一张 作为默认图在列表显示
         if ($images) {
             $imageUrl = str_replace("240", "240c", str_replace("display", "display/e", Util_ImageUtils::getResizeURL($images[0]['hash'], $images[0]['host'], 290, 240)));
         }
         //不同 室内图
         if (!$compareImages) {
             //删除老图片插入新图片
             foreach ($oldImages as $image) {
                 if ($image->imageType == 1) {
                     $image->isDelete = 1;
                     //删除
                     $image->save();
                 }
             }
             //插入新图片
             if ($images) {
                 foreach ($images as $key => $img) {
                     $img_params['propId'] = $propId;
                     $img_params['imageHostId'] = $img['host'];
                     $img_params['imageHash'] = $img['hash'];
                     $img_params['isDelete'] = 0;
                     $img_params['isDefault'] = $key == 0 ? 1 : 0;
                     $img_params['imageType'] = 1;
                     //室内图
                     $img_params['createTime'] = date('Y-m-d H:i:s', time());
                     $img_params['updateTime'] = date('Y-m-d H:i:s', time());
                     //存储新图片
                     Model_Weshop_PropImages::insertWeshopPropImages($img_params);
                 }
             }
         }
         $compareOutImages = $this->compareImages($oldOutImageHashAndHost, $newOutImageHashAndHost);
         //不同 房型图
         if (!$compareOutImages) {
             //删除老图片插入新图片
             foreach ($oldImages as $image) {
                 if ($image->imageType == 2) {
                     $image->isDelete = 1;
                     //删除
                     $image->save();
                 }
             }
             //插入新图片
             if ($outdoorImage) {
                 $img_params['propId'] = $propId;
                 $img_params['imageHostId'] = $outdoorImage['host'];
                 $img_params['imageHash'] = $outdoorImage['hash'];
                 $img_params['isDelete'] = 0;
                 $img_params['isDefault'] = 0;
                 $img_params['imageType'] = 2;
                 //户型图
                 $img_params['createTime'] = date('Y-m-d H:i:s', time());
                 $img_params['updateTime'] = date('Y-m-d H:i:s', time());
                 //存储新图片
                 Model_Weshop_PropImages::insertWeshopPropImages($img_params);
             }
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('imageUrl' => $imageUrl, 'message' => '保存成功'));
 }
예제 #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);
     }
     //获取房源信息
     $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);
 }
예제 #3
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $propId = $this->_params['propId'];
     //好丑陋。。。。。。好无奈。。。。。。
     //委托房源自动转发停用,为了app能够展示报错信息。。。
     if (empty($propId)) {
         $this->_params['apiDebug'] = 1;
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '0000', 'message' => '委托房源自动转发功能已停用;若要发布请手动发布');
     }
     $propInfo = Bll_Ppc_ServiceAPI::getHouseInfo($propId);
     $brokerId = $this->_params['brokerId'];
     $houseInfo = Model_House_EsfHouseElementFactory::getHouseBaseInfo($propId);
     if (empty($houseInfo)) {
         $cityId = Model_Broker_AjkBrokerExtend::getCityIdByBrokerId($this->_params['brokerId']);
         $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId);
     }
     if (!empty($houseInfo)) {
         $result['status'] = 'ok';
         $areaCode = $houseInfo['areaCode'];
         $block = Bll_Commtype_Api::getInfoByTypeCode($areaCode);
         $area = Bll_Commtype_Api::getInfoByTypeId($block['parentId']);
         $area_name = $area['typeName'];
         $block_name = $block['typeName'];
         $data['title'] = $houseInfo['proName'];
         $data['commId'] = $houseInfo['commId'];
         $data['commName'] = $houseInfo['commName'];
         //小区信息
         $commInfo = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($data['commId'], 2);
         $data['commLocation'] = $commInfo['commLocal'];
         $data['sosolat'] = $commInfo['sosolat'];
         //纬度
         $data['sosolng'] = $commInfo['sosolng'];
         //经度
         $data['floor'] = $propInfo['property']['ProFloor'];
         $data['totalFloor'] = $propInfo['property']['FloorNum'];
         $propDescription = $propInfo['property']['sale']['AddExplan'];
         $propDescription = str_replace('<p>', "", $propDescription);
         $propDescription = str_replace('</p>', "", $propDescription);
         $propDescription = trim($propDescription);
         $data['propDescription'] = $propDescription;
         $data['areaname'] = $area_name;
         $data['blockname'] = $block_name;
         $data['roomNum'] = $houseInfo['roomNum'];
         $data['hallNum'] = $houseInfo['hallNum'];
         $data['toiletNum'] = $houseInfo['toiletNum'];
         $data['area'] = $houseInfo['areaNum'];
         $data['areaUnit'] = '平米';
         $data['price'] = $houseInfo['proPrice'];
         $data['priceUnit'] = '万';
         $data['isMoreImg'] = $houseInfo['isHighQulity'];
         $data['isVisible'] = $houseInfo['isVisible'];
         $data['isPhonePub'] = $houseInfo['uriCode'] == 'mobile.asyn' || $houseInfo['uriCode'] == 'mobile-ajk-broker.asyn' ? 1 : 0;
         $data['propImagesUrl'] = array();
         $data['propImages'] = $data['outdoorImage'] = array();
         if ($propInfo['attachments']['attachments']) {
             $propImageNum = 0;
             $outdoorImageNum = 0;
             $images = $propInfo['attachments']['attachments'];
             foreach ($images as $image) {
                 if ($image['DataType'] == 2) {
                     if ($propImageNum >= 8) {
                         continue;
                     }
                     $imageInfo = array();
                     $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 600, 600);
                     $url = str_replace("display", "display/e", $url);
                     $imageInfo['bigImageUrl'] = $url;
                     $data['propImages'][] = $imageInfo;
                     $propImageNum += 1;
                 } else {
                     if ($image['DataType'] == 3) {
                         if ($outdoorImageNum >= 1) {
                             continue;
                         }
                         $imageInfo = array();
                         $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 600, 600);
                         $url = str_replace("display", "display/e", $url);
                         $imageInfo['bigImageUrl'] = $url;
                         $data['outdoorImage'][] = $imageInfo;
                         $outdoorImageNum += 1;
                     }
                 }
             }
         }
         $spread = Model_Plan_AjkPropspread::getAjkPropSpreadByIds($propId);
         $data['isChoice'] = $data['isBid'] = 0;
         if (!empty($spread)) {
             if ($spread[0]['bidVersion'] == 1 && $spread[0]['status'] == 1) {
                 $data['isBid'] = 1;
             } elseif ($spread[0]['bidVersion'] == 2 && ($spread[0]['status'] == 1 || $spread[0]['status'] == 11)) {
                 $data['isChoice'] = 1;
             }
         }
         //计算出房源推广天数
         $timeFixStr = strtotime(date("Ymd", $houseInfo['postDate']));
         $leftDay = floor((time() - $timeFixStr) / 86400);
         $data['publishDaysMsg'] = $leftDay > 0 ? $leftDay . '天前发布' : '今天发布';
         $imgBll = Bll_Image_EsfHouseImage::getInstance();
         $data['imgUrl'] = $imgBll->getThumbImageUrl($propId, $houseInfo['commId']);
         $mobileBaseDomain = APF::get_instance()->get_config("mobile_base_domain");
         $data['url'] = 'http://' . $mobileBaseDomain . '/sale/x/' . $houseInfo['cityId'] . '/' . $houseInfo->proId;
         //增加委托房源标签
         if ($houseInfo['commitionType'] == 2) {
             $data['isEntrust'] = 1;
         } else {
             $data['isEntrust'] = 0;
         }
     } else {
         $data['status'] = 'error';
         $data['message'] = '房源信息不存在';
     }
     $result['data'] = $data;
     return $result;
 }
예제 #4
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));
 }
예제 #5
0
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     $fields = array('commId', 'roomNum', 'hallNum', 'toiletNum', 'houseOri');
     $apiParams = array();
     foreach ($fields as $field) {
         if (!isset($params[$field])) {
             $this->responseJSON('error', array(), '参数不全');
             return;
         }
         $apiParams[$field] = $params[$field];
     }
     $data = array('MODELPIC' => array(), 'COMMPIC' => array());
     $apiParams['houseOri'] = Bll_House_EsfPublish::getPropOrigin($apiParams['houseOri']);
     try {
         /**
          * @var $result Bll_Service_Client_HttpResponse
          */
         $result = Bll_Service_Image::esfGetImgInfo($apiParams);
         if ($result->isFailed()) {
             $this->responseJSON('error', $data, '调用API超时');
             return;
         }
         if ($result['status'] != 'ok') {
             $this->responseJSON('error', $data, '调用API失败');
             return;
         }
         /** 房型图 */
         $modelPicAIds = array();
         if (isset($result['publicPicResult']['fineImg']['count']) && isset($result['publicPicResult']['fineImg']['list'])) {
             foreach ($result['publicPicResult']['fineImg']['list'] as $imageInfo) {
                 $modelPicAIds[] = $imageInfo['Aid'];
             }
         }
         if (isset($result['publicPicResult']['readyImg']['count']) && isset($result['publicPicResult']['readyImg']['list'])) {
             foreach ($result['publicPicResult']['readyImg']['list'] as $imageInfo) {
                 $modelPicAIds[] = $imageInfo['Aid'];
             }
         }
         if (!empty($modelPicAIds)) {
             $modelImageList = Model_Community_Attachment::getImageInfoById($modelPicAIds, array('aid', 'fileName', 'hostId'));
             foreach ($modelImageList as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 600, 600);
                 $data['MODELPIC'][] = $imageInfo;
             }
         }
         if (isset($result['publicPicResult']['othResult']['count']) && isset($result['publicPicResult']['othResult']['attachmentsComm'])) {
             foreach ($result['publicPicResult']['othResult']['attachmentsComm'] as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['Aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['Aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600);
                 $data['MODELPIC'][] = $imageInfo;
             }
         }
         /** 小区图 */
         if (isset($result['publicPicResult']['commPic']['count']) && isset($result['publicPicResult']['commPic']['attachmentsComm'])) {
             foreach ($result['publicPicResult']['commPic']['attachmentsComm'] as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['Aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['Aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600);
                 $data['COMMPIC'][] = $imageInfo;
             }
         }
         $data['MODELPIC'] = array_slice($data['MODELPIC'], 0, 10);
         $data['COMMPIC'] = array_slice($data['COMMPIC'], 0, 20);
         $this->responseJSON('ok', $data, '');
     } catch (Exception $e) {
         $this->responseJSON('error', $data, $e->getMessage());
     }
 }
예제 #6
0
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $propIds = explode(',', $this->_params['propIds']);
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //房源表查寻后 添加到队列表
     $propsInfos = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $brokerInfo->cityId);
     if (count($propIds) == 1) {
         //插入 房源列表  并返回
         $propInfo = Bll_Ppc_ServiceAPI::getHouseInfo($propIds[0]);
         if ($propInfo) {
             $params = array();
             $params['cityId'] = $propInfo['property']['CityId'];
             $params['commId'] = $propInfo['property']['CommId'];
             $params['brokerId'] = $brokerId;
             $params['areaId'] = substr($propInfo['property']['AreaCode'], 0, 8);
             $params['blockId'] = $propInfo['property']['AreaCode'];
             $params['price'] = $propInfo['property']['ProPrice'];
             $params['acreage'] = $propInfo['property']['AreaNum'];
             $params['room'] = $propInfo['property']['RoomNum'];
             $params['hall'] = $propInfo['property']['HallNum'];
             $params['toilet'] = $propInfo['property']['ToiletNum'];
             $propDescription = $propInfo['property']['sale']['AddExplan'];
             $propDescription = str_replace('<p>', "", $propDescription);
             $propDescription = str_replace('</p>', "", $propDescription);
             $propDescription = trim($propDescription);
             $params['description'] = json_encode($propDescription);
             $params['title'] = $propInfo['property']['ProName'];
             $params['floor'] = $propInfo['property']['ProFloor'];
             $params['totalFloor'] = $propInfo['property']['FloorNum'];
             $params['status'] = 1;
             $params['createTime'] = date('Y-m-d H:i:s', time());
             $params['updateTime'] = date('Y-m-d H:i:s', time());
             $result = Model_Weshop_Props::insertWeshopProps($params);
             //存储图片 默认图 区分 室内图8张 户型图 1张
             $imageUrl = '';
             if ($propInfo['attachments']['attachments']) {
                 $propImageNum = 0;
                 $outdoorImageNum = 0;
                 $images = $propInfo['attachments']['attachments'];
                 foreach ($images as $image) {
                     if ($image['DataType'] == 2) {
                         if ($propImageNum >= 8) {
                             continue;
                         }
                         if ($propImageNum == 0) {
                             $img_params['isDefault'] = 1;
                             //默认图
                             $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 290, 240);
                             //(拼好小图)
                             $imageUrl = str_replace("240", "240c", $url);
                             //无水印格式
                         } else {
                             $img_params['isDefault'] = 0;
                         }
                         $img_params['imageType'] = 1;
                         //室内图
                         $propImageNum += 1;
                     } else {
                         if ($image['DataType'] == 3) {
                             if ($outdoorImageNum >= 1) {
                                 continue;
                             }
                             $img_params['imageType'] = 2;
                             //户型图
                             $outdoorImageNum += 1;
                         }
                     }
                     $img_params['propId'] = $result->id;
                     $img_params['imageHostId'] = $image['host_id'];
                     $img_params['imageHash'] = $image['FileName'];
                     $img_params['isDelete'] = 0;
                     $img_params['createTime'] = date('Y-m-d H:i:s', time());
                     $img_params['updateTime'] = date('Y-m-d H:i:s', time());
                     //存储图片
                     Model_Weshop_PropImages::insertWeshopPropImages($img_params);
                 }
             }
             if ($result) {
                 //插入 weshop_prop_ext表
                 $tmp = array('weshopPropId' => $result->id, 'brokerId' => $brokerId, 'propId' => $propIds[0]);
                 Model_Weshop_PropsFilter::insertRecord($tmp);
                 //区域板块
                 $areaAndBlockIds = array();
                 $areaId = $params['areaId'];
                 $blockId = $params['blockId'];
                 $areaAndBlockIds[] = $areaId;
                 $areaAndBlockIds[] = $blockId;
                 $commTypeInfos = Bll_Community_CommunityGardener::getCommTypeInfo($areaAndBlockIds);
                 $previewUrl = Bll_Weshop::getPropPreviewUrl(array('brokerId' => $brokerId, 'propId' => $result->id));
                 return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propId' => $result->id, 'title' => $propInfo['property']['ProName'], 'areaName' => $commTypeInfos[$areaId], 'blockName' => $commTypeInfos[$blockId], 'commId' => $propInfo['property']['CommId'], 'commName' => $propInfo['property']['CommName'], 'room' => $propInfo['property']['RoomNum'], 'hall' => $propInfo['property']['HallNum'], 'toilet' => $propInfo['property']['ToiletNum'], 'price' => $propInfo['property']['ProPrice'], 'priceUnit' => '万', 'area' => $propInfo['property']['AreaNum'], 'areaUnit' => '平米', 'propDescription' => $propDescription, 'previewUrl' => $previewUrl, 'imageUrl' => $imageUrl));
             }
         }
     }
     //插入队列表
     foreach ($propsInfos as $propsInfo) {
         if ($propsInfo['brokerId'] == $brokerId) {
             $params = array();
             $params['brokerId'] = $brokerId;
             $params['propId'] = $propsInfo['proId'];
             $params['cityId'] = $brokerInfo->cityId;
             $params['status'] = 0;
             $params['addTime'] = date('Y-m-d H:i:s', time());
             $params['updateTime'] = date('Y-m-d H:i:s', time());
             Model_Weshop_PropQueue::insertWeshopPropQueue($params);
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('message' => '导入成功'));
 }
예제 #7
0
 public static function getHouseImageEx($brokerId, $houseId)
 {
     $result = array('COMMPIC' => array(), 'MODELPIC' => array(), 'SELCOMM' => array(), 'SELMODEL' => array(), 'UPDCOMM' => array(), 'UPDMODEL' => array(), 'UPDROOM' => array(), 'DEFAULTIMGID' => '', 'ALLCOMM' => array(), 'ALLMODEL' => array());
     $apiResult = Bll_Service_House_EsfHouseInfo::getHouseImage($houseId);
     if ($apiResult->isFailed()) {
         return $result;
     }
     if ($apiResult['status'] != 'ok') {
         return $result;
     }
     $houseBaseInfo = $apiResult['property'];
     if ($houseBaseInfo['BrokerId'] != $brokerId) {
         return $result;
     }
     $attachments = array();
     if (isset($apiResult['attachments']['attachments'])) {
         foreach ($apiResult['attachments']['attachments'] as $imageInfo) {
             if (empty($imageInfo['FileName'])) {
                 continue;
             }
             if ($imageInfo['IsSel']) {
                 $result['DEFAULTIMGID'] = $imageInfo['AId'];
             }
             $imageInfo['imageId'] = $imageInfo['AId'];
             $imageInfo['AID'] = $imageInfo['AId'];
             $imageInfo['url'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75);
             $imageInfo['bigImageUrl'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600);
             $attachments[$imageInfo['AId']] = $imageInfo;
             if ($imageInfo['CommPicId'] != 0 && !isset($attachments[$imageInfo['AId']])) {
                 $attachments[$imageInfo['CommPicId']] = $imageInfo;
             }
         }
     }
     if (empty($attachments)) {
         return $result;
     }
     $communityImageIds = array();
     $roomImageIds = array();
     $modelImageIds = array();
     static::parseSideOther($houseBaseInfo['SideOther'], $communityImageIds, $roomImageIds, $modelImageIds);
     /*
     if (!empty($communityImageIds) && is_array($communityImageIds)) {
         foreach ($communityImageIds as $imageId) {
             if (isset($attachments[$imageId])) {
                 $result['ALLCOMM'][] = $attachments[$imageId];
             }
         }
     }
     
     if (!empty($roomImageIds) && is_array($roomImageIds)) {
         foreach ($roomImageIds as $imageId) {
             if (isset($attachments[$imageId])) {
                 $result['UPDROOM'][] = $attachments[$imageId];
             }
         }
     }
     
     if (!empty($modelImageIds) && is_array($modelImageIds)) {
         foreach ($modelImageIds as $imageId) {
             if (isset($attachments[$imageId])) {
                 $result['ALLMODEL'][] = $attachments[$imageId];
             }
         }
     }
     */
     $result['ALLCOMM'] = static::getCommunityImage($attachments, $communityImageIds, 1);
     $result['UPDROOM'] = static::getCommunityImage($attachments, $roomImageIds, 2);
     $result['ALLMODEL'] = static::getCommunityImage($attachments, $modelImageIds, 3);
     return $result;
 }
예제 #8
0
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     //存储房源  存储图片
     $brokerId = $this->_params['brokerId'];
     $data = $this->_params;
     //header('Content-Type: application/json; charset=utf-8');
     $images = json_decode($data['imageJson'], true);
     if (count($images) > 8) {
         throw new Exception_Prop_PropImageBeyondLimit();
     }
     if (mb_strlen($data['propDescription'], 'utf-8') > 500) {
         throw new Exception_Prop_PropDescriptionBeyondLimit();
     }
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $tagIds = explode(',', $data['tagIds']);
     if (count($tagIds) > 4) {
         throw new Exception_Prop_PropTagsBeyondLimit();
     }
     $tmpBrokerIds = array(1471136);
     // ios5.2 加急审核
     if ($data['tagIds'] == 2 && $data['cv'] == 5.2 && in_array($data['brokerId'], $tmpBrokerIds)) {
         return array();
     }
     //小区信息
     $commInfo = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($data['commId']);
     if (empty($commInfo)) {
         throw new Exception_Property_CommNotFound(Const_APIStatus::E_COMM_NOT_EXISTS);
     }
     $propInfo = array();
     $propInfo['cityId'] = $brokerInfo->cityId;
     $propInfo['commId'] = $data['commId'];
     $propInfo['brokerId'] = $brokerId;
     $propInfo['areaId'] = substr($commInfo['areaCode'], 0, 8);
     $propInfo['blockId'] = $commInfo['areaCode'];
     $propInfo['price'] = $data['price'] > 0 ? $data['price'] : 0;
     $propInfo['acreage'] = $data['area'];
     $propInfo['room'] = $data['room'];
     $propInfo['hall'] = $data['hall'];
     $propInfo['toilet'] = $data['toilet'];
     $propInfo['description'] = json_encode($data['propDescription']);
     if (!empty($data['title'])) {
         $propInfo['title'] = trim($data['title']);
     }
     if (!empty($data['floor'])) {
         $propInfo['floor'] = intval($data['floor']);
     }
     if (!empty($data['totalFloor'])) {
         $propInfo['totalFloor'] = intval($data['totalFloor']);
     }
     $propInfo['tagIds'] = $data['tagIds'];
     //特色
     $propInfo['status'] = 1;
     $propInfo['createTime'] = date('Y-m-d H:i:s', time());
     $propInfo['updateTime'] = date('Y-m-d H:i:s', time());
     //存储房源
     $result = Model_Weshop_Props::insertWeshopProps($propInfo);
     $propId = $result->id;
     //$areaInfo = Model_City_TypeCode::getTypeName($propInfo['areaId']);
     //$areaName = $areaInfo->typeName;
     //$blockInfo = Model_City_TypeCode::getTypeName($propInfo['blockId']);
     //$blockName = $blockInfo->typeName;
     $areaInfo = Bll_Commtype_Api::getInfoByTypeCode($propInfo['areaId']);
     $areaName = $areaInfo['typeName'];
     $blockInfo = Bll_Commtype_Api::getInfoByTypeCode($propInfo['blockId']);
     $blockName = $blockInfo['typeName'];
     $imageUrl = '';
     if ($images) {
         foreach ($images as $key => $img) {
             $img_params['propId'] = $propId;
             $img_params['imageHostId'] = $img['host'];
             $img_params['imageHash'] = $img['hash'];
             $img_params['isDelete'] = 0;
             if ($key == 0) {
                 $img_params['isDefault'] = 1;
                 $url = Util_ImageUtils::getResizeURL($img_params['imageHash'], $img_params['imageHostId'], 290, 240);
                 //(拼好小图)
                 $imageUrl = str_replace("240", "240c", $url);
                 //无水印格式
             } else {
                 $img_params['isDefault'] = 0;
             }
             $img_params['createTime'] = date('Y-m-d H:i:s', time());
             $img_params['updateTime'] = date('Y-m-d H:i:s', time());
             $img_params['imageType'] = 1;
             //室内图
             //存储图片
             Model_Weshop_PropImages::insertWeshopPropImages($img_params);
         }
     }
     //户型图
     if (!empty($data['outdoorImageJson'])) {
         $outdoorImages = json_decode($data['outdoorImageJson'], true);
         if (!empty($outdoorImages)) {
             $img_params['propId'] = $propId;
             $img_params['imageHostId'] = $outdoorImages['host'];
             $img_params['imageHash'] = $outdoorImages['hash'];
             $img_params['isDelete'] = 0;
             $img_params['isDefault'] = 0;
             $img_params['createTime'] = date('Y-m-d H:i:s', time());
             $img_params['updateTime'] = date('Y-m-d H:i:s', time());
             $img_params['imageType'] = 2;
             //户型图
             //存储图片
             Model_Weshop_PropImages::insertWeshopPropImages($img_params);
         }
     }
     header("Access-Control-Allow-Origin: *");
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propId' => $propId, 'title' => $propInfo['title'] ? $propInfo['title'] : $commInfo['commName'] . ' ' . $result->room . '室' . $result->hall . '厅' . ' ' . $result->acreage . '平' . ' ' . intval($result->price) . '万', 'areaName' => $areaName, 'blockName' => $blockName, 'commId' => $commInfo['commId'], 'commName' => $commInfo['commName'], 'room' => $result->room, 'hall' => $result->hall, 'toilet' => $result->toilet, 'price' => intval($result->price), 'priceUnit' => '万', 'area' => $result->acreage, 'areaUnit' => '平米', 'propDescription' => json_decode($propInfo['description']), 'previewUrl' => Bll_Weshop::getPropPreviewUrl(array('brokerId' => $brokerId, 'propId' => $propId)), 'imageUrl' => $imageUrl));
 }