shish 3 лет назад
Родитель
Сommit
2a24e1d696
1 измененных файлов с 34 добавлено и 0 удалено
  1. 34 0
      app-ghs/controllers/OrderController.php

+ 34 - 0
app-ghs/controllers/OrderController.php

@@ -786,6 +786,40 @@ class OrderController extends BaseController
         if (empty($productList)) {
             util::fail('请选择花材');
         }
+
+        $dealPrice = $post['dealPrice'] ?? 0;
+        $ids = array_unique(array_filter(array_column($productList, 'productId')));
+        $itemInfo = ProductClass::getByIds($ids, null, 'id');
+        if (empty($itemInfo)) {
+            util::fail('请选择花材哦');
+        }
+        foreach ($itemInfo as $itemData) {
+            if (isset($itemData['mainId']) == false || $itemData['mainId'] != $this->mainId) {
+                util::fail('只能选择同一家的商品下单');
+            }
+        }
+        //开单提交订单时,别人修改价格,暂成提交价格不是真实卖价问题解决
+        if ($dealPrice == 0) {
+            $diff = [];
+            foreach ($productList as $currentProduct) {
+                $currentPrice = $currentProduct['price'] ?? 0;
+                $currentId = $currentProduct['productId'] ?? 0;
+                $systemInfo = $itemInfo[$currentId] ?? [];
+                $systemPrice = $systemInfo['price'] ?? 0;
+                $name = $systemInfo['name'] ?? '';
+                if (floatval($currentPrice) != floatval($systemPrice)) {
+                    $diff[] = [
+                        'name' => $name,
+                        'price' => $systemPrice,
+                        'kdPrice' => $currentPrice,
+                    ];
+                }
+            }
+            if (!empty($diff)) {
+                util::success(['diff' => $diff, 'respondType' => 'priceError']);
+            }
+        }
+
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {