From d9cae425f0174058160a6678d8290267b40a7258 Mon Sep 17 00:00:00 2001 From: renshen <1005457301@qq.com> Date: Fri, 6 Nov 2026 15:06:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=88=E5=B9=B6=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=B8=80=E5=A4=A9=E5=81=9C=E7=95=99=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShopInfoFlowMirrorRepository.php | 22 ++++++++++--------- tests/Feature/Settings/NavigationTest.php | 1 + .../ShopInfoFlowMirrorRepositoryTest.php | 6 ++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/EcommerceFinance/Repositories/ShopInfoFlowMirrorRepository.php b/modules/EcommerceFinance/Repositories/ShopInfoFlowMirrorRepository.php index 6aae083d..fff01789 100644 --- a/modules/EcommerceFinance/Repositories/ShopInfoFlowMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/ShopInfoFlowMirrorRepository.php @@ -40,8 +40,7 @@ class ShopInfoFlowMirrorRepository /** 当前节点等待天数分档:值为该档包含的最小天数(含)和最大天数(不含)。 */ public const WAITING_DAY_BUCKETS = [ - '1天内' => [0, 1], - '1天' => [1, 2], + '1天' => [0, 2], '2天' => [2, 3], '3天' => [3, 4], '4天' => [4, 5], @@ -168,10 +167,13 @@ class ShopInfoFlowMirrorRepository $query->whereIn('o.flowStatus', $codes === [] ? [-1] : $codes); } - $waitingDays = array_values(array_intersect( - $this->filterValues($filters['node_waiting_days'] ?? ''), + $waitingDays = array_values(array_unique(array_intersect( + array_map( + static fn (string $label): string => $label === '1天内' ? '1天' : $label, + $this->filterValues($filters['node_waiting_days'] ?? ''), + ), array_keys(self::WAITING_DAY_BUCKETS), - )); + ))); if ($waitingDays !== []) { $now = now(); $query->where(function (Builder $buckets) use ($waitingDays, $now): void { @@ -180,13 +182,13 @@ class ShopInfoFlowMirrorRepository $buckets->orWhere(function (Builder $bucket) use ($minimumDays, $maximumDays, $now): void { $bucket->whereIn('o.flowStatus', [1, 7]) ->where('o.updateTime', '<=', $now); - if ($minimumDays === 0) { - $bucket->where('o.updateTime', '>', $now->copy()->subDay()); - } elseif ($maximumDays === null) { + if ($maximumDays === null) { $bucket->where('o.updateTime', '<=', $now->copy()->subDays($minimumDays)); } else { - $bucket->where('o.updateTime', '>', $now->copy()->subDays($maximumDays)) - ->where('o.updateTime', '<=', $now->copy()->subDays($minimumDays)); + $bucket->where('o.updateTime', '>', $now->copy()->subDays($maximumDays)); + if ($minimumDays > 0) { + $bucket->where('o.updateTime', '<=', $now->copy()->subDays($minimumDays)); + } } }); } diff --git a/tests/Feature/Settings/NavigationTest.php b/tests/Feature/Settings/NavigationTest.php index 87d0332e..7e3e9a3f 100644 --- a/tests/Feature/Settings/NavigationTest.php +++ b/tests/Feature/Settings/NavigationTest.php @@ -423,6 +423,7 @@ class NavigationTest extends FeatureTestCase ->assertSee('data-directory-multi-select="flow_type"', false) ->assertSee('data-directory-multi-select="approval_status"', false) ->assertSee('data-directory-multi-select="node_waiting_days"', false) + ->assertDontSeeText('1天内') // 当前节点和进入时间只展示,不再生成查询条件。 ->assertDontSee('data-directory-query-field="current_node"', false) ->assertDontSee('data-directory-query-field="node_entered_at"', false) diff --git a/tests/Unit/EcommerceFinance/ShopInfoFlowMirrorRepositoryTest.php b/tests/Unit/EcommerceFinance/ShopInfoFlowMirrorRepositoryTest.php index b905001d..95859a2c 100644 --- a/tests/Unit/EcommerceFinance/ShopInfoFlowMirrorRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/ShopInfoFlowMirrorRepositoryTest.php @@ -110,7 +110,7 @@ class ShopInfoFlowMirrorRepositoryTest extends TestCase $this->assertSame('审批节点(审核人A)', $rows['shp-2']['current_node']); $this->assertSame('2026-10-02 10:00:00', $rows['shp-2']['node_entered_at']); $this->assertSame('2小时30分钟', $rows['shp-2']['node_waiting_duration']); - $this->assertSame('1天内', $rows['shp-2']['node_waiting_days']); + $this->assertSame('1天', $rows['shp-2']['node_waiting_days']); $this->assertSame('店铺关店', $rows['shp-3']['flow_type']); $this->assertSame('拒绝', $rows['shp-3']['approval_status']); $this->assertSame('已拒绝', $rows['shp-3']['current_node']); @@ -145,6 +145,8 @@ class ShopInfoFlowMirrorRepositoryTest extends TestCase try { $fixtures = [ + [8, 'waiting-under-1d', '流程中', '2026-11-05 02:00:00', '1天'], + [9, 'waiting-exact-1d', '流程中', '2026-11-04 12:00:00', '1天'], [10, 'waiting-5d', '流程中', '2026-10-31 11:00:00', '5天'], [11, 'waiting-6d', '流程中', '2026-10-30 10:00:00', '6天'], [12, 'waiting-7d', '流程中', '2026-10-29 10:00:00', '7天'], @@ -184,6 +186,8 @@ class ShopInfoFlowMirrorRepositoryTest extends TestCase 'flow_id' => 'waiting-', 'node_waiting_days' => $days, ])['total']; + $this->assertSame(2, $count(['1天'])); + $this->assertSame(2, $count(['1天内'])); $this->assertSame(1, $count(['5天'])); $this->assertSame(2, $count(['6天', '7天'])); $this->assertSame(1, $count(['8-14天'])); -- 2.47.2