feat(performance): 카페24 주문 매출 수집 연동 + 과거 매출 가져오기

카페24 (Admin API GET /admin/orders, 문서 2026-09-01 기준)
- 결제(SALE): date_type=pay_date, embed=items — 결제된 주문의 품목 결제금액(할인 반영·배송비 제외), 결제일
- 취소(CANCEL): cancel_complete_date, 품목 C40~C43 만 음수(입금전취소 C47~C49 제외)
- 반품(RETURN): return_complete_date, 품목 R40~R43 음수, 부분 반품은 claim_quantity 비율
- 자체몰 주문만(market_id=self) — 카페24로 연동된 다른 마켓 주문은 이중 집계 방지로 제외
- 60일 단위 분할(한 호출 3개월 미만), limit 1000 페이지 넘김, 개인정보 미저장(raw 는 금액·상태만)
- 기존 app/integrations/cafe24 토큰·클라이언트 재사용, 연결 테스트는 주문 권한까지 확인
- DEFAULT_SCOPES 에 mall.read_order 추가(읽기만) — 카페24 상품관리 → 시스템에서 재연결 필요

과거 매출 가져오기(설정, 관리자): 기간 지정 수집(최대 366일), 일반 사용자는 403

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 16:25:25 +09:00
parent 6e175d0bac
commit 04a1fddd95
9 changed files with 414 additions and 32 deletions
@@ -102,6 +102,19 @@
</p>
</div>
<div class="erp-card perf-card">
<div class="perf-card-head"><h2 class="perf-h">과거 매출 가져오기</h2></div>
<p class="perf-muted">[매출 업데이트]는 최근 며칠만 가져옵니다. 처음 연동했거나 빠진 기간이 있으면 기간을 지정해 한 번에
가져오세요(연동된 쇼핑몰만, 최대 366일). 같은 주문은 덮어써서 여러 번 해도 중복되지 않습니다.</p>
<div class="perf-sample-form">
<input class="erp-input perf-date" type="date" id="perf-backfill-from" value="{{ default_sample_from }}" />
<span class="perf-muted">~</span>
<input class="erp-input perf-date" type="date" id="perf-backfill-to" value="{{ default_sample_to }}" />
<button type="button" class="erp-btn erp-btn-primary" id="perf-backfill">가져오기</button>
</div>
<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">테스트 데이터</h2>
<span class="perf-muted">현재 {{ "{:,}".format(sample_count) }}건</span></div>
@@ -118,4 +131,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20260929b" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20260929c" defer></script>{% endblock %}