Merge branch 'dev'
Deploy / deploy (push) Failing after 11m21s
CI / build (push) Failing after 13m9s

This commit is contained in:
ByungCheol
2026-06-12 22:22:59 +09:00
3 changed files with 33 additions and 3 deletions
@@ -66,6 +66,11 @@ public interface AccountEntryMapper {
/** 미확인(확인 필요) 내역 개수 */
int countPending(@Param("memberId") Long memberId);
/** 자동인식 분류 학습: 같은 메모 키워드로 과거에 가장 많이 쓴 분류 1건(없으면 null) */
String findLearnedCategory(@Param("memberId") Long memberId,
@Param("type") String type,
@Param("memo") String memo);
/** 미확인 내역 확정 (pending=0, 분류/계좌 보정) */
int confirm(@Param("id") Long id, @Param("memberId") Long memberId,
@Param("category") String category, @Param("walletId") Long walletId);
@@ -231,13 +231,20 @@ public class AccountService {
String walletType = p.isBankTransfer() ? "BANK" : "CARD";
Long walletId = matchWalletId(p.getIssuer(), memberId, walletType);
// 분류 자동학습: 같은 메모(가맹점) 키워드로 과거에 확정한 분류가 있으면 그대로 채워준다.
String type = p.isIncome() ? "INCOME" : "EXPENSE";
String merchant = p.getMerchant();
String learnedCategory = (merchant != null && !merchant.isBlank())
? mapper.findLearnedCategory(memberId, type, merchant)
: null;
AccountEntry entry = AccountEntry.builder()
.memberId(memberId)
.entryDate(p.getDate() != null ? p.getDate() : java.time.LocalDate.now())
.type(p.isIncome() ? "INCOME" : "EXPENSE")
.category(null)
.type(type)
.category(learnedCategory)
.amount(p.getAmount())
.memo(p.getMerchant())
.memo(merchant)
.walletId(walletId)
.toWalletId(null)
.installmentMonths(null)
@@ -160,6 +160,24 @@
SELECT COUNT(*) FROM account_entry WHERE member_id = #{memberId} AND pending = 1
</select>
<!-- 자동인식 분류 학습: 같은 메모 키워드로 과거에 확정된 분류 중 가장 많이 쓴 1건.
메모가 서로 포함관계여도(예: '스타벅스' ↔ '스타벅스 강남점') 매칭. -->
<select id="findLearnedCategory" resultType="string">
SELECT category
FROM account_entry
WHERE member_id = #{memberId}
AND type = #{type}
AND pending = 0
AND category IS NOT NULL AND category != ''
AND memo IS NOT NULL AND memo != ''
AND (memo = #{memo}
OR memo LIKE CONCAT('%', #{memo}, '%')
OR #{memo} LIKE CONCAT('%', memo, '%'))
GROUP BY category
ORDER BY COUNT(*) DESC, MAX(entry_date) DESC, MAX(id) DESC
LIMIT 1
</select>
<update id="confirm">
UPDATE account_entry
SET pending = 0,