shish 3 лет назад
Родитель
Сommit
528e72bbee

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

@@ -248,6 +248,11 @@ class ProductController extends BaseController
             $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'part') {
+            //报损花材
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::partItemGroup($itemInfoData, $level);
         } elseif ($requestType == 'stockOut') {
             //出库花材
             $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio';

+ 23 - 1
biz-ghs/product/classes/ProductClass.php

@@ -199,7 +199,7 @@ class ProductClass extends BaseClass
             $list[$k]['price'] = $price;
             $list[$k]['bigPrice'] = $price;
             $smallRatio = $v['smallRatio'] ?? 0;
-            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 1;
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 20;
             $smallPrice = bcdiv($price, $ratio, 2);
             $smallPrice = bcmul($smallPrice, $smallRatio, 2);
             $list[$k]['smallPrice'] = $smallPrice;
@@ -207,11 +207,33 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    //拆散花材 ssh 20230329
+    public static function partItemGroup($list, $level = 0)
+    {
+        foreach ($list as $k => $v) {
+            $shortCover = $v['cover'] ?? '';
+
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 20;
+            $stockInfo = self::formatStock($v['stock'], $ratio);
+            $list[$k]['bigNum'] = $stockInfo['bigNum'];
+            $list[$k]['smallNum'] = $stockInfo['smallNum'];
+
+            $list[$k]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
+        }
+        return $list;
+    }
+
     //报损花材列表 ssh 20221226
     public static function breakItemGroup($list, $level = 0)
     {
         foreach ($list as $k => $v) {
             $shortCover = $v['cover'] ?? '';
+
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 20;
+            $stockInfo = self::formatStock($v['stock'], $ratio);
+            $list[$k]['bigNum'] = $stockInfo['bigNum'];
+            $list[$k]['smallNum'] = $stockInfo['smallNum'];
+
             $list[$k]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
         }
         return $list;