shish 3 سال پیش
والد
کامیت
528e72bbee
2فایلهای تغییر یافته به همراه28 افزوده شده و 1 حذف شده
  1. 5 0
      app-ghs/controllers/ProductController.php
  2. 23 1
      biz-ghs/product/classes/ProductClass.php

+ 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';
             $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::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
             $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') {
         } elseif ($requestType == 'stockOut') {
             //出库花材
             //出库花材
             $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio';
             $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]['price'] = $price;
             $list[$k]['bigPrice'] = $price;
             $list[$k]['bigPrice'] = $price;
             $smallRatio = $v['smallRatio'] ?? 0;
             $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 = bcdiv($price, $ratio, 2);
             $smallPrice = bcmul($smallPrice, $smallRatio, 2);
             $smallPrice = bcmul($smallPrice, $smallRatio, 2);
             $list[$k]['smallPrice'] = $smallPrice;
             $list[$k]['smallPrice'] = $smallPrice;
@@ -207,11 +207,33 @@ class ProductClass extends BaseClass
         return $list;
         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
     //报损花材列表 ssh 20221226
     public static function breakItemGroup($list, $level = 0)
     public static function breakItemGroup($list, $level = 0)
     {
     {
         foreach ($list as $k => $v) {
         foreach ($list as $k => $v) {
             $shortCover = $v['cover'] ?? '';
             $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";
             $list[$k]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
         }
         }
         return $list;
         return $list;