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
{