shish 2 лет назад
Родитель
Сommit
626b899b7c
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      app-ghs/controllers/ProductController.php

+ 8 - 5
app-ghs/controllers/ProductController.php

@@ -475,6 +475,7 @@ class ProductController extends BaseController
     //所有花材分页和不分页
     public function actionList()
     {
+        $get = Yii::$app->request->get();
         $where = [];
         $classId = Yii::$app->request->get('classId', 0);
         if (!empty($classId)) {
@@ -508,10 +509,8 @@ class ProductController extends BaseController
                 $where['id'] = ['in', $productIdArr];
             }
         }
-
         //输出标准会员价,即批发价,默认显示的是批发价
         $level = 1;
-
         $type = Yii::$app->request->get('type', '');
         $showPage = Yii::$app->request->get('showPage', 0);
         if ($showPage) {
@@ -525,6 +524,13 @@ class ProductController extends BaseController
                 $where['id'] = ['in', $lackIds];
                 $respond = ProductClass::getList("*", $where, "actualSold desc");
             } else {
+                $hasStock = $get['hasStock']??-1;
+                if($hasStock == 0){
+                    $where['stock']=0;
+                }
+                if($hasStock == 1){
+                    $where['stock>']=0;
+                }
                 $respond = ProductClass::getList("*", $where, "inTurn desc");
             }
             $respond['list'] = ProductClass::groupProductInfo($respond['list'], $level);
@@ -541,12 +547,9 @@ class ProductController extends BaseController
                 } else {
                     $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
                 }
-
             }
-
             $data = ProductClass::groupProductInfo($data, $level);
             $data = ProductClass::groupClassName($this->sjId, $data);
-
             if ($type == 'waring') {
                 //库存预警
                 $newData = [];