From 7bb4667a4717e28359ca6feb8f9d77fa8b634c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Wed, 2 Dec 2026 19:35:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8C=89=E4=BB=B7=E6=A0=BC=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=97=A5=E6=8E=92=E9=99=A4=E4=BA=8B=E5=90=8E=E8=A1=A5?= =?UTF-8?q?=E5=BD=95=E4=BB=B7=E6=A0=BC=20Co-authored-by:=20=E8=8B=8F?= =?UTF-8?q?=E6=9C=A8=20<594326199@qq.com>=20Co-committed-by:=20=E8=8B=8F?= =?UTF-8?q?=E6=9C=A8=20<594326199@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/PayablesUnpricedCycleProcessor.php | 8 +++++++- .../Business/PayablesUnpricedCycleTest.php | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/EcommerceFinance/Services/PayablesUnpricedCycleProcessor.php b/modules/EcommerceFinance/Services/PayablesUnpricedCycleProcessor.php index 309499dcb..81db6a4f2 100644 --- a/modules/EcommerceFinance/Services/PayablesUnpricedCycleProcessor.php +++ b/modules/EcommerceFinance/Services/PayablesUnpricedCycleProcessor.php @@ -294,6 +294,10 @@ class PayablesUnpricedCycleProcessor $rows = DB::connection($connectionName) ->table(SupplierPayableForecastRepository::PRICE_TABLE) ->where('effectStartTime', '<=', $cutoffAt->format('Y-m-d H:i:s')) + ->where(static function ($query) use ($cutoffAt): void { + $query->whereNull('createTime') + ->orWhere('createTime', '<=', $cutoffAt->format('Y-m-d H:i:s')); + }) ->where(static function ($query) use ($cutoffAt): void { $query->whereNull('effectEndTime') ->orWhere('effectEndTime', '') @@ -312,7 +316,9 @@ class PayablesUnpricedCycleProcessor $completed = $this->date($row->createTime ?? null); $end = $this->date($row->effectEndTime ?? null); if ($code === '' || $price === null || $start === null - || $start > $cutoffAt || ($end !== null && $end < $cutoffAt)) { + || $start > $cutoffAt + || ($completed !== null && $completed > $cutoffAt) + || ($end !== null && $end < $cutoffAt)) { continue; } diff --git a/tests/Feature/Business/PayablesUnpricedCycleTest.php b/tests/Feature/Business/PayablesUnpricedCycleTest.php index 21eb91688..c2f04ef6d 100644 --- a/tests/Feature/Business/PayablesUnpricedCycleTest.php +++ b/tests/Feature/Business/PayablesUnpricedCycleTest.php @@ -236,6 +236,9 @@ class PayablesUnpricedCycleTest extends FeatureTestCase 'id:auto:delivery:matched-1' => [ 'supplier' => '供应商甲', 'barCode' => 'M-1', 'qty' => '2', 'unitPrice' => null, 'amount' => null, ], + 'id:auto:delivery:late-created-price' => [ + 'supplier' => '供应商乙', 'barCode' => 'LATE-1', 'qty' => '1', 'unitPrice' => null, 'amount' => null, + ], ], $companyId, $userId, 'test'); $store->saveBatch(PayablesUnpricedCycleProcessor::RETURN_HISTORY_DATASET, [ 'id:auto:return:matched' => [ @@ -257,6 +260,9 @@ class PayablesUnpricedCycleTest extends FeatureTestCase $this->assertSame('8', $pricedReturn[0]['unit_price']); $this->assertSame('24.00', $pricedReturn[0]['amount']); $this->assertSame('2026-10', $pricedDelivery[0]['_accounting_period']); + $remainingDelivery = $store->listRows(PayablesUnpricedCycleProcessor::DELIVERY_HISTORY_DATASET, $companyId); + $this->assertCount(1, $remainingDelivery); + $this->assertSame('LATE-1', $remainingDelivery[0]['barCode']); $this->artisan('payables:unpriced-cycle:auto', [ '--company' => $companyId, @@ -356,6 +362,17 @@ class PayablesUnpricedCycleTest extends FeatureTestCase 'effectEndTime' => null, 'createTime' => '2026-09-01 00:00:00', ], + [ + 'Id' => 4, + 'skucode' => 'LATE-1', + 'priceType' => '定价', + 'originalPrice' => 9, + 'afterPrice' => 9, + 'diffPrice' => 0, + 'effectStartTime' => '2000-01-01 00:00:00', + 'effectEndTime' => null, + 'createTime' => '2026-11-02 09:21:01', + ], ]); DB::connection('business_mirror')->table('business_mirror_table_states')->insert([ 'dataset_key' => 'jiansun.dbo.pm_priceAdjustment_log',