Exemple #1
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();
 }
 /**
  * 判断小区是否是完善小区
  *
  * @param array $communityInfo
  * @return bool
  */
 public static function checkCommunityIsComplete($communityInfo)
 {
     $checkCommunityCompleteFields = array('baseInfo' => array('commLocal', 'useType'), 'extendInfo' => array('commBuilder', 'manageCompany', 'managePay', 'buildArea', 'carbarnState', 'containPert', 'greenPert', 'houseTotal', 'sendDate', 'commIntro', 'commOther'));
     $lockMapping = array('commOtherName' => 1, 'commLocal' => 2, 'useType' => 3, 'commBuilder' => 4, 'manageCompany' => 5, 'managePay' => 6, 'buildArea' => 7, 'carbarnState' => 8, 'containPert' => 9, 'greenPert' => 10, 'houseTotal' => 11, 'sendDate' => 12, 'commIntro' => 13, 'commOther' => 14);
     $communityId = $communityInfo['baseInfo']['commId'];
     $communityLockInfo = Bll_Community_CommunityGardener::getCommunityWikiInfo($communityId);
     foreach ($checkCommunityCompleteFields as $infoType => $checkFields) {
         if (!isset($communityInfo[$infoType]) || empty($communityInfo[$infoType]) || !is_array($communityInfo[$infoType])) {
             return false;
         }
         foreach ($checkFields as $checkField) {
             if (isset($communityLockInfo[$lockMapping[$checkField]]) && $communityLockInfo[$lockMapping[$checkField]] != 1) {
                 continue;
             }
             if (!isset($communityInfo[$infoType][$checkField]) || empty($communityInfo[$infoType][$checkField])) {
                 return false;
             }
         }
     }
     /** 判断小区图片是否满10张 */
     $communityImageCount = Model_Community_Attachment::getCommunityPictureCount($communityId);
     if ($communityImageCount < 10) {
         return false;
     }
     return true;
 }
 public function handle_request_abs()
 {
     $action = $this->getParameter(static::ACTION);
     $this->setAttribute('show_searchbar', false);
     /** 小区可以纠错的信息 */
     $communityInfo = $this->getCommunityCorrectInfo($this->communityInfo);
     /**
      * 所有字段都锁定(除小区别名)的情况下,直接跳到下一步,第一步基础详情纠错不展示
      */
     if ($this->baseInfoIsLocked) {
         if ($this->isLockMap) {
             if ($this->communityImageCount <= 0) {
                 if (Bll_Community_CommunityGardener::setCheckGardener($this->communityId, static::$intBrokerID)) {
                     $this->setAttribute('isOk', 1);
                 } else {
                     $this->setAttribute('isOk', 2);
                 }
                 return 'Community_Gardener_PhotoCommitOk';
             }
             $this->redirect(Bll_Community_CommunityGardener::buildGardenerPhotoCommit($this->communityId, array(self::VERIFY => $this->verifyCode)));
         } else {
             $this->redirect(Bll_Community_CommunityGardener::buildGardenerCorrectMap($this->communityId, array(self::VERIFY => $this->verifyCode)));
         }
     }
     /** 获取 物业类型 */
     $typeList = Model_Community_UseType::getUseTypeByCityId($communityInfo['cityId']);
     /** 小区锁定字段信息 */
     $communityWikiLockInfo = Bll_Community_CommunityGardener::getCommunityWikiInfo($this->communityId);
     /** 经纪人未完成的记录 */
     $applyHistory = Bll_Community_CommunityGardener::getBrokerUnfinishedApply($this->communityId, static::$intBrokerID);
     if ($action == 'save') {
         //用于保存小区基本信息的纠错
         $a = $this->checkAndSaveCorrectData(static::$intBrokerID, $communityWikiLockInfo, $this->getParameters(), $typeList, $applyHistory['applyData']);
         // if ($a || !empty($applyHistory['applyData']) || $this->communityGardenerId == 0) {
         if ($a) {
             if ($this->isLockMap) {
                 if ($this->communityImageCount <= 0) {
                     if (Bll_Community_CommunityGardener::setCheckGardener($this->communityId, static::$intBrokerID)) {
                         $this->setAttribute('isOk', 1);
                     } else {
                         $this->setAttribute('isOk', 2);
                     }
                     return 'Community_Gardener_PhotoCommitOk';
                 }
                 $this->redirect(Bll_Community_CommunityGardener::buildGardenerPhotoCommit($this->communityId, array(self::VERIFY => $this->verifyCode)));
             } else {
                 $this->redirect(Bll_Community_CommunityGardener::buildGardenerCorrectMap($this->communityId, array(self::VERIFY => $this->verifyCode)));
             }
         } else {
             $this->redirect(Bll_Community_CommunityGardener::buildGardenerCorrectInfo($this->communityId, array(self::VERIFY => $this->verifyCode)));
         }
     }
     $hasCorrectInfo = false;
     if (!empty($applyHistory['applyData'])) {
         $applyData = json_decode($applyHistory['applyData'], true);
         unset($applyData['map'], $applyData['images']);
         $hasCorrectInfo = !empty($applyData);
     }
     $this->setAttribute('typeList', $typeList);
     $this->setAttribute('applyHistory', $applyHistory);
     $this->setAttribute('hasCorrectInfo', $hasCorrectInfo);
     $this->setAttribute('commInfo', $communityInfo);
     $this->setAttribute('infoLock', $communityWikiLockInfo);
     $this->setAttribute('brokerid', static::$intBrokerID);
     $this->setAttribute('existGardener', $this->communityGardenerId > 0);
     $this->setAttribute('fields', self::$fields);
     $this->setAttribute('facilities', self::$facilities);
     return 'Community_Gardener_CorrectInfo';
 }