shish 3 years ago
parent
commit
c2c8cf7dfa
2 changed files with 45 additions and 30 deletions
  1. 35 30
      app-ghs/controllers/ProductController.php
  2. 10 0
      biz-ghs/product/classes/ProductClass.php

+ 35 - 30
app-ghs/controllers/ProductController.php

@@ -109,36 +109,6 @@ class ProductController extends BaseController
         util::complete();
     }
 
-    //取出今天有入库的花材 ssh 20221224
-    public function actionGetStockIn()
-    {
-        $py = Yii::$app->request->get('py', '');
-        $version = Yii::$app->request->get('version', 0);
-        if ($version == 0) {
-            util::fail('请先升级版本到1.0.70以上');
-        }
-        $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
-        $mainId = $this->mainId ?? 0;
-        $where['mainId'] = $mainId;
-        if ($py) {
-            $pyName = strtolower($py);
-            $where['py'] = $pyName;
-        }
-        $arr = StockInDayClass::getAllByCondition(['mainId' => $mainId], null, '*');
-        if (empty($arr)) {
-            util::fail('没有花材需要盘点');
-        }
-        $ids = array_column($arr, 'itemId');
-        $ids = array_unique($ids);
-        $where['id'] = ['in', $ids];
-        $level = 1;
-        $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);
-        util::success($data);
-    }
-
     //取出今天有入库的花材 ssh 20221024
     public function actionStockIn()
     {
@@ -221,6 +191,11 @@ class ProductController extends BaseController
             $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 == 'check') {
+            //采购花材
+            $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::checkItemGroup($itemInfoData, $level);
         } elseif ($requestType == 'cg') {
             //采购花材
             $field = 'id,py,cover,name,itemId,classId,variety,price,stock,presell,ratioType,smallUnit,bigUnit,ratio';
@@ -244,6 +219,36 @@ class ProductController extends BaseController
         util::success($data);
     }
 
+    //取出今天有入库的花材 ssh 20221224
+    public function actionGetStockIn()
+    {
+        $py = Yii::$app->request->get('py', '');
+        $version = Yii::$app->request->get('version', 0);
+        if ($version == 0) {
+            util::fail('请先升级版本到1.0.70以上');
+        }
+        $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
+        $mainId = $this->mainId ?? 0;
+        $where['mainId'] = $mainId;
+        if ($py) {
+            $pyName = strtolower($py);
+            $where['py'] = $pyName;
+        }
+        $arr = StockInDayClass::getAllByCondition(['mainId' => $mainId], null, '*');
+        if (empty($arr)) {
+            util::fail('没有花材需要盘点');
+        }
+        $ids = array_column($arr, 'itemId');
+        $ids = array_unique($ids);
+        $where['id'] = ['in', $ids];
+        $level = 1;
+        $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);
+        util::success($data);
+    }
+
     //按分类列出所有花材
     public function actionIndex()
     {

+ 10 - 0
biz-ghs/product/classes/ProductClass.php

@@ -111,6 +111,16 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    //盘点用到的数据组合
+    public static function checkItemGroup($list, $level = 0)
+    {
+        foreach ($list as $k => $v) {
+            $shortCover = $v['cover'] ?? '';
+            $list[$k]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
+        }
+        return $list;
+    }
+
     //采购花材列表用到的数据组合 ssh 20221225
     public static function cgItemGroup($list, $level = 0)
     {