瀏覽代碼

显示的价格

shish 3 年之前
父節點
當前提交
ce390f311e
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      app-mall/controllers/ItemController.php

+ 10 - 4
app-mall/controllers/ItemController.php

@@ -64,10 +64,16 @@ class ItemController extends BaseController
             util::stop('');
         }
         if (isset($item->discountPrice) && $item->discountPrice > 0) {
-            $price = $item->discountPrice;
-            $skMore = $item->skMore;
-            $skPrice = bcadd($price, $skMore, 2);
-            $skPrice = floatval($skPrice);
+            $discountPrice = $item->discountPrice;
+            $skMore = $item->skMore ?? 0;
+            $addPrice = $item->addPrice ?? 0;
+            $diff = bcsub($skMore, $addPrice, 2);
+            if ($diff > 0) {
+                $skPrice = bcadd($discountPrice, $diff, 2);
+                $skPrice = floatval($skPrice);
+            } else {
+                $skPrice = floatval($discountPrice);
+            }
         } else {
             $skPrice = $item->skPrice ?? 0;
             $skPrice = floatval($skPrice);