/** * @param $cityId * @param $q * @param $pb * @param int $limit * @param int $memberId * @return mixed */ public static function getJpSearchProperty($cityId, $q, $pb, $memberId, $limit = 0) { $limit = $limit > 0 ? $limit : 10; $solr = ''; if ($pb == 'building') { $solr = new Solr_SolrList('solrJpBuildingServer', true, false); } elseif ($pb == 'property') { $solr = new Solr_SolrList('solrJpPropertyServer', true, false); } $buildings = array(); $solr->set_row($limit); $solr->set_q($q); $solr->set_fq('city_id:' . $cityId); if ($pb == 'property') { $solr->set_sort('is_spider asc,type asc'); } $url = $solr->get_lucene_uri('', false, false); $json_data = $solr->get_result_from_lucene($url); $solrData = Solr_SolrList::get_properties($json_data); $solrIds = array(); foreach ($solrData as $solr) { $solrIds[] = $solr['id']; } //var_dump($solrIds);die; if (!empty($solrIds)) { $temp = array(); if ($pb == 'building') { $temp = Model_House_JpBuilding::data_access()->filter(Model_House_JpBuilding::ID, $solrIds)->filter(Model_House_JpBuilding::IS_ACTIVED, Model_House_JpBuilding::ENUM_IS_ACTIVED_YES)->limit($limit)->get_all(); } elseif ($pb == 'property') { $temp = Model_House_JpProperty::data_access()->filter('id', $solrIds)->filter('isActived', Model_House_JpProperty::ENUM_IS_ACTIVED_YES)->sort('isSpider')->limit($limit)->get_all(); } $cityIds = $districtIds = $blockIds = array(); foreach ($temp as $tmp) { $cityIds[] = $tmp['cityId']; $districtIds[] = $tmp['districtId']; $blockIds[] = $tmp['blockId']; } $cityIds = array_unique($cityIds); $districtIds = array_unique($districtIds); $blockIds = array_unique($blockIds); $citys = $districts = $blocks = array(); if ($cityIds) { $citysT = Model_Jinpu_City::data_access()->filter('id', $cityIds)->get_all(); foreach ($citysT as $c) { $citys[$c['id']] = $c['name']; } } if ($districts) { $districtsT = Model_Jinpu_District::data_access()->filter('id', $districtIds)->get_all(); foreach ($districtsT as $d) { $districts[$d['id']] = $d['name']; } } if ($blockIds) { $blocksT = Model_Jinpu_Block::data_access()->filter('id', $blockIds)->get_all(); foreach ($blocksT as $d) { $blocks[$d['id']] = $d['name']; } } foreach ($temp as $b) { $allLock = BLL_House_JpProperty::getBuildingLockById($b['id']); $buildings[] = array('id' => $b['id'], 'district_id' => $b['districtId'], 'block_id' => $b['blockId'], 'name' => $b['name'] . ($pb == 'property' ? '商铺' : ''), 'city' => empty($citys[$b['cityId']]) ? '' : $citys[$b['cityId']], 'district' => empty($districts[$b['districtId']]) ? '' : $districts[$b['districtId']], 'block' => empty($blocks[$b['blockId']]) ? '' : $blocks[$b['blockId']], 'business_cycle' => empty($b['businessCycle']) ? '' : $b['businessCycle'], 'address' => empty($b['address']) ? '' : $b['address'], 'manage_fee' => empty($b['manageFee']) ? '' : $b['manageFee'], 'property_company' => $b['propertyCompany'], 'has_uploaded_image' => BLL_House_JpProperty::hasLibrary($memberId, $b['id'], $pb), 'property_company_lock' => isset($allLock['property_company']) && $allLock['property_company'] || $b['isNew'] ? 1 : 0); } } return $buildings; }
/** * 修改物业表,如果物业office_state=1更新写字楼表 * @param $task * @return mixed * @throws Exception */ private function updatePropertyInfo($task) { //check 信息 $this->propertyInfo = $propertyInfo = Model_House_JpProperty::getPropertyById($task['propertyId']); if (trim($propertyInfo['name']) != trim($task['propertyName'])) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:该物业id和名称不匹配')); return array('code' => 'error', 'message' => '该物业id和名称不匹配'); } $districtInfo = Model_Jinpu_District::getDistrictInfoByName(trim($task['newAreaName'])); if (empty($districtInfo)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:新的区域名称不存在')); return array('code' => 'error', 'message' => '新的区域名称不存在'); } if ($districtInfo['city_id'] != $task['cityId']) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:新的区域所属城市不匹配')); return array('code' => 'error', 'message' => '新的区域所属城市不匹配'); } $this->newDistrictId = $districtInfo['id']; $blockInfos = Model_Jinpu_Block::getBlockInfoByName(trim($task['newBlockName'])); if (empty($blockInfos)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:新的板块名称不存在')); return array('code' => 'error', 'message' => '新的板块名称不存在'); } $blockList = Model_Jinpu_DistrictBlock::getBlockListByDistrictId($districtInfo['id']); $blockIds = array(); foreach ($blockList as $val) { $blockIds[] = $val['blockId']; } $districtBlockRelation = false; foreach ($blockInfos as $key => $val) { if (in_array($val['id'], $blockIds)) { $districtBlockRelation = true; $this->newBlockId = $val['id']; $blockInfo = $val; break; } } if ($districtBlockRelation == false) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:新的板块和新的区域对应关系错误')); return array('code' => 'error', 'message' => '新的板块和新的区域对应关系错误'); } if (empty($this->newDistrictId) || empty($this->newBlockId)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更信息验证【 失败 】; 处理id:' . $task['id'] . '; msg:新的板块或者新的区域id为空')); return array('code' => 'error', 'message' => '新的板块或者新的区域id为空'); } //todo 修改物业表 $where = array('id' => $task['propertyId']); $data = array('districtId' => $districtInfo['id'], 'blockId' => $blockInfo['id']); if (!Model_House_JpProperty::updateInfo($where, $data)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更【 失败 】; 物业id:' . $task['propertyId'] . '; msg:物业区域板块更新表')); } else { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业变更【 成功 】; 物业id:' . $task['propertyId'] . '; msg:物业区域板块更新表')); } //todo 通知solr $ret = $this->get_new_district_business_by_old_block($blockInfo['id']); $propertyDataInfo = array('id' => $propertyInfo['id'], 'city_id' => $propertyInfo['cityId'], 'name' => $propertyInfo['name'], 'match_name' => $propertyInfo['name'], 'address' => $propertyInfo['address'], 'is_road' => $propertyInfo['isRoad'], 'district_id' => $districtInfo['id'], 'district_name' => $districtInfo['name'], 'block_id' => $blockInfo['id'], 'block_name' => $blockInfo['name'], 'new_district_id' => $ret['new_district_id'], 'new_district_name' => $ret['new_district_name'], 'new_business_id' => $ret['new_business_id'], 'new_business_name' => $ret['new_business_name']); $count = 0; while (true) { if ($count >= 3) { break; } $updatePropertySolrResult = $this->updateSolrPropertyData($task['propertyId'], $propertyDataInfo); if ($updatePropertySolrResult['responseHeader']['status'] == 0) { break; } else { $count++; } } if ($updatePropertySolrResult['responseHeader']['status'] != 0) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业更新solr【 失败 】; 物业id:' . $task['propertyId'] . '; msg:物业区域板块更新solr; data:' . json_encode($updatePropertySolrResult))); } else { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '物业更新solr【 成功 】; 物业id:' . $task['propertyId'] . '; msg:物业区域板块更新solr;')); } //线上查询solr http://sc10-001.a.ajkdns.com:8983/jp-property-v4/select/?&q=白金湾广场 //todo 如果物业office_state=1更新写字楼表 if ($propertyInfo['officeState'] == 1) { $buildingInfo = Model_House_JpBuilding::getBuildingById($task['propertyId']); if (empty($buildingInfo)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '写字楼变更【 失败 】; 物业id:' . $task['propertyId'] . '; msg:该写字楼不存在')); return array('code' => 'error', 'message' => '该写字楼不存在'); } //todo 修改写字楼表 $where = array('id' => $task['propertyId']); $data = array('districtId' => $districtInfo['id'], 'blockId' => $blockInfo['id']); if (!Model_House_JpBuilding::updateInfo($where, $data)) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '写字楼变更【 失败 】; 写字楼id:' . $task['propertyId'] . '; msg:写字楼区域板块更新表')); } else { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '写字楼变更【 成功 】; 写字楼id:' . $task['propertyId'] . '; msg:写字楼区域板块更新表')); } //todo 通知solr $buildingDataInfo = array('id' => $buildingInfo['id'], 'name' => $buildingInfo['name'], 'address' => $buildingInfo['address'], 'city_id' => $buildingInfo['cityId'], 'completion_data' => $buildingInfo['completion_data'], 'district_id' => $districtInfo['id'], 'district_name' => $districtInfo['name'], 'block_id' => $blockInfo['id'], 'block_name' => $blockInfo['name'], 'new_district_id' => $ret['new_district_id'], 'new_district_name' => $ret['new_district_name'], 'new_business_id' => $ret['new_business_id'], 'new_business_name' => $ret['new_business_name']); //线上查询solr http://sc10-001.a.ajkdns.com:8983/jp-building-v4/select/?&q=白金湾广场 $count2 = 0; while (true) { if ($count2 >= 3) { break; } $updateBuildingSolrResult = $this->updateSolrBuildingData($task['propertyId'], $buildingDataInfo); if ($updateBuildingSolrResult['responseHeader']['status'] == 0) { break; } else { $count2++; } } if ($updateBuildingSolrResult['responseHeader']['status'] != 0) { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '写字楼更新solr【 失败 】; 写字楼id:' . $task['propertyId'] . '; msg:写字楼区域板块更新solr; data:' . json_encode($updatePropertySolrResult))); } else { $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '写字楼更新solr【 成功 】; 写字楼id:' . $task['propertyId'] . '; msg:写字楼区域板块更新solr;')); } } return array('code' => 'success', 'message' => '物业区域板块更新成功 & 物业solr更新成功 & 写字楼区域板块更新成功 & 写字楼solr更新成功'); }
/** * 精选计划板块变更 * * @param array $queueInfo * @return array */ public static function houseBlockChange($queueInfo) { $choicePlanInfo = Model_Plan_Jp::getPlanInfoById($queueInfo['planId'], true); if (empty($choicePlanInfo)) { return self::buildReturn(0, '没有获取到计划'); } if ($choicePlanInfo['status'] != Model_Plan_Jp::ENUM_STATUS_ONLINE && $choicePlanInfo['status'] != Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD) { return self::buildReturn(1, sprintf('计划状态[%d]不处理', $choicePlanInfo['status'])); } /** 获取房源信息 */ $houseInfo = Model_House_JpHouseIdx::getHouseInfoById($choicePlanInfo['houseId']); if (empty($houseInfo)) { return self::buildReturn(0, sprintf('没有获取到房源[%d]信息', $choicePlanInfo['houseId'])); } if ($houseInfo['isDelete'] == Model_House_JpHouseIdx::ENUM_IS_DELETE_YES) { return self::buildReturn(0, sprintf('房源[%d]已经删除[%d]', $choicePlanInfo['houseId'], $houseInfo['isDelete'])); } /** 获取房源的板块id */ if (in_array($houseInfo['houseType'], array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_RENT, Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_OFFICE_SALE))) { $propertyInfo = Model_House_JpBuilding::getBuildingById($houseInfo['propertyId'], array('blockId')); } else { $propertyInfo = Model_House_JpProperty::getPropertyById($houseInfo['propertyId'], array('blockId', 'isRoad')); } $blockId = $propertyInfo['blockId']; /** 商铺自选房源精选板块ID从房源信息表里取 */ if (in_array($houseInfo['houseType'], array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_RENT, Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_SALE)) && $propertyInfo['isRoad'] == 1) { $houseTypeClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfo['houseType']); $extendHouseInfo = $houseTypeClass::getPropInfoById($houseInfo['id']); $blockId = $extendHouseInfo['blockId']; } /** 获取商圈ID */ $businessCycleId = Bll_House_JpHouseInfo::getBusinessCycleId($houseInfo['cityId'], $blockId, $houseInfo['houseType']); /** 更新计划的板块和商圈ID */ if (!Model_Plan_Jp::updatePlanBlockIdAndNewBlockIdById($choicePlanInfo['id'], $blockId, $businessCycleId)) { return self::buildReturn(0, sprintf('更新计划[%d]的板块[%d -> %d]和商圈[%d -> %d]id失败', $choicePlanInfo['id'], $choicePlanInfo['blockId'], $blockId, $choicePlanInfo['newBlockId'], $businessCycleId)); } if (!Model_Choice_JPBidBucket::getBucketInfo($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId'])) { Model_Choice_JPBidBucket::initBucketInfo($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId'], $choicePlanInfo['cityId']); } Model_Choice_JPBidBucket::incrementUsedNumEx($blockId, $businessCycleId, $choicePlanInfo['houseType'], $choicePlanInfo['priceId']); return self::buildReturn(1, sprintf('更新计划[%d]的板块[%d -> %d]和商圈[%d -> %d]id成功', $choicePlanInfo['id'], $choicePlanInfo['blockId'], $blockId, $choicePlanInfo['newBlockId'], $businessCycleId)); }
public static function getBlock($houseType, $houseObj) { $blockArr = array(); $houseType = (int) $houseType; if ($houseType == 1 || $houseType == 2) { $objBuilding = Model_House_JpBuilding::data_access()->find_by_pk($houseObj->buildingId, false); if (empty($objBuilding)) { $objBuilding = Model_House_JpProperty::data_access()->find_by_pk($houseObj->buildingId, false); if (empty($objBuilding)) { return array(); } } $blockArr['blockId'] = $objBuilding->blockId; $blockArr['districtId'] = $objBuilding->districtId; } else { $objProperty = Model_House_JpProperty::data_access()->find_by_pk($houseObj->propertyId); if ($objProperty->isRoad == 1) { $blockArr['blockId'] = $houseObj->blockId; $blockArr['districtId'] = $houseObj->districtId; } else { $blockArr['blockId'] = $objProperty->blockId; $blockArr['districtId'] = $objProperty->districtId; } } if (isset($blockArr['blockId']) && !empty($blockArr['blockId'])) { $blockInfo = Model_Jinpu_Block::data_access()->load_field('name')->filter('id', $blockArr['blockId'])->get_row(); if (!empty($blockInfo)) { $blockArr['name'] = $blockInfo['name']; } } //判断和获取新板块 $arrBlockConfigs = array('1' => 'clues_search_condition_office_rent_list_switch', '2' => 'clues_search_condition_office_sale_list_switch', '3' => 'clues_search_condition_shop_rent_list_switch', '4' => 'clues_search_condition_shop_sale_list_switch'); $strBlockConfig = isset($arrBlockConfigs[$houseType]) ? $arrBlockConfigs[$houseType] : array(); if (empty($strBlockConfig)) { return array(); } $arrBlockConfig = APF::get_instance()->get_config($strBlockConfig, 'jpmulticity'); $intCityId = $houseObj->cityId; $bolUseNewBlock = isset($arrBlockConfig[$intCityId]) ? $arrBlockConfig[$intCityId] : false; if ($bolUseNewBlock) { $arrHouseType = array('1' => 'office_rent', '2' => 'office_sale', '3' => 'shop_rent', '4' => 'shop_sale'); $strHouseType = isset($arrHouseType[$houseType]) ? $arrHouseType[$houseType] : ''; if (empty($strHouseType)) { return array(); } if (in_array($houseType, array(1, 2))) { $DDistrictBusiness = Model_Jinpu_NewBusinessBlockMap::data_access()->filter(Model_Jinpu_NewBusinessBlockMap::OLD_BLOCK, $blockArr['blockId'])->find_only(); } else { $DDistrictBusiness = Model_Jinpu_NewShopBusinessBlockMap::data_access()->filter(Model_Jinpu_NewShopBusinessBlockMap::OLD_BLOCK, $blockArr['blockId'])->find_only(); } $blockArr['newBlockId'] = $DDistrictBusiness->new_business_cycle; try { $businessObj = Model_Jinpu_NewBusinessBlock::data_access()->filter(Model_Jinpu_NewBusinessBlock::IS_ACTIVED, 1)->filter(Model_Jinpu_NewBusinessBlock::ID, $DDistrictBusiness->new_business_cycle)->get_row(); $blockArr['newName'] = $businessObj->name; } catch (Exception $e) { } } return $blockArr; }
/** * @param $buildingId * @return array|mixed|null * @throws Exception */ public static function getBuildingInfo($buildingId) { $DBuilding = (array) BLL_House_JpProperty::getProperty($buildingId); if (!$DBuilding) { return false; } $HBuilding = Model_House_JpBuilding::data_access()->filter(Model_House_JpBuilding::ID, $DBuilding['id'])->get_row(); $DBuilding['manageFee'] = $HBuilding->manageFee; $cityInfo = Model_Jinpu_City::data_access()->filter(Model_Jinpu_City::ID, intval($DBuilding['cityId']))->get_row(); $districtInfo = Model_Jinpu_District::data_access()->filter(Model_Jinpu_District::ID, intval($DBuilding['districtId']))->get_row(); $blockInfo = Model_Jinpu_Block::data_access()->filter('id', intval($DBuilding['blockId']))->get_row(); $DBuilding['cityName'] = $cityInfo['name']; $DBuilding['districtName'] = $districtInfo['name']; $DBuilding['cityName'] = $blockInfo['name']; return $DBuilding; }