From 0c5dbd48c6d7b349e4bfca737a3dc726017dc44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Thu, 5 Nov 2026 09:19:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=88=E7=89=88=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E9=98=BB=E6=96=AD=E9=87=8D=E5=A4=8D=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/PayablesFinalImportRunner.php | 6 ------ .../Services/PayablesFinalImporter.php | 4 ---- .../PayablesFinalImportRunnerTest.php | 19 +++++++++++++++++++ .../SupplierPayableFinalPagesTest.php | 19 +++++++++++++++++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/modules/EcommerceFinance/Services/PayablesFinalImportRunner.php b/modules/EcommerceFinance/Services/PayablesFinalImportRunner.php index c574bd39..1fb91903 100644 --- a/modules/EcommerceFinance/Services/PayablesFinalImportRunner.php +++ b/modules/EcommerceFinance/Services/PayablesFinalImportRunner.php @@ -201,12 +201,6 @@ class PayablesFinalImportRunner } $key = $this->store->key($dataset, $normalized); - if (isset($records[$key])) { - $message = '第 ' . ($firstRow + $line - 1) . ' 行与前一行内容重复。'; - $this->fail($meta, $line - 1, $created, $updated, $message); - throw ValidationException::withMessages(['import' => $message]); - } - $records[$key] = $normalized; $processed++; diff --git a/modules/EcommerceFinance/Services/PayablesFinalImporter.php b/modules/EcommerceFinance/Services/PayablesFinalImporter.php index 2dd761c3..004bd71d 100644 --- a/modules/EcommerceFinance/Services/PayablesFinalImporter.php +++ b/modules/EcommerceFinance/Services/PayablesFinalImporter.php @@ -97,10 +97,6 @@ class PayablesFinalImporter $key = $store->key($storeDataset, $values); } - if (isset($records[$key])) { - throw ValidationException::withMessages(['import' => "第 {$line} 行与前一行内容重复。"]); - } - $records[$key] = $values; if (count($records) > self::MAX_ROWS) { diff --git a/tests/Feature/Business/PayablesFinalImportRunnerTest.php b/tests/Feature/Business/PayablesFinalImportRunnerTest.php index 0c2cd7dc..9eeb72e2 100644 --- a/tests/Feature/Business/PayablesFinalImportRunnerTest.php +++ b/tests/Feature/Business/PayablesFinalImportRunnerTest.php @@ -93,6 +93,25 @@ class PayablesFinalImportRunnerTest extends FeatureTestCase $this->assertDirectoryDoesNotExist($runner->storagePath() . '/' . $prepared['token'], '完成后应删除缓存'); } + public function test_runner_does_not_block_import_when_rows_have_identical_content(): void + { + $row = '2026-09,RK-1,CG-1,2026-09-08,供应商甲,X-1,P-1,规格甲,2,10,20,9,18,SC-1,备注甲,华东仓,顺丰,SF-1,未发出,对账人甲'; + $file = UploadedFile::fake()->createWithContent( + 'duplicate.csv', + "\xEF\xBB\xBF" . implode(',', self::HEADER) . "\n{$row}\n{$row}\n", + ); + $runner = app(PayablesFinalImportRunner::class); + $fields = app(PayablesFinalRegistry::class)->fields('supplier-payables-final', 'payment-reconciliation'); + $dataset = 'final:supplier:payment-reconciliation'; + + $prepared = $runner->prepare($file, $fields, $dataset, (int) $this->company->id, (int) $this->user->id); + $progress = $runner->process($prepared['token'], 0, 10); + + $this->assertTrue($progress['done']); + $this->assertSame(1, $progress['created']); + $this->assertCount(1, app(SupplierPayableOverrideStore::class)->listRows($dataset, (int) $this->company->id)); + } + public function test_import_endpoints_accept_uploads_and_chunks(): void { $file = UploadedFile::fake()->createWithContent( diff --git a/tests/Feature/Business/SupplierPayableFinalPagesTest.php b/tests/Feature/Business/SupplierPayableFinalPagesTest.php index e7a2ab01..954453f1 100644 --- a/tests/Feature/Business/SupplierPayableFinalPagesTest.php +++ b/tests/Feature/Business/SupplierPayableFinalPagesTest.php @@ -318,6 +318,25 @@ class SupplierPayableFinalPagesTest extends FeatureTestCase $this->assertSame(['created' => 4500, 'updated' => 0, 'rows' => 4500], $result); } + public function test_final_import_does_not_reject_identical_rows(): void + { + $row = '2026-09,RK-1,CG-1,2026-09-08,供应商甲,X-1,P-1,规格甲,2,10,20,9,18,SC-1,备注甲,华东仓,顺丰,SF-1,未发出,对账人甲'; + $file = UploadedFile::fake()->createWithContent( + 'payment-reconciliation.csv', + "\xEF\xBB\xBF月份,入库单号,采购单号,日期,供应商,货号,商品编码,规格名称,数量,单价,金额,预估单价,预估金额,供应商商品编码,备注,仓库名称,快递名称,快递单号,未发出,对账人\n{$row}\n{$row}\n", + ); + + $result = app(PayablesFinalImporter::class)->import( + app(PayablesFinalRegistry::class)->fields('supplier-payables-final', 'payment-reconciliation'), + 'final:supplier:payment-reconciliation', + $file, + (int) $this->company->id, + (int) $this->user->id, + ); + + $this->assertSame(['created' => 1, 'updated' => 0, 'rows' => 1], $result); + } + public function test_final_import_stops_at_the_row_limit_without_writing(): void { $lines = ['月份,入库单号,采购单号,日期,供应商,货号,商品编码,规格名称,数量,单价,金额,预估单价,预估金额,供应商商品编码,备注,仓库名称,快递名称,快递单号,未发出,对账人'];