fix: 알림톡 14자 제한 수정 - 특수문자 제거 로직 삭제 (불필요했음) - 14자 제한으로 자르기 (카카오 API 제한)
This commit is contained in:
parent
0aebdaea0c
commit
9ba2846820
@ -100,15 +100,25 @@ def _send_alimtalk(template_code, recipient_no, template_params):
|
||||
|
||||
|
||||
def build_item_summary(items):
|
||||
"""구매 품목 요약 문자열 생성 (예: '타이레놀 외 3건')"""
|
||||
"""구매 품목 요약 문자열 생성 (예: '타이레놀 외 3건')
|
||||
|
||||
Note: 카카오 알림톡 템플릿 변수는 14자 제한
|
||||
(에러: "Blacklist can't use more than 14 characters in template value.")
|
||||
특수문자(%, 괄호 등)는 문제없이 발송 가능!
|
||||
"""
|
||||
if not items:
|
||||
return "약국 구매"
|
||||
first = items[0]['name']
|
||||
if len(first) > 20:
|
||||
first = first[:18] + '..'
|
||||
first = first.strip()
|
||||
|
||||
if len(items) == 1:
|
||||
return first
|
||||
return f"{first} 외 {len(items) - 1}건"
|
||||
# 단일 품목: 14자 제한 (그냥 자름)
|
||||
return first[:14]
|
||||
|
||||
# 복수 품목: "외 N건" 붙으므로 전체 14자 맞춤
|
||||
suffix = f" 외 {len(items) - 1}건"
|
||||
max_first = 14 - len(suffix)
|
||||
return f"{first[:max_first]}{suffix}"
|
||||
|
||||
|
||||
def send_mileage_claim_alimtalk(phone, name, points, balance, items=None,
|
||||
@ -146,24 +156,7 @@ def send_mileage_claim_alimtalk(phone, name, points, balance, items=None,
|
||||
|
||||
success, msg = _send_alimtalk(template_code, phone, params)
|
||||
|
||||
if not success:
|
||||
# V3 실패 로그
|
||||
_log_to_db(template_code, phone, False, msg,
|
||||
template_params=params, user_id=user_id,
|
||||
trigger_source=trigger_source, transaction_id=transaction_id)
|
||||
|
||||
# V2 폴백
|
||||
template_code = 'MILEAGE_CLAIM_V2'
|
||||
params = {
|
||||
'고객명': name,
|
||||
'적립포인트': f'{points:,}',
|
||||
'총잔액': f'{balance:,}',
|
||||
'적립일시': now_kst,
|
||||
'전화번호': phone
|
||||
}
|
||||
success, msg = _send_alimtalk(template_code, phone, params)
|
||||
|
||||
# 최종 결과 로그
|
||||
# 결과 로그 (V3만 사용, V2 폴백 제거 - V2 반려 상태)
|
||||
_log_to_db(template_code, phone, success, msg,
|
||||
template_params=params, user_id=user_id,
|
||||
trigger_source=trigger_source, transaction_id=transaction_id)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user