From a2fbc66fb7cd8575bcac1d16bf4099121556e78a Mon Sep 17 00:00:00 2001 From: DoDo <1060330844@qq.com> Date: Wed, 18 Nov 2026 14:52:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E9=97=A8=E8=B4=9F=E8=B4=A3?= =?UTF-8?q?=E4=BA=BA=E5=8F=AA=E5=8F=96=E5=BA=97=E9=93=BA=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E8=B5=84=E6=96=99=20(#1231)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Business/UpstreamBusinessInformation.php | 16 ++++---- .../UpstreamBusinessInformationTest.php | 40 +++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/Business/UpstreamBusinessInformation.php b/app/Business/UpstreamBusinessInformation.php index 779efd62..bd5dc633 100644 --- a/app/Business/UpstreamBusinessInformation.php +++ b/app/Business/UpstreamBusinessInformation.php @@ -529,7 +529,7 @@ SQL); } /** - * 店铺基础信息页每次读取时把负责人字段覆盖为店铺账号镜像中的值。 + * 店铺基础信息页从店铺账号镜像关联负责人;部门负责人不使用旧档案兜底。 * 账号店铺名与 ERP 店铺名只差下划线/空格,因此统一归一后关联。 * * @param list> $rows @@ -542,16 +542,16 @@ SQL); $key = StoreAccountMirrorRepository::storeNameKey($row['erp_store_name'] ?? ''); $match = $ownership[$key] ?? null; if ($match === null) { + // 部门负责人只认店铺账号密码镜像,不能沿用可能属于其他口径的旧档案值。 + $row['department_manager'] = null; continue; } - foreach ([ - 'store_manager' => $match['operation_owner'], - 'department_manager' => $match['operation_department_head'], - ] as $field => $value) { - if ($value !== '') { - $row[$field] = $value; - } + + if ($match['operation_owner'] !== '') { + $row['store_manager'] = $match['operation_owner']; } + $departmentManager = trim((string) $match['operation_department_head']); + $row['department_manager'] = $departmentManager !== '' ? $departmentManager : null; } unset($row); diff --git a/tests/Unit/EcommerceFinance/UpstreamBusinessInformationTest.php b/tests/Unit/EcommerceFinance/UpstreamBusinessInformationTest.php index bb05bf3b..127c041d 100644 --- a/tests/Unit/EcommerceFinance/UpstreamBusinessInformationTest.php +++ b/tests/Unit/EcommerceFinance/UpstreamBusinessInformationTest.php @@ -165,6 +165,46 @@ class UpstreamBusinessInformationTest extends TestCase $this->assertSame([], $summaryCards->all()); } + public function test_store_basic_information_does_not_fall_back_to_stale_department_manager(): void + { + $mirror = Mockery::mock(BusinessInformationMirrorRepository::class); + $mirror->shouldReceive('ready')->once()->with('store-information.read')->andReturnTrue(); + $mirror->shouldReceive('allStores')->once()->with([])->andReturn([ + [ + 'id' => 7, + 'erp_store_name' => '拼多多-无账号店铺', + 'store_manager' => '旧店铺负责人', + 'department_manager' => '错误的旧部门负责人', + ], + [ + 'id' => 8, + 'erp_store_name' => '拼多多-账号无部门店铺', + 'store_manager' => '旧店铺负责人', + 'department_manager' => '另一个错误的旧部门负责人', + ], + ]); + $accounts = Mockery::mock(StoreAccountMirrorRepository::class); + $accounts->shouldReceive('ownershipByStoreName')->once()->andReturn([ + StoreAccountMirrorRepository::storeNameKey('拼多多-账号无部门店铺') => [ + 'operation_owner' => '账号店铺负责人', + 'operation_department_head' => '', + 'operation_director' => '运营总监', + 'profit_center' => '运营中心A', + ], + ]); + + $paginator = (new UpstreamBusinessInformation( + Mockery::mock(UpstreamQueryCacheFactory::class), + $mirror, + null, + $accounts, + ))->paginate('store-management', 'basic-information', 50); + + $rows = collect($paginator->items())->keyBy('erp_store_name'); + $this->assertNull($rows['拼多多-无账号店铺']->department_manager); + $this->assertNull($rows['拼多多-账号无部门店铺']->department_manager); + } + public function test_trademark_classification_is_normalized_to_digits_only(): void { $mirror = Mockery::mock(BusinessInformationMirrorRepository::class);