/** * 修改物业表,如果物业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)); }