Przeglądaj źródła

refactor(ThirdParty): 更新商品价格计算逻辑以支持SKU规格

- 将价格处理逻辑从priceRanges改为skuInfos数据结构
- 实现SKU规格价格提取,优先使用consignPrice,备选pifaPrice
- 添加SKU价格过滤机制,只处理大于0的价格
- 重新实现最小最大价格计算逻辑
- 更新注释说明为"取SKU规格价格"
shichen 3 miesięcy temu
rodzic
commit
9a1bd2a83a

+ 14 - 6
app/services/ThirdParty/AlibabaAgent/ProductService.php

@@ -246,15 +246,23 @@ class ProductService extends AlibabaAgentBaseService
246
             }
246
             }
247
         }
247
         }
248
 
248
 
249
-        // --- 价格处理 ---
249
+        // --- 价格处理(取SKU规格价格) ---
250
         $saleInfo = $productInfo['saleInfo'] ?? [];
250
         $saleInfo = $productInfo['saleInfo'] ?? [];
251
-        $priceRanges = $saleInfo['priceRanges'] ?? [];
251
+        $skuInfos = $productInfo['skuInfos'] ?? [];
252
         $minPrice = 0;
252
         $minPrice = 0;
253
         $maxPrice = 0;
253
         $maxPrice = 0;
254
-        if (!empty($priceRanges)) {
255
-            $prices = array_column($priceRanges, 'price');
256
-            $minPrice = !empty($prices) ? (float)min($prices) : 0;
257
-            $maxPrice = !empty($prices) ? (float)max($prices) : 0;
254
+        if (!empty($skuInfos)) {
255
+            $skuPrices = [];
256
+            foreach ($skuInfos as $sku) {
257
+                $skuPrice = (float)($sku['consignPrice'] ?? $sku['pifaPrice'] ?? 0);
258
+                if ($skuPrice > 0) {
259
+                    $skuPrices[] = $skuPrice;
260
+                }
261
+            }
262
+            if (!empty($skuPrices)) {
263
+                $minPrice = (float)min($skuPrices);
264
+                $maxPrice = (float)max($skuPrices);
265
+            }
258
         }
266
         }
259
 
267
 
260
         // --- 商品属性(如品牌、货号、规格等) ---
268
         // --- 商品属性(如品牌、货号、规格等) ---