public function handle_request_internal() { if (!$this->isBrokerLogin()) { echo json_encode(array('error' => -5, 'msg' => '请先登入!')); return; } /** * @var $request AJKRequest */ $request = APF::get_instance()->get_request(); $propertyId = $request->get_parameter('property_id'); $loadField = array('isDel', 'isActived', 'cityId', 'districtId', 'blockId', 'pointStatus'); $propertyInfo = Model_House_JpProperty::getPropertyById($propertyId, $loadField); if (empty($propertyInfo)) { $this->responseJSON(false, array('msg' => '没有获取到物业信息')); return; } if ($propertyInfo['isDel']) { $this->responseJSON(false, array('msg' => '物业已经删除')); return; } $propertyMap = Model_Jinpu_MapProperty::getPropertyMapById($propertyId); if (empty($propertyMap)) { $this->responseJSON(false, array('msg' => '没有获取到物业坐标信息')); return; } $this->responseJSON(true, $propertyMap); }
/** * @param $id * @return array|mixed|null */ public static function getProperty($id) { $DObject = null; $da = Model_House_JpProperty::data_access(); $da->force_master = true; try { $DObject = $da->find_by_pk($id); } catch (Exception $e) { } unset($da); /* if (isset($DObject->type)) { $property_type = self::get_property_type_info($DObject->type); if ($property_type) { $DObject->property_type_name = $property_type->name; } else { $DObject->property_type_name = ''; } } */ return $DObject; }
/** * @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; }
public static function getSubregionId($propertyId, $type, $blockId) { $propertyInfo = Model_House_JpProperty::data_access()->filter('id', $propertyId)->get_row(); if (empty($propertyInfo)) { return 0; } return $propertyInfo['isRoad'] && $type > 2 ? $blockId : $propertyInfo['blockId']; }
/** * 修改物业表,如果物业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更新成功'); }
public static function get_property_by_ids($ids) { $DProperty = Model_House_JpProperty::data_access()->filter('id', $ids)->get_all(); return $DProperty; }
/** * 商铺物业板块变更,处理自选房源 * * @param $cityId * @param $oldBlockId * @param $newBlockId * @param $houseType * @param $houseLogType * @param $actionType * @return array * @throws Exception */ public static function dealRoadPropertyAreaChange($cityId, $oldBlockId, $newBlockId, $houseType, $houseLogType, $actionType) { $useBusinessCycleConfigOption = array(Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_RENT => 'clues_search_condition_shop_rent_list_switch', Model_House_JpHouseIdx::ENUM_HOUSE_TYPE_SHOP_SALE => 'clues_search_condition_shop_sale_list_switch'); $useBusinessCycleConfig = APF::get_instance()->get_config($useBusinessCycleConfigOption[$houseType], 'jpmulticity'); $useBusinessCycle = isset($useBusinessCycleConfig[$cityId]) && $useBusinessCycleConfig[$cityId]; if ($useBusinessCycle) { $oldBusinessCycleId = Model_Jinpu_NewShopBusinessBlockMap::getNewBusinessCycleByOldBlockId($oldBlockId); $choicePlanList = Model_Plan_Jp::getValidChoicePlanByBlockIdAndNewBlockId($oldBlockId, $oldBusinessCycleId, $houseType); } else { $choicePlanList = Model_Plan_Jp::getValidChoicePlanByBlockIdAndNewBlockId($oldBlockId, 0, $houseType); } $rtn = array(); foreach ($choicePlanList as $choicePlan) { $houseInfo = Model_House_JpHouseIdx::getHouseInfoById($choicePlan['houseId']); if (empty($houseInfo)) { $rtn[] = sprintf('没有获取到房源[%d]信息', $choicePlan['houseId']); continue; } if ($houseInfo['isDelete'] != 0) { $rtn[] = sprintf('房源[%d]已删除', $choicePlan['houseId']); continue; } $propertyInfo = Model_House_JpProperty::getPropertyById($houseInfo['propertyId']); if (empty($propertyInfo)) { $rtn[] = sprintf('物业[%d]没有获取到', $houseInfo['propertyId']); continue; } if ($propertyInfo['isRoad'] != 1) { $rtn[] = sprintf('物业[%d]非道路型,不处理', $houseInfo['propertyId']); continue; } $houseLog = array(); $houseLog['houseId'] = $choicePlan['houseId']; $houseLog['planId'] = $choicePlan['id']; $houseLog['brokerId'] = $choicePlan['ajkBrokerId']; $houseLog['cityId'] = $choicePlan['cityId']; $houseLog['type'] = $houseLogType; $houseLog['changeType'] = $actionType; $houseLog['remark'] = sprintf('房源所在物业、写字楼板块发生变更[%d -> %d]', $oldBlockId, $newBlockId); $houseLog['addDate'] = date('Y-m-d H:i:s'); $houseLog['operatorId'] = 0; $houseLog['siteType'] = 3; if (!Model_Log_HouseLogNew::create($houseLog, date('Ymd'))->save()) { $rtn[] = sprintf('板块变更房源[%d]日志写入失败', $choicePlan['houseId']); continue; } $rtn[] = sprintf('板块变更房源[%d]日志写入成功', $choicePlan['houseId']); } return $rtn; }
/** * 精选计划板块变更 * * @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)); }