shish 3 лет назад
Родитель
Сommit
519480c1f8

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

@@ -651,8 +651,11 @@ class ProductClass extends BaseClass
             $bigItemPrice = $itemPrice;
 
             if ($smallNum > 0) {
-                $itemPrice = bcdiv($itemPrice, $ratio, 2);
-                $itemPrice = bcmul($itemPrice, $smallRatio, 2);
+				//如果是小单位数量,则传过来的就是小单位价格,无需转换
+                if (empty($changePrice)) {
+                    $itemPrice = bcdiv($itemPrice, $ratio, 2);
+                    $itemPrice = bcmul($itemPrice, $smallRatio, 2);
+                }
                 $price = bcmul($smallNum, $itemPrice, 2);
             } else {
                 $price = bcmul($bigNum, $itemPrice, 2);

+ 7 - 4
biz-hd/purchase/classes/PurchaseClass.php

@@ -371,10 +371,13 @@ class PurchaseClass extends BaseClass
             $bigPrice = $price;
 
             if ($currentSmallNum > 0) {
-                $ghsRatio = $currentProduct['ratio'] ?? 0;
-                $ghsSmallRatio = $currentProduct['smallRatio'] ?? 1;
-                $price = bcdiv($price, $ghsRatio, 2);
-                $price = bcmul($price, $ghsSmallRatio, 2);
+				//如果是小单位数量,则传过来的就是小单位价格,无需转换
+                if (empty($changePrice)) {
+                    $ghsRatio = $currentProduct['ratio'] ?? 0;
+                    $ghsSmallRatio = $currentProduct['smallRatio'] ?? 1;
+                    $price = bcdiv($price, $ghsRatio, 2);
+                    $price = bcmul($price, $ghsSmallRatio, 2);
+                }
                 $productTotalPrice = bcmul($currentSmallNum, $price, 2);
             } else {
                 $productTotalPrice = bcmul($currentBigNum, $price, 2);