From 9f73d1915c0534038f3fd24f2df2ba416499fa40 Mon Sep 17 00:00:00 2001 From: yueyang Date: Tue, 29 Sep 2026 17:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E7=9B=AE=E6=98=A0=E5=B0=84=E8=A1=A8?= =?UTF-8?q?=EF=BC=9A=E5=8C=BA=E5=88=86=E6=9D=A1=E4=BB=B6=E7=95=99=E7=A9=BA?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B9=B6=E5=AF=BC=E5=87=BA=E4=B8=BA=E3=80=8C?= =?UTF-8?q?-=E3=80=8D=EF=BC=8C=E5=AF=BC=E5=85=A5=E6=8C=89=E4=B8=8D?= =?UTF-8?q?=E9=99=90=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Business/AccountMappingActions.php | 7 ++++++- .../Services/AccountMappingStore.php | 7 +++++++ .../financial-rules/account-mapping.blade.php | 12 ++++++------ .../Feature/Business/AccountMappingMatcherTest.php | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Business/AccountMappingActions.php b/app/Http/Controllers/Business/AccountMappingActions.php index 045f5d6d6..e37d314cd 100644 --- a/app/Http/Controllers/Business/AccountMappingActions.php +++ b/app/Http/Controllers/Business/AccountMappingActions.php @@ -333,7 +333,12 @@ class AccountMappingActions extends Controller foreach ($rules as $rule) { $row = []; foreach (array_keys(AccountMappingStore::LABELS) as $field) { - $row[] = $this->csvText($rule[$field] ?? ''); + $value = (string) ($rule[$field] ?? ''); + // 商品名称关键词留空时导出成「-」,与页面一致(导回来会按空处理) + if ($field === 'goods' && trim($value) === '') { + $value = '-'; + } + $row[] = $this->csvText($value); } fputcsv($csv, $row); } diff --git a/modules/EcommerceFinance/Services/AccountMappingStore.php b/modules/EcommerceFinance/Services/AccountMappingStore.php index 18030d053..4f49b0e68 100644 --- a/modules/EcommerceFinance/Services/AccountMappingStore.php +++ b/modules/EcommerceFinance/Services/AccountMappingStore.php @@ -300,6 +300,13 @@ class AccountMappingStore $out['basis'] = self::CATEGORY_BASIS[$out['category']] ?? self::BASIS_OUT; } + // 区分条件里的「-」「—」表示“不限”,按空处理:否则匹配时会拿它去找关键词,规则永远命中不了 + foreach (['memo', 'goods'] as $field) { + if (in_array($out[$field], ['-', '—', '-'], true)) { + $out[$field] = ''; + } + } + return $out; } diff --git a/resources/views/business/pages/financial-rules/account-mapping.blade.php b/resources/views/business/pages/financial-rules/account-mapping.blade.php index 179109d6e..fcea45a9d 100644 --- a/resources/views/business/pages/financial-rules/account-mapping.blade.php +++ b/resources/views/business/pages/financial-rules/account-mapping.blade.php @@ -541,8 +541,8 @@ + '' + (index + 1) + '' + '' + '' - + '' - + '' + + '' + + '' + '' + '' + '' + acctEditor('dAcct', 'dSub') + '' @@ -558,8 +558,8 @@ + '' + (index + 1) + '' + '' + esc(r.platform) + '' + '▶ ' + esc(r.item) + '' - + '' + esc(r.memo) + '' - + '' + esc(r.goods) + '' + + '' + esc(r.memo || '-') + '' + + '' + esc(r.goods || '-') + '' + '' + esc(r.invoice || '—') + '' + '' + esc(r.category) + '' + '' + acct(r.dAcct, r.dSub) + '' @@ -822,8 +822,8 @@ + '新' + '' + '' - + '' - + '' + + '' + + '' + '' + '' + '' + acctEditor('dAcct', 'dSub') + '' diff --git a/tests/Feature/Business/AccountMappingMatcherTest.php b/tests/Feature/Business/AccountMappingMatcherTest.php index 6d9c55017..7d350199d 100644 --- a/tests/Feature/Business/AccountMappingMatcherTest.php +++ b/tests/Feature/Business/AccountMappingMatcherTest.php @@ -136,6 +136,20 @@ class AccountMappingMatcherTest extends FeatureTestCase $this->assertContains('duplicate_pair', $this->issueCodes([$second['id'], $third['id']]), '条件相同的两条要报重复'); } + /** 「-」表示不限:存进去按空处理,匹配时不会拿它当关键词去找 */ + public function test_dash_means_no_condition(): void + { + $rule = $this->rule(['item' => '在线支付', 'memo' => '-', 'goods' => '-']); + + $this->assertSame('', $rule['memo']); + $this->assertSame('', $rule['goods']); + + $hit = $this->matcher->match('测试平台', '在线支付', ['推广充值'], 'P4P充值包'); + $this->assertNotNull($hit); + $this->assertFalse($hit['matched']); + $this->assertSame($rule['id'], $hit['rule']['id']); + } + /** 校验:同项目下有兜底规则时给出提示,提醒它只做兜底 */ public function test_validator_hints_fallback_rule(): void {