From 2f4b309430d29db14a694076be236109616ce987 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 2 Dec 2023 13:42:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/merchant/store/StoreImport.php | 5 +++-- crmeb/services/SpreadsheetExcelService.php | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controller/merchant/store/StoreImport.php b/app/controller/merchant/store/StoreImport.php index 7b397065..7947b8f1 100644 --- a/app/controller/merchant/store/StoreImport.php +++ b/app/controller/merchant/store/StoreImport.php @@ -223,7 +223,8 @@ class StoreImport extends BaseController 'L1'=>'商品条码', 'M1'=>'商品品牌', ]; - SpreadsheetExcelService::instance()->checkImport($path,$check); + $a=SpreadsheetExcelService::instance()->checkImport($path,$check,true); + $data = [ 'mer_id' => $this->request->merId(), 'data' => [ @@ -251,7 +252,7 @@ class StoreImport extends BaseController 'K1'=>'商品条码', 'L1'=>'商品品牌', ]; - SpreadsheetExcelService::instance()->checkImport($path,$check); + SpreadsheetExcelService::instance()->checkImport($path,$check,true); $data = [ 'mer_id' => $this->request->merId(), 'data' => [ diff --git a/crmeb/services/SpreadsheetExcelService.php b/crmeb/services/SpreadsheetExcelService.php index 48b37749..ad83abab 100644 --- a/crmeb/services/SpreadsheetExcelService.php +++ b/crmeb/services/SpreadsheetExcelService.php @@ -369,12 +369,19 @@ class SpreadsheetExcelService * @author Qinii * @day 5/7/21 */ - public function checkImport($filePath,$check = []) + public function checkImport($filePath,$check = [],$is_limit=false,$count=1000) { $ext = ucfirst(pathinfo($filePath, PATHINFO_EXTENSION)); $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext); $spreadsheet = $reader->load($filePath); $sheet = $spreadsheet->getActiveSheet(); + if($is_limit==true){ + $limit=$sheet->getHighestRow(); + if($limit>$count){ + throw new ValidateException('导入的条数超过限制数量:'.$count); + } + } + if(!empty($check)){ foreach ($check as $s => $c){ $_c = $sheet->getCell($s)->getValue();