feat(performance): 카페24 매출 대조 — 환불합계 후보·환불 건별·취소/반품 완료 품목

9/26 은 결제합계가 카페24와 같고 환불만 97,580 모자라며 완료일·접수일·적립금
어느 기준으로도 맞지 않아, 환불 API 에 빠진 건을 찾는 진단을 추가.
- 환불합계 후보 표: 카페24 화면 값을 입력하면 같은 줄 강조
- 환불 건별 목록(완료일·접수일 기준 합침, 계좌 등 개인정보 제외)
- 그날 취소/반품/교환 완료 품목(orders date_type=*_complete_date, embed=items)
  품목 판매가·결제금액·쿠폰·환불 기록 유무

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 17:44:21 +09:00
parent a19c1f4cab
commit 370834b58b
7 changed files with 199 additions and 6 deletions
+52
View File
@@ -541,6 +541,47 @@
}).join("") + "</tbody></table>";
})()
: "") +
((r.refund_candidates || []).length
? '<h4 class="perf-h" style="margin:14px 0 6px">환불합계 후보 — 카페24 화면 값을 넣으면 같은 줄을 표시합니다</h4>' +
'<div class="perf-row-inline" style="margin-bottom:6px"><input class="erp-input perf-date" type="text" inputmode="numeric" ' +
'id="perf-recon-target" placeholder="카페24 환불합계" /></div>' +
'<table class="perf-table" id="perf-recon-cands"><thead><tr><th class="perf-th-label">후보</th><th>금액</th><th>차이</th></tr></thead><tbody>' +
r.refund_candidates.map(function (c) {
return '<tr data-amount="' + c.amount + '"><td class="perf-td-label">' + esc(c.label) + '</td><td class="perf-num">' +
won(c.amount) + '</td><td class="perf-num perf-cand-diff">–</td></tr>';
}).join("") + "</tbody></table>"
: "") +
((r.refund_list || []).length
? '<h4 class="perf-h" style="margin:14px 0 6px">환불 건별 (환불 API)</h4>' +
'<table class="perf-table"><thead><tr><th class="perf-th-label">환불코드</th><th class="perf-th-label">주문번호</th>' +
'<th class="perf-th-label">채널</th><th class="perf-th-label">상태</th><th class="perf-th-label">접수일</th><th class="perf-th-label">완료일</th>' +
"<th>수량</th><th>실제 환불액</th><th>적립금·예치금</th><th class=\"perf-th-label\">환불수단</th></tr></thead><tbody>" +
r.refund_list.map(function (x) {
const st = { T: "환불완료", F: "환불전", M: "환불보류" }[x.status] || x.status;
return '<tr><td class="perf-td-label">' + esc(x.refund_code) + "</td><td>" + esc(x.order_id) + "</td><td>" + esc(x.channel || "–") +
"</td><td>" + esc(st) + "</td><td>" + esc(x.accepted_date || "–") + "</td><td>" + esc(x.refund_date || "–") +
'</td><td class="perf-num">' + fmt(x.quantity) + '</td><td class="perf-num">' + won(x.actual_refund_amount) +
'</td><td class="perf-num">' + won(x.used_points + x.used_credits) + "</td><td>" + esc((x.methods || []).join(", ") || "–") + "</td></tr>";
}).join("") + "</tbody></table>"
: "") +
(r.claims
? '<h4 class="perf-h" style="margin:14px 0 6px">그날 취소·반품·교환 완료 품목 (주문 API)</h4>' +
((r.claims.errors || []).length ? '<p class="perf-notice is-warn">' + esc(r.claims.errors.join(" / ")) + "</p>" : "") +
((r.claims.items || []).length
? '<table class="perf-table"><thead><tr><th class="perf-th-label">조회</th><th class="perf-th-label">주문번호</th>' +
'<th class="perf-th-label">채널</th><th class="perf-th-label">상태</th><th class="perf-th-label">클레임</th><th class="perf-th-label">상품</th>' +
"<th>수량</th><th>판매가×수량</th><th>품목 결제금액</th><th>쿠폰</th><th class=\"perf-th-label\">환불 기록</th></tr></thead><tbody>" +
r.claims.items.map(function (c) {
return "<tr" + (c.done ? "" : ' class="perf-muted"') + '><td class="perf-td-label">' + esc(c.via) + "</td><td>" + esc(c.order_id) +
"</td><td>" + esc(c.channel || "–") + "</td><td>" + esc(c.status + (c.status_text ? " " + c.status_text : "")) +
"</td><td>" + esc(c.claim_code || "–") + "</td><td>" + esc(c.product_name) + '</td><td class="perf-num">' + fmt(c.quantity) +
'</td><td class="perf-num">' + won(c.product_amount) + '</td><td class="perf-num">' + won(c.payment_amount) +
'</td><td class="perf-num">' + won(c.coupon) + "</td><td>" + (c.has_refund ? "있음" : '<b>없음</b>') + "</td></tr>";
}).join("") + "</tbody></table>" +
'<p class="perf-foot perf-muted">전체취소 주문 배송비 ' + won(r.claims.full_cancel_shipping) +
'. 흐린 줄은 아직 완료되지 않은 클레임(후보 합계에서 제외).</p>'
: '<p class="perf-muted">없음</p>')
: "") +
((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>' +
@@ -586,6 +627,17 @@
: "") +
'<p class="perf-foot perf-muted">' + esc(r.formula) + ". 미결제 주문 " + fmt(r.unpaid_orders) +
"건 제외. \"알 수 없는 채널\"은 카페24 열에 넣습니다 — 외부 마켓이면 어느 쇼핑몰인지 알려 주세요.</p>";
const target = document.getElementById("perf-recon-target");
if (target) target.addEventListener("input", function () {
const v = parseInt(target.value.replace(/[^0-9-]/g, ""), 10);
out.querySelectorAll("#perf-recon-cands tr[data-amount]").forEach(function (tr) {
const a = parseInt(tr.dataset.amount, 10);
const d = tr.querySelector(".perf-cand-diff");
if (isNaN(v)) { d.textContent = "–"; tr.classList.remove("perf-row-match"); return; }
d.textContent = a === v ? "일치" : fmt(a - v);
tr.classList.toggle("perf-row-match", a === v);
});
});
} catch (err) {
out.innerHTML = '<p class="perf-notice is-warn">' + esc(err.message) + "</p>";
} finally { recon.disabled = false; }