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']; $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' => '导入成功')); }
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)); }
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)); }