Просмотр исходного кода

feat(AlibabaAgent): 添加主图参数传递到SKU插入方法

- 在insertStoreSkus方法中新增$mainImage参数
- 将商品主图传递给SKU数据插入流程
- 为默认SKU设置主图为默认图片字段值
shichen месяцев назад: 3
Родитель
Сommit
6bfe28ba59
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      app/services/ThirdParty/AlibabaAgent/ProductService.php

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

@@ -487,7 +487,7 @@ class ProductService extends AlibabaAgentBaseService
487
             ]);
487
             ]);
488
 
488
 
489
             // 9. 写入 store_product_attr 和 store_product_attr_value
489
             // 9. 写入 store_product_attr 和 store_product_attr_value
490
-            $this->insertStoreSkus($productId, $skuList, $merId, $costPrice);
490
+            $this->insertStoreSkus($productId, $skuList, $merId, $costPrice,$mainImage);
491
 
491
 
492
             Log::channel('alibaba')->info("[1688正式入库1] 商品{$importGoods['product_id']}入库成功,product_id={$productId},mer_id={$merId}");
492
             Log::channel('alibaba')->info("[1688正式入库1] 商品{$importGoods['product_id']}入库成功,product_id={$productId},mer_id={$merId}");
493
 
493
 
@@ -509,7 +509,7 @@ class ProductService extends AlibabaAgentBaseService
509
      * @param array $skuList    formatDetailResult 返回的 skuList
509
      * @param array $skuList    formatDetailResult 返回的 skuList
510
      * @param int   $merId
510
      * @param int   $merId
511
      */
511
      */
512
-    protected function insertStoreSkus(int $productId, array $skuList, int $merId, $costPrice): void
512
+    protected function insertStoreSkus(int $productId, array $skuList, int $merId, $costPrice, $mainImage): void
513
     {
513
     {
514
         if (empty($skuList)) {
514
         if (empty($skuList)) {
515
             // 单规格:写入默认规格
515
             // 单规格:写入默认规格
@@ -525,7 +525,7 @@ class ProductService extends AlibabaAgentBaseService
525
                 'product_id'  => $productId,
525
                 'product_id'  => $productId,
526
                 'detail'      => json_encode(['规格' => '默认'], JSON_UNESCAPED_UNICODE),
526
                 'detail'      => json_encode(['规格' => '默认'], JSON_UNESCAPED_UNICODE),
527
                 'sku'         => '默认',
527
                 'sku'         => '默认',
528
-                'image'       => '',
528
+                'image'       => $mainImage,
529
                 'cost'        => $costPrice,
529
                 'cost'        => $costPrice,
530
                 'ot_price'    => $costPrice,
530
                 'ot_price'    => $costPrice,
531
                 'price'       => $costPrice,
531
                 'price'       => $costPrice,