导入
This commit is contained in:
@@ -91,12 +91,14 @@ class SkuController extends BaseController
|
||||
{
|
||||
|
||||
$file = $request->file('file');
|
||||
if (!$file) return json(['code'=>1,'msg'=>'未上传文件']);
|
||||
if (!$file) return $this->error('未上传文件');;
|
||||
|
||||
$zipPath = runtime_path('upload/' . uniqid() . '.zip');
|
||||
$file->move($zipPath);
|
||||
|
||||
$extractTo = runtime_path('upload/import/');
|
||||
|
||||
clearstatcache(true, $zipPath);
|
||||
$this->unzipPackage($zipPath,$extractTo);
|
||||
|
||||
$path = runtime_path('upload/import/product.xlsx');
|
||||
@@ -172,12 +174,16 @@ class SkuController extends BaseController
|
||||
if(!empty($rowData[6])){
|
||||
$tmpPath = runtime_path('upload/import/pic/'.$rowData[6]);
|
||||
$res = $uploadService->uploadLocalFile(['path' => $tmpPath, 'scene' => 'sku']);
|
||||
$data['main_image'] = $res['file_url'];
|
||||
$data['main_image'] = $res['file_name'];
|
||||
}
|
||||
//详情
|
||||
if(!empty($rowData[7])){
|
||||
$docxFullPath = runtime_path('upload/import/docs/'.$rowData[7]);
|
||||
$data['desc'] =$this->docxToHtmlWithImages($docxFullPath);
|
||||
|
||||
if (filesize($docxFullPath) !== 0 && file_exists($zipPath)) {
|
||||
$data['desc'] =$this->docxToHtmlWithImages($docxFullPath);
|
||||
}
|
||||
//$data['desc'] =$this->docxToHtmlWithImages($docxFullPath);
|
||||
}
|
||||
|
||||
$data['code'] = $this->service->generateUniqueCode();
|
||||
@@ -198,6 +204,7 @@ class SkuController extends BaseController
|
||||
// Db::table('sku')->insert($insertData);
|
||||
$insertData = [];
|
||||
}
|
||||
@unlink($zipPath);
|
||||
}
|
||||
|
||||
if ($insertData) {
|
||||
@@ -205,7 +212,6 @@ class SkuController extends BaseController
|
||||
// Db::table('sku')->insert($insertData);
|
||||
}
|
||||
|
||||
@unlink($zipPath);
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
|
||||
Reference in New Issue
Block a user