Files
dbx-main/app/modules/performance/templates/performance/settings.html
T
king 7d96f2e738 fix(performance): 11번가 원본 데이터 확인 — "해당 건 없음"은 0건, 기간 조회·구매확정 후보
9/9 확인 결과: 취소·반품 주소는 코드 -1 "해당 건이 없습니다"(= 0건)인데 실패로
표시했고, 주문 목록 4개는 지금 그 상태인 주문만 주는 듯해 이미 구매확정된
9/9 주문이 어디에도 없었다. 정산 내역은 정산확정일 기준일 가능성이 있다.

- 결과 문구가 "해당 건이 없습니다" 류면 오류가 아니라 0건
- 기간 조회(최대 31일, 7일씩 나눠 호출) — 매출일부터 정산확정일까지 넓게 확인
- 구매확정 목록 후보 주소 추가
- 테스트 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 01:14:32 +09:00

174 lines
11 KiB
HTML

{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20260930e" />{% endblock %}
{%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%}
{% block content %}
<section class="perf perf-settings" id="perf-settings">
{% include "performance/_tabs.html" %}
{% if not key_info.ok %}
<div class="perf-notice is-warn">
<b>암호화 마스터 키가 없습니다.</b> {{ key_info.message }}
— 키가 없으면 API 인증정보를 저장할 수 없습니다(수수료 설정·대시보드는 사용 가능).
</div>
{% endif %}
<div class="erp-card perf-card">
<div class="perf-card-head">
<h2 class="perf-h">쇼핑몰 설정</h2>
<span class="perf-muted">사용 · 매출 집계 · 수수료율은 바로 저장됩니다. API 인증정보는 [설정]에서 입력합니다.</span>
</div>
<div class="erp-table-wrap">
<table class="perf-table perf-set-table">
<thead>
<tr>
<th class="perf-th-label">쇼핑몰</th>
<th>사용</th>
<th>매출 집계</th>
<th>수수료율</th>
<th>API 설정</th>
<th>연결 상태</th>
<th>마지막 동기화</th>
<th></th>
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr data-code="{{ r.code }}" data-name="{{ r.name }}">
<th class="perf-td-label" scope="row">{{ r.name }}</th>
<td class="perf-center">
<label class="perf-switch" title="사용 여부">
<input type="checkbox" data-field="enabled"{% if r.enabled %} checked{% endif %} /><span></span>
</label>
</td>
<td class="perf-center">
<label class="perf-switch" title="매출 집계에 포함">
<input type="checkbox" data-field="include_in_sales"{% if r.include_in_sales %} checked{% endif %} /><span></span>
</label>
</td>
<td class="perf-rate-cell">
<span class="perf-rate">{% if r.rate %}{{ r.rate }}%{% else %}<span class="perf-muted">미설정</span>{% endif %}</span>
<button type="button" class="erp-btn erp-btn-ghost erp-btn-sm" data-act="rate"
data-has-history="{{ 1 if r.rate_history else 0 }}">변경{% if r.rate_history > 1 %} · 이력 {{ r.rate_history }}{% endif %}</button>
</td>
<td>
{% if r.shared %}<span class="perf-pill">공통 연동</span>
{% elif r.configured %}<span class="perf-pill is-ok">설정완료</span>
{% else %}<span class="perf-pill">미설정</span>{% endif %}
{% if r.via_cafe24 %}<span class="perf-pill is-ok" title="카페24 마켓 통합관리로 들어온 이 쇼핑몰 주문을 카페24 수집 때 함께 반영합니다">카페24 경유</span>{% endif %}
</td>
<td>
<span class="perf-status st-{{ r.status }}"
title="마지막 연결 테스트: {{ when(r.last_test_at) }}{% if r.last_error %}&#10;최근 오류({{ when(r.last_error_at) }}): {{ r.last_error }}{% endif %}">
<i></i>{{ r.status_label }}</span>
{% if r.last_error and r.status not in ('ok', 'disabled') %}<div class="perf-err">{{ r.last_error }}</div>{% endif %}
</td>
<td class="perf-muted perf-nowrap" title="마지막 시도: {{ when(r.last_sync_at) }}">{{ when(r.last_success_sync_at) }}</td>
<td class="perf-nowrap">
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" data-act="creds">설정</button>
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" data-act="test">연결 테스트</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<p class="perf-foot perf-muted">
수수료율은 <b>적용 시작일</b>부터 반영되고, 그 전 실적은 예전 요율로 계산됩니다(과거 실적이 바뀌지 않음).
상태에 마우스를 올리면 마지막 연결 테스트 시각과 최근 오류를 볼 수 있습니다.
</p>
</div>
<div class="perf-grid2">
<div class="erp-card perf-card">
<div class="perf-card-head"><h2 class="perf-h">인증정보 암호화</h2></div>
<dl class="perf-dl">
<dt>마스터 키</dt>
<dd>{% if key_info.ok %}<span class="perf-pill is-ok">설정됨 · 현재 v{{ key_info.current_version }}</span>
{% set olds = key_info.versions | reject('equalto', key_info.current_version) | list %}
{% if olds %}<span class="perf-muted">(예전 키 v{{ olds | join(', v') }} 보관 중)</span>{% endif %}
{% else %}<span class="perf-pill is-bad">미설정</span>{% endif %}</dd>
<dt>저장된 항목</dt>
<dd>{% for v, n in key_versions_in_use.items() %}v{{ v }}: {{ n }}개{% if not loop.last %}, {% endif %}{% else %}<span class="perf-muted">없음</span>{% endfor %}</dd>
</dl>
{% if stale_key_rows %}
<p class="perf-notice is-warn">예전 키로 암호화된 항목이 {{ stale_key_rows }}개 있습니다.
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" id="perf-rekey">현재 키로 다시 암호화</button></p>
{% endif %}
<p class="perf-foot perf-muted">
API 인증정보는 서버에서 AES-256-GCM 으로 암호화해 DB 에 저장합니다. 마스터 키(APP_ENCRYPTION_KEY)는 DB 가 아닌
서버 환경변수에만 있으며, 키를 잃으면 저장된 인증정보를 복구할 수 없으니 별도로 안전하게 보관하세요.
</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 perf-card-wide">
<div class="perf-card-head"><h2 class="perf-h">11번가 원본 데이터 확인</h2></div>
<p class="perf-muted">11번가 셀러 API 의 주문·클레임·정산 조회 주소를 기간(최대 31일)으로 실제 불러, 어느 주소가 동작하는지와
받은 항목·금액 합계를 보여 줍니다(저장하지 않음). 주문 목록은 지금 그 상태인 주문만, 정산은 정산일 기준일 수 있어
매출이 있던 날부터 넉넉히(예: 3주) 잡아 주세요. 셀러오피스에서 매출이 있던 날을 넣고 결과를 알려 주시면 그 항목으로
매출 수집을 맞춥니다. 이름·연락처·주소 같은 개인정보는 값을 보이지 않습니다.</p>
<div class="perf-sample-form">
<input class="erp-input perf-date" type="date" id="perf-probe-date" value="{{ default_sample_to }}" />
<span class="perf-muted">~</span>
<input class="erp-input perf-date" type="date" id="perf-probe-to" value="{{ default_sample_to }}" />
<button type="button" class="erp-btn erp-btn-outline" id="perf-probe" data-code="elevenst">불러오기</button>
</div>
<div id="perf-probe-result"></div>
</div>
<div class="erp-card perf-card perf-card-wide">
<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>
<h3 class="perf-h" style="margin:18px 0 6px">일별 한 번에 비교</h3>
<p class="perf-muted">카페24 일별 매출내역 표를 그대로 복사해 붙여 넣으면 날짜마다 결제합계·환불합계를 저장된 값과 비교합니다.
[API 값도 계산]을 켜면 지금 규칙으로 카페24에서 다시 계산한 값(저장 안 함)도 함께 보여 줘, 저장값만 틀린 날(다시 가져오면 해결)과
규칙이 틀린 날을 나눠 볼 수 있습니다. 날짜를 누르면 위 대조를 그날로 엽니다.</p>
<textarea class="erp-input perf-paste" id="perf-daily-paste" rows="5"
placeholder="2026-09-29(화) 47 116 2,475,300 … 2,477,800 158,000 2,319,800"></textarea>
<div class="perf-sample-form" style="margin-top:6px">
<label class="perf-muted"><input type="checkbox" id="perf-daily-live" /> API 값도 계산(느림)</label>
<button type="button" class="erp-btn erp-btn-outline" id="perf-daily-check">비교</button>
</div>
<div id="perf-daily-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>
<p class="perf-muted">실제 API 연동 전 화면 확인용 모의 매출입니다(사용 중인 쇼핑몰 대상). 실제 데이터와 구분되어 한 번에 지울 수 있습니다.</p>
<div class="perf-sample-form">
<input class="erp-input perf-date" type="date" id="perf-sample-from" value="{{ default_sample_from }}" />
<span class="perf-muted">~</span>
<input class="erp-input perf-date" type="date" id="perf-sample-to" value="{{ default_sample_to }}" />
<button type="button" class="erp-btn erp-btn-outline" id="perf-sample-gen">생성</button>
<button type="button" class="erp-btn erp-btn-danger" id="perf-sample-del"{% if not sample_count %} disabled{% endif %}>모두 삭제</button>
</div>
</div>
</div>
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20260930v" defer></script>{% endblock %}