From 1c107cf3aeb856e1fb560dcdaddfc1ff29bc4ce5 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Mon, 2 Nov 2026 17:48:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4OA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=B4=B9=E7=A7=91=E7=9B=AE=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0000_refresh_oa_platform_usage_mapping.php | 74 +++++++++++++++++++ .../data/oa_process_account_mapping.json | 6 +- .../ManagementExpensesPageDataTest.php | 3 + 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2026_11_02_220000_refresh_oa_platform_usage_mapping.php diff --git a/database/migrations/2026_11_02_220000_refresh_oa_platform_usage_mapping.php b/database/migrations/2026_11_02_220000_refresh_oa_platform_usage_mapping.php new file mode 100644 index 00000000..98300dc3 --- /dev/null +++ b/database/migrations/2026_11_02_220000_refresh_oa_platform_usage_mapping.php @@ -0,0 +1,74 @@ +environment('testing') + || (string) config('system_database.mode', 'bootstrap') === 'bootstrap') { + return; + } + + $schema = Schema::connection($this->connection()); + if (! $schema->hasTable('oa_process_account_mapping')) { + return; + } + + $mapping = json_decode( + (string) file_get_contents(base_path('resources/data/oa_process_account_mapping.json')), + true, + 512, + JSON_THROW_ON_ERROR, + ); + $codes = array_column($mapping, 'account_code'); + if ($mapping === [] || count($codes) !== count(array_unique($codes))) { + throw new \RuntimeException('流程科目映射快照为空或科目编码重复。'); + } + + $database = $schema->getConnection(); + $now = now(); + foreach (array_chunk($mapping, 100) as $chunk) { + $database->table('oa_process_account_mapping')->upsert( + array_map(static fn (array $row): array => [ + 'account_code' => (string) $row['account_code'], + 'account_name' => (string) $row['account_name'], + 'expense_category' => (string) $row['expense_category'], + 'second_level' => $row['second_level'] + ?? ((string) $row['expense_category'] . '(未细分)'), + 'third_level' => $row['third_level'] ?? '未细分', + 'in_fee_ratio' => (bool) $row['in_fee_ratio'], + 'allocation' => $row['allocation'] ?? null, + 'created_at' => $now, + 'updated_at' => $now, + ], $chunk), + ['account_code'], + [ + 'account_name', + 'expense_category', + 'second_level', + 'third_level', + 'in_fee_ratio', + 'allocation', + 'updated_at', + ], + ); + } + + $database->table('oa_process_account_mapping') + ->whereNotIn('account_code', $codes) + ->delete(); + } + + public function down(): void + { + // 已确认的业务映射在回滚时保留。 + } +}; diff --git a/resources/data/oa_process_account_mapping.json b/resources/data/oa_process_account_mapping.json index 020b9ebd..e8ddf422 100644 --- a/resources/data/oa_process_account_mapping.json +++ b/resources/data/oa_process_account_mapping.json @@ -752,9 +752,9 @@ { "account_code": "1123.11", "account_name": "预付账款_平台使用费", - "expense_category": "往来", - "second_level": "往来", - "third_level": "充值", + "expense_category": "摊销", + "second_level": "摊销", + "third_level": "平台使用费", "in_fee_ratio": false, "allocation": "分摊", "source_row": 77 diff --git a/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php b/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php index 82961b38..d00004d2 100644 --- a/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php +++ b/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php @@ -251,6 +251,9 @@ class ManagementExpensesPageDataTest extends TestCase $this->assertSame('摊销', $mappingByCode['1123.09.99']['expense_category']); $this->assertSame('摊销', $mappingByCode['1123.09.99']['second_level']); $this->assertSame('租赁', $mappingByCode['1123.09.99']['third_level']); + $this->assertSame('摊销', $mappingByCode['1123.11']['expense_category']); + $this->assertSame('摊销', $mappingByCode['1123.11']['second_level']); + $this->assertSame('平台使用费', $mappingByCode['1123.11']['third_level']); $this->assertSame('空包费', $mappingByCode['1221.07']['third_level']); $this->assertTrue($mappingByCode['1221.07']['in_fee_ratio']); $this->assertSame('管理费用', $mappingByCode['5602.11.03.19']['expense_category']); -- 2.47.2