From 957504ac1eb276d2530110b5dee9670ac6134b4d Mon Sep 17 00:00:00 2001 From: shanshi <3316401569@qq.com> Date: Wed, 18 Nov 2026 13:51:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=86=85=E9=83=A8?= =?UTF-8?q?=E8=BD=AC=E8=B4=A6=E5=AE=A1=E8=AE=A1=E5=AD=97=E6=AE=B5=E8=B6=85?= =?UTF-8?q?=E9=95=BF=20(#1227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复内部转账审计类型超过 `fin_ledger_edit_events.entity_type` 20 字符限制导致的事务回滚和 Server Error。 将类型缩短为 `internal_xfer_create` / `internal_xfer_delete`,并补充审计落库测试。 验证:内部转账创建、删除测试 2 项通过,38 个断言。 --- .../Services/FinanceLedgerInternalTransferEditor.php | 4 ++-- .../Business/FinanceLedgerManualTransactionTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/EcommerceFinance/Services/FinanceLedgerInternalTransferEditor.php b/modules/EcommerceFinance/Services/FinanceLedgerInternalTransferEditor.php index 9caacdeb..30cd1248 100644 --- a/modules/EcommerceFinance/Services/FinanceLedgerInternalTransferEditor.php +++ b/modules/EcommerceFinance/Services/FinanceLedgerInternalTransferEditor.php @@ -112,7 +112,7 @@ class FinanceLedgerInternalTransferEditor } if ($created > 0) { - $this->audit('internal_transfer_create', $approvalNo, [ + $this->audit('internal_xfer_create', $approvalNo, [ 'txn_date' => $date, 'from_account_short' => $from, 'to_account_short' => $to, @@ -162,7 +162,7 @@ class FinanceLedgerInternalTransferEditor ->where('source', FinanceLedgerTransactionWriter::INTERNAL_TRANSFER_SOURCE) ->where('approval_no', $approvalNo) ->delete(); - $this->audit('internal_transfer_delete', $approvalNo, [ + $this->audit('internal_xfer_delete', $approvalNo, [ 'rows' => $rows->map(static fn (object $item): array => [ 'account_short' => (string) $item->account_short, 'income' => round((float) $item->income, 2), diff --git a/tests/Feature/Business/FinanceLedgerManualTransactionTest.php b/tests/Feature/Business/FinanceLedgerManualTransactionTest.php index a2b6f1f3..a4bce2d0 100644 --- a/tests/Feature/Business/FinanceLedgerManualTransactionTest.php +++ b/tests/Feature/Business/FinanceLedgerManualTransactionTest.php @@ -435,6 +435,10 @@ class FinanceLedgerManualTransactionTest extends FeatureTestCase 'account_short' => '手工账户乙', 'current_balance' => 30, ], 'business_mirror'); + $this->assertDatabaseHas('fin_ledger_edit_events', [ + 'entity_type' => 'internal_xfer_create', + 'user_name' => 'Test User', + ], 'business_mirror'); $this->postJson($this->internalTransferUrl(), $payload) ->assertOk() @@ -469,6 +473,10 @@ class FinanceLedgerManualTransactionTest extends FeatureTestCase 'account_short' => '手工账户乙', 'current_balance' => 0, ], 'business_mirror'); + $this->assertDatabaseHas('fin_ledger_edit_events', [ + 'entity_type' => 'internal_xfer_delete', + 'user_name' => 'Test User', + ], 'business_mirror'); } public function test_internal_transfer_page_and_same_account_validation(): void