Преглед на файлове

命令行-修复拉取微唯宝商品逻辑

sunxbiao преди 6 месеца
родител
ревизия
db49018390
променени са 1 файла, в които са добавени 6 реда и са изтрити 7 реда
  1. 6 7
      app/command/WiwibaoProductSync.php

+ 6 - 7
app/command/WiwibaoProductSync.php

@@ -176,7 +176,7 @@ class WiwibaoProductSync extends Command
176
             $processedSku = [
176
             $processedSku = [
177
                 'sku_id' => $sku['sku_id'] ?? 0,
177
                 'sku_id' => $sku['sku_id'] ?? 0,
178
                 'plat_price' => $sku['plat_price'],
178
                 'plat_price' => $sku['plat_price'],
179
-                'img_url' => $sku['img_url'],
179
+                'img_url' => $sku['main_img'],
180
                 'retail_price' => $sku['retail_price'] ?? 0,
180
                 'retail_price' => $sku['retail_price'] ?? 0,
181
                 'cost_price' => $this->calculateCostPrice($sku['plat_price']),
181
                 'cost_price' => $this->calculateCostPrice($sku['plat_price']),
182
                 'market_price' => $this->calculateMarketPrice($sku['plat_price']),
182
                 'market_price' => $this->calculateMarketPrice($sku['plat_price']),
@@ -566,7 +566,7 @@ class WiwibaoProductSync extends Command
566
         $spuIdInfo = json_decode($data['spuId_info'], true);
566
         $spuIdInfo = json_decode($data['spuId_info'], true);
567
 
567
 
568
         // 4. 处理图片数据
568
         // 4. 处理图片数据
569
-        $sliderImage = $spuIdInfo['detail_img_list'] ?? '';
569
+        $sliderImage = $spuIdInfo['detail_img_list'] ?: '[]';
570
         $image = $spuIdInfo['cover_url'] ?? '';
570
         $image = $spuIdInfo['cover_url'] ?? '';
571
 
571
 
572
         try {
572
         try {
@@ -618,7 +618,7 @@ class WiwibaoProductSync extends Command
618
             $this->offlineProductBySpuId($spuId, 'third_party_offline');
618
             $this->offlineProductBySpuId($spuId, 'third_party_offline');
619
         }
619
         }
620
 
620
 
621
-        Log::info("下架第三方已下架商品", ['count' => count($offlineSpuIds), 'spu_ids' => $offlineSpuIds]);
621
+        Log::info("下架第三方已下架商品" . json_encode(['count' => count($offlineSpuIds), 'spu_ids' => $offlineSpuIds]));
622
     }
622
     }
623
 
623
 
624
     /**
624
     /**
@@ -647,8 +647,7 @@ class WiwibaoProductSync extends Command
647
                 ->where('product_id', $product['product_id'])
647
                 ->where('product_id', $product['product_id'])
648
                 ->update([
648
                 ->update([
649
                     'is_show' => 0,
649
                     'is_show' => 0,
650
-                    'offline_time' => time(),
651
-                    'offline_reason' => $reason
650
+                    'status' => 2
652
                 ]);
651
                 ]);
653
 
652
 
654
             // 记录日志
653
             // 记录日志
@@ -703,7 +702,7 @@ class WiwibaoProductSync extends Command
703
      */
702
      */
704
     protected function calculateCostPrice($platPrice)
703
     protected function calculateCostPrice($platPrice)
705
     {
704
     {
706
-        return bcadd($platPrice, bcmul($platPrice, '0.03', 4), 2);
705
+        return bcadd((string)$platPrice, bcmul((string)$platPrice, '0.03', 4), 2);
707
     }
706
     }
708
 
707
 
709
     /**
708
     /**
@@ -747,7 +746,7 @@ class WiwibaoProductSync extends Command
747
             'error' => $e->getMessage()
746
             'error' => $e->getMessage()
748
         ];
747
         ];
749
 
748
 
750
-        Log::error('商品同步错误', $errorInfo);
749
+        Log::error('商品同步错误' . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
751
 
750
 
752
         Db::name('log')->insert([
751
         Db::name('log')->insert([
753
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
752
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),