shish vor 2 Jahren
Ursprung
Commit
b162d431a4

+ 1 - 0
biz-ghs/order/classes/OrderClass.php

@@ -462,6 +462,7 @@ class OrderClass extends BaseClass
         $data['bigNum'] = $respond['bigNum'] ?? 0;
         $data['bigNum'] = $respond['bigNum'] ?? 0;
         $data['smallNum'] = $respond['smallNum'] ?? 0;
         $data['smallNum'] = $respond['smallNum'] ?? 0;
         $data['itemNum'] = $respond['totalItemNum'] ?? 0;
         $data['itemNum'] = $respond['totalItemNum'] ?? 0;
+        $data['reachDiscountPrice'] = $respond['totalReachDiscount'] ?? 0;
 
 
         //默认订单要打单
         //默认订单要打单
         $data['needPrint'] = $data['needPrint'] ?? dict::getDict('needPrint', 'need');
         $data['needPrint'] = $data['needPrint'] ?? dict::getDict('needPrint', 'need');

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

@@ -1156,6 +1156,8 @@ class ProductClass extends BaseClass
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
 
 
         $totalItemNum = 0;
         $totalItemNum = 0;
+        //满减累计
+        $totalReachDiscount = 0;
 
 
         foreach ($itemInfo as $v) {
         foreach ($itemInfo as $v) {
             $ghsProductId = $v['productId'];
             $ghsProductId = $v['productId'];
@@ -1176,8 +1178,18 @@ class ProductClass extends BaseClass
                 //供货商开单可以传单价过来
                 //供货商开单可以传单价过来
                 $changePrice = isset($v['price']) && $v['price'] > 0 ? $v['price'] : 0;
                 $changePrice = isset($v['price']) && $v['price'] > 0 ? $v['price'] : 0;
                 //今日特价、会员价
                 //今日特价、会员价
-                $itemPrice = self::getFinalPrice($currentGhsProduct, $level, $priceMap, $addPriceMap, $changePrice);
+                $itemPrice = self::getFinalPrice($currentGhsProduct, $level, $priceMap, $addPriceMap, $changePrice, $itemNum);
                 $thisPrice = $itemPrice;
                 $thisPrice = $itemPrice;
+
+                $reachNum = $currentGhsProduct['reachNum'] ?? 0;
+                if ($reachNum > 0) {
+                    if ($itemNum >= $reachNum) {
+                        $reachNumDiscount = $currentGhsProduct['reachNumDiscount'] ?? 0;
+                        $currentReachDiscount = bcmul($reachNumDiscount, $itemNum, 2);
+                        $totalReachDiscount = bcadd($totalReachDiscount, $currentReachDiscount, 2);
+                    }
+                }
+
             } else {
             } else {
                 $itemPrice = $v['unitPrice'] ?? 0;
                 $itemPrice = $v['unitPrice'] ?? 0;
                 $thisPrice = $itemPrice;
                 $thisPrice = $itemPrice;
@@ -1253,7 +1265,7 @@ class ProductClass extends BaseClass
             $data[] = $tmp;
             $data[] = $tmp;
         }
         }
 
 
-        return ['product' => $data, 'smallNum' => $totalSmallNum, 'bigNum' => $totalBigNum, 'price' => $totalPrice, 'totalItemNum' => $totalItemNum];
+        return ['product' => $data, 'totalReachDiscount' => $totalReachDiscount, 'smallNum' => $totalSmallNum, 'bigNum' => $totalBigNum, 'price' => $totalPrice, 'totalItemNum' => $totalItemNum];
     }
     }
 
 
     //  //修改某个花材的成本价(采购之后要用到) lqh 2021.04.06
     //  //修改某个花材的成本价(采购之后要用到) lqh 2021.04.06

+ 14 - 0
biz-hd/purchase/classes/PurchaseClass.php

@@ -447,6 +447,9 @@ class PurchaseClass extends BaseClass
         $priceMap = CustomClass::$levelPriceKeyMap;
         $priceMap = CustomClass::$levelPriceKeyMap;
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
 
 
+        //累计满减
+        $totalReachDiscount = 0;
+
         //计算价格= 各个productId的price*num(bigNum,smallNum) + sendCost(配送费)
         //计算价格= 各个productId的price*num(bigNum,smallNum) + sendCost(配送费)
         $bigNum = 0; //总共多少扎
         $bigNum = 0; //总共多少扎
         $smallNum = 0; //总共多少支
         $smallNum = 0; //总共多少支
@@ -492,6 +495,16 @@ class PurchaseClass extends BaseClass
                 //用批发店花材的价格
                 //用批发店花材的价格
                 $price = ProductClass::getFinalPrice($currentGhsProduct, $giveLevel, $priceMap, $addPriceMap, $userPrice, $itemNum);
                 $price = ProductClass::getFinalPrice($currentGhsProduct, $giveLevel, $priceMap, $addPriceMap, $userPrice, $itemNum);
                 $thisPrice = $price;
                 $thisPrice = $price;
+
+                $reachNum = $currentGhsProduct['reachNum'] ?? 0;
+                if ($reachNum > 0) {
+                    if ($itemNum >= $reachNum) {
+                        $reachNumDiscount = $currentGhsProduct['reachNumDiscount'] ?? 0;
+                        $currentReachDiscount = bcmul($reachNumDiscount, $itemNum, 2);
+                        $totalReachDiscount = bcadd($totalReachDiscount, $currentReachDiscount, 2);
+                    }
+                }
+
             } else {
             } else {
                 $currentHdProduct = $hdProductData[$hdProductId] ?? [];
                 $currentHdProduct = $hdProductData[$hdProductId] ?? [];
                 if (empty($currentHdProduct)) {
                 if (empty($currentHdProduct)) {
@@ -616,6 +629,7 @@ class PurchaseClass extends BaseClass
             $realPrice = $modifyPrice;
             $realPrice = $modifyPrice;
         }
         }
 
 
+        $data['reachDiscountPrice'] = $totalReachDiscount;
         $data['prePrice'] = $prePrice;
         $data['prePrice'] = $prePrice;
         $data['bookPrice'] = $actPrice;
         $data['bookPrice'] = $actPrice;
         $data['orderPrice'] = $actPrice;
         $data['orderPrice'] = $actPrice;