shish vor 11 Monaten
Ursprung
Commit
baf51f2a41

+ 1 - 4
app-mall/controllers/CategoryController.php

@@ -61,11 +61,8 @@ class CategoryController extends BaseController
         $where['mainId'] = $this->mainId;
         $where['delStatus'] = 0;//只获取非删除状态
         $where['status'] = 1;//上下架状态为1(正常)
-
         $searchText = $get['searchText'] ?? '';
-        if (!empty($searchText)) {
-            $where['name'] = ['like', $searchText];
-        }
+        $where['searchText'] = $searchText;
         $shop = $this->shop;
         $custom = $this->custom;
         $params = [];

+ 7 - 4
biz-hd/goods/classes/GoodsCategoryClass.php

@@ -28,16 +28,19 @@ class GoodsCategoryClass extends BaseClass
         if (!empty($where['cId'])) {
             $query->andWhere(['xhGoodsCategory.cId' => $where['cId']]);
         }
-        if (!empty($where['name'])) {
-            $query->andWhere(['like', 'xhGoodsCategory.name', $where['name']]);
+        if (!empty($where['searchText'])) {
+            $query->andWhere(['like', 'xhGoodsCategory.name', $where['searchText']]);
         }
 
         $flowerNum = $params['flowerNum'] ?? -1;
         $priceStatus = $where['priceStatus'] ?? -1;
         $stockStatus = $where['stockStatus'] ?? -1;
+        $requestType = $get['requestType'] ?? '';
 
-        $query->joinWith(['goods' => function ($query) use ($flowerNum, $priceStatus, $stockStatus) {
-            $query->andWhere(['>', 'xhGoods.stock', 0]);
+        $query->joinWith(['goods' => function ($query) use ($flowerNum, $priceStatus, $stockStatus, $requestType) {
+            if ($requestType == 'kd') {
+                $query->andWhere(['>', 'xhGoods.stock', 0]);
+            }
             if ($stockStatus == 1) {
                 $query->andWhere(['>', 'xhGoods.stock', 0]);
             }