fix: [barobill] 알림톡 발송 파라미터 구조 전면 수정
- SenderID: 바로빌 계정 ID (barobill_id) 사용 - YellowId: 카카오톡 채널 ID 필수 전달 (기존에 빈값) - SmsReply: 'N' (대체문자 미발송) 또는 'S' (발송) 명시 - 템플릿 본문: API에서 조회 후 변수 치환 (정확한 포맷 유지) - getKakaotalkSenderId → getKakaotalkChannelId 이름 변경 - EsignPublicController: 잘못된 필드명(corp_num, is_test_mode) 수정
This commit is contained in:
@@ -970,9 +970,9 @@ private function sendAlimtalk(
|
||||
$barobill = app(BarobillService::class);
|
||||
$barobill->setServerMode($member->server_mode ?? 'production');
|
||||
|
||||
// 카카오톡 채널 목록에서 발신프로필 키(SenderID) 조회
|
||||
$senderId = $this->getKakaotalkSenderId($barobill, $member->biz_no);
|
||||
if (! $senderId) {
|
||||
// 카카오톡 채널 ID 조회 (YellowId로 사용)
|
||||
$channelId = $this->getKakaotalkChannelId($barobill, $member->biz_no);
|
||||
if (! $channelId) {
|
||||
return ['success' => false, 'channel' => 'alimtalk', 'error' => '등록된 카카오톡 채널이 없습니다'];
|
||||
}
|
||||
|
||||
@@ -981,10 +981,21 @@ private function sendAlimtalk(
|
||||
|
||||
$templateName = $isReminder ? '전자계약_리마인드' : '전자계약_서명요청';
|
||||
|
||||
// 등록된 템플릿 본문과 정확히 일치해야 함 (변수만 치환)
|
||||
$message = $isReminder
|
||||
? "안녕하세요, {$signer->name}님.\n아직 서명이 완료되지 않은 전자계약이 있습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 기한 내에 서명을 완료해 주세요."
|
||||
: " 안녕하세요, {$signer->name}님. \n 전자계약 서명 요청이 도착했습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 아래 버튼을 눌러 계약서를 확인하고 서명해 주세요.";
|
||||
// 등록된 템플릿 본문을 가져와서 변수 치환 (정확한 포맷 유지)
|
||||
$templateContent = $this->getTemplateContent($barobill, $member->biz_no, $channelId, $templateName);
|
||||
|
||||
if ($templateContent) {
|
||||
$message = str_replace(
|
||||
['#{이름}', '#{계약명}', '#{기한}'],
|
||||
[$signer->name, $contract->title, $expires],
|
||||
$templateContent
|
||||
);
|
||||
} else {
|
||||
// 템플릿 조회 실패 시 하드코딩 폴백
|
||||
$message = $isReminder
|
||||
? "안녕하세요, {$signer->name}님.\n아직 서명이 완료되지 않은 전자계약이 있습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 기한 내에 서명을 완료해 주세요."
|
||||
: " 안녕하세요, {$signer->name}님. \n 전자계약 서명 요청이 도착했습니다.\n\n ■ 계약명: {$contract->title}\n ■ 서명 기한: {$expires}\n\n 아래 버튼을 눌러 계약서를 확인하고 서명해 주세요.";
|
||||
}
|
||||
|
||||
$smsMessage = $smsFallback
|
||||
? "[SAM] {$signer->name}님, 전자계약 서명 요청이 도착했습니다. {$signUrl}"
|
||||
@@ -992,15 +1003,16 @@ private function sendAlimtalk(
|
||||
|
||||
$result = $barobill->sendATKakaotalkEx(
|
||||
corpNum: $member->biz_no,
|
||||
senderId: $senderId,
|
||||
senderId: $member->barobill_id,
|
||||
yellowId: $channelId,
|
||||
templateName: $templateName,
|
||||
receiverName: $signer->name,
|
||||
receiverNum: preg_replace('/[^0-9]/', '', $signer->phone),
|
||||
title: $isReminder ? '전자계약 리마인드' : '전자계약 서명 요청',
|
||||
title: '',
|
||||
message: $message,
|
||||
buttons: [
|
||||
[
|
||||
'Name' => $isReminder ? '서명하기' : '계약서 확인하기',
|
||||
'Name' => '계약서 확인하기',
|
||||
'ButtonType' => 'WL',
|
||||
'Url1' => $signUrl,
|
||||
'Url2' => $signUrl,
|
||||
@@ -1032,9 +1044,9 @@ private function sendAlimtalk(
|
||||
}
|
||||
|
||||
/**
|
||||
* 바로빌 카카오톡 채널 목록에서 발신프로필 키(ChannelId) 조회
|
||||
* 바로빌 카카오톡 채널 ID 조회 (YellowId로 사용)
|
||||
*/
|
||||
private function getKakaotalkSenderId(BarobillService $barobill, string $bizNo): ?string
|
||||
private function getKakaotalkChannelId(BarobillService $barobill, string $bizNo): ?string
|
||||
{
|
||||
$result = $barobill->getKakaotalkChannels($bizNo);
|
||||
|
||||
@@ -1044,10 +1056,7 @@ private function getKakaotalkSenderId(BarobillService $barobill, string $bizNo):
|
||||
|
||||
$data = $result['data'];
|
||||
|
||||
// 바로빌 응답 형식에 따라 채널 목록 파싱
|
||||
if (is_array($data) && isset($data[0])) {
|
||||
$channels = $data;
|
||||
} elseif (is_object($data) && isset($data->KakaotalkChannel)) {
|
||||
if (is_object($data) && isset($data->KakaotalkChannel)) {
|
||||
$channels = is_array($data->KakaotalkChannel)
|
||||
? $data->KakaotalkChannel
|
||||
: [$data->KakaotalkChannel];
|
||||
@@ -1056,7 +1065,7 @@ private function getKakaotalkSenderId(BarobillService $barobill, string $bizNo):
|
||||
? $data['KakaotalkChannel']
|
||||
: [$data['KakaotalkChannel']];
|
||||
} else {
|
||||
$channels = [$data];
|
||||
$channels = is_array($data) ? $data : [$data];
|
||||
}
|
||||
|
||||
$channel = $channels[0] ?? null;
|
||||
@@ -1070,6 +1079,35 @@ private function getKakaotalkSenderId(BarobillService $barobill, string $bizNo):
|
||||
: ($channel->ChannelId ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 바로빌 등록 템플릿의 본문 내용 조회
|
||||
*/
|
||||
private function getTemplateContent(BarobillService $barobill, string $bizNo, string $channelId, string $templateName): ?string
|
||||
{
|
||||
$result = $barobill->getKakaotalkTemplates($bizNo, $channelId);
|
||||
|
||||
if (! ($result['success'] ?? false) || empty($result['data'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $result['data'];
|
||||
$items = [];
|
||||
|
||||
if (is_object($data) && isset($data->KakaotalkTemplate)) {
|
||||
$items = is_array($data->KakaotalkTemplate)
|
||||
? $data->KakaotalkTemplate
|
||||
: [$data->KakaotalkTemplate];
|
||||
}
|
||||
|
||||
foreach ($items as $tpl) {
|
||||
if (($tpl->TemplateName ?? '') === $templateName) {
|
||||
return $tpl->TemplateContent ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* PDF 다운로드
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user