Răsfoiți Sursa

花材列表

shish 3 ani în urmă
părinte
comite
39fe82a0a4

+ 28 - 39
app-ghs/controllers/ProductController.php

@@ -109,7 +109,6 @@ class ProductController extends BaseController
         util::complete();
     }
 
-
     //取出今天有入库的花材 ssh 20221224
     public function actionGetStockIn()
     {
@@ -136,7 +135,7 @@ class ProductController extends BaseController
         $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
         $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
-        $data = ProductService::assembleItemData($classInfo, $itemInfoData, true);
+        $data = ProductService::assembleItemData($classInfo, $itemInfoData);
         util::success($data);
     }
 
@@ -180,7 +179,6 @@ class ProductController extends BaseController
         $status = Yii::$app->request->get('status', 1);
         //默认显示未删除商品
         $delStatus = Yii::$app->request->get('delStatus', 0);
-        $warning = Yii::$app->request->get('warning', 0);
 
         //获取所有当前供货商的分类 (全部、常用)
         //根据分类组装分类下的花材信息
@@ -209,49 +207,40 @@ class ProductController extends BaseController
             $level = $custom->level ?? 1;
         }
 
-        if ($warning == 1) {
+        if ($requestType == 'hasStockList') {
+            //有库存的花材列表
+            $field = 'id,py,name,classId,itemId,price,skPrice,stock';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+        } elseif ($requestType == 'changePrice') {
+            //修改价格列表
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,presell';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
+        } elseif ($requestType == 'itemList') {
+            //花材列表
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,stock,presell';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
+        } elseif ($requestType == 'cg') {
+            //采购花材
+            $field = 'id,py,cover,name,itemId,classId,variety,price,stock,presell,ratioType,smallUnit,bigUnit,ratio';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'warning') {
             //库存预警
-            $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,stock,presell,stockWarning';
             $itemInfoData = Product::find()->where("mainId={$this->mainId}")
                 ->andWhere('`stock`<`stockWarning`')
                 ->andWhere("delStatus=0")
                 ->select($field)->asArray()->all();
+            $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
         } else {
-            if ($requestType == 'hasStockList') {
-                //有库存的花材列表
-                $field = 'id,py,name,classId,itemId,price,skPrice,stock';
-                $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            } elseif ($requestType == 'changePrice') {
-                //修改价格列表
-                $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,presell';
-                $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-                $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
-            } elseif ($requestType == 'itemList') {
-                //花材列表
-                $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,stock,presell';
-                $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-                $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
-            } elseif ($requestType == 'cg') {
-                //采购花材
-                $field = 'id,py,cover,name,itemId,classId,variety,price,stock,presell,ratioType,smallUnit,bigUnit,ratio';
-                $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-                $itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
-            } elseif ($requestType == 'warning') {
-                //库存预警
-                $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,stock,presell,stockWarning';
-                $itemInfoData = Product::find()->where("mainId={$this->mainId}")
-                    ->andWhere('`stock`<`stockWarning`')
-                    ->andWhere("delStatus=0")
-                    ->select($field)->asArray()->all();
-                $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
-            } else {
-                //通用
-                $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
-                $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-                $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
-            }
+            //通用
+            $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
         }
-        $data = ProductService::assembleItemData($classInfo, $itemInfoData, true);
+        $data = ProductService::assembleItemData($classInfo, $itemInfoData);
         util::success($data);
     }
 

+ 3 - 3
biz-ghs/product/services/ProductService.php

@@ -25,7 +25,7 @@ class ProductService extends BaseService
     const PRESELL_CLASS_ID = '-3';
 
     //组装分类花材数据
-    public static function assembleItemData($classInfo, $itemInfoData, $showTodayDiscount = false)
+    public static function assembleItemData($classInfo, $itemInfoData)
     {
         $itemGroup = [];
         $tjItem = [];
@@ -88,12 +88,12 @@ class ProductService extends BaseService
                 $classData[] = $tmp;
             }
         }
-        if ($showTodayDiscount && !empty($tjItem)) {
+        if (!empty($tjItem)) {
             $tjClass = [['classId' => self::TJ_CLASS_ID, 'className' => '今日特价', 'print' => 0,
                 'classCover' => imgUtil::groupImg('item_class/tj.jpg'), 'child' => $tjItem,]];
             $classData = array_merge($tjClass, $classData);
         }
-        if ($showTodayDiscount && !empty($preSellItem)) {
+        if (!empty($preSellItem)) {
             $preSellClass = [['classId' => self::PRESELL_CLASS_ID, 'className' => '预售专区', 'print' => 0,
                 'classCover' => imgUtil::groupImg('item_class/mrfl.png'), 'child' => $preSellItem,]];
             $classData = array_merge($preSellClass, $classData);