shish 11 месяцев назад
Родитель
Сommit
0ecac92a40

+ 2 - 2
app-hd/controllers/GoodsController.php

@@ -150,8 +150,8 @@ class GoodsController extends BaseController
     public function actionGetGoodsInfoList()
     {
         $get = Yii::$app->request->get();
-        $cId = isset($get['cId']) ? $get['cId'] : 0;
-        $flowerNum = isset($get['flowerNum']) ? $get['flowerNum'] : 0;
+        $cId = $get['cId'] ?? 0;
+        $flowerNum = $get['flowerNum'] ?? 0;
         if (empty($cId)) {
             util::fail('分类不能为空');
         }

+ 49 - 13
app-hd/controllers/OrderController.php

@@ -472,6 +472,7 @@ class OrderController extends BaseController
         $post['sjId'] = $this->sjId;
         $post['shopId'] = $this->shopId;
         $post['mainId'] = $this->mainId ?? 0;
+        $shop = $this->shop;
         $now = time();
         $orderValidTime = getenv('ORDER_VALID_TIME') == false ? 600 : getenv('ORDER_VALID_TIME');
         $expireTime = $now + $orderValidTime;
@@ -597,29 +598,64 @@ class OrderController extends BaseController
             if ($version == 2) {
                 $dealPrice = $post['dealPrice'] ?? 0;
                 if ($dealPrice == 0) {
-                    $ids = array_unique(array_filter(array_column($productList, 'productId')));
-                    $itemInfo = ProductClass::getByIds($ids, null, 'id');
-                    if (empty($itemInfo)) {
-                        util::fail('要选择花材哦');
+                    $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');
                     }
                     $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;
-                        $systemInfo = $itemInfo[$currentId] ?? [];
-                        $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,
-                            ];
+                        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 (floatval($currentPrice) != floatval($systemPrice)) {
+                                    $diff[] = [
+                                        'name' => $name,
+                                        'price' => $systemPrice,
+                                        'kdPrice' => $currentPrice,
+                                    ];
+                                }
+                            }
                         }
                     }
+
                     if (!empty($diff)) {
                         util::success(['diff' => $diff, 'respondType' => 'priceError']);
                     }

+ 1 - 1
biz-hd/goods/classes/GoodsClass.php

@@ -375,7 +375,7 @@ class GoodsClass extends BaseClass
         $price = $data['price'] ?? 0;
         $priceBeforeRise = $price;
         //后台修改商品时,取原价,不需要显示涨价金额 getOriginalPrice=1 有涨价也强制取原价
-        $getOriginalPrice = $data['getOriginalPrice'] ?? 0;
+        $getOriginalPrice = $params['getOriginalPrice'] ?? 0;
         if ($riseSwitch == 1 && $riseAmount > 0 && $getOriginalPrice == 0) {
             if ($riseType == 0) {
                 //百分比