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' => '删除成功')); }
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); }
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' => '保存成功')); }
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)); }