fix: 입금자명 매칭 시 앞 7글자만 비교
은행 SMS는 입금자명을 7글자까지만 표시하므로, 매칭 시 SUBSTR(depositor_name, 1, 7)로 비교하도록 수정 - deposit-agent.ts: 사용자 입력 → bank_notifications 검색 - index.ts: SMS 수신 → deposit_transactions 검색 - CLAUDE.md: 매칭 로직 문서화 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
13
CLAUDE.md
13
CLAUDE.md
@@ -479,6 +479,19 @@ cat /home/admin/namecheap_api/.env # REGISTRANT_* 변수들
|
||||
| 자동 매칭 성공 | ✅ 입금액 + 현재 잔액 | ✅ 입금 정보 + 매칭 완료 |
|
||||
| 매칭 대기 (SMS만) | - | ✅ 입금 정보 + 대기 상태 |
|
||||
|
||||
**매칭 로직 (입금자명 7글자 제한):**
|
||||
```
|
||||
은행 SMS는 입금자명을 7글자까지만 표시
|
||||
↓
|
||||
사용자 입력: "홍길동아버지님" (8글자)
|
||||
은행 SMS: "홍길동아버지" (7글자)
|
||||
↓
|
||||
매칭 시 SUBSTR(depositor_name, 1, 7) 비교 → 매칭 성공
|
||||
```
|
||||
|
||||
- `deposit-agent.ts:72`: 사용자 입력의 앞 7글자로 bank_notifications 검색
|
||||
- `index.ts:908`: deposit_transactions의 앞 7글자와 SMS 입금자명 비교
|
||||
|
||||
**Email Routing 설정:**
|
||||
- Cloudflare Dashboard → Email → Email Routing → Routes
|
||||
- 수신 주소 → Worker: `telegram-summary-bot` 라우팅
|
||||
|
||||
@@ -66,10 +66,10 @@ export async function executeDepositFunction(
|
||||
return { error: '입금자명을 입력해주세요.' };
|
||||
}
|
||||
|
||||
// 먼저 매칭되는 은행 알림이 있는지 확인
|
||||
// 먼저 매칭되는 은행 알림이 있는지 확인 (은행 SMS는 7글자 제한)
|
||||
const bankNotification = await db.prepare(
|
||||
`SELECT id, amount FROM bank_notifications
|
||||
WHERE depositor_name = ? AND amount = ? AND matched_transaction_id IS NULL
|
||||
WHERE depositor_name = SUBSTR(?, 1, 7) AND amount = ? AND matched_transaction_id IS NULL
|
||||
ORDER BY created_at DESC LIMIT 1`
|
||||
).bind(depositor_name, amount).first<{ id: number; amount: number }>();
|
||||
|
||||
|
||||
@@ -898,13 +898,14 @@ async function tryAutoMatch(
|
||||
notificationId: number,
|
||||
notification: BankNotification
|
||||
): Promise<{ transactionId: number; userId: number; amount: number } | null> {
|
||||
// 매칭 조건: 입금자명 + 금액이 일치하는 pending 거래
|
||||
// 매칭 조건: 입금자명(앞 7글자) + 금액이 일치하는 pending 거래
|
||||
// 은행 SMS는 입금자명이 7글자까지만 표시됨
|
||||
const pendingTx = await db.prepare(
|
||||
`SELECT dt.id, dt.user_id, dt.amount
|
||||
FROM deposit_transactions dt
|
||||
WHERE dt.status = 'pending'
|
||||
AND dt.type = 'deposit'
|
||||
AND dt.depositor_name = ?
|
||||
AND SUBSTR(dt.depositor_name, 1, 7) = ?
|
||||
AND dt.amount = ?
|
||||
ORDER BY dt.created_at ASC
|
||||
LIMIT 1`
|
||||
|
||||
Reference in New Issue
Block a user