Ejemplo n.º 1
0
 function get_category_data()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array('classify' => array(), 'brand_list' => array(), 'attribute_list' => array(), 'feature_list' => array());
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         //必须为ajax请求
         if (!$this->is_ajax_request()) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         //数据验证
         if (!isset($request_data['category_id']) || !is_numeric($request_data['category_id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404);
         }
         if ($request_data['category_id'] == 0) {
             //当前站点品牌
             $return_data['brand_list'] = BrandService::get_instance()->get_brands();
             //当前站点规格
             $return_data['attribute_list'] = AttributeService::get_instance()->get_attribute_spec_options();
             //当前站点品牌
             $return_data['feature_list'] = AttributeService::get_instance()->get_attribute_feature_options();
         } else {
             // 调用底层服务
             $category_service = CategoryService::get_instance();
             $classify_service = ClassifyService::get_instance();
             //获取数据
             $category = $category_service->get($request_data['category_id']);
             if ($category['classify_id']) {
                 $return_data['classify'] = $classify_service->get($category['classify_id']);
                 //获取关联品牌数组
                 $return_data['brand_list'] = $classify_service->get_brands_by_classify_id($category['classify_id']);
                 //获取关联规格及规格项数组
                 $return_data['attribute_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_SPEC);
                 //获取关联特性及特性值数组
                 $return_data['feature_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_FEATURE);
             }
         }
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Ejemplo n.º 2
0
 public function put()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         if (empty($request_data['product_id']) or !isset($request_data['relation_ids'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400);
         }
         //* 权限验证 ==根据业务逻辑定制== */
         $product_service = ProductService::get_instance();
         $product_relation_service = Product_relationService::get_instance();
         $product = $product_service->get($request_data['product_id']);
         ORM::factory('product_relation')->where('product_id', $product['id'])->delete_all();
         $query_relation_ids = explode('-', $request_data['relation_ids']);
         $relation_ids = array();
         $products = array();
         $category_ids = array();
         $categorys = array();
         $brand_ids = array();
         $brands = array();
         if (!empty($query_relation_ids)) {
             $query_struct = array('where' => array('id' => $query_relation_ids));
             foreach ($product_service->query_assoc($query_struct) as $relation) {
                 if ($relation['site_id'] == $product['site_id']) {
                     $relation_ids[$relation['id']] = TRUE;
                     $category_ids[$relation['category_id']] = TRUE;
                     if ($relation['brand_id'] > 0) {
                         $brand_ids[$relation['brand_id']] = TRUE;
                     }
                     $products[] = $relation;
                 }
             }
         }
         if (!empty($category_ids)) {
             $query_struct = array('where' => array('id' => array_keys($category_ids)));
             foreach (CategoryService::get_instance()->query_assoc($query_struct) as $category) {
                 $categorys[$category['id']] = $category['title_manage'];
             }
         }
         if (!empty($brand_ids)) {
             $query_struct = array('where' => array('id' => array_keys($brand_ids)));
             foreach (BrandService::get_instance()->query_assoc($query_struct) as $brand) {
                 $brands[$brand['id']] = $brand['name'];
             }
         }
         if (!empty($relation_ids)) {
             foreach ($relation_ids as $key => $val) {
                 $product_relation_service->create(array('product_id' => $product['id'], 'relation_product_id' => $key));
             }
         }
         ProductService::get_instance()->set($product['id'], array('update_timestamp' => time()));
         $list = new View($this->package_name . '/' . $this->class_name . '/list');
         $list->brands = $brands;
         $list->categorys = $categorys;
         $list->products = $products;
         $return_data['relation_ids'] = $relation_ids;
         $return_data['list'] = (string) $list;
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '关联成功!';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             throw new MyRuntimeException();
             // html 输出
             $this->template = new View('layout/empty_html');
             //$this->template->manager_data = $this->manager;
             //* 模板输出 */
             //$this->template->return_struct = $return_struct;
             $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__);
             //* 变量绑定 */
             //$this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
             //:: 当前应用专用数据
             $this->template->content->title = Kohana::config('site.name');
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             //$return_struct['action']['type']= 'close';  // 当前应用为弹出窗口所以定义失败后续动作为关闭窗口
             $this->template = new View('layout/default_html');
             $this->template->return_struct = $return_struct;
             $content = new View('info2');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Ejemplo n.º 3
0
 /** 
  * 根据 classify_id获取该类型下所有品牌数组 
  * @param classify_id  in 
  * @return array 
  */
 public function get_brands_by_classify_id($classify_id)
 {
     $result = array();
     $brand_ids = $this->get_brand_ids_by_classify_id($classify_id);
     if (!empty($brand_ids)) {
         $query_struct = array('where' => array('id' => $brand_ids));
         $brands = BrandService::get_instance()->index($query_struct);
         if (!empty($brands)) {
             foreach ($brands as $key => $val) {
                 $result[$val['id']] = $val;
             }
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function add_products()
 {
     role::check('product_auction');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         $experience = $this->input->get('experience', 0);
         $relation_query_struct = array('where' => array('status!=' => 2, 'experience' => $experience), 'orderby' => array('id' => 'DESC'));
         //$relations = Product_auctionService::get_instance()->index($relation_query_struct);
         $product_ids = array();
         //foreach ($relations as $relation){
         //$product_ids[] = $relation['product_id'];
         //}
         $struct = product::get_struct($request_data);
         $query_struct_current = $struct['query'];
         $request_struct_current = $struct['request'];
         $query_struct_current['where']['type'] = ProductService::PRODUCT_TYPE_GOODS;
         //* 调用后端服务获取数据 */
         $product_service = ProductService::get_instance();
         $return_data['assoc'] = $product_service->index($query_struct_current);
         $return_data['count'] = $product_service->count($query_struct_current);
         // 初始化分类列表
         $category_list = array();
         // 初始化品牌列表
         $brand_list = array();
         if (!empty($return_data['assoc'])) {
             // 获取该商品列表中涉及到的分类以及品牌ID
             $category_ids = array();
             $brand_ids = array();
             foreach ($return_data['assoc'] as $product) {
                 if ($product['category_id'] != 0) {
                     $category_ids[$product['category_id']] = TRUE;
                 }
                 if ($product['brand_id'] != 0) {
                     $brand_ids[$product['brand_id']] = TRUE;
                 }
             }
             // 获取分类列表
             if (!empty($category_ids)) {
                 $query_struct = array('where' => array('id' => array_keys($category_ids)));
                 $categorys = CategoryService::get_instance()->query_assoc($query_struct);
                 foreach ($categorys as $category) {
                     $category_list[$category['id']] = $category['title_manage'];
                 }
             }
             // 获取品牌列表
             if (!empty($brand_ids)) {
                 $query_struct = array('where' => array('id' => array_keys($brand_ids)));
                 $brands = BrandService::get_instance()->query_assoc($query_struct);
                 foreach ($brands as $brand) {
                     $brand_list[$brand['id']] = $brand['name'];
                 }
             }
         }
         // 模板输出 分页
         $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page']));
         //* 如果是ajax请求缩减返回的字段 ==根据业务逻辑定制== */
         if ($this->is_ajax_request()) {
             $requestkeys = array('id', 'category_id', 'title', 'uri_name', 'store', 'on_sale', 'goods_price', 'sku');
             array_walk($return_data['assoc'], 'util::simplify_return_array', $requestkeys);
         }
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //exit("<div id=\"do_debug\" style=\"clear:both;display:;\"><pre>\n".var_export($return_struct,TRUE)."\n</pre></div>");
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             //* html 输出 ==根据业务逻辑定制== */
             $this->template = new View('layout/commonfix_html');
             //* 模板输出 */
             $this->template->return_struct = $return_struct;
             $content = new View('product/auction/add_products', array('experience' => $experience));
             //* 变量绑定 */
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
             //:: 当前应用专用数据
             $this->template->content->title = Kohana::config('site.name');
             $this->template->content->product_ids = $product_ids;
             $this->template->content->category_list = $category_list;
             $this->template->content->brand_list = $brand_list;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $this->_ex($ex, $return_struct, $request_data);
     }
 }
Ejemplo n.º 5
0
 protected function parse_brand($l)
 {
     static $names = array();
     $name = $this->get($l, 'brand');
     if ($name !== '') {
         $upper = strtoupper($name);
         if (isset($names[0][$upper])) {
             return $names[0][$upper];
         }
         $brand = BrandService::get_instance()->query_row(array('where' => array('name' => $name)));
         if (!empty($brand)) {
             $names[][$upper] = $brand['id'];
             return $brand['id'];
         } else {
             $this->set_error(new MyRuntimeException(sprintf('未找到名称为 "%s" 的品牌', $name)));
         }
     }
     return '0';
 }
Ejemplo n.º 6
0
 public function search_products()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array('assoc' => NULL, 'count' => 0);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         if (empty($request_data)) {
             $request_data = array_merge($_POST, $_GET);
         }
         $site_ids = role::get_site_ids();
         if (empty($site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         $in_site_id = site::id();
         if (isset($request_data['site_id']) and $request_data['site_id'] === '0') {
             unset($request_data['site_id']);
         }
         if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         if ($in_site_id > 0) {
             $query_site_id = $in_site_id;
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         $page = isset($request_data['page']) ? intval($request_data['page']) : 1;
         $page < 1 ? $page = 1 : '';
         $per_page = 10;
         $query_struct = array('where' => array('site_id' => $query_site_id, 'status' => 1), 'limit' => array('page' => $page, 'per_page' => $per_page));
         if (isset($request_data['type']) && trim($request_data['keyword']) != '') {
             $select_key = mysql_escape_string($request_data['keyword']);
             if ($request_data['type'] == 'sku') {
                 $query_struct['where']['sku'] = $select_key;
             } elseif ($request_data['type'] == 'name_manage') {
                 $query_struct['like']['name_manage'] = $select_key;
             } elseif ($request_data['type'] == 'title') {
                 $query_struct['like']['title'] = $select_key;
             } elseif ($request_data['type'] == 'category_id') {
                 $categories_select = CategoryService::get_instance()->index(array('where' => array('site_id' => $query_site_id), 'like' => array('title' => $select_key)));
                 if (!empty($categories_select)) {
                     $categories_ids = array();
                     for ($i = 0; $i < count($categories_select); $i++) {
                         $categories_ids[] = $categories_select[$i]['id'];
                     }
                     $query_struct['where']['category_id'] = $categories_ids;
                 }
             } elseif ($request_data['type'] == 'brand_id') {
                 $brands_select = BrandService::get_instance()->index(array('where' => array('site_id' => $query_site_id), 'like' => array('name' => $select_key)));
                 if (!empty($brands_select)) {
                     $brands_ids = array();
                     for ($i = 0; $i < count($brands_select); $i++) {
                         $brands_ids[] = $brands_select[$i]['id'];
                     }
                     $query_struct['where']['brand_id'] = $brands_ids;
                 } else {
                     $query_struct['where']['brand_id'] = -1;
                 }
             }
         }
         //print_r($query_struct);
         $return_data = BLL_Product::index($query_struct);
         $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $per_page));
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             $this->template = new View('layout/commonblank_html');
             //* 模板输出 */
             $this->template->return_struct = $return_struct;
             $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__);
             //* 变量绑定 */
             $this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->products = $return_data['assoc'];
             $this->template->content->pagination = $this->pagination;
             if (isset($request_data['type'])) {
                 $this->template->content->search_type = $request_data['type'];
             }
             $this->template->content->pagination = $this->pagination;
             //:: 当前应用专用数据
             $this->template->content->title = Kohana::config('site.name');
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Ejemplo n.º 7
0
function product_get_struct_brand_id($bname, $rstruct)
{
    if (empty($bname)) {
        return NULL;
    }
    if ($bname == '无') {
        return '0';
    }
    /*
    	$query_struct = array('where' => array(
    		'site_id' => $rstruct['site_id'],
    		'name'    => $bname,
    	));*/
    //模糊搜索
    $query_struct = array('where' => array(), 'like' => array('name' => $bname));
    $brands = BrandService::get_instance()->query_assoc($query_struct);
    if (empty($brands)) {
        return '-1';
    } else {
        $brand_ids = array();
        foreach ($brands as $brand) {
            $brand_ids[] = $brand['id'];
        }
        return $brand_ids;
    }
}
Ejemplo n.º 8
0
 protected function get_brand_name($brand_id)
 {
     if (!isset($this->brand_names[$brand_id])) {
         $brand = BrandService::get_instance()->get($brand_id);
         $this->brand_names[$brand_id] = $brand['name'];
     }
     return $this->brand_names[$brand_id];
 }
Ejemplo n.º 9
0
 /**
  * 获取商品列表
  *
  * @param array $query_struct
  * @return array
  */
 public static function index($query_struct)
 {
     $products = ProductService::get_instance()->index($query_struct);
     if (isset($query_struct['where']['sku'])) {
         $add_struct = array('where' => array());
         $add_struct['where']['sku'] = $query_struct['where']['sku'];
         if (isset($query_struct['where']['on_sale'])) {
             $add_struct['where']['on_sale'] = $query_struct['where']['on_sale'];
         }
         if (!empty($add_struct['where'])) {
             $goods = ProductService::get_instance()->index($add_struct);
             if (!empty($goods)) {
                 $add_ids = array();
                 $pdt_ids = array();
                 foreach ($products as $product) {
                     $pdt_ids[$product['id']] = TRUE;
                 }
                 foreach ($goods as $good) {
                     if (!isset($pdt_ids[$good['product_id']])) {
                         $add_ids[] = $good['product_id'];
                         $pdt_ids[$good['product_id']] = TRUE;
                     }
                 }
                 if (!empty($add_ids)) {
                     $add_pdts = ProductService::get_instance()->index(array('where' => array('id' => $add_ids)));
                     foreach ($add_pdts as $product) {
                         $products[] = $product;
                     }
                 }
             }
         }
     }
     $category_ids = array();
     $classify_ids = array();
     $brand_ids = array();
     foreach ($products as $product) {
         $product['category_id'] > 0 and $category_ids[$product['category_id']] = TRUE;
         $product['classify_id'] > 0 and $classify_ids[$product['classify_id']] = TRUE;
         $product['brand_id'] > 0 and $brand_ids[$product['brand_id']] = TRUE;
     }
     $category_ids = array_keys($category_ids);
     $classify_ids = array_keys($classify_ids);
     $brand_ids = array_keys($brand_ids);
     $categorys = array();
     if (!empty($category_ids)) {
         foreach (CategoryService::get_instance()->index(array('where' => array('id' => $category_ids))) as $category) {
             $categorys[$category['id']] = $category;
         }
     }
     $classifys = array();
     if (!empty($classify_ids)) {
         foreach (ClassifyService::get_instance()->index(array('where' => array('id' => $classify_ids))) as $classify) {
             $classifys[$classify['id']] = $classify;
         }
     }
     $brands = array();
     if (!empty($brand_ids)) {
         foreach (BrandService::get_instance()->index(array('where' => array('id' => $brand_ids))) as $brand) {
             $brands[$brand['id']] = $brand;
         }
     }
     foreach ($products as $index => $product) {
         $product = coding::decode_product($product);
         isset($categorys[$product['category_id']]) and $product['category'] = $categorys[$product['category_id']];
         isset($classifys[$product['classify_id']]) and $product['classify'] = $classifys[$product['classify_id']];
         isset($brands[$product['brand_id']]) and $product['brand'] = $brands[$product['brand_id']];
         $product['name_manage'] || ($product['name_manage'] = $product['title']);
         $product['category_name'] = isset($product['category']['title_manage']) ? $product['category']['title_manage'] : '';
         $products[$index] = $product;
     }
     return array('assoc' => $products, 'count' => ProductService::get_instance()->count($query_struct));
 }
Ejemplo n.º 10
0
 /**
  * 设定菜单的排序
  */
 public function set_order()
 {
     //初始化返回数组
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     $request_data = $this->input->get();
     $id = isset($request_data['id']) ? $request_data['id'] : '';
     $order = isset($request_data['order']) ? $request_data['order'] : '';
     /* 验证是否可以操作 */
     if (!role::verify('product_brand')) {
         $return_struct['msg'] = Kohana::lang('o_global.permission_enough');
         exit(json_encode($return_struct));
     }
     if (empty($id) || empty($order) && $order != 0) {
         $return_struct['msg'] = Kohana::lang('o_global.bad_request');
         exit(json_encode($return_struct));
     }
     if (!is_numeric($order) || $order < 0) {
         $return_struct['msg'] = Kohana::lang('o_global.position_rule');
         exit(json_encode($return_struct));
     }
     $brand_service = BrandService::get_instance();
     $brand_service->set($id, array('order' => $order));
     $return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
     exit(json_encode($return_struct));
 }
Ejemplo n.º 11
0
 function get_site_data()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array('brand_list' => NULL, 'attribute_list' => NULL, 'feature_list' => NULL);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         //* 实现功能后屏蔽此异常抛出 */
         //throw new MyRuntimeException('Not Implemented',501);
         //必须为ajax请求
         if (!$this->is_ajax_request()) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         //* 权限验证 */
         $site_id_list = role::check('product_classify', 0, 0);
         if (empty($site_id_list)) {
             throw new MyRuntimeException('Access Denied', 403);
         }
         if (isset($request_data['site_id']) && is_numeric($request_data['site_id'])) {
             if (!in_array($request_data['site_id'], $site_id_list)) {
                 throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
             }
         }
         //数据验证
         if (!isset($request_data['site_id']) || !is_numeric($request_data['site_id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         // 调用底层服务
         $classify_service = ClassifyService::get_instance();
         //请求站点品牌列表
         $brands = BrandService::get_instance()->get_brands_by_site_id($request_data['site_id']);
         foreach ($brands as $val) {
             $return_data['brand_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //请求站点规格列表
         $attributes = AttributeService::get_instance()->get_attributes_by_site_id($request_data['site_id']);
         foreach ($attributes as $val) {
             $return_data['attribute_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //请求站点规格列表
         $features = FeatureService::get_instance()->get_features_by_site_id($request_data['site_id']);
         foreach ($features as $val) {
             $return_data['feature_list'] .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
         }
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             //* 模板输出 */
             $content = new View($this->package . '/' . $this->class_name . '/' . __FUNCTION__);
             //* 变量绑定 */
             $this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }