瀏覽代碼

库存对比导入报错修改

haozi 5 年之前
父節點
當前提交
8bb178bcdf
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      app/Imports/InventoryCompareImport.php

+ 4 - 5
app/Imports/InventoryCompareImport.php

@@ -24,7 +24,6 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
     protected $ownerArr=[];
     public function __construct()
     {
-//            $this->owner_id=$owner_id;
             app()->singleton('InventoryCompareService',InventoryCompareService::class);
     }
 
@@ -45,9 +44,9 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
             if($array[0]['仓库']??false) return '仓库';
             if($array[0]['属性仓']??false) return '属性仓';
         })();
-        $sku=$array[0][$skuName];
-        $amount=$array[0][$amountName];
-        $customLocation=$array[0][$customLocationName];
+        $sku=$array[0][$skuName] ?? null;
+        $amount=$array[0][$amountName] ?? null;
+        $customLocation=$array[0][$customLocationName] ?? null;
 
         $endIS = false;
         if (!isset($sku) || !isset($amount) || !isset($customLocation)) {
@@ -57,7 +56,7 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
         }
         foreach ($collection as $row) {
             $customLocationArr=[
-                'custom_location'=>$row[$customLocationName],
+                'custom_location'=>$row[$customLocationName] ?? null,
             ];
             array_push($this->customLocationArrs,$customLocationArr);
         }