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

fix(product): 修复产品库存数据处理中的空值问题

- 为 cost_price 字段添加空值合并操作符,避免空值导致的错误
- 添加 sku_id 和 spec_id 字段的空值处理,确保数据完整性
- 优化库存数据结构,提高数据处理的稳定性
shichen месяцев назад: 3
Родитель
Сommit
17316230b1
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      app/common/repositories/store/product/ProductRepository.php

+ 3 - 1
app/common/repositories/store/product/ProductRepository.php

@@ -463,7 +463,7 @@ class ProductRepository extends BaseRepository
463 463
                         "sku"           => $sku,
464 464
                         "unique"        => $unique,
465 465
                         "dacang_price"  => $value['dacang_price'],
466
-                        "cost_price"    => $value['cost_price'],
466
+                        "cost_price"    => $value['cost_price'] ?? 0.00,
467 467
                         "gong_sku_id"   => $value['gong_sku_id'],
468 468
                         "pension_num"   => 0,
469 469
                         "share_num"     => 0,
@@ -473,6 +473,8 @@ class ProductRepository extends BaseRepository
473 473
                         'gong_mer_profit' => $value['gong_mer_profit'] ?? 0.00,
474 474
                         'gong_market_price' => $value['gong_market_price'] ?? 0.00,
475 475
                         'plate_mer_profit' => $value['plate_mer_profit'] ?? 0.00,
476
+                        'sku_id' => $value['sku_id'] ?? null,
477
+                        'spec_id' => $value['spec_id'] ?? null,
476 478
                     ];
477 479
                 } else {
478 480
                     $result['attrValue'][] = [