Browse Source

小单位调整

shish 5 năm trước cách đây
mục cha
commit
26dd3a1e5f
1 tập tin đã thay đổi với 6 bổ sung5 xóa
  1. 6 5
      biz-ghs/product/classes/ProductClass.php

+ 6 - 5
biz-ghs/product/classes/ProductClass.php

@@ -110,7 +110,7 @@ class ProductClass extends BaseClass
                 }
                 $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
             }
-            $ratio = $v['ratio'];
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 1;
             $stockInfo = self::formatStock($v['stock'], $ratio);
             $list[$k]['cover'] = $cover;
             $list[$k]['bigCover'] = $bigCover;
@@ -120,10 +120,11 @@ class ProductClass extends BaseClass
             $list[$k]['itemName'] = $v['name'] ?? '';
             //换算大小单位对应价格
             $list[$k]['bigPrice'] = $v['price']; //大单位价格就是product表存的价格
-            $smallPrice = 0;
-            if ($ratio) {
-                $smallPrice = bcdiv($v['price'], $ratio, 2);
-            }
+
+            //小单位根据供应商要求+2倍
+            $smallPrice = bcdiv($v['price'], $ratio, 2);
+            $smallPrice = bcmul($smallPrice, 2, 2);
+
             $list[$k]['smallPrice'] = $smallPrice;
             //原价 shish 20210703
             $list[$k]['prePrice'] = bcadd($v['cost'], $v['addPrice'], 2);