feat(performance): new marketplace order, 쿠팡(윙) rename, manual-only 쿠팡(로켓)·애터미아자몰
- Column order: 카페24 · 네이버 · 쿠팡(윙) · 쿠팡(로켓) · 오늘의집 · G마켓 · 카카오 · GS샵 · 11번가 · 롯데ON · 토스 · 애터미아자몰 (registry + migration 003 sort_order) - Existing coupang (WING API) renamed to 쿠팡(윙) - New manual-only marketplaces coupang_rocket / atomy (adapters/manual.py, manual_only flag): skipped by sync_all, no credentials / connection test in settings, status "수동 입력", manual input always on (API refuses turning it off) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ STATUS_LABELS: dict[str, str] = {
|
||||
"unknown": "확인 전",
|
||||
"disabled": "사용 중지", # DB 에는 저장하지 않는 화면 전용 상태(쇼핑몰 사용 OFF)
|
||||
"cancelled": "취소됨", # 화면 전용 — 매출 업데이트 창에서 [업데이트 취소](연결 상태는 바꾸지 않음)
|
||||
"manual": "수동 입력", # 화면 전용 — API 없이 수동 입력만 쓰는 쇼핑몰(manual_only)
|
||||
}
|
||||
|
||||
EVENT_TYPES = ("SALE", "CANCEL", "RETURN", "ADJUST")
|
||||
@@ -175,6 +176,8 @@ class MarketplaceAdapter(ABC):
|
||||
auth_type: str = "api_key" # api_key / oauth / shared(공통 연동 계층 재사용)
|
||||
docs_url: str = ""
|
||||
implemented: bool = False # 실제 수집(fetch)이 구현됐는가
|
||||
# True 면 API 연동이 없는 수동 입력 전용 쇼핑몰 — 매출 업데이트에서 빠지고, 인증 설정·연결 테스트가 없다.
|
||||
manual_only: bool = False
|
||||
# True 면 동기화 때 그 기간(sales_date)의 이 쇼핑몰 실데이터를 지우고 새로 넣는다(한 트랜잭션).
|
||||
# 쇼핑몰 API 가 "기간 안 결제·환불"을 빠짐없이 돌려줄 때만 켠다 — 규칙이 바뀌거나
|
||||
# 주문이 사라져도 예전 행이 남지 않는다. False 면 같은 사건 ID 만 덮어쓴다(upsert).
|
||||
|
||||
@@ -231,7 +231,7 @@ def group_lines(lines: Iterable[dict[str, Any]], prefix: str) -> dict[str, dict[
|
||||
|
||||
class CoupangAdapter(MarketplaceAdapter):
|
||||
code = "coupang"
|
||||
name = "쿠팡"
|
||||
name = "쿠팡(윙)"
|
||||
auth_type = "api_key"
|
||||
implemented = True
|
||||
replace_range = True
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
"""수동 입력 전용 쇼핑몰 — API 연동 없이 실적 일자별 표의 날짜 칸에 총매출을 직접 넣는다.
|
||||
|
||||
어댑터는 쇼핑몰의 "종류"만 알린다: 인증 항목이 없고(manual_only), 매출 업데이트(sync_all)에서 빠진다.
|
||||
DB(perf_marketplaces)에는 manual_input = TRUE 로 넣는다(마이그레이션 003).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MarketplaceAdapter
|
||||
|
||||
|
||||
class ManualOnlyAdapter(MarketplaceAdapter):
|
||||
auth_type = "manual"
|
||||
manual_only = True
|
||||
note = "API 연동 없이 실적 일자별 표의 날짜 칸에 총매출을 직접 입력합니다."
|
||||
|
||||
|
||||
class CoupangRocketAdapter(ManualOnlyAdapter):
|
||||
code = "coupang_rocket"
|
||||
name = "쿠팡(로켓)"
|
||||
|
||||
|
||||
class AtomyAzmallAdapter(ManualOnlyAdapter):
|
||||
code = "atomy"
|
||||
name = "애터미아자몰"
|
||||
@@ -14,22 +14,25 @@ from .gmarket import GmarketAdapter
|
||||
from .gsshop import GsshopAdapter
|
||||
from .kakao import KakaoAdapter
|
||||
from .lotteon import LotteonAdapter
|
||||
from .manual import AtomyAzmallAdapter, CoupangRocketAdapter
|
||||
from .naver import NaverAdapter
|
||||
from .ohouse import OhouseAdapter
|
||||
from .toss import TossAdapter
|
||||
|
||||
_ADAPTERS: tuple[MarketplaceAdapter, ...] = (
|
||||
# 화면 순서와 같게(DB sort_order 도 같은 순서 — 마이그레이션 002)
|
||||
# 화면 순서와 같게(DB sort_order 도 같은 순서 — 마이그레이션 003)
|
||||
Cafe24Adapter(),
|
||||
NaverAdapter(),
|
||||
CoupangAdapter(),
|
||||
TossAdapter(),
|
||||
GsshopAdapter(),
|
||||
ElevenstAdapter(),
|
||||
CoupangAdapter(), # 쿠팡(윙)
|
||||
CoupangRocketAdapter(), # 쿠팡(로켓) — 수동 입력 전용
|
||||
OhouseAdapter(),
|
||||
GmarketAdapter(),
|
||||
KakaoAdapter(),
|
||||
GsshopAdapter(),
|
||||
ElevenstAdapter(),
|
||||
LotteonAdapter(),
|
||||
TossAdapter(),
|
||||
AtomyAzmallAdapter(), # 애터미아자몰 — 수동 입력 전용
|
||||
)
|
||||
_BY_CODE = {a.code: a for a in _ADAPTERS}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ def display_status(marketplace: Mapping[str, Any], status_row: Mapping[str, Any]
|
||||
if not marketplace.get("enabled"):
|
||||
return "disabled"
|
||||
adapter = get_adapter(marketplace["code"])
|
||||
if adapter is not None and adapter.manual_only:
|
||||
return "manual"
|
||||
if adapter is not None and not adapter.uses_shared_integration and not configured:
|
||||
return "not_configured"
|
||||
return (status_row or {}).get("status") or "unknown"
|
||||
@@ -186,6 +188,7 @@ def build_settings(store: Any, *, configured: Mapping[str, bool], key_info: Mapp
|
||||
"rate": _fmt_rate(cur_rate) if has_rate else "",
|
||||
"rate_history": len(rates.get(adapter.code, ())),
|
||||
"auth_type": adapter.auth_type, "shared": adapter.uses_shared_integration,
|
||||
"manual_only": adapter.manual_only,
|
||||
"implemented": adapter.implemented, "note": adapter.note, "docs_url": adapter.docs_url,
|
||||
"configured": configured.get(adapter.code, False),
|
||||
"via_cafe24": adapter.code in via_cafe24,
|
||||
|
||||
@@ -316,6 +316,10 @@ def api_update_marketplace(request: Request, code: str, payload: dict[str, Any]
|
||||
_code_or_404(store, code)
|
||||
from .db import ManualMigrationNeeded # noqa: WPS433
|
||||
|
||||
adapter = get_adapter(code)
|
||||
if adapter is not None and adapter.manual_only and payload.get("manual_input") is False:
|
||||
raise HTTPException(status_code=400, detail="수동 입력 전용 쇼핑몰은 수동 입력을 끌 수 없습니다.")
|
||||
|
||||
try:
|
||||
row = store.update_marketplace(
|
||||
code,
|
||||
|
||||
@@ -162,7 +162,9 @@ class SyncService:
|
||||
end = end or today_kst()
|
||||
start = start or (end - timedelta(days=sync_days() - 1))
|
||||
enabled = {m["code"] for m in self._store.list_marketplaces() if m["enabled"]}
|
||||
targets = [a for a in all_adapters() if a.code in enabled and (not codes or a.code in codes)]
|
||||
# 수동 입력 전용 쇼핑몰(manual_only)은 가져올 API 가 없어 매출 업데이트에서 뺀다
|
||||
targets = [a for a in all_adapters()
|
||||
if a.code in enabled and not a.manual_only and (not codes or a.code in codes)]
|
||||
progress: dict[str, Any] = {}
|
||||
if job is not None:
|
||||
# 수집이 구현되고 인증정보가 있는 쇼핑몰만 막대로(active), 나머지는 "건너뜀" 한 줄로 — 바로 끝나는
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
</label>
|
||||
</td>
|
||||
<td class="perf-center">
|
||||
<label class="perf-switch" title="수동 입력 사용 — 켜면 실적 일자별 표에서 날짜 칸에 매출을 직접 입력(입력한 날은 API 값 대신)">
|
||||
<input type="checkbox" data-field="manual_input"{% if r.manual_input %} checked{% endif %} /><span></span>
|
||||
<label class="perf-switch" title="{% if r.manual_only %}수동 입력 전용 쇼핑몰 — API 연동이 없어 늘 켜져 있습니다{% else %}수동 입력 사용 — 켜면 실적 일자별 표에서 날짜 칸에 매출을 직접 입력(입력한 날은 API 값 대신){% endif %}">
|
||||
<input type="checkbox" data-field="manual_input"{% if r.manual_input or r.manual_only %} checked{% endif %}{% if r.manual_only %} disabled{% endif %} /><span></span>
|
||||
</label>
|
||||
</td>
|
||||
{% endif %}
|
||||
@@ -69,7 +69,8 @@
|
||||
</td>
|
||||
{% if is_admin %}
|
||||
<td>
|
||||
{% if r.shared %}<span class="perf-pill">공통 연동</span>
|
||||
{% if r.manual_only %}<span class="perf-pill">수동 입력 전용</span>
|
||||
{% elif 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 %}
|
||||
@@ -84,8 +85,10 @@
|
||||
<td class="perf-muted perf-nowrap" title="마지막 시도: {{ when(r.last_sync_at) }}">{{ when(r.last_success_sync_at) }}</td>
|
||||
{% if is_admin %}
|
||||
<td class="perf-nowrap">
|
||||
{% if not r.manual_only %}
|
||||
<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>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
@@ -144,14 +147,14 @@
|
||||
· <b>11번가</b>: 주문·클레임·정산 조회 주소별 동작 여부. 정산은 정산일 기준일 수 있어 매출이 있던 날부터 넉넉히(예: 3주).<br>
|
||||
· <b>GS샵</b>: 매출 내역·배송비 내역(매출인식일 기준)의 항목별 합계 — 협력사 포털 매출 화면의 같은 기간 숫자와 비교해 주세요.<br>
|
||||
· <b>토스쇼핑</b>: 날짜별 매출·환불·순 거래액(= 저장되는 매출)과 주문 상태별·정산 항목 합계 — 토스쇼핑 파트너스의 같은 날 숫자와 비교해 주세요.<br>
|
||||
· <b>쿠팡</b>: 판매자배송 발주서 + 로켓그로스 주문을 결제일로 모아 날짜별 매출 후보(할인 전·후, 취소분 뺀 값, 로켓그로스 따로)와 판매량 — WING 비즈니스 인사이트 → 판매분석에서 같은 날짜의 "매출(원)"·"판매량"과 비교해 주세요.</p>
|
||||
· <b>쿠팡(윙)</b>: 판매자배송 발주서 + 로켓그로스 주문을 결제일로 모아 날짜별 매출 후보(할인 전·후, 취소분 뺀 값, 로켓그로스 따로)와 판매량 — WING 비즈니스 인사이트 → 판매분석에서 같은 날짜의 "매출(원)"·"판매량"과 비교해 주세요.</p>
|
||||
<div class="perf-sample-form">
|
||||
<select class="erp-input" id="perf-probe-code" aria-label="쇼핑몰">
|
||||
<option value="naver">네이버 스마트스토어</option>
|
||||
<option value="elevenst">11번가</option>
|
||||
<option value="gsshop">GS샵</option>
|
||||
<option value="toss">토스쇼핑</option>
|
||||
<option value="coupang">쿠팡</option>
|
||||
<option value="coupang">쿠팡(윙)</option>
|
||||
</select>
|
||||
<input class="erp-input perf-date" type="date" id="perf-probe-date" value="{{ default_sample_to }}" />
|
||||
<span class="perf-muted">~</span>
|
||||
|
||||
@@ -1378,10 +1378,15 @@ def test_elevenst_collect_sales():
|
||||
|
||||
def test_registry_and_event_validation():
|
||||
codes = [a.code for a in all_adapters()]
|
||||
assert len(codes) == len(set(codes)) == 10
|
||||
assert len(codes) == len(set(codes)) == 12
|
||||
assert codes == ["cafe24", "naver", "coupang", "coupang_rocket", "ohouse", "gmarket", "kakao",
|
||||
"gsshop", "elevenst", "lotteon", "toss", "atomy"]
|
||||
for a in all_adapters():
|
||||
keys = [f.key for f in a.credential_fields()]
|
||||
assert len(keys) == len(set(keys)), a.code
|
||||
if a.manual_only: # 수동 입력 전용 — 인증 항목 없음
|
||||
assert not keys and not a.implemented, a.code
|
||||
continue
|
||||
assert a.uses_shared_integration or any(f.secret for f in a.visible_fields()), a.code
|
||||
for bad in (SaleEvent("SALE", "x", "o", date.today(), -1), SaleEvent("CANCEL", "x", "o", date.today(), 5),
|
||||
SaleEvent("SALE", "x", "o", date.today(), 1.5), SaleEvent("BOGUS", "x", "o", date.today(), 1)):
|
||||
@@ -1874,6 +1879,21 @@ def test_sync_job_stop_shop():
|
||||
assert not job.stop_shop("toss") and not job.stop_shop("nope") # 끝난 작업·없는 쇼핑몰
|
||||
|
||||
|
||||
def test_manual_only_marketplaces_skip_sync_and_show_manual_status():
|
||||
"""쿠팡(로켓)·애터미아자몰 = 수동 입력 전용 — 매출 업데이트 대상이 아니고 연결 상태는 "수동 입력"."""
|
||||
from app.modules.performance.dashboard import display_status
|
||||
|
||||
st = FakeStore()
|
||||
creds = CredentialService(st, lambda: ring())
|
||||
res = SyncService(st, creds).sync_all(start=date(2026, 10, 1), end=date(2026, 10, 2),
|
||||
codes=["coupang_rocket", "atomy"], user="king@x")
|
||||
assert res == [] and not st.events and not st.status
|
||||
for code in ("coupang_rocket", "atomy"):
|
||||
assert display_status({"code": code, "enabled": True}, None, False) == "manual"
|
||||
assert display_status({"code": "coupang_rocket", "enabled": False}, None, False) == "disabled"
|
||||
assert display_status({"code": "ohouse", "enabled": True}, None, False) == "not_configured"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.pop("APP_ENCRYPTION_KEY", None)
|
||||
n = 0
|
||||
|
||||
Reference in New Issue
Block a user