shish 3 лет назад
Родитель
Сommit
48567c9ecd
1 измененных файлов с 15 добавлено и 3 удалено
  1. 15 3
      biz-ghs/product/classes/ProductClass.php

+ 15 - 3
biz-ghs/product/classes/ProductClass.php

@@ -238,13 +238,13 @@ class ProductClass extends BaseClass
             }
             $list[$k]['price'] = $price;
             $cost = $v['cost'] ?? 0;
-            if ($cost == 0) {
-                $mll = 0;
-            } else {
+            if ($price > 0) {
                 $profit = bcsub($price, $cost, 2);
                 $mll = bcdiv($profit, $price, 3);
                 $mll = bcmul($mll, 100);
                 $mll = round($mll, 1);
+            }else{
+                $mll = 0;
             }
             $list[$k]['mll'] = $mll;
         }
@@ -282,6 +282,18 @@ class ProductClass extends BaseClass
                 $list[$k]['skPrice'] = bcadd($v['discountPrice'], $currentAddPrice, 2);
             }
             $list[$k]['price'] = $price;
+
+            $cost = $v['cost'] ?? 0;
+            if ($price > 0) {
+                $profit = bcsub($price, $cost, 2);
+                $mll = bcdiv($profit, $price, 3);
+                $mll = bcmul($mll, 100);
+                $mll = round($mll, 1);
+            } else {
+                $mll = 0;
+            }
+            $list[$k]['mll'] = $mll;
+
         }
         return $list;
     }