Browse Source

modify goods.php request_helper.php

root 9 years ago
parent
commit
7b4f448bad
2 changed files with 56 additions and 22 deletions
  1. 47 22
      mobile/control/goods.php
  2. 9 0
      request_helper.php

+ 47 - 22
mobile/control/goods.php

@@ -43,20 +43,45 @@ class goodsControl extends mobileHomeControl
      */
     public function goods_listOp()
     {
-
         $model_goods = Model('goods');
         $model_search = Model('search');
 
         $this->_initpage();
 
-        //查询条件
         $condition = array();
-        if (!empty($_GET['gc_id']) && intval($_GET['gc_id']) > 0) {
-            $condition['gc_id'] = $_GET['gc_id'];
-        } elseif (!empty($_GET['keyword'])) {
+        if (!empty($_GET['gc_id'])) {
+            $condition['gc_id'] = intval($_GET['gc_id']);
+        }
+
+        // 关键字
+        if (!empty($_GET['keyword'])) {
             $condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%');
-        } elseif (!empty($_GET['brand_id']) && intval($_GET['brand_id'])) {
-            $condition['brand_id'] = $_GET['brand_id'];
+        }
+
+        // 品牌查询
+        if (!empty($_GET['brand_id'])) {
+            $condition['brand_id'] = intval($_GET['brand_id']);
+        }
+
+        // 功效查询
+        if (!empty($_GET['efficacy_id'])) {
+            $condition['efficacy_id'] = intval($_GET['efficacy_id']);
+        }
+
+        // 彩妆护肤查询
+        if (!empty($_GET['attr_value_id']) && !empty($_GET['type_id'])) {
+
+            $type_id = intval($_GET['type_id']);
+            $attr_value_id = intval($_GET['attr_value_id']);
+
+            $goods_id_list = Model()->table('goods_attr_index')->field('distinct goods_id as goods_id')->where(array('type_id'=>$type_id,'attr_value_id'=>$attr_value_id))->select();
+
+            $array_list = array();
+            foreach($goods_id_list as $value){
+                array_push($array_list,$value['goods_id']);
+            }
+
+            $condition['goods_id'] = array('in',$array_list);
         }
 
         //所需字段
@@ -69,20 +94,21 @@ class goodsControl extends mobileHomeControl
         $order = $this->_goods_list_order($_GET['key'], $_GET['order']);
 
         //优先从全文索引库里查找
-        list($indexer_ids, $indexer_count) = $model_search->indexerSearch($_GET, $this->page);
-        if (is_array($indexer_ids)) {
-            //商品主键搜索
-            $goods_list = $model_goods->getGoodsOnlineList(array('goods_id' => array('in', $indexer_ids)), $fieldstr, 0, $order, $this->page, null, false);
-
-            //如果有商品下架等情况,则删除下架商品的搜索索引信息
-            if (count($goods_list) != count($indexer_ids)) {
-                $model_search->delInvalidGoods($goods_list, $indexer_ids);
-            }
-            pagecmd('setEachNum', $this->page);
-            pagecmd('setTotalNum', $indexer_count);
-        } else {
-            $goods_list = $model_goods->getGoodsListByColorDistinct($condition, $fieldstr, $order, $this->page);
-        }
+//        list($indexer_ids, $indexer_count) = $model_search->indexerSearch($_GET, $this->page);
+//        if (is_array($indexer_ids)) {
+//            //商品主键搜索
+//            $goods_list = $model_goods->getGoodsOnlineList(array('goods_id' => array('in', $indexer_ids)), $fieldstr, 0, $order, $this->page, null, false);
+//
+//            //如果有商品下架等情况,则删除下架商品的搜索索引信息
+//            if (count($goods_list) != count($indexer_ids)) {
+//                $model_search->delInvalidGoods($goods_list, $indexer_ids);
+//            }
+//            pagecmd('setEachNum', $this->page);
+//            pagecmd('setTotalNum', $indexer_count);
+//        } else {
+        $goods_list = $model_goods->getGoodsListByColorDistinct($condition, $fieldstr, $order, $this->page);
+//        }
+
         $page_count = $model_goods->gettotalpage();
 
         //处理商品列表(抢购、限时折扣、商品图片)
@@ -597,6 +623,5 @@ class goodsControl extends mobileHomeControl
         foreach ($goods_attr as $value) {
 
         }
-
     }
 }

+ 9 - 0
request_helper.php

@@ -92,6 +92,15 @@ class request_helper
 
 function init_request()
 {
+
+//    foreach($_GET as $key=>$val){
+//        unset($_GET[$key]);
+//    }
+//
+//    foreach($_POST as $key=>$val){
+//        unset($_POST[$key]);
+//    }
+
     $_GET['act'] = 'index';
     $_GET['op'] = 'index';