fix(performance): 카페24 매출을 카페24 "일별 매출내역" 기준으로(결제합계·환불합계) + 매출 대조 도구

원인: 품목 결제금액(배송비 제외)을 매출로, 취소·반품 완료일의 품목 금액을 환불로 잡아
카페24 화면(결제합계 = 상품구매금액 + 배송비 − 할인 − 쿠폰, 환불합계 = 환불완료일 실제 환불액)과 달랐다.

- SALE: 결제일 기준 주문 단위 결제합계(initial_order_amount — 결제 당시 금액)
- CANCEL/RETURN: GET /admin/refunds 환불완료일, 실제 환불액(환불코드 R=반품)
- 환불도 원 주문 market_id 로 자체몰만(다른 마켓 연동 주문 제외)
- 기간 교체(replace_range): 동기화한 기간의 카페24 실데이터를 지우고 새로 넣음(한 트랜잭션,
  테스트 데이터 제외) — 예전 품목 단위 행이 남아 이중 집계되지 않게
- 설정 화면 "카페24 매출 대조": 날짜별로 카페24 화면 열 순서대로 원천 금액 합산(자체몰/마켓 구분, 저장 안 함)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 16:38:44 +09:00
parent 04a1fddd95
commit 27ee92c0a6
10 changed files with 421 additions and 205 deletions
@@ -115,6 +115,17 @@
<div class="perf-notice" id="perf-backfill-result" hidden></div>
</div>
<div class="erp-card perf-card">
<div class="perf-card-head"><h2 class="perf-h">카페24 매출 대조</h2></div>
<p class="perf-muted">카페24 관리자 → 통계 → 일별 매출내역과 같은 날짜를 비교합니다. 그날 결제 주문과 환불을 카페24 API 에서
바로 합산하며(저장하지 않음), 자체몰과 다른 마켓 연동 주문을 나눠 보여 줍니다.</p>
<div class="perf-sample-form">
<input class="erp-input perf-date" type="date" id="perf-recon-date" value="{{ default_sample_to }}" />
<button type="button" class="erp-btn erp-btn-outline" id="perf-recon">대조</button>
</div>
<div id="perf-recon-result"></div>
</div>
<div class="erp-card perf-card">
<div class="perf-card-head"><h2 class="perf-h">테스트 데이터</h2>
<span class="perf-muted">현재 {{ "{:,}".format(sample_count) }}건</span></div>
@@ -131,4 +142,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20260929c" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20260930a" defer></script>{% endblock %}