Ejemplo n.º 1
0
 public function handle_request_internal()
 {
     /**
      * @var $request AJKRequest
      */
     $request = APF::get_instance()->get_request();
     $response = APF::get_instance()->get_response();
     $params = $this->getParameters();
     $route_matches = $request->get_router_matches();
     $brokerId = $request->getBrokerId();
     $cityId = $request->getBrokerCityId();
     $userId = $request->getUserId();
     $business = trim($route_matches[1]);
     $prop_id = $route_matches[2];
     if (empty($brokerId)) {
         $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query(array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '请登陆操作', 'from' => 'bid_blockset'))));
         return false;
     }
     $isChoiceCity = false;
     $isChoiceCityTwo = false;
     switch ($business) {
         case 'ajk':
             $isChoiceCity = Bll_City::isBlockChoice($cityId, Const_Site::ANJUKE);
             //修改表city_biz_types 的type还有配置
             $isChoiceCityTwo = Bll_City::isChoiceCity($cityId, Const_Site::ANJUKE);
             break;
     }
     if (!$isChoiceCity) {
         $response->redirect('/user/combo/brokerhome?from=not_choice_city');
         return false;
     }
     //return 'Choice_BlockSet';
     //验证choice城市
     $config = Model_Config_CommonCity::getConfig(Model_Config_CommonCity::CHOICENAME, $cityId);
     /** 判断精选计划开启时间是否到了 */
     //$request->set_attribute('choiceStarted', time()<$config['startTime']);
     $request->set_attribute('choiceStarted', !$this->getCityOpenTimeBegin($config['startTime']));
     $request->set_attribute('choiceStartTimeMsg', sprintf('%d点准时开放', date('H', $config['startTime'])));
     /*if(time()<$config['startTime']){
           $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query(array('err_no'=>Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg'=>'还未到精选房源开始时间。', 'from'=>'bid_blockset'))));
           return false;
       }*/
     if (empty($route_matches) || count($route_matches) < 3) {
         $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query(array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '请从精选房源管理页设置精选房源计划', 'from' => 'bid_blockset'))));
         return false;
     }
     if (!is_numeric($route_matches[2])) {
         $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query(array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '房源ID必须是数字', 'from' => 'bid_blockset'))));
         return false;
     }
     $params['ip'] = $request->get_client_ip();
     //        var_dump($business);exit;
     if ($request->is_post_method()) {
         switch ($business) {
             case 'ajk':
                 try {
                     $result = Bll_Plan_Bid_BlockChoice::esf_setting_post($brokerId, $cityId, $prop_id, $userId, $params);
                 } catch (Exception $e) {
                     $result = array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '服务器繁忙,请重试');
                 }
                 break;
             default:
                 $result = http_build_query(array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '参数错误。', 'from' => 'bid_blockset'));
                 break;
         }
         $result = array_merge($result, array('act' => $business, 'propId' => $prop_id));
         $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query($result)));
         return false;
     }
     switch ($business) {
         case 'ajk':
             try {
                 $pageAttributes = Bll_Plan_Bid_BlockChoice::esf_setting($brokerId, $cityId, $prop_id, $userId, $params);
             } catch (Exception $e) {
                 $pageAttributes = array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '服务器繁忙,请重试');
             }
             break;
         default:
             $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query(array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => '参数错误。', 'from' => 'bid_blockset'))));
             break;
     }
     if (isset($pageAttributes['err_no'])) {
         $result = array('err_no' => Bll_Plan_Bid_BlockChoice::BID_FAIL_OTHER, 'err_msg' => $pageAttributes['err_msg'], 'from' => 'bid_blockset');
         $result = array_merge($result, array('act' => $business, 'propId' => $prop_id));
         $response->redirect(Util_Url::buildChoiceResultUrl(http_build_query($result)));
         return false;
     }
     $request->set_attribute('isChoiceCityTwo', $isChoiceCityTwo);
     $request->set_attribute('isChoiceCity', $isChoiceCity);
     $request->set_attribute('business', $business);
     $request->set_attribute('prop_id', $prop_id);
     $this->set_attributes($pageAttributes);
     /**
      * 2015 年关精选打折 预计时间2.1 ~ 3.5
      * TODO 2015.4.1 删除这部分代码
      */
     $isChoiceRebate = Bll_Onoff_Choice::getChoiceRebateByBroekrId($brokerId);
     $this->setAttribute('isChoiceRebate', $isChoiceRebate);
     switch ($business) {
         case 'jp':
             return 'Choice_BlockSetJP';
             break;
         default:
             return 'Choice_BlockSet';
     }
 }
Ejemplo n.º 2
0
 /**
  * 获取 配置
  *
  * @param $name
  * @param $cityId
  * @return array
  */
 public static function getConfig($name, $cityId)
 {
     try {
         $config = Model_Config_CommonCity::data_access()->filter('name', $name)->filter('cityId', $cityId)->get_row();
     } catch (Exception $e) {
         return array();
     }
     if (is_null($config)) {
         return array();
     }
     return $config;
 }