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

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

sunxbiao месяцев назад: 6
Родитель
Сommit
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 176
             $processedSku = [
177 177
                 'sku_id' => $sku['sku_id'] ?? 0,
178 178
                 'plat_price' => $sku['plat_price'],
179
-                'img_url' => $sku['img_url'],
179
+                'img_url' => $sku['main_img'],
180 180
                 'retail_price' => $sku['retail_price'] ?? 0,
181 181
                 'cost_price' => $this->calculateCostPrice($sku['plat_price']),
182 182
                 'market_price' => $this->calculateMarketPrice($sku['plat_price']),
@@ -566,7 +566,7 @@ class WiwibaoProductSync extends Command
566 566
         $spuIdInfo = json_decode($data['spuId_info'], true);
567 567
 
568 568
         // 4. 处理图片数据
569
-        $sliderImage = $spuIdInfo['detail_img_list'] ?? '';
569
+        $sliderImage = $spuIdInfo['detail_img_list'] ?: '[]';
570 570
         $image = $spuIdInfo['cover_url'] ?? '';
571 571
 
572 572
         try {
@@ -618,7 +618,7 @@ class WiwibaoProductSync extends Command
618 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 647
                 ->where('product_id', $product['product_id'])
648 648
                 ->update([
649 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 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 746
             'error' => $e->getMessage()
748 747
         ];
749 748
 
750
-        Log::error('商品同步错误', $errorInfo);
749
+        Log::error('商品同步错误' . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
751 750
 
752 751
         Db::name('log')->insert([
753 752
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),