File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
// n8n Code 노드: 도메인 JSON → Slack Block Kit
// 입력: 이전 HTTP Request 노드의 JSON 응답
const d = $input.first().json;
const won = (n) => (n == null ? '0' : Number(n).toLocaleString('ko-KR')) + '원';
const sales = d.sales || {};
const m = d.members || {};
const sms = d.sms || {};
const agentLines = (sms.agents || [])
.map(a => `• ${a.agentCode}: 성공 ${Number(a.succCnt).toLocaleString('ko-KR')} / 실패 ${Number(a.failCnt).toLocaleString('ko-KR')} (성공률 ${a.succRate}%)`)
.join('\n') || '데이터 없음';
const dayLines = (sales.dayChart || [])
.map(p => `${p.label} ${won(p.amt)}`)
.join(' | ') || '데이터 없음';
const blocks = [
{ type: 'header', text: { type: 'plain_text', text: `📊 문자ON 일일 리포트 — ${d.baseDate}`, emoji: true } },
{ type: 'section', fields: [
{ type: 'mrkdwn', text: `*당일 매출*\n${won(sales.todayAmt)}` },
{ type: 'mrkdwn', text: `*연간 누적*\n${won(sales.yearAmtSum)}` },
] },
{ type: 'section', text: { type: 'mrkdwn', text: `*최근 매출(일별)*\n${dayLines}` } },
{ type: 'divider' },
{ type: 'section', fields: [
{ type: 'mrkdwn', text: `*개인/기업 회원*\n${m.userNorCnt} / ${m.userComCnt}` },
{ type: 'mrkdwn', text: `*기업 신청/승인/반려*\n${m.cmpApply} / ${m.cmpApprove} / ${m.cmpReject}` },
{ type: 'mrkdwn', text: `*금일 탈퇴/정지*\n${m.todayExpireCnt} / ${m.todayStopCnt}` },
{ type: 'mrkdwn', text: `*일 가입자수*\n${sms.todaySignupCnt}` },
] },
{ type: 'divider' },
{ type: 'section', text: { type: 'mrkdwn', text: `*전송사별 발송*\n${agentLines}` } },
];
return [{ json: { blocks } }];