public function handle_request_internal()
 {
     if (!Bll_City::isNewCommunityApplyCity(static::$intBrokerCityID)) {
         $this->redirect('/ajkbroker/broker/applygardener/?from=illegal_request');
     }
     $params = $this->getParameters();
     $page = isset($params['p']) ? max(1, $params['p']) : 1;
     $applyCommunityGardenerAd = Bll_Community_CommunityGardener::getCommunityGardenerApplyBannerAdInfo(static::$intBrokerCityID);
     if (!empty($applyCommunityGardenerAd)) {
         $this->setAttribute('applyCommunityGardenerAd', $applyCommunityGardenerAd[0]);
     }
     $houseCommunityInfo = Bll_Community_CommunityGardener::getBrokerOnlineHouseCommunityInfo(static::$intBrokerID, static::$intBrokerCityID, array('commId', 'commName', 'showDay', 'showDate'));
     $communityIds = $this->getCommunityIdFromHouseInfo($houseCommunityInfo);
     sort($communityIds, SORT_NUMERIC);
     $communityInfoList = array();
     foreach ($communityIds as $communityId) {
         $communityInfo = Bll_Community_CommunityGardener::getCommunityDetail($communityId);
         /** 过滤掉隐藏小区 */
         if ($communityInfo['baseInfo']['typeFlag'] == 0) {
             continue;
         }
         $communityInfoList[] = $communityInfo;
     }
     /** 移除完善小区 */
     $canApplyCommunityList = $this->removeCompleteCommunity($communityInfoList);
     if (!empty($canApplyCommunityList)) {
         $communityCount = count($canApplyCommunityList);
         /** 如果当前页大于最大页数,则跳转至第一页 */
         if ($page > ceil($communityCount / self::PAGE_SIZE)) {
             $this->redirect(BASE_URI . '/broker/applygardener2/?from=error_page_number');
         }
         //usort($canApplyCommunityList, array($this, 'sortCommunity'));
         $communityList = array_slice($canApplyCommunityList, ($page - 1) * self::PAGE_SIZE, self::PAGE_SIZE);
         $communityIds = $this->getCommunityIdFromCommunityInfo($communityList);
         /** 获取小区的小区园丁状态 */
         $communityStateInfoList = Bll_Community_CommunityGardener::getMultiCommunityApplyInfo($communityIds);
         /** 转换小区园丁的列表为以小区ID为key */
         $communityStateInfoList = $this->changeCommunityStateInfoList2CommunityId($communityStateInfoList);
         /** TODO 拼接小区申请额外信息 */
         $canApplyCommunityStateList = $this->initCommunityGardenerStateInfo($communityList, $communityStateInfoList, static::$intBrokerID);
         // if (!empty($canApplyCommunityStateList['gardenerIds'])) {
         //    $gardenerInfoList = Bll_Community_CommunityGardener::getMultiBrokerInfo($canApplyCommunityStateList['gardenerIds'], array('brokerId', 'trueName'));
         //    $this->setAttribute("gardenerInfos", $gardenerInfoList);
         // }
         /** 分页信息 */
         $multiPageShow = false;
         if ($communityCount > self::PAGE_SIZE) {
             $multiPage = $this->getMultiPage(array('p' => $page), $communityCount, self::PAGE_COUNT, self::PAGE_SIZE);
             $multiPageShow = true;
             $this->setAttribute("multipage", $multiPage);
         }
         $this->setAttribute("commCount", $communityCount);
         $this->setAttribute("BrokerId", static::$intBrokerID);
         $this->setAttribute("multipageShow", $multiPageShow);
         $this->setAttribute("onlineCommInfos", $canApplyCommunityStateList['communityList']);
     }
     return 'Broker_CommunityApplyGardeners2';
 }
