From a2138704fb29036fa89041da0010a1ed9ce94aef Mon Sep 17 00:00:00 2001 From: DoDo <1060330844@qq.com> Date: Tue, 8 Sep 2026 16:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=8A=A5=E8=A1=A8=E5=BA=97=E9=93=BA=20ID=20=E5=B9=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=97=E9=93=BA=E5=90=8D=E7=A7=B0=E5=88=97?= =?UTF-8?q?=20(#128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Business/UpstreamBusinessInformation.php | 10 ++++------ config/business_navigation.php | 1 + .../BusinessInformationMirrorRepository.php | 5 +++-- .../Repositories/StoreReportRepository.php | 3 +-- .../pages/partials/directory-table.blade.php | 2 +- .../pages/partials/prototype-page.blade.php | 2 +- tests/Feature/Business/ManagementCrudTest.php | 13 ++++++++----- .../BusinessInformationMirrorRepositoryTest.php | 7 +++++++ .../EcommerceFinance/StoreReportRepositoryTest.php | 4 +++- 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/app/Business/UpstreamBusinessInformation.php b/app/Business/UpstreamBusinessInformation.php index 8d6b1884..24039b72 100644 --- a/app/Business/UpstreamBusinessInformation.php +++ b/app/Business/UpstreamBusinessInformation.php @@ -189,15 +189,12 @@ SQL); */ private function storeMatchesFilters(array $row, array $filters): bool { - foreach (['erp_store_name', 'store_id', 'profit_center', 'store_manager', 'department_manager', 'company_type'] as $key) { + foreach (['erp_store_name', 'store_name', 'store_id', 'profit_center', 'store_manager', 'department_manager', 'company_type'] as $key) { $expected = trim((string) ($filters[$key] ?? '')); if ($expected === '') { continue; } - // 页面“店铺ID(唯一值)”展示 ERP 店铺名称,筛选按同一列匹配。 - $actual = $key === 'store_id' - ? trim((string) ($row['erp_store_name'] ?? '')) - : trim((string) ($row[$key] ?? '')); + $actual = trim((string) ($row[$key] ?? '')); if ($actual !== $expected) { return false; } @@ -231,7 +228,7 @@ SQL); { $rows = $query->select(<< '店铺维度报表尚未完成共享数据导入。', 'fields' => [ ['name' => 'erp_store_name', 'label' => 'ERP系统店铺名称'], + ['name' => 'store_name', 'label' => '店铺名称'], ['name' => 'store_id', 'label' => '店铺ID(唯一值)'], ['name' => 'profit_center', 'label' => '店铺所属利润中心'], ['name' => 'store_manager', 'label' => '店铺负责人'], diff --git a/modules/EcommerceFinance/Repositories/BusinessInformationMirrorRepository.php b/modules/EcommerceFinance/Repositories/BusinessInformationMirrorRepository.php index 43b197ed..0700039e 100644 --- a/modules/EcommerceFinance/Repositories/BusinessInformationMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/BusinessInformationMirrorRepository.php @@ -110,8 +110,8 @@ SQL) { foreach ([ 'erp_store_name' => 's.erpShopName', - // 页面“店铺ID(唯一值)”列展示的就是 ERP 店铺名称,筛选按同一列匹配。 - 'store_id' => 's.erpShopName', + 'store_name' => 's.shopName', + 'store_id' => 's.sotreId', 'profit_center' => 's.responsibleDepartment', 'store_manager' => 's.shopHead', 'department_manager' => 's.customerDeptManager', @@ -225,6 +225,7 @@ s.sotreId AS store_id, s.openTime AS opened_at, s.renewalTime AS renewed_at, s.erpShopName AS erp_store_name, +s.shopName AS store_name, s.unifiedSocialCreditCode AS unified_social_credit_code, c.businessLicenseName AS company_name, c.businessLicenseType AS company_type, diff --git a/modules/EcommerceFinance/Repositories/StoreReportRepository.php b/modules/EcommerceFinance/Repositories/StoreReportRepository.php index 398f342a..3da15e78 100644 --- a/modules/EcommerceFinance/Repositories/StoreReportRepository.php +++ b/modules/EcommerceFinance/Repositories/StoreReportRepository.php @@ -49,7 +49,7 @@ class StoreReportRepository $rules[$prefix . '_to'][] = 'after_or_equal:' . $prefix . '_from'; } } - foreach (['erp_store_name', 'store_id', 'profit_center', 'store_manager', 'department_manager', 'entity', 'company_type'] as $key) { + foreach (['erp_store_name', 'store_name', 'store_id', 'profit_center', 'store_manager', 'department_manager', 'entity', 'company_type'] as $key) { $rules[$key] = ['nullable', 'string', 'max:191']; } $rules['status'] = ['nullable', 'string', 'in:0,3,6']; @@ -125,7 +125,6 @@ class StoreReportRepository $expiresAt = $this->date($period['expires_at'] ?? null, self::DEFAULT_EXPIRES_AT); $row = [ ...$store, - 'store_id' => $storeName, 'status' => $this->status($store['store_status'] ?? null), 'can_change' => $this->canChange($store['platform'] ?? null), 'entity' => $period['company_name'] ?: ($store['company_name'] ?? null), diff --git a/resources/views/business/pages/partials/directory-table.blade.php b/resources/views/business/pages/partials/directory-table.blade.php index 73c7719a..bce18cb2 100644 --- a/resources/views/business/pages/partials/directory-table.blade.php +++ b/resources/views/business/pages/partials/directory-table.blade.php @@ -388,7 +388,7 @@
@php $storeFilterTextFields = [ - ['name' => 'erp_store_name', 'label' => '店铺名称:'], + ['name' => 'store_name', 'label' => '店铺名称:'], ['name' => 'store_id', 'label' => '店铺ID:'], ['name' => 'profit_center', 'label' => '利润中心:'], ['name' => 'store_manager', 'label' => '店铺负责人:'], diff --git a/resources/views/business/pages/partials/prototype-page.blade.php b/resources/views/business/pages/partials/prototype-page.blade.php index 9c8a2234..73a88c57 100644 --- a/resources/views/business/pages/partials/prototype-page.blade.php +++ b/resources/views/business/pages/partials/prototype-page.blade.php @@ -62,7 +62,7 @@ ], 'store-report' => [ 'title' => '店铺维度报表', 'description' => '查看店铺销量及历史主体归属', - 'columns' => ['ERP系统店铺名称', '店铺ID(唯一值)', '店铺所属利润中心', '店铺负责人', '部门负责人', '开店时间', '状态', '能否变更', '主体', '公司类型', '生效时间', '失效时间', '期间销量', '1月销量', '2月销量', '3月销量', '4月销量', '5月销量', '6月销量', '7月销量', '8月销量', '9月销量', '10月销量', '11月销量', '12月销量'], + 'columns' => ['ERP系统店铺名称', '店铺名称', '店铺ID(唯一值)', '店铺所属利润中心', '店铺负责人', '部门负责人', '开店时间', '状态', '能否变更', '主体', '公司类型', '生效时间', '失效时间', '期间销量', '1月销量', '2月销量', '3月销量', '4月销量', '5月销量', '6月销量', '7月销量', '8月销量', '9月销量', '10月销量', '11月销量', '12月销量'], ], ]; $definition = $definitions[$slug] ?? ['title' => $page['title'] ?? '业务页面', 'description' => '', 'columns' => [], 'rows' => []]; diff --git a/tests/Feature/Business/ManagementCrudTest.php b/tests/Feature/Business/ManagementCrudTest.php index 5ee45c6d..c7e6c5cc 100644 --- a/tests/Feature/Business/ManagementCrudTest.php +++ b/tests/Feature/Business/ManagementCrudTest.php @@ -227,8 +227,9 @@ class ManagementCrudTest extends FeatureTestCase $service = Mockery::mock(UpstreamBusinessInformation::class); $service->shouldReceive('paginate')->once()->with('store-management', 'store-report', 50)->andReturn( new LengthAwarePaginator([[ - 'erp_store_name' => '测试店铺', - 'store_id' => '测试店铺', + 'erp_store_name' => 'ERP测试店铺', + 'store_name' => '前台测试店铺', + 'store_id' => 'SHOP-001', 'profit_center' => '运营中心A', 'store_manager' => '店铺负责人', 'department_manager' => '部门负责人', @@ -252,7 +253,9 @@ class ManagementCrudTest extends FeatureTestCase $response ->assertOk() ->assertSeeText('店铺维度报表') - ->assertSeeText('测试店铺') + ->assertSeeText('ERP测试店铺') + ->assertSeeText('前台测试店铺') + ->assertSeeText('SHOP-001') ->assertSeeText('测试主体') ->assertSeeText('2026-07-01') ->assertSeeText('存续中') @@ -261,7 +264,7 @@ class ManagementCrudTest extends FeatureTestCase ->assertSeeText('共享镜像'); preg_match_all('/)/', $response->getContent(), $headers); - $this->assertCount(26, $headers[0]); + $this->assertCount(27, $headers[0]); } public function testTrademarkInformationShowsReadOnlyUpstreamRows(): void @@ -385,7 +388,7 @@ class ManagementCrudTest extends FeatureTestCase ['section' => 'company-management', 'page' => 'personnel-inventory', 'headers' => ['人员名称', '税务局密码', '可担任公司数量']], ['section' => 'company-management', 'page' => 'company-progress', 'headers' => ['公司进度表字段尚未定义']], ['section' => 'trademark-management', 'page' => 'trademark-progress', 'headers' => ['商标号', '是否完成', '办理人']], - ['section' => 'store-management', 'page' => 'store-report', 'headers' => ['店铺ID(唯一值)', '1月销量', '12月销量']], + ['section' => 'store-management', 'page' => 'store-report', 'headers' => ['ERP系统店铺名称', '店铺名称', '店铺ID(唯一值)', '1月销量', '12月销量']], ['section' => 'store-management', 'page' => 'change-progress', 'headers' => ['接替公司', '完成时间', '办理人']], ['section' => 'other', 'page' => 'todos', 'headers' => ['待办编号', '是否逾期', '关闭日期']], ['section' => 'other', 'page' => 'warnings', 'headers' => ['风险等级', '影响金额', '处理证据']], diff --git a/tests/Unit/EcommerceFinance/BusinessInformationMirrorRepositoryTest.php b/tests/Unit/EcommerceFinance/BusinessInformationMirrorRepositoryTest.php index 3c9d6422..fc41ca46 100644 --- a/tests/Unit/EcommerceFinance/BusinessInformationMirrorRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/BusinessInformationMirrorRepositoryTest.php @@ -65,6 +65,10 @@ class BusinessInformationMirrorRepositoryTest extends TestCase $store = $this->repository->paginate('store-information.read', 1, 20); $trademarks = $this->repository->paginate('trademark-information.read', 1, 20); $receivingStores = $this->repository->receivingAccountStores(); + $filteredStores = $this->repository->allStores([ + 'store_name' => '上游店铺名', + 'store_id' => 'STORE-8', + ]); $this->assertSame(3, $companies['total']); $this->assertSame(1, $companies['data'][0]['id']); @@ -74,6 +78,9 @@ class BusinessInformationMirrorRepositoryTest extends TestCase $this->assertSame('有效商标', $trademarks['data'][0]['trademark_name']); $this->assertSame('2027-01-01', $companies['data'][0]['subscribed_at']); $this->assertSame('STORE-8', $store['data'][0]['store_id']); + $this->assertSame('上游店铺名', $store['data'][0]['store_name']); + $this->assertCount(1, $filteredStores); + $this->assertSame([], $this->repository->allStores(['store_id' => '测试店'])); $this->assertSame('2027-08-14', $store['data'][0]['renewed_at']); $this->assertSame('负责人', $store['data'][0]['store_manager']); $this->assertSame('上游店铺名', $receivingStores[0]['shop_name']); diff --git a/tests/Unit/EcommerceFinance/StoreReportRepositoryTest.php b/tests/Unit/EcommerceFinance/StoreReportRepositoryTest.php index 148e47d3..9ff6a97e 100644 --- a/tests/Unit/EcommerceFinance/StoreReportRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/StoreReportRepositoryTest.php @@ -82,7 +82,7 @@ class StoreReportRepositoryTest extends TestCase $this->insertBill('店铺A', '2027-01-01 10:00:00', 5); $rows = $this->repository->rows([ - ['erp_store_name' => '店铺A', 'company_name' => '旧主体', 'store_status' => '3'], + ['erp_store_name' => '店铺A', 'store_name' => '前台店铺A', 'store_id' => 'SHOP-001', 'company_name' => '旧主体', 'store_status' => '3'], ], 2026); $this->assertSame(['主体甲', '主体乙'], array_column($rows, 'entity')); @@ -91,6 +91,8 @@ class StoreReportRepositoryTest extends TestCase $this->assertSame([100.0, 0.0], array_column($rows, 'sales_05')); $this->assertSame([0.0, 70.0], array_column($rows, 'sales_07')); $this->assertSame(['关店中', '关店中'], array_column($rows, 'status')); + $this->assertSame(['前台店铺A', '前台店铺A'], array_column($rows, 'store_name')); + $this->assertSame(['SHOP-001', 'SHOP-001'], array_column($rows, 'store_id')); $this->assertSame(['2026-07-01', '存续中'], array_column($rows, 'invalid_at')); }