Ejemplo n.º 1
0
 /**
  * 获取二手房、好租房源的推广状态
  */
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     if (!$request->is_post_method()) {
         $this->responseJSON('error', array(), '请以POST方式发送请求');
         return;
     }
     $routeMatches = $request->get_router_matches();
     $business = $routeMatches[1];
     /** 处理二手房 */
     if (strcasecmp($business, 'ajk') == 0) {
         $siteType = Bll_Combo_HouseRelation::SITE_TYPE_AJK;
     } elseif (strcasecmp($business, 'hz') == 0) {
         $siteType = Bll_Combo_HouseRelation::SITE_TYPE_HZ;
     } else {
         $this->responseJSON('error', array(), '非法请求');
         return;
     }
     $params = $request->get_parameters();
     if (!isset($params['house_id'])) {
         $this->responseJSON('error', array(), '请提交房源id');
         return;
     }
     if (strpos($params['house_id'], ',') === false) {
         $houseIds = intval($params['house_id']);
     } else {
         $houseIds = explode(',', $params['house_id']);
     }
     $houseComboRelationList = Bll_Combo_HouseRelation::getRelationByHouseIdEx($houseIds, $siteType);
     if (empty($houseComboRelationList)) {
         $this->responseJSON('ok', array(), '没有获取到房源推广信息');
         return;
     }
     $result = array('spread_house' => array(), 'not_spread_house' => array());
     foreach ($houseComboRelationList as $houseComboRelation) {
         if (Bll_Combo_HouseRelation::isRelationOnline($houseComboRelation['state'])) {
             $result['spread_house'][] = $houseComboRelation['houseId'];
         } else {
             $result['not_spread_house'][] = $houseComboRelation['houseId'];
         }
     }
     $this->responseJSON('ok', $result, $request->get_parameter('house_id'));
 }