Compare commits

...

1 Commits

Author SHA1 Message Date
3c4f47b3fc 总账备注取科目映射表:平台/账单项目键做大小写与空格归一
科目映射表里平台写「唯品会JX」,页签内部键是「唯品会jx」,此前按原样索引匹配不到;
改为统一小写去空格后索引与查找(其它平台如唯品会MP/阿里巴巴不受影响)。
2026-10-07 15:30:45 +08:00

View File

@ -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)。
*