feat(performance): 매출 업데이트는 보고 있는 기간을 가져오기 + 카페24 환불 기준 비교

- 대시보드 [매출 업데이트]가 최근 7일 고정이 아니라 지금 보고 있는 기간(오늘까지)을 가져온다
  ("이번달"이면 1일~오늘). 모듈 권한자 92일까지, 더 긴 기간(최대 366일)은 관리자만. 미래 기간은 400
- 카페24 매출 대조에 "환불 기준 비교": 환불완료일(완료) vs 환불접수일(전체 상태·상태별),
  실제 환불액만 / 적립금·예치금 포함 — 9/23~27 순매출이 카페24보다 크게 나오는 원인 확인용

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 17:21:08 +09:00
parent fb7c29833e
commit a19c1f4cab
7 changed files with 79 additions and 14 deletions
+22 -1
View File
@@ -126,7 +126,10 @@
const label = syncBtn.textContent;
syncBtn.textContent = "업데이트 중…";
try {
const res = await api("POST", "/performance/api/sync", {});
// 지금 보고 있는 기간(오늘까지)을 가져온다 — "이번달"이면 1일부터 오늘까지.
const from = data.period_start, to = data.period_end < data.today ? data.period_end : data.today;
if (from > data.today) throw new Error("앞으로의 기간은 가져올 수 없습니다.");
const res = await api("POST", "/performance/api/sync", { from: from, to: to });
// 실패(빨강)는 인증 실패·API 오류처럼 손봐야 하는 것만. 인증정보를 아직 안 넣은 쇼핑몰(미설정)과
// 수집을 아직 만들지 않은 쇼핑몰(연동 준비 중)은 회색 한 줄로 이름만.
const ok = [], bad = [], pending = [], unset = [], busy = [];
@@ -520,6 +523,24 @@
return "<tr" + cls + '><th class="perf-td-label' + (x[3] === "sub" ? " perf-muted" : "") + '">' + esc(x[0]) +
'</th><td class="perf-num">' + f(x[1]) + '</td><td class="perf-num">' + f(x[2]) + "</td></tr>";
}).join("") + "</tbody></table>" +
(r.refund_basis
? (function () {
const b = r.refund_basis;
const row = function (label, x, cls) {
return "<tr" + (cls ? ' class="' + cls + '"' : "") + '><th class="perf-td-label">' + label + '</th><td class="perf-num">' +
fmt(x.count) + '</td><td class="perf-num">' + won(x.actual_refund_amount) + '</td><td class="perf-num">' +
won(x.used_points + x.used_credits) + '</td><td class="perf-num">' + won(x.with_points) + "</td></tr>";
};
return '<h4 class="perf-h" style="margin:14px 0 6px">환불 기준 비교 — 카페24 화면의 그날 "환불합계"와 같은 칸을 찾아 주세요</h4>' +
'<table class="perf-table"><thead><tr><th class="perf-th-label">기준</th><th>건수</th><th>실제 환불액</th>' +
"<th>적립금·예치금 환불</th><th>합계(포함)</th></tr></thead><tbody>" +
row("환불완료일 기준 · 완료 <span class='perf-pill is-ok'>현재 적용</span>", b.completed, "perf-row-week") +
row("환불접수일 기준 · 전체 상태", b.accepted_all) +
(b.accepted_by_status || []).map(function (s) {
return row(" · 접수일 기준 " + esc(s.label), s);
}).join("") + "</tbody></table>";
})()
: "") +
((r.by_channel || []).length
? '<h4 class="perf-h" style="margin:14px 0 6px">주문 채널별</h4>' +
'<table class="perf-table"><thead><tr><th class="perf-th-label">market_id</th><th class="perf-th-label">주문경로</th>' +