Beispiel #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();
     }
     if ($propInfo->brokerId != $brokerId) {
         throw new Exception_Prop_PropNotBelongBroker('brokerId' . $propInfo->brokerId);
     }
     //更新房源状态 删除
     $propInfo->status = 0;
     $propInfo->save();
     //获取房源图片 删除房源图片
     $oldImages = Model_Weshop_PropImages::getWeshopPropImages($propId);
     foreach ($oldImages as $image) {
         $image->isDelete = 1;
         //删除
         $image->save();
     }
     $weshopExtData = Bll_Weshop_WeshopPropExt::getDataByBrokerId($brokerId);
     $weshopExtId = 0;
     foreach ($weshopExtData as $v) {
         if ($v['weshopPropId'] == $propId) {
             $weshopExtId = $v['id'];
             break;
         }
     }
     Bll_Weshop_WeshopPropExt::deleteDataById($weshopExtId);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('message' => '删除成功'));
 }
Beispiel #2
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' => '保存成功'));
 }
Beispiel #3
0
 public function getPreviewUrl()
 {
     $previewUrl = Bll_Weshop::getShopPreviewUrl(array('brokerId' => $this->brokerId));
     return $previewUrl;
 }
Beispiel #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);
     }
     //获取房源信息
     $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);
 }
Beispiel #5
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));
 }
 public function handle_request_internal()
 {
     if (Bll_Weshop::weshopPropsIsMaintain()) {
         return array('status' => 'error', 'message' => "系统维护中,请稍后再试!");
     }
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $commId = $this->_params['commId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //查找经纪人所有房源  过滤所有违规房源
     if ($commId) {
         $tempHouseInfoList = Bll_House_EsfHouse::getBrokerAllPropInfoList($brokerId, $brokerInfo->cityId, array(), $commId);
     } else {
         $tempHouseInfoList = Bll_House_EsfHouse::getBrokerAllPropInfoList($brokerId, $brokerInfo->cityId);
     }
     //获取经纪人已经导入的二手房房源id
     $EsPropIdWeshopPropIdTmp = Model_Weshop_PropsFilter::getPropIdAndWeshopPropIdByBroker($brokerId);
     //获取微店中已有房源的propid
     /*
     $weshopProps = Model_Weshop_Props::getWeshopPropsByBrokerId($brokerId);
     $weshopPropIds = array();
     if(!empty($weshopProps)) {
         foreach($weshopProps as $key => $value)
         {
             $weshopPropIds[]=$value->id;
         }
         $EsPropIdTmp = Model_Weshop_PropsFilter::getPropIdByWeshopPropId($weshopPropIds);
     }
     */
     $EsPropIdWeshopPropId = array();
     $EsPropId = array();
     if (!empty($EsPropIdWeshopPropIdTmp)) {
         foreach ($EsPropIdWeshopPropIdTmp as $k => $v) {
             if (!in_array($v['propId'], $EsPropId)) {
                 $EsPropId[] = $v['propId'];
                 $EsPropIdWeshopPropId[$v['propId']] = array();
             }
             array_push($EsPropIdWeshopPropId[$v['propId']], $v['weshopPropId']);
         }
     }
     //过滤违规房源和重复房源
     $areaAndBlockIds = array();
     $propIds = array();
     foreach ($tempHouseInfoList as $key => $houseInfo) {
         $illegal = isset($houseInfo['isVisible']) ? $houseInfo['isVisible'] : 1;
         if ($illegal == 0 && $houseInfo['ExpireWorker'] != 'propertyReport') {
             unset($tempHouseInfoList[$key]);
             continue;
         }
         //过滤重复房源
         if (in_array($houseInfo['proId'], $EsPropId)) {
             $data = Model_Weshop_Props::getWeshopProp($EsPropIdWeshopPropId[$houseInfo['proId']]);
             if (!empty($data)) {
                 unset($tempHouseInfoList[$key]);
                 continue;
             }
         }
         $areaAndBlockIds[] = substr($houseInfo['areaCode'], 0, 8);
         $areaAndBlockIds[] = $houseInfo['areaCode'];
         $propIds[] = $houseInfo['proId'];
     }
     //批量获取区域板块信息
     $commTypeInfos = Bll_Community_CommunityGardener::getCommTypeInfo($areaAndBlockIds);
     //批量获取默认图片
     $propDefImages = Model_House_AjkPropertyData::getDafImages($propIds);
     //批量获取房源描述信息 ajk_propertysale
     $houseExtInfo = Model_House_PropertySale::getPropertySaleInfos($propIds);
     $propList = array();
     foreach ($tempHouseInfoList as $house) {
         $row = array();
         $row['propId'] = $house['proId'];
         $row['title'] = $house['proName'];
         $row['commId'] = $house['commId'];
         $row['commName'] = $house['commName'];
         $areaId = substr($house['areaCode'], 0, 8);
         $blockId = $house['areaCode'];
         $row['areaName'] = $commTypeInfos[$areaId];
         $row['blockName'] = $commTypeInfos[$blockId];
         $row['room'] = $house['roomNum'];
         $row['hall'] = $house['hallNum'];
         $row['toilet'] = $house['toiletNum'];
         $row['area'] = round($house['areaNum']);
         $row['areaUnit'] = '平米';
         $row['price'] = intval($house['proPrice']);
         $row['priceUnit'] = '万';
         //房源描述
         $propDescription = $houseExtInfo[$row['propId']]['addExplan'];
         $propDescription = str_replace('<p>', "", $propDescription);
         $propDescription = str_replace('</p>', "", $propDescription);
         $propDescription = trim($propDescription);
         $row['propDescription'] = $propDescription;
         $row['imageUrl'] = Model_House_AjkPropertyData::imageUrl($propDefImages[$house['proId']]);
         $row['previewUrl'] = Bll_Weshop::getPropPreviewUrl(array('brokerId' => $brokerId, 'propId' => $row['propId']));
         $propList[] = $row;
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propList' => $propList));
 }
Beispiel #7
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' => '导入成功'));
 }
Beispiel #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));
 }