Explorar el Código

更新 actionGoodsList

shizhongqi hace 11 meses
padre
commit
6b93264de2

+ 12 - 7
app-mall/controllers/CategoryController.php

@@ -51,15 +51,20 @@ class CategoryController extends BaseController
             util::success(['list' => []]);
         }
 
-        $categoryId = Yii::$app->request->get('categoryId');
-        if (empty($categoryId)) {
-            util::fail('没有找到分类');
-        }
         $where = [];
+        $get = Yii::$app->request->get();
+        $categoryId = isset($get['categoryId']) ? intval($get['categoryId']) : 0;
+        if ($categoryId != 0) {
+            $where['cId'] = $categoryId;
+        }
         $where['mainId'] = $this->mainId;
-        $where['cId'] = $categoryId;
-        $where['delStatus'] = 0;
-        $where['status'] = 1;
+        $where['delStatus'] = 0;//只获取非删除状态
+        $where['status'] = 1;//上下架状态为1(正常)
+
+        $searchText = $get['searchText'] ?? '';
+        if (!empty($searchText)) {
+            $where['name'] = ['like', $searchText];
+        }
 
         $shop = $this->shop;
         $stockModel = $shop->stockModel ?? 0;

+ 0 - 1
biz-mall/goods/services/GoodsCategoryService.php

@@ -15,7 +15,6 @@ class GoodsCategoryService extends BaseService
     //查询一个分类下的商品,有分页 ssh 2019.12.2
     public static function getGoodsList($where)
     {
-        unset($where['delStatus']);//这个后面改进
         $data = GoodsCategoryClass::getList('*', $where, 'inTurn DESC');
         $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
         if (empty($list)) {