feat: 카드 알림 계좌 자동선택 - 카드사 표기 차이 유연 매칭
CI / build (push) Failing after 14m23s

- CardIssuerMatcher: 공백·접미사(카드/은행/페이/뱅크) 제거 + 별칭 통합(KB↔국민, 농협↔NH, 비씨↔BC, 씨티↔시티)
  · KB카드/국민카드/KB국민/국민 어떻게 등록해도 KB국민카드 알림에 자동 매칭
- AccountService.overlaps 가 CardIssuerMatcher 사용
- 단위테스트 4 추가

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-06 17:33:33 +09:00
parent eded44a476
commit 2da43b2f77
3 changed files with 98 additions and 3 deletions
@@ -277,10 +277,9 @@ public class AccountService {
return cards.size() == 1 ? cards.get(0).getId() : null;
}
/** 양방향 부분일치 (KB국민 ↔ 국민 등) */
/** 표기 차이를 흡수한 카드사 매칭 (KB국민 ↔ 국민 ↔ 국민카드 ↔ KB카드 등) */
private boolean overlaps(String walletField, String issuer) {
if (walletField == null || issuer == null) return false;
return walletField.contains(issuer) || issuer.contains(walletField);
return CardIssuerMatcher.matches(walletField, issuer);
}
/* ===================== 상환/납부 ===================== */
@@ -0,0 +1,44 @@
package com.sb.web.account.service;
/**
* 카드사명 유연 매칭.
* 알림에서 감지한 카드사와 사용자가 등록한 카드의 「카드사/이름」을, 표기 차이
* (KB / 국민 / 국민카드 / KB카드, 농협 / NH, 비씨 / BC 등)에 관계없이 같은 카드사로 인식한다.
*/
public final class CardIssuerMatcher {
private CardIssuerMatcher() {
}
/** 두 표기가 같은 카드사를 가리키면 true */
public static boolean matches(String walletField, String issuer) {
String a = canon(walletField);
String b = canon(issuer);
if (a.isEmpty() || b.isEmpty()) {
return false;
}
return a.equals(b) || a.contains(b) || b.contains(a);
}
/** 공백·접미사(카드/은행/페이/뱅크) 제거 + 동일 카드사 별칭 통합 후 소문자 키 */
static String canon(String s) {
if (s == null) {
return "";
}
String x = s.replaceAll("\\s+", "").toLowerCase()
.replace("카드", "").replace("은행", "").replace("페이", "").replace("뱅크", "");
if (x.contains("kb") || x.contains("국민")) {
return "국민";
}
if (x.contains("nh") || x.contains("농협")) {
return "농협";
}
if (x.equals("bc") || x.contains("비씨")) {
return "비씨";
}
if (x.contains("씨티") || x.contains("시티") || x.contains("citi")) {
return "씨티";
}
return x;
}
}