Exemple #2
0
 public function handle_request_internal()
 {
     $this->communityId = $this->getCommunityId();
     $this->setAttribute('show_searchbar', false);
     /** 判断小区地图是都已经锁定 */
     $this->isLockMap = Bll_Community_CommunityGardener::checkCommunityMapIsLock($this->communityId);
     $this->setAttribute('isLockMap', $this->isLockMap);
     /** 获取小区当前的图片数量 */
     $this->communityImageCount = self::COMMUNITY_PHOTO_COUNT - intval(Model_Community_Attachment::getCommunityPictureCount($this->communityId));
     $this->setAttribute('brokerShouldUploadPhotoCount', $this->communityImageCount);
     /** 获取小区详细信息 */
     $this->communityInfo = Bll_Community_CommunityGardener::getCommunityDetail($this->communityId);
     /** 如果是隐藏小区,那么就直接跳转到小区详情页 */
     $this->isHiddenCommunity($this->communityInfo);
     $communityWikiInfo = Bll_Community_CommunityGardener::getCommunityWikiInfo($this->communityId);
     if (!empty($communityWikiInfo)) {
         $this->baseInfoIsLocked = true;
         for ($fieldIndex = 2; $fieldIndex < 15; $fieldIndex++) {
             if (!isset($communityWikiInfo[$fieldIndex]) || $communityWikiInfo[$fieldIndex] == 1) {
                 $this->baseInfoIsLocked = false;
                 break;
             }
         }
     }
     $this->setAttribute('baseInfoIsLocked', $this->baseInfoIsLocked);
     /** TODO 判断是否是完善小区 */
     if (Bll_Community_CommunityGardener::checkCommunityIsComplete($this->communityInfo)) {
         $this->setAttribute('isOk', 3);
         return 'Community_Gardener_PhotoCommitOk';
     }
     /** 验证码 */
     $this->verifyCode = Bll_Community_CommunityGardener::getVerifyCode($this->communityId, static::$intBrokerID);
     $this->setAttribute('verify', $this->verifyCode);
     /** TODO 判断小区园丁申请是否有效 */
     if (!$this->checkApplyIsValid($this->communityId, static::$intBrokerID, $this->getParameter('verify'))) {
         $this->setAttribute('isOk', 2);
         return 'Community_Gardener_PhotoCommitOk';
     }
     /** TODO 过滤小区信息 */
     /** TODO 初始化小区信息 */
     $this->setAttributes($this->communityInfo);
     $this->setAttribute('commId', $this->communityId);
     return $this->handle_request_abs();
 }
 public function handle_request_internal()
 {
     if (!Bll_City::isNewCommunityApplyCity(static::$intBrokerCityID)) {
         $this->redirect2Result(false, '非法请求', __LINE__);
     }
     $request = APF::get_instance()->get_request();
     $params = $this->getParameters();
     $verifyCode = $params[self::VERIFY];
     $matches = $request->get_router_matches();
     $communityId = intval($matches[1]);
     $brokerId = static::$intBrokerID;
     if ($verifyCode != Bll_Community_CommunityGardener::getVerifyCode($communityId, $brokerId)) {
         $this->redirect2Result(false, '请求不合法', __LINE__);
     }
     $communityInfo = Bll_Community_CommunityGardener::getCommunityDetail($communityId);
     if ($communityInfo['baseInfo']['typeFlag'] == 0) {
         $this->redirect2Result(false, '小区不存在', __LINE__);
     }
     if (!Bll_Community_CommunityGardener::checkCommunityCanApply($communityId, $brokerId, true)) {
         $this->redirect2Result(false, '小区不可以申请', __LINE__);
     }
     $communityGardenerApplyState = Bll_Community_CommunityGardener::getCommunityGardenerState($communityId);
     if (empty($communityGardenerApplyState)) {
         if (!Bll_Community_CommunityGardener::initCommunityGardenerState($communityId, $brokerId)) {
             $this->redirect2Result(false, '初始化小区状态失败', __LINE__);
         }
     } elseif ($communityGardenerApplyState['state'] == Model_Community_CommunityState::COMMUNITY_STATE_CHECKING) {
         $this->redirect2Result(false, '审核中的小区不允许申请', __LINE__);
     } elseif ($communityGardenerApplyState['state'] == Model_Community_CommunityState::COMMUNITY_STATE_APPLYING) {
         //状态为锁定
         if ($communityGardenerApplyState['applyExpirationTime'] < time()) {
             //锁定时间过期
             //重新锁定
             if (!Bll_Community_CommunityGardener::lockCommunityGardenerApply($communityId, $brokerId)) {
                 $this->redirect2Result(false, '锁定小区申请状态失败', __LINE__);
             }
         } else {
             //锁定时间未过期
             //别人不能申请
             if ($communityGardenerApplyState['applyBrokerId'] != $brokerId) {
                 $this->redirect2Result(false, '小区正在被申请', __LINE__);
             }
         }
     } else {
         if (!Bll_Community_CommunityGardener::lockCommunityGardenerApply($communityId, $brokerId)) {
             $this->redirect2Result(false, '锁定小区申请状态失败', __LINE__);
         }
     }
     $action = $params[self::ACTION];
     $applyHistory = Bll_Community_CommunityGardener::getBrokerUnfinishedApply($communityId, $brokerId);
     $history = array();
     if (!empty($applyHistory) && !empty($applyHistory['applyData'])) {
         $history = json_decode($applyHistory['applyData'], true);
     }
     // $communityImageList = Bll_Community_CommunityGardener::getValidateCommunityImagesList($communityId);
     // $communityImageCount = count($communityImageList);
     // $brokerShouldUploadPhotoCount = max(0, Bll_Community_CommunityGardener::COMMUNITY_IMAGE_BASE_COUNT - $communityImageCount);
     $brokerShouldUploadPhotoCount = Bll_Community_CommunityGardener::COMMUNITY_IMAGE_BASE_COUNT;
     if ($action == 'save') {
         $image = array();
         foreach ($params as $key => $val) {
             $keyName = explode('_', $key);
             if (isset($keyName[1]) && in_array($keyName[0], array('host', 'hash', 'content'))) {
                 if ($keyName[0] == 'content') {
                     $val = Util_PublicMethods::cutStr($val, 50);
                 }
                 $image[$keyName[1]][$keyName[0]] = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401 | ENT_IGNORE, 'UTF-8');
             } else {
                 continue;
             }
         }
         if (count($image) >= $brokerShouldUploadPhotoCount) {
             $uploadedImageList = array_values($image);
             $history['images'] = array_slice($uploadedImageList, 0, Bll_Community_CommunityGardener::COMMUNITY_IMAGE_COUNT_LIMIT);
             $storeSuccess = Bll_Community_CommunityGardener::storeApplyCommunityCorrectData($communityId, $brokerId, static::$intBrokerCityID, $history, Model_Community_GardenerApply::APPLY_STATUS_PENDING_APPROVAL);
             if ($storeSuccess) {
                 Model_Community_CommunityState::setCheckGardener($communityId, $brokerId);
                 $this->redirect2Result(true, '小区申请成功', __LINE__);
             }
             $this->redirect2Result(false, '保存图片信息失败', __LINE__);
         }
         $this->redirect2Result(false, '提交的图片数量不够', __LINE__);
     }
     $hasCorrectPhoto = !empty($history['images']);
     $this->setAttribute('brokerShouldUploadPhotoCount', $brokerShouldUploadPhotoCount);
     $this->setAttribute('brokerUploadPhotoCountLimit', Bll_Community_CommunityGardener::COMMUNITY_IMAGE_COUNT_LIMIT);
     $this->setAttribute('hasCorrectPhoto', $hasCorrectPhoto);
     $this->setAttribute('updatedImageList', isset($history['images']) ? $history['images'] : array());
     $this->setAttribute('brokerId', $brokerId);
     $this->setAttribute('communityInfo', $communityInfo['baseInfo']);
     $this->setAttribute('verify', $verifyCode);
     return 'Community_Gardener2_PhotoCommit';
 }