Переглянути джерело

feat(AlibabaAgent): 更新商品服务以支持成本价传递

- 在 insertStoreSkus 方法中添加 costPrice 参数
- 将成本价应用于商品 SKU 的成本、原价和价格字段
- 修复 1688 商品入库流程中的价格设置逻辑
shichen 3 місяців тому
батько
коміт
8018de97d2

+ 5 - 5
app/services/ThirdParty/AlibabaAgent/ProductService.php

@@ -482,7 +482,7 @@ class ProductService extends AlibabaAgentBaseService
482 482
             ]);
483 483
 
484 484
             // 9. 写入 store_product_attr 和 store_product_attr_value
485
-            $this->insertStoreSkus($productId, $skuList, $merId);
485
+            $this->insertStoreSkus($productId, $skuList, $merId, $costPrice);
486 486
 
487 487
             Log::channel('alibaba')->info("[1688正式入库1] 商品{$importGoods['product_id']}入库成功,product_id={$productId},mer_id={$merId}");
488 488
 
@@ -504,7 +504,7 @@ class ProductService extends AlibabaAgentBaseService
504 504
      * @param array $skuList    formatDetailResult 返回的 skuList
505 505
      * @param int   $merId
506 506
      */
507
-    protected function insertStoreSkus(int $productId, array $skuList, int $merId): void
507
+    protected function insertStoreSkus(int $productId, array $skuList, int $merId, $costPrice): void
508 508
     {
509 509
         if (empty($skuList)) {
510 510
             // 单规格:写入默认规格
@@ -521,9 +521,9 @@ class ProductService extends AlibabaAgentBaseService
521 521
                 'detail'      => json_encode(['规格' => '默认'], JSON_UNESCAPED_UNICODE),
522 522
                 'sku'         => '默认',
523 523
                 'image'       => '',
524
-                'cost'        => 0,
525
-                'ot_price'    => 0,
526
-                'price'       => 0,
524
+                'cost'        => $costPrice,
525
+                'ot_price'    => $costPrice,
526
+                'price'       => $costPrice,
527 527
                 'unique'      => $unique,
528 528
                 'stock'       => 9999,
529 529
                 'cost_price'  => 0,