shish %!s(int64=3) %!d(string=hai) anos
pai
achega
1f194e91e9
Modificáronse 1 ficheiros con 13 adicións e 5 borrados
  1. 13 5
      app-ghs/controllers/ProductController.php

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

@@ -133,10 +133,6 @@ class ProductController extends BaseController
         }
         $where['delStatus'] = $delStatus;
 
-        if ($warning == 1) {
-            $where['stock<'] = '`stockWarning`';
-        }
-
         //客户等级
         $customId = Yii::$app->request->get('customId', 0);
         $level = 1;
@@ -145,7 +141,19 @@ class ProductController extends BaseController
             $level = $custom->level ?? 1;
         }
 
-        $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
+        if ($warning == 1) {
+            //库存预警
+//            $sql = "SELECT * FROM `" . Product::tableName() . "` WHERE mainId={$this->mainId} and delStatus=0 and stock<stockWarning";
+//            $command = Yii::$app->db->createCommand($sql);
+//            $itemInfoData = $command->queryAll();
+
+            $itemInfoData = Product::find()->where("mainId={$this->mainId}")->andWhere('`stock`<`stockWarning`')
+                ->andWhere("delStatus=0")
+                ->select('*')->asArray()->all();
+
+        } else {
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
+        }
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
 
         $data = ProductService::assembleData($classIds, $itemInfoData, true);