feat(performance): 카페24 적립금 제외 · 네이버 배송비 포함·환불일 환불 차감 · 주문 내역 칸·합계

- 카페24 매출 = 결제합계 − 적립금, 환불도 적립금 환불 제외, 주문 내역 [적립금 사용] 칸·합계
- 네이버 매출 = 판매금액(총) + 배송비, 환불 = 클레임 완료일 기준 취소·반품 완료(naver:{상품주문}-RF)
- 주문 내역 [배송비]·[환불금액] 칸·합계, 예전 자료는 과거 매출 가져오기로 다시 받으면 새 규칙

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 15:46:31 +09:00
parent 39d730faa0
commit 28e6cdd78a
11 changed files with 164 additions and 35 deletions
+4
View File
@@ -366,3 +366,7 @@ td.is-link:hover { background: #eef2ff; text-decoration: underline; }
.perf-opt-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.perf-opt-label { font-weight: 600; }
.perf-head-notes { display: inline-flex; align-items: center; gap: 12px; margin-right: auto; margin-left: 12px; font-size: 12px; }
/* 주문 내역 추가 칸(카페24 적립금 · 네이버 배송비·환불금액, 2026-10-19) */
.perf-ev-table .perf-ev-x { white-space: nowrap; color: #6b4e00; }
.perf-ev-xsub { font-size: 11px; font-weight: 500; color: var(--color-midtone-gray, #777); }
.perf-ev-table tfoot .perf-ev-x, .perf-ev-table tfoot .perf-ev-xsub { color: inherit; }
+26 -4
View File
@@ -653,29 +653,51 @@
const rows = res.rows || [];
if (!rows.length) { m.body.innerHTML = '<p class="perf-muted">내역이 없습니다.</p>'; return; }
const KIND = { SALE: "결제", CANCEL: "취소", RETURN: "반품", ADJUST: "조정" };
// 쇼핑몰별 추가 칸(2026-10-19) — 카페24 적립금 사용(매출에서 뺀 금액, 환불 줄은 돌려준 적립금 −),
// 네이버 배송비(매출에 더한 금액)·환불금액(환불된 날 매출에서 뺀 금액). 맨 아래 합계.
const EXTRA = { cafe24: [{ key: "points", label: "적립금 사용" }],
naver: [{ key: "ship", label: "배송비" }, { key: "refund", label: "환불금액" }] }[code] || [];
const xsum = EXTRA.map(function () { return { plus: 0, minus: 0 }; });
let sum = 0, sales = 0, minus = 0;
const body = rows.map(function (r) {
sum += r.amount;
if (r.amount >= 0) sales += r.amount; else minus += r.amount;
const xcells = EXTRA.map(function (x, k) {
const v = r[x.key];
if (v == null || v === 0) return '<td class="perf-num perf-ev-x"></td>';
if (v > 0) xsum[k].plus += v; else xsum[k].minus += v;
return '<td class="perf-num perf-ev-x">' + fmt(v) + "</td>";
}).join("");
return '<tr class="' + (r.event_type === "CANCEL" ? "is-cancel" : r.amount < 0 ? "perf-ev-cancel" : "") + '">' +
"<td>" + esc(r.sales_date) + "</td><td>" + esc(KIND[r.event_type] || r.event_type) +
(r.is_sample ? ' <span class="perf-pill">테스트</span>' : "") + "</td>" +
"<td>" + esc(r.external_order_id) + "</td>" +
'<td class="perf-ev-name">' + esc(r.product_name) + (r.option_name ? " <span class='perf-muted'>" + esc(r.option_name) + "</span>" : "") + "</td>" +
'<td class="perf-num">' + esc(r.quantity) + "</td>" +
'<td class="perf-num">' + fmt(r.amount) + "</td>" +
'<td class="perf-num">' + fmt(r.amount) + "</td>" + xcells +
"<td>" + esc(r.order_date || "") + "</td><td>" + esc(r.payment_date || "") + "</td>" +
"<td>" + esc(r.order_status) + "</td></tr>";
}).join("");
m.body.innerHTML =
'<div class="perf-ev-wrap"><table class="perf-table perf-ev-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 perf-ev-name">상품명</th><th>수량</th><th>금액</th><th class="perf-th-label">주문일</th>' +
'<th class="perf-th-label perf-ev-name">상품명</th><th>수량</th><th>금액</th>' +
EXTRA.map(function (x) { return '<th class="perf-ev-x">' + esc(x.label) + "</th>"; }).join("") +
'<th class="perf-th-label">주문일</th>' +
'<th class="perf-th-label">결제일</th><th class="perf-th-label">상태</th></tr></thead><tbody>' + body +
'</tbody><tfoot><tr class="perf-row-total"><th class="perf-td-label" colspan="5">결제 ' + fmt(sales) +
" / 취소·반품 " + fmt(minus) + '</th><td class="perf-num">' + fmt(sum) + '</td><td colspan="3"></td></tr></tfoot></table></div>' +
" / 취소·반품 " + fmt(minus) + '</th><td class="perf-num">' + fmt(sum) + "</td>" +
EXTRA.map(function (x, k) {
const s = xsum[k];
return '<td class="perf-num perf-ev-x"><b>' + fmt(s.plus || s.minus ? (s.plus || s.minus) : 0) + "</b>" +
(s.plus && s.minus ? '<div class="perf-ev-xsub">환불 ' + fmt(s.minus) + "</div>" : "") + "</td>";
}).join("") +
'<td colspan="3"></td></tr></tfoot></table></div>' +
(res.truncated ? '<p class="perf-muted">처음 500건만 표시합니다.</p>' : "") +
'<p class="perf-muted">수수료는 일·쇼핑몰 단위로 계산되어 주문별로는 표시하지 않습니다.</p>';
'<p class="perf-muted">수수료는 일·쇼핑몰 단위로 계산되어 주문별로는 표시하지 않습니다.' +
(code === "cafe24" ? " 금액은 적립금 사용분을 뺀 값입니다(환불도 적립금으로 돌려준 금액은 뺌)." : "") +
(code === "naver" ? " 결제 금액은 판매금액 + 배송비, 환불은 환불된 날에 빠집니다." : "") +
" 적립금·배송비 칸이 비어 있으면 규칙을 바꾸기 전에 받은 자료입니다 — 실적 설정 → 과거 매출 가져오기로 그 기간을 다시 받으세요.</p>";
} catch (err) {
m.body.innerHTML = '<p class="perf-notice is-warn">' + esc(err.message) + "</p>";
}