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

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

@@ -10,6 +10,7 @@ use biz\admin\classes\AdminRoleClass;
 use bizGhs\item\classes\ItemClassClass;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\product\classes\ProductClass;
+use bizGhs\product\models\Product;
 use bizGhs\product\services\ProductService;
 use common\components\stringUtil;
 use common\components\util;
@@ -116,7 +117,13 @@ class ProductController extends BaseController
         $showPage = Yii::$app->request->get('showPage', 0);
         if ($showPage) {
             if ($type == 'waring') {
-                $where['stock<'] = 'stockWarning';
+                $pro = Product::find()->where("shopId={$shopId}")->andWhere('`stock`<`stockWarning`')->select('id')->asArray()->all();
+                $lackIds = array_column($pro, 'id');
+                if (empty($lackIds)) {
+                    util::success([]);
+                }
+                $lackIds = array_filter(array_unique($lackIds));
+                $where[id] = ['in', $lackIds];
                 $respond = ProductClass::getList("*", $where, "stock asc");
             } else {
                 $respond = ProductClass::getList("*", $where, "inTurn desc");