示例#1
0
 public function handle_request_internal()
 {
     $params = APF::get_instance()->get_request()->get_parameters();
     $districtId = intval($params['q']);
     if ($districtId > 0) {
         $blocks = Model_Jinpu_DistrictBlock::data_access()->filter(Model_Jinpu_DistrictBlock::DISTRICT_ID, $districtId)->sort(Model_Jinpu_DistrictBlock::DISPLAY_ORDER, 'asc')->get_all();
         $return = array();
         if (!empty($blocks)) {
             foreach ($blocks as $block) {
                 $blockInfo = Model_Jinpu_Block::data_access()->filter('id', $block['blockId'])->get_row();
                 if (!empty($blockInfo) && $blockInfo['isActived'] == 1) {
                     $return[] = $blockInfo;
                 }
             }
             echo json_encode(array('status' => 'ok', 'data' => $return));
             die;
         }
     }
     echo json_encode(array('status' => 'error', 'data' => array()));
     die;
 }
 /**
  * 修改物业表,如果物业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更新成功');
 }