瀏覽代碼

涨价问题

shish 7 月之前
父節點
當前提交
62e72454ee
共有 2 個文件被更改,包括 33 次插入16 次删除
  1. 6 1
      app-ghs/controllers/OrderController.php
  2. 27 15
      biz-hd/purchase/classes/PurchaseClass.php

+ 6 - 1
app-ghs/controllers/OrderController.php

@@ -1225,7 +1225,11 @@ class OrderController extends BaseController
 
         $diff = [];
         $priceMap = CustomClass::$levelPriceKeyMap;
+        //这个参数应该是要作废的,但下面加的参数是有用的,多处要同步修改,关键词 abandon_add_price_map ,ssh 20260116
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+        //但这边加的参数是有用的,给指定客户涨价的
+        $addPriceMap['risePercent'] = $custom['risePercent'] ?? 0;
+
         $level = $custom['level'] ?? 1;
         foreach ($productList as $currentProduct) {
             $currentPrice = $currentProduct['price'] ?? 0;
@@ -3037,7 +3041,8 @@ class OrderController extends BaseController
         $order->lat = $lat;
         $order->long = $long;
         $order->save();
-        if ($post['syncDefaultAddress'] == 1) {
+        $syncDefaultAddress = $post['syncDefaultAddress'] ?? 0;
+        if ($syncDefaultAddress == 1) {
             $customId = $order->customId ?? 0;
             $custom = CustomClass::getById($customId, true);
             if (!empty($custom)) {

+ 27 - 15
biz-hd/purchase/classes/PurchaseClass.php

@@ -784,7 +784,10 @@ class PurchaseClass extends BaseClass
 
         $giveLevel = $ghs['giveLevel'] ?? 0;
         $priceMap = CustomClass::$levelPriceKeyMap;
+        //这个参数应该是要作废的,但下面加的参数是有用的,多处要同步修改,关键词 abandon_add_price_map ,ssh 20260116
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+        //但这边加的参数是有用的,给指定客户涨价的
+        $addPriceMap['risePercent'] = $ghs['risePercent'] ?? 0;
 
         //累计满减
         $totalReachDiscount = 0;
@@ -1004,21 +1007,30 @@ class PurchaseClass extends BaseClass
         }
 
         //如果有设置指定客户涨价百分之几,然后又设置了涨价的幅度。【这个功能主要用于客户不收他运费,门店不赚钱,收他运费客户不乐意,所以把运费加到花材里】,多处同步修改,关键词rise_percent_rang
-        if (isset($data['itemPrice']) && $actPrice >= $data['itemPrice']) {
-            if (isset($ghs['risePercent']) && $ghs['risePercent'] > 0) {
-                if (isset($ghs['riseRange']) && $ghs['riseRange'] > 0) {
-                    $risePercent = $ghs['risePercent'];
-                    $riseRange = $ghs['riseRange'];
-                    // 计算涨价金额:涨价后金额 * (涨价百分比 / (100 + 涨价百分比))
-                    $riseAmount = bcmul($data['itemPrice'], bcdiv($risePercent, bcadd(100, $risePercent, 0), 4), 2);
-                    if($riseAmount>$riseRange){
-                        //应该退回的金额
-                        $backAmount = bcsub($riseAmount, $riseRange, 2);
-                        $actPrice = bcsub($actPrice, $backAmount, 2);
-                        if(isset($data['orderReachDiscountPrice'])){
-                            $data['orderReachDiscountPrice'] = bcadd($data['orderReachDiscountPrice'], $backAmount, 2);
-                        }else{
-                            $data['orderReachDiscountPrice'] = $backAmount;
+        if (isset($data['itemPrice'])) {
+            if(isset($data['orderReachDiscountPrice'])){
+                $myActPrice = bcadd($actPrice, $data['orderReachDiscountPrice'], 2);
+            }else{
+                $myActPrice = $actPrice;
+            }
+            if($myActPrice >= $data['itemPrice']){
+                if (isset($ghs['risePercent']) && $ghs['risePercent'] > 0) {
+                    if (isset($ghs['riseRange']) && $ghs['riseRange'] > 0) {
+                        $risePercent = $ghs['risePercent'];
+                        $riseRange = $ghs['riseRange'];
+                        // 计算涨价金额:涨价后金额 * (涨价百分比 / (100 + 涨价百分比))
+                        $riseAmount = bcmul($data['itemPrice'], bcdiv($risePercent, bcadd(100, $risePercent, 0), 4), 2);
+                        if($riseAmount>$riseRange){
+                            //应该退回的金额
+                            $backAmount = bcsub($riseAmount, $riseRange, 2);
+                            $actPrice = bcsub($actPrice, $backAmount, 2);
+                            if(isset($data['orderReachDiscountPrice'])){
+                                if($data['orderReachDiscountPrice']<$backAmount){
+                                    $data['orderReachDiscountPrice'] = $backAmount;
+                                }
+                            }else{
+                                $data['orderReachDiscountPrice'] = $backAmount;
+                            }
                         }
                     }
                 }