shish 11 месяцев назад
Родитель
Сommit
405b5d79eb
1 измененных файлов с 52 добавлено и 55 удалено
  1. 52 55
      app-hd/controllers/OrderController.php

+ 52 - 55
app-hd/controllers/OrderController.php

@@ -655,42 +655,56 @@ class OrderController extends BaseController
             }
 
             //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
-            $version = $post['version'] ?? 0;
-            if ($version == 2) {
-                $dealPrice = $post['dealPrice'] ?? 0;
-                if ($dealPrice == 0) {
-                    $productIds = [];
-                    $hsIds = [];
-                    foreach ($productList as $pv) {
-                        $property = $pv['property'] ?? 0;
-                        $puId = $pv['productId'] ?? 0;
-                        if ($property == 0) {
-                            $hsIds[] = $puId;
-                        } else {
-                            $productIds[] = $puId;
-                        }
-                    }
-                    $itemInfo = [];
-                    if (!empty($productIds)) {
-                        $itemInfo = ProductClass::getByIds($productIds, null, 'id');
-                    }
-                    $hsInfo = [];
-                    if (!empty($hsIds)) {
-                        $hsInfo = GoodsClass::getByIds($hsIds, null, 'id');
+            $dealPrice = $post['dealPrice'] ?? 0;
+            if ($dealPrice == 0) {
+                $productIds = [];
+                $hsIds = [];
+                foreach ($productList as $pv) {
+                    $property = $pv['property'] ?? 0;
+                    $puId = $pv['productId'] ?? 0;
+                    if ($property == 0) {
+                        $hsIds[] = $puId;
+                    } else {
+                        $productIds[] = $puId;
                     }
-                    $diff = [];
-                    $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
-                    $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
-                    $level = 0;
-                    foreach ($productList as $currentProduct) {
-                        $property = $currentProduct['property'] ?? 0;
-                        $currentPrice = $currentProduct['unitPrice'] ?? 0;
-                        $currentId = $currentProduct['productId'] ?? 0;
-                        if ($property == 1) {
-                            $systemInfo = $itemInfo[$currentId] ?? [];
-                            if (!empty($systemInfo)) {
-                                $name = $systemInfo['name'] ?? '';
-                                $systemPrice = \bizGhs\product\classes\ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
+                }
+                $itemInfo = [];
+                if (!empty($productIds)) {
+                    $itemInfo = ProductClass::getByIds($productIds, null, 'id');
+                }
+                $hsInfo = [];
+                if (!empty($hsIds)) {
+                    $hsInfo = GoodsClass::getByIds($hsIds, null, 'id');
+                }
+                $diff = [];
+                $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
+                $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
+                $level = 0;
+                foreach ($productList as $currentProduct) {
+                    $property = $currentProduct['property'] ?? 0;
+                    $currentPrice = $currentProduct['unitPrice'] ?? 0;
+                    $currentId = $currentProduct['productId'] ?? 0;
+                    if ($property == 1) {
+                        $systemInfo = $itemInfo[$currentId] ?? [];
+                        if (!empty($systemInfo)) {
+                            $name = $systemInfo['name'] ?? '';
+                            $systemPrice = \bizGhs\product\classes\ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
+                            if (floatval($currentPrice) != floatval($systemPrice)) {
+                                $diff[] = [
+                                    'name' => $name,
+                                    'price' => $systemPrice,
+                                    'kdPrice' => $currentPrice,
+                                ];
+                            }
+                        }
+                    } else {
+                        $systemInfo = $hsInfo[$currentId] ?? [];
+                        if (!empty($systemInfo)) {
+                            $params = [];
+                            $name = $systemInfo['name'] ?? '';
+                            $hsData = GoodsClass::getFinalPrice($systemInfo, $shop, $custom, $params);
+                            $systemPrice = $hsData['price'] ?? 0;
+                            if ($systemInfo['priceType'] == 1) {
                                 if (floatval($currentPrice) != floatval($systemPrice)) {
                                     $diff[] = [
                                         'name' => $name,
@@ -699,29 +713,12 @@ class OrderController extends BaseController
                                     ];
                                 }
                             }
-                        } else {
-                            $systemInfo = $hsInfo[$currentId] ?? [];
-                            if (!empty($systemInfo)) {
-                                $params = [];
-                                $name = $systemInfo['name'] ?? '';
-                                $hsData = GoodsClass::getFinalPrice($systemInfo, $shop, $custom, $params);
-                                $systemPrice = $hsData['price'] ?? 0;
-                                if ($systemInfo['priceType'] == 1) {
-                                    if (floatval($currentPrice) != floatval($systemPrice)) {
-                                        $diff[] = [
-                                            'name' => $name,
-                                            'price' => $systemPrice,
-                                            'kdPrice' => $currentPrice,
-                                        ];
-                                    }
-                                }
-                            }
                         }
                     }
+                }
 
-                    if (!empty($diff)) {
-                        util::success(['diff' => $diff, 'respondType' => 'priceError']);
-                    }
+                if (!empty($diff)) {
+                    util::success(['diff' => $diff, 'respondType' => 'priceError']);
                 }
             }