diff --git a/modules/EcommerceFinance/Services/AccountLedgerRemarkMap.php b/modules/EcommerceFinance/Services/AccountLedgerRemarkMap.php index 2cecbefb..b7853f5f 100644 --- a/modules/EcommerceFinance/Services/AccountLedgerRemarkMap.php +++ b/modules/EcommerceFinance/Services/AccountLedgerRemarkMap.php @@ -311,7 +311,8 @@ class AccountLedgerRemarkMap if ($platform === '' || $item === '') { continue; } - $index[$platform][$item][] = $rule; + // 平台/账单项目做大小写与空格归一:映射表里写的是「唯品会JX」,页签内部键是「唯品会jx」 + $index[$this->normalizeKey($platform)][$this->normalizeKey($item)][] = $rule; } } catch (Throwable) { $index = []; @@ -323,7 +324,7 @@ class AccountLedgerRemarkMap /** 同平台同账单项目的「财务备注」;没有规则或财务备注为空时返回 null(由调用方回落)。 */ private function accountMappingRemark(string $platform, string $item, array $businessRemarks, string $goodsName): ?string { - $rules = $this->accountMappingIndex()[$platform][$item] ?? []; + $rules = $this->accountMappingIndex()[$this->normalizeKey($platform)][$this->normalizeKey($item)] ?? []; if ($rules === []) { return null; } @@ -346,6 +347,11 @@ class AccountLedgerRemarkMap return $remark === '' ? null : $remark; } + private function normalizeKey(string $value): string + { + return mb_strtolower(preg_replace('/\s+/u', '', $value) ?? $value); + } + /** * 给一行账单补上 payload.ledger_remark(内部字段名 ledger_remark)。 *