Sfoglia il codice sorgente

fix(ThirdParty): 解决阿里代理商品服务中的重复检查和价格计算问题

- 注释掉商品重复入库检查逻辑以允许重复导入
- 添加空SKU列表的价格计算回退机制
- 当SKU列表为空时使用产品基础价格作为最小最大成本价格
- 确保价格计算逻辑在所有情况下都能正常工作
shichen 3 mesi fa
parent
commit
2d349c1420
1 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 9 4
      app/services/ThirdParty/AlibabaAgent/ProductService.php

+ 9 - 4
app/services/ThirdParty/AlibabaAgent/ProductService.php

@@ -407,9 +407,9 @@ class ProductService extends AlibabaAgentBaseService
407 407
                 ->where('is_del', 0)
408 408
                 ->value('product_id');
409 409
 
410
-            if ($exists) {
411
-                return ['code' => 400, 'msg' => '商品已入库,product_id=' . $exists, 'product_id' => $exists];
412
-            }
410
+            // if ($exists) {
411
+            //     return ['code' => 400, 'msg' => '商品已入库,product_id=' . $exists, 'product_id' => $exists];
412
+            // }
413 413
 
414 414
             // 3. 解析 product_info JSON
415 415
             $productInfo = json_decode($importGoods['product_info'], true) ?: [];
@@ -433,9 +433,14 @@ class ProductService extends AlibabaAgentBaseService
433 433
             $prices = array_column($skuList, 'price');
434 434
             $minPrice = !empty($prices) ? (float)min($prices) : 0;
435 435
             $maxPrice = !empty($prices) ? (float)max($prices) : 0;
436
-
437 436
             // 成本价取第一个SKU的成本价
438 437
             $costPrice = $skuList[0]['costPrice'] ?? 0;
438
+            if (empty($skuList)) {
439
+                $prices = $productInfo['price'];
440
+                $minPrice = $prices;
441
+                $maxPrice = $prices;
442
+                $costPrice = $prices;
443
+            }
439 444
 
440 445
             // 7. 写入 store_product 表
441 446
             $productData = [