shish 16 часов назад
Родитель
Сommit
1b3c296cf0
1 измененных файлов с 35 добавлено и 12 удалено
  1. 35 12
      app-ghs/controllers/OrderController.php

+ 35 - 12
app-ghs/controllers/OrderController.php

@@ -1621,25 +1621,48 @@ class OrderController extends BaseController
                     'kdPrice' => $currentPrice,
                 ];
             } else {
-                //后端开单,如果没有改价格,并且数量达到花材满减要求,则自动给减价格,关键词 back_order_reach_discount_price
+
+                $limitBuy = $systemInfo['limitBuy'] ?? 0;
                 $bigNum = $currentProduct['bigNum'] ?? 0;
-                $reachNum = $systemInfo['reachNum'] ?? 0;
-                if ($reachNum > 0 && $bigNum >= $reachNum) {
-                    $reachNumDiscount = $systemInfo['reachNumDiscount'] ?? 0;
-                    $unitPrice = $currentProduct['price'] ?? 0;
-                    if ($unitPrice > $reachNumDiscount) {
-                        $newUnitPrice = bcsub($unitPrice, $reachNumDiscount, 2);
-                        $calcPrice = bcmul($reachNumDiscount, $bigNum, 2);
-                        if ($calcPrice > 0 && isset($post['modifyPrice']) && $post['modifyPrice'] > $calcPrice) {
-                            $productList[$ptKey]['price'] = $newUnitPrice;
-                            //提交给后端的总金额也要减掉,否则会有问题
+                if ($limitBuy == 1) {
+                    if ($bigNum > 0) {
+                        //限购在这里开发,关键词 xg_develop
+                        $productList[$ptKey]['price'] = $systemPrice;
+                        if ($currentPrice > $systemPrice) {
+                            $diffPrice = bcsub($currentPrice, $systemPrice, 2);
+                            $calcPrice = bcmul($diffPrice, $bigNum, 2);
                             $post['modifyPrice'] = bcsub($post['modifyPrice'], $calcPrice, 2);
-                            $post['reachDiscountPrice'] = bcadd($post['reachDiscountPrice'], $calcPrice, 2);
+                        }
+                        if ($currentPrice < $systemPrice) {
+                            $diffPrice = bcsub($systemPrice, $currentPrice, 2);
+                            $calcPrice = bcmul($diffPrice, $bigNum, 2);
+                            $post['modifyPrice'] = bcadd($post['modifyPrice'], $calcPrice, 2);
+                        }
+                    } else {
+                        util::fail('限购花材暂不能开小单位');
+                    }
+                } else {
+                    //后端开单,如果没有改价格,并且数量达到花材满减要求,则自动给减价格,关键词 back_order_reach_discount_price
+                    $reachNum = $systemInfo['reachNum'] ?? 0;
+                    if ($reachNum > 0 && $bigNum >= $reachNum) {
+                        $reachNumDiscount = $systemInfo['reachNumDiscount'] ?? 0;
+                        $unitPrice = $currentProduct['price'] ?? 0;
+                        if ($unitPrice > $reachNumDiscount) {
+                            $newUnitPrice = bcsub($unitPrice, $reachNumDiscount, 2);
+                            $calcPrice = bcmul($reachNumDiscount, $bigNum, 2);
+                            if ($calcPrice > 0 && isset($post['modifyPrice']) && $post['modifyPrice'] > $calcPrice) {
+                                $productList[$ptKey]['price'] = $newUnitPrice;
+                                //提交给后端的总金额也要减掉,否则会有问题
+                                $post['modifyPrice'] = bcsub($post['modifyPrice'], $calcPrice, 2);
+                                $post['reachDiscountPrice'] = bcadd($post['reachDiscountPrice'], $calcPrice, 2);
+                            }
                         }
                     }
                 }
+
             }
         }
+
         //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
         if ($dealPrice == 0) {
             if (!empty($diff)) {