moonsflyer 3 luni în urmă
părinte
comite
c9d0140dc2
1 a modificat fișierele cu 1 adăugiri și 70 ștergeri
  1. 1 70
      app/adminapi/logic/goods/GoodsLogic.php

+ 1 - 70
app/adminapi/logic/goods/GoodsLogic.php

@@ -1008,75 +1008,6 @@ class GoodsLogic
             return $e->getMessage();
         }
     }
-    {
-        try {
-            // 使用PhpSpreadsheet处理Excel文件
-            if (is_array($file)) {
-                return $file;
-            }
-            
-            // 检查文件是否存在
-            if (!file_exists($file)) {
-                throw new \Exception('文件不存在');
-            }
-            
-            // 加载Excel文件
-            $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file);
-            $worksheet = $spreadsheet->getActiveSheet();
-            $data = $worksheet->toArray();
-            
-            if (empty($data)) {
-                throw new \Exception('Excel文件为空');
-            }
-            
-            // 获取表头
-            $headers = array_shift($data);
-            $result = [];
-            
-            // 将表头映射为字段名
-            $fieldMap = [
-                '商品ID' => 'goods_id',
-                '商品编码' => 'goods_code',
-                '商品名称' => 'goods_name',
-                '规格ID' => 'item_id',
-                '规格名称' => 'spec_value_str',
-                '销售价格' => 'sell_price',
-                '划线价格' => 'lineation_price',
-                '成本价格' => 'cost_price',
-                '库存数量' => 'stock',
-                '重量(kg)' => 'weight',
-                '体积(m³)' => 'volume'
-            ];
-            
-            // 创建字段索引映射
-            $fieldIndexes = [];
-            foreach ($headers as $index => $header) {
-                if (isset($fieldMap[$header])) {
-                    $fieldIndexes[$fieldMap[$header]] = $index;
-                }
-            }
-            
-            // 处理数据行
-            foreach ($data as $rowIndex => $row) {
-                if (empty(array_filter($row))) {
-                    continue; // 跳过空行
-                }
-                
-                $item = [];
-                foreach ($fieldIndexes as $field => $index) {
-                    $item[$field] = isset($row[$index]) ? trim($row[$index]) : '';
-                }
-                
-                if (!empty($item)) {
-                    $result[$rowIndex + 2] = $item; // +2 因为表头占一行,数组从0开始
-                }
-            }
-            
-            return $result;
-            
-        } catch (\Exception $e) {
-            throw new \Exception('Excel文件解析失败:' . $e->getMessage());
-        }
-    }
 
+    
 }