supplier_id = $supplier_id; $this->zip_file = $zip_file; } /** * Execute the job. * * @return void * @throws Exception */ public function handle() { if (!$this->supplier_id) { throw new Exception('未指定要导入的供应商'); } else if (!$this->zip_file) { throw new Exception('未指定要导入的zip文件'); } $extract_path = Storage::path('excel/extract/' . basename($this->zip_file, '.zip')); $zip = new ZipArchive; if ($zip->open($this->zip_file) === TRUE && $zip->extractTo($extract_path)) { $zip->close(); } else { throw new Exception("解压文件 {$this->zip_file} 失败!"); } # 解压后删除压缩文件 unlink($this->zip_file); Excel::import(new ProductImport($this->supplier_id, $extract_path), $extract_path . '/产品.xlsx'); } }