feat: 알림톡 MILEAGE_CLAIM_V3 템플릿 대응 + 구매품목 요약
- nhn_alimtalk.py: build_item_summary() 추가 ("타이레놀 외 3건" 형식)
- send_mileage_claim_alimtalk()에 items 파라미터 추가, V3 우선 시도
- app.py: kiosk_current_session 클리어 전 items 캡처 버그 수정
- NHN API에 MILEAGE_CLAIM_V3 템플릿 등록 (발송 근거 문구 포함)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,7 +70,19 @@ def _send_alimtalk(template_code, recipient_no, template_params):
|
||||
return (False, str(e))
|
||||
|
||||
|
||||
def send_mileage_claim_alimtalk(phone, name, points, balance):
|
||||
def build_item_summary(items):
|
||||
"""구매 품목 요약 문자열 생성 (예: '타이레놀 외 3건')"""
|
||||
if not items:
|
||||
return "약국 구매"
|
||||
first = items[0]['name']
|
||||
if len(first) > 20:
|
||||
first = first[:18] + '..'
|
||||
if len(items) == 1:
|
||||
return first
|
||||
return f"{first} 외 {len(items) - 1}건"
|
||||
|
||||
|
||||
def send_mileage_claim_alimtalk(phone, name, points, balance, items=None):
|
||||
"""
|
||||
마일리지 적립 완료 알림톡 발송
|
||||
|
||||
@@ -79,16 +91,19 @@ def send_mileage_claim_alimtalk(phone, name, points, balance):
|
||||
name: 고객명
|
||||
points: 적립 포인트
|
||||
balance: 적립 후 총 잔액
|
||||
items: 구매 품목 리스트 [{'name': ..., 'qty': ..., 'total': ...}, ...]
|
||||
|
||||
Returns:
|
||||
tuple: (성공 여부, 메시지)
|
||||
"""
|
||||
now_kst = datetime.now(KST).strftime('%Y-%m-%d %H:%M')
|
||||
item_summary = build_item_summary(items)
|
||||
|
||||
# MILEAGE_CLAIM_V2 (버튼 포함 버전) 우선 시도
|
||||
template_code = 'MILEAGE_CLAIM_V2'
|
||||
# MILEAGE_CLAIM_V3 (발송 근거 + 구매품목 포함) 우선 시도
|
||||
template_code = 'MILEAGE_CLAIM_V3'
|
||||
params = {
|
||||
'고객명': name,
|
||||
'구매품목': item_summary,
|
||||
'적립포인트': f'{points:,}',
|
||||
'총잔액': f'{balance:,}',
|
||||
'적립일시': now_kst,
|
||||
@@ -98,14 +113,15 @@ def send_mileage_claim_alimtalk(phone, name, points, balance):
|
||||
success, msg = _send_alimtalk(template_code, phone, params)
|
||||
|
||||
if not success:
|
||||
# V2 실패 시 V1 (버튼 없는 버전) 시도
|
||||
template_code = 'MILEAGE_CLAIM'
|
||||
params_v1 = {
|
||||
# V3 실패 시 V2 폴백 (구매품목 변수 없는 버전)
|
||||
template_code = 'MILEAGE_CLAIM_V2'
|
||||
params_v2 = {
|
||||
'고객명': name,
|
||||
'적립포인트': f'{points:,}',
|
||||
'총잔액': f'{balance:,}',
|
||||
'적립일시': now_kst
|
||||
'적립일시': now_kst,
|
||||
'전화번호': phone
|
||||
}
|
||||
success, msg = _send_alimtalk(template_code, phone, params_v1)
|
||||
success, msg = _send_alimtalk(template_code, phone, params_v2)
|
||||
|
||||
return (success, msg)
|
||||
|
||||
Reference in New Issue
Block a user