From 6ebf705e27015ee6a252d0a50f3f502808dff896 Mon Sep 17 00:00:00 2001
From: king
Date: Tue, 13 Oct 2026 02:35:18 +0900
Subject: [PATCH] =?UTF-8?q?feat(performance):=20new=20marketplace=20order,?=
=?UTF-8?q?=20=EC=BF=A0=ED=8C=A1(=EC=9C=99)=20rename,=20manual-only=20?=
=?UTF-8?q?=EC=BF=A0=ED=8C=A1(=EB=A1=9C=EC=BC=93)=C2=B7=EC=95=A0=ED=84=B0?=
=?UTF-8?q?=EB=AF=B8=EC=95=84=EC=9E=90=EB=AA=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 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
---
CLAUDE.md | 2 +-
app/modules/performance/adapters/base.py | 3 ++
app/modules/performance/adapters/coupang.py | 2 +-
app/modules/performance/adapters/manual.py | 25 ++++++++++++++
app/modules/performance/adapters/registry.py | 13 +++++---
app/modules/performance/dashboard.py | 3 ++
app/modules/performance/router.py | 4 +++
app/modules/performance/sync.py | 4 ++-
.../templates/performance/settings.html | 13 +++++---
.../performance/tests/test_performance.py | 22 ++++++++++++-
docs/DEPLOYMENT.md | 12 +++++++
docs/PERFORMANCE_MODULE.md | 6 +++-
.../performance_db_003_marketplace_order.sql | 33 +++++++++++++++++++
scripts/sql/performance_db_init.sql | 24 +++++++-------
14 files changed, 140 insertions(+), 26 deletions(-)
create mode 100644 app/modules/performance/adapters/manual.py
create mode 100644 scripts/sql/performance_db_003_marketplace_order.sql
diff --git a/CLAUDE.md b/CLAUDE.md
index ef70187..7708d42 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -38,7 +38,7 @@ Claude Code는 이 저장소에서 작업을 시작하기 전에 **반드시 아
- 카페24 상품관리 (`app/modules/cafe24/`, `cafe24_db`) — 카페24 관리자에 들어가지 않고 상품 상세페이지(description HTML) 조회·편집·즉시적용·예약적용·버전 이력. 3분할 화면(목록 | HTML 편집기 | 상품 정보 패널). 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지(`POST /admin/products/{no}/images` 에 base64 data URI + `image_upload_type=A` — NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨), 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매)을 수정. 카페24 OAuth/API 클라이언트는 향후 주문관리와 공유하기 위해 **공통 계층 `app/integrations/cafe24/`** 에 둔다 — 라우터에서 `httpx`/`requests` 직접 호출 금지. 토큰은 Fernet 암호화 저장(`CAFE24_TOKEN_SECRET`), 로그/화면에 토큰·시크릿 절대 미출력. 쓰기 직전 항상 카페24 현재 HTML 을 다시 읽어 `BACKUP` revision 생성(로컬 값을 현재값으로 가정 금지). **카페24 관리자 API 는 PUT 뒤 한동안 GET 에서 예전 값을 돌려준다(읽기 지연)** — 우리 캐시 문제가 아니다. 그래서 "마지막 쓰기가 권위": 상세설명은 카페24 값이 최근 revision 중 하나와 같으면 지연으로 보고 마지막 MANUAL/SCHEDULED 를 표시·지문 기준으로 쓰고(`store.resolve_description`), 스칼라(상품명·가격·이미지·진열/판매)는 PUT 응답 스냅샷(`cafe24_products.last_write_snapshot`, 마이그레이션 004)과 GET 의 `updated_date` 를 비교해 덮어씌운다(`store.overlay_recent_write`). 유예시간 `CAFE24_READ_LAG_GRACE_MIN`(기본 360분). 쓰기 후 화면은 PUT 응답으로 그리고 다시 GET 하지 않는다. 예약은 DB 저장 + 별도 worker(`app/modules/cafe24/worker.py`, compose 서비스 `dbx-cafe24-worker`)가 처리 — 웹 프로세스에서 대기하지 않는다. 권한키 `cafe24`(연결/해제는 admin 전용). 상세는 `docs/CAFE24_MODULE.md`
- 프로젝트 관리 (`app/modules/project/`, `project_db`) — 아사나식. 프로젝트/서브프로젝트(self-FK `parent_id`, CASCADE)·프로젝트 색상(32색 — 아사나 16색 + 진한 16색, 수정 창 12열)·아이콘(`projects.icon`, Material Symbols 42종, 마이그레이션 011 + [아사나 아이콘] 탭 33종 `"asana:"+이름`, 채워진 모양 전용 부분 글꼴 `material-symbols-asana.woff2`)·작업(`tasks`: 담당자·우선순위·시작/마감)·진행단계(`project_stages` 칸반, 새 프로젝트는 섹션 없이 시작 — `create_project(seed_stages=True)` 일 때만 기본 4단계, 섹션 머리는 모두 `#f3f3f3` — 섹션별 색 지정 없음, 섹션 이름 굵게, 섹션 기본 담당자 `default_assignee_email` — 담당자 빈 작업을 그 섹션에 만들거나 옮기면 자동 배정, 마이그레이션 009)·멤버 배정(`project_members`)·활동이력(`project_activity`). 첫 화면(`/project/`)은 **내 작업 목록**(프로젝트 홈 카드 화면은 폐지). 프로젝트 화면은 캘린더(FullCalendar)/타임라인(vis-timeline)/보드/목록/대시보드 뷰 토글. 좌측 사이드바는 수신함·내 작업·휴지통·프로젝트 화면 공용(`templates/project/_side.html` + 프로젝트 목록 동작 `initSideTree`, 새 프로젝트/수정 모달 `_side_modals.html`) — 프로젝트 목록(순서 변경·✎·×)은 어느 화면에서나 같다. 보드는 아사나처럼 섹션이 가로로 계속 늘어나고(넘치면 가로 스크롤) 카드의 담당자·마감일을 클릭해 그 자리에서 바꾼다. 좌측 사이드바에 수신함·전체 보기(Pro user 이상 — 예전 오른쪽 위 "전체 프로젝트" 토글, `?scope=all`)·내 작업(접이식) 메뉴. 설명란 서식 도구에 글자 색·크기(서버는 span style 의 color·font-size 만 허용, `desc_inline_style`). 설명란은 주소 붙여넣기 시 자동 링크, 설명란·댓글에서 @로 멤버를 태그하면 (`task_mentions`, 마이그레이션 006) 수신함에 그 작업이 쌓인다. 진입 권한키 `project`(관리자 페이지 토글로 직원별 부여, admin 자동). **관리자 등급 4단계(2026-10-12) — 수퍼관리자(`SUPER_ADMIN_EMAIL` 한 명 고정, 추가 불가) > Admin(`role=admin`) > Pro user(`role=pro`) > User** — 판단은 `access.is_pro`(Pro user 이상)·`access.is_project_admin`(Admin 이상), 라우터 `_require_pro`, 화면 `pj_pro`·`pj_admin`(`_role_ctx`, `is_admin` 은 ERP 상단 관리자 메뉴용 그대로). pro 는 프로젝트 모듈 밖에서는 user 와 같다. 새 프로젝트·프로젝트 이름/색/아이콘/소유자 수정·멤버 배정(자기가 멤버인 프로젝트)·사이드바 순서·남의 댓글 수정/삭제·휴지통·전체 보기·담당자별 합계·전체 멤버 = Pro user 이상, 프로젝트·섹션 삭제 = Admin 이상 또는 만든 사람, 작업 삭제·서브프로젝트 = 멤버 누구나(표는 docs/PROJECT_MODULE.md 6-14). 배정 멤버(또는 owner)만 그 프로젝트를 조회 — **관리자도 멤버가 아니면 안 보임, 예외는 슈퍼관리자뿐**(2026-10-07, `access.sees_all_projects`; 사이드바 목록·검색·휴지통·알림도 같은 기준, 화면·API 모두 비멤버 403)하고 서브프로젝트/작업/단계 CRUD — URL 의 섹션·부모 작업이 그 프로젝트 것인지 서버가 검증. 실시간 반영은 `project_live_version` 카운터(마이그레이션 007, 미적용 시 MAX 폴백). 사이드바 전체 검색(`/api/search`, 제목·설명·댓글, pg_trgm) + 프로젝트/내 작업 필터 바(찾기·상태·담당자·마감·우선순위·정렬, 클라이언트 필터). 협업자(`task_followers`, 자동 팔로우: 만든 사람·담당자·댓글·@태그) — 완료·댓글 알림은 담당자+협업자에게만. 나를 태그하거나 작업이 배정되면 프로젝트 화면 가운데 아래에 깜박이는 큰 팝업(닫기 전까지, `initTaskAlerts` + `GET /api/notifications/alerts`). 작업 삭제는 휴지통(`project_trash`, 마이그레이션 010) — 삭제 직전 스냅샷 3개월 보관, Pro user 이상만 보기·복구(`/project/trash`). 권한은 **지금 기준 공통 모듈 `access.py`**(목록·배지·알림·멘션·메일 수신자·삭제·댓글 수정까지 — 멤버에서 빠지면 기록이 있어도 안 보이고 알림도 없음), 소유자 변경은 Pro user 이상, 연결(멀티호밍)된 작업은 연결된 프로젝트 멤버에게 읽기 전용(docs/PROJECT_MODULE.md 6-10). 연간 목표(마이그레이션 013, `goal_*` 테이블) — 사이드바 "목표" → 연도 펼침 → `/project/goals/{연도}` 에 매출(목표·실적·달성)·로아스 월별 숫자 + 업무 영역(상품·마케팅·컨텐츠·유통 등)별 연간·월별 글, 조회는 전원·입력(주차별 목표·연도 추가/삭제 포함)은 Pro user 이상. 3·6·9·12월 오른쪽 1~4분기 칸(글 칸 13=1분기·15=2분기·14=3분기·16=4분기 — 예전 반기 칸 번호 재사용, 15·16 은 마이그레이션 017) + 분기 월 칸 접기 애니메이션(localStorage `pj_goal_fold_q`, 표는 `width:1px`+`table-layout:fixed`), 영역·줄 이름 클릭 바로 수정, **엑셀식 칸 병합**(마우스로 끌어 사각형 선택 → 우클릭 셀 병합/병합 해제, 같은 영역 안 세로 `row_span` + 같은 분기 월 칸 가로, 글은 왼쪽 위 칸 — `goal_cell_merges`, 마이그레이션 014·015·017), 3열 줄 추가는 같은 항목 칸(2열) 안에(`goal_rows.label_cont`, 마이그레이션 016), 구조 변경은 새로고침 없이 제자리 다시 그리기(`refreshTable`)+애니메이션, 로아스는 % 표기. 월 머리 → **주간 회의록**(`/project/goals/{연도}/meetings/{월}`, 프로젝트 권한자 **누구나 수정** — Pro user 이상 [회의 완료](`completed_at`, 마이그레이션 022)면 잠금(지난주 결과는 다음 주 회의록이 열려 있는 동안 허용), 삭제·완료·완료 해제는 Pro user 이상, 표 첫 열 머리 글자 "구분", 주차 탭 — **주차는 그 달 안**(`store.month_weeks`: 1일이 월~금이면 1일~일요일이 1주차, 토·일이면 1일~다음 주 일요일, 그 뒤 월~일, 말일이 월·화면 앞 주차에 붙음, 회의록 `week_start` = 주차 시작일, 마이그레이션 020), `goal_meetings`·`goal_meeting_items` 마이그레이션 015 — 지난주 = **바로 앞 주차**(`store.prev_week_period`) 회의록의 같은 연결키 줄(`line_key`, 마이그레이션 018 — 생성 순서·이름 변경과 무관, 이름 추정 연결 금지)로 리뷰(열: 주요 업무·정량 목표 ‖ 전주 업무·결과(글, `result_note` 020)·전주 목표·결과 — 정량 목표·결과는 숫자면 원 정수 칸, 아니면 글 칸 `target_text`·`result_text`(예: 20개, 021)), 실적 조회 장애는 0원이 아니라 "미확인", 위에 목표 표 그 달 열 글을 영역별 "N월 계획" 카드로, 참석자 옆 [회의록 보드] = 그 주차의 빈 Google 슬라이드를 독립 창으로(오른쪽 🔗 아이콘 = 그 보드 링크 복사)(공유 드라이브 `MEETING_BOARD_FOLDER_ID`, 없으면 만듦, `app/integrations/google_slides.py`, Drive appProperties 로 주차 연결 — Drive·Slides 권한 토큰 필요), 표를 스크롤해도 보이는 머리 영역 3칸 = ① 월 계획 + 머리 줄에 숫자 4개 작게 1행(월 목표 매출·월 누적 목표 매출(목표 표 **주차별 매출 목표** `goal_week_targets` 1주차~이 주차 합 — 목표 표 매출 목표 월 칸을 누르면 입력 창 — 월 전체 목표는 직접 입력(주차 합계와 별개), 맨 아래 차이 = 월 목표 − 주차 합계)·월 누적 실적(1일~오늘)·누적 목표 대비 차액·%) | ② 결정 사항·메모 | ③ "N주차 작업 등록" 표(제목·담당자·프로젝트·섹션 → [적용] = 서버가 그 프로젝트에 작업 생성, `initMeetQuickTasks` — 주차별 서버 표 `goal_meeting_tasks`(마이그레이션 025)라 모두가 같이 보고, 남의 프로젝트 이름은 가림, 완료 프로젝트·섹션은 목록에서 뺌, 작업 칸(마이그레이션 026 `parent_task_id`) = 이미 있는 작업을 고르면 그 작업의 세부 작업으로 등록, 등록된 줄 제목 = 오른쪽 작업 창(편집, 저장 대기), [크게 열기] = 같은 표를 넓은 창으로), 실적 모듈 `performance_store` 매출은 머리 카드에만 읽기 전용 — 줄(쇼핑몰)별 자동 결과·이번주 실적·연결 배지·쇼핑몰 연결 메뉴는 폐지, 지난주 결과는 늘 직접 입력). 모든 열 너비 끌어서 조절(localStorage `pj_goal_col_w`), 세로 스크롤 틀 고정은 머리 줄+매출·로아스 줄까지, 항목 칸 +·우클릭으로 줄 위/아래 추가·삭제, 회의록 "주요 업무" 칸 우클릭 위/아래 줄 추가 = 항목 칸은 그대로 그 항목 안에(마이그레이션 027 `label_cont`, 항목 칸 나누기), 회의록 줄 작업은 새로고침 없이 제자리 다시 그리기(`refreshMeeting`)+애니메이션, 구분(구역) 칸 우클릭·⋯ = 구역 통째로 위/아래(`move-section`). 마감 알림(`reminders.py` 데몬 스레드, 영업일 09시, D-1/당일/지연, `task_reminders` 로 중복 방지, `PROJECT_REMINDER_*` env) — 마이그레이션 008. 라우터 핸들러는 동기 DB 라 `def` 로 둔다(`async def` 금지). 말풍선은 전부 아사나식 공용 말풍선(`.pj-hovertip`) — 새 기능도 `title=`/`data-tip=` 만 달고 별도 툴팁 구현 금지. 멤버 배정 후보는 `project` 권한 보유 등록 사용자에서 자동 목록(`GET /project/api/assignable-users`). 작업 배정·완료 시 관리자에게 메일(`app/mail.py` stdlib smtplib, `SMTP_*`+`PROJECT_NOTIFY_EMAIL` env, 미설정 시 조용히 skip, `BackgroundTasks` 비동기). 목표 표·회의록 칸 저장은 공용 `createFieldSaver`(같은 칸 요청 직렬화·보낸 값만 저장됨·실패 시 초안 유지·localStorage 초안 백업, 저장 실패면 구조 변경 중단 — docs/PROJECT_MODULE.md 6-9-3), 구역·항목 메뉴는 우클릭 + ⋮ 버튼(키보드·터치). ERP 메뉴 이름은 "Project"(`app/main.py` 모듈 목록 title). **PC 알림 프로그램**(`desktop/notifier/`, C# .NET Framework 4.8 WinForms exe 하나·트레이 상주, 마이그레이션 023 `notifier_links`·`notifier_tokens`) — 브라우저가 뒤에 있어도 태그·배정 알림을 웹 팝업과 같은 모양으로 화면 위에. 브라우저 `/project/notifier?code=` 승인으로 PC별 토큰(서버는 SHA-256 만, PC 는 DPAPI), `GET /project/api/notifier/alerts`(Bearer)는 웹 알림과 같은 `_alerts_payload`, 토큰마다 지금 사용자·권한 재확인. 프로그램이 돌고 있으면(최근 3분 확인, `notifier_active`) 웹 큰 팝업은 쉰다(`desktop: true`). 압축·난독화 금지(백신 오탐), 빌드 `desktop/notifier/build.ps1`, 상세 docs/PROJECT_MODULE.md 6-11. 댓글·답글 입력칸은 Enter 등록·Shift+Enter 줄바꿈(textarea), 설명란 이미지 더블클릭 = 별도 창 이미지 보기(확대·축소·끌어 이동). 작업 창은 **저장 버튼 없이 실시간 저장**(칸별 PUT, `saveField`/`saveChain`, 새 작업은 제목이 생기는 순간 생성). 댓글 답글·이모티콘 반응(마이그레이션 012 `task_comments.parent_id`·`task_comment_reactions`, 미적용 시 버튼 숨김·API 503), 완료 이력 줄은 `project_activity` completed 를 댓글 사이에 표시(댓글 수 제외), 댓글 `@아이디` 는 아이콘+이름 칩. 수신함은 확인 안 한 태그·읽지 않은 알림만(2026-10-08) — [확인] 버튼 없이 줄을 누르면 읽음·확인 처리(같은 작업 줄 함께) + 페이지 이동 없이 오른쪽 iframe 패널, 다른 줄을 고르거나 패널을 닫으면 그 줄은 목록에서 빠짐. 용어는 "세부 작업"(예전 하위 작업)·"메인 작업 추가". 패널(`/project/p/{pid}?task=&embed=1`, `html.pj-embed`). 상단 바 화면 배율 토글(`html.pj-ui-scale` → `.erp-app` zoom .75, 2880×1620·200%용) — **팝업은 반드시 `document.body` 에 붙인다**(배율 안의 fixed 좌표는 어긋남). 상세는 `docs/PROJECT_MODULE.md`
-- 실적 (`app/modules/performance/`, `performance_db`) — 쇼핑몰 통합 매출. 네 영역 분리: ① 수집 `adapters/`(쇼핑몰 하나 = 어댑터 파일 하나 + `registry.py` 한 줄 + SQL seed 한 줄) + `sync.py`(공통 동기화, 같은 쇼핑몰 동시 실행 차단, 쇼핑몰별 실패 격리) ② 보안 `security/`(AES-256-GCM, 키 버전, 비밀값 가리기) + `credentials.py` ③ 계산 `calc.py`(주=월~일, 수수료 반올림은 `commission()` 한 곳, 요율 이력) + `db.py` ④ 화면 `dashboard.py`/`router.py`/템플릿. 쇼핑몰 API 인증정보는 `.env` 가 아니라 **설정 화면에서 입력 → 마스터 키 `APP_ENCRYPTION_KEY` 로 암호화해 DB 저장**, secret 원문은 화면으로 다시 보내지 않는다. 쇼핑몰 API 는 백엔드에서만 호출, 오류·로그·raw 는 `redact` 후 저장. 매출 기준일: 결제=결제일, 취소·반품=발생일(`sync.sales_date_for`). 금액은 원 단위 정수. 권한키 `performance`, 설정 화면은 모듈 권한자 누구나(일반 사용자는 수수료율만), 수수료 외 설정 API 는 `is_admin`. 매출 업데이트 진행 창에서 쇼핑몰별 [중지](그 쇼핑몰만 멈추고 다음 쇼핑몰로). 카페24 어댑터는 기존 `app/integrations/cafe24` 토큰 재사용. 1단계는 모의 데이터(`is_sample`)·구조까지, 실제 수집은 쇼핑몰별로 공식 문서 확인 후 순차 구현. 쿠팡은 판매자배송 발주서 + 로켓그로스 주문을 결제일로 합산(WING 판매분석 대조는 원본 데이터 확인으로). 설정의 쇼핑몰별 **수동 입력** 토글(마이그레이션 002 `manual_input`·`perf_manual_sales`) — 켜면 일자별 표 날짜 칸에 총매출 직접 입력, 넣은 날은 API 값 대신(`daily_amounts` 한 곳). 열 순서 카페24·네이버·쿠팡·토스·GS샵·11번가·나머지. 상세는 `docs/PERFORMANCE_MODULE.md`
+- 실적 (`app/modules/performance/`, `performance_db`) — 쇼핑몰 통합 매출. 네 영역 분리: ① 수집 `adapters/`(쇼핑몰 하나 = 어댑터 파일 하나 + `registry.py` 한 줄 + SQL seed 한 줄) + `sync.py`(공통 동기화, 같은 쇼핑몰 동시 실행 차단, 쇼핑몰별 실패 격리) ② 보안 `security/`(AES-256-GCM, 키 버전, 비밀값 가리기) + `credentials.py` ③ 계산 `calc.py`(주=월~일, 수수료 반올림은 `commission()` 한 곳, 요율 이력) + `db.py` ④ 화면 `dashboard.py`/`router.py`/템플릿. 쇼핑몰 API 인증정보는 `.env` 가 아니라 **설정 화면에서 입력 → 마스터 키 `APP_ENCRYPTION_KEY` 로 암호화해 DB 저장**, secret 원문은 화면으로 다시 보내지 않는다. 쇼핑몰 API 는 백엔드에서만 호출, 오류·로그·raw 는 `redact` 후 저장. 매출 기준일: 결제=결제일, 취소·반품=발생일(`sync.sales_date_for`). 금액은 원 단위 정수. 권한키 `performance`, 설정 화면은 모듈 권한자 누구나(일반 사용자는 수수료율만), 수수료 외 설정 API 는 `is_admin`. 매출 업데이트 진행 창에서 쇼핑몰별 [중지](그 쇼핑몰만 멈추고 다음 쇼핑몰로). 카페24 어댑터는 기존 `app/integrations/cafe24` 토큰 재사용. 1단계는 모의 데이터(`is_sample`)·구조까지, 실제 수집은 쇼핑몰별로 공식 문서 확인 후 순차 구현. 쿠팡은 판매자배송 발주서 + 로켓그로스 주문을 결제일로 합산(WING 판매분석 대조는 원본 데이터 확인으로). 설정의 쇼핑몰별 **수동 입력** 토글(마이그레이션 002 `manual_input`·`perf_manual_sales`) — 켜면 일자별 표 날짜 칸에 총매출 직접 입력, 넣은 날은 API 값 대신(`daily_amounts` 한 곳). 열 순서 카페24·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰(마이그레이션 003). 쿠팡(로켓)·애터미아자몰은 **수동 입력 전용**(`adapters/manual.py`, `manual_only` — 매출 업데이트에서 빠지고 인증 설정·연결 테스트 없음, 수동 입력 늘 켜짐). 상세는 `docs/PERFORMANCE_MODULE.md`
- 긴급 공지 (`app/modules/notice/`, `project_db` 마이그레이션 024 `urgent_notice*`) — 수퍼관리자만 작성(`/notice/`, ERP 왼쪽 아래·Project ⚙ 옵션). 제목·내용(이미지 bytea)·띄울 시각·전체/고른 사람 → ERP 모든 화면(`erp_base.html`·`main.html`·`admin.html` 의 `static/erp-notice.js`) 가로·세로 정가운데에 [확인] 누를 때까지(Esc·바깥 클릭 무시), 확인 기록. 연결 풀은 `ProjectStore.pool` 공유, 새 환경변수 없음. PC 알림 프로그램은 아직 미지원. 상세는 `docs/NOTICE_MODULE.md`
diff --git a/app/modules/performance/adapters/base.py b/app/modules/performance/adapters/base.py
index c4ebef5..962c078 100644
--- a/app/modules/performance/adapters/base.py
+++ b/app/modules/performance/adapters/base.py
@@ -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).
diff --git a/app/modules/performance/adapters/coupang.py b/app/modules/performance/adapters/coupang.py
index 0cecd35..73710f1 100644
--- a/app/modules/performance/adapters/coupang.py
+++ b/app/modules/performance/adapters/coupang.py
@@ -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
diff --git a/app/modules/performance/adapters/manual.py b/app/modules/performance/adapters/manual.py
new file mode 100644
index 0000000..57efd4a
--- /dev/null
+++ b/app/modules/performance/adapters/manual.py
@@ -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 = "애터미아자몰"
diff --git a/app/modules/performance/adapters/registry.py b/app/modules/performance/adapters/registry.py
index ea95bd2..c51ae43 100644
--- a/app/modules/performance/adapters/registry.py
+++ b/app/modules/performance/adapters/registry.py
@@ -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}
diff --git a/app/modules/performance/dashboard.py b/app/modules/performance/dashboard.py
index 654c390..43102ef 100644
--- a/app/modules/performance/dashboard.py
+++ b/app/modules/performance/dashboard.py
@@ -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,
diff --git a/app/modules/performance/router.py b/app/modules/performance/router.py
index a1cfc85..854a09e 100644
--- a/app/modules/performance/router.py
+++ b/app/modules/performance/router.py
@@ -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,
diff --git a/app/modules/performance/sync.py b/app/modules/performance/sync.py
index 569d273..f241165 100644
--- a/app/modules/performance/sync.py
+++ b/app/modules/performance/sync.py
@@ -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), 나머지는 "건너뜀" 한 줄로 — 바로 끝나는
diff --git a/app/modules/performance/templates/performance/settings.html b/app/modules/performance/templates/performance/settings.html
index ea01778..9e44c3e 100644
--- a/app/modules/performance/templates/performance/settings.html
+++ b/app/modules/performance/templates/performance/settings.html
@@ -57,8 +57,8 @@
-
{% endif %}
@@ -69,7 +69,8 @@
{% if is_admin %}
- {% if r.shared %}공통 연동
+ {% if r.manual_only %}수동 입력 전용
+ {% elif r.shared %}공통 연동
{% elif r.configured %}설정완료
{% else %}미설정{% endif %}
{% if r.via_cafe24 %}카페24 경유{% endif %}
@@ -84,8 +85,10 @@
{{ when(r.last_success_sync_at) }}
{% if is_admin %}
+ {% if not r.manual_only %}
+ {% endif %}
{% endif %}
@@ -144,14 +147,14 @@
· 11번가: 주문·클레임·정산 조회 주소별 동작 여부. 정산은 정산일 기준일 수 있어 매출이 있던 날부터 넉넉히(예: 3주).
· GS샵: 매출 내역·배송비 내역(매출인식일 기준)의 항목별 합계 — 협력사 포털 매출 화면의 같은 기간 숫자와 비교해 주세요.
· 토스쇼핑: 날짜별 매출·환불·순 거래액(= 저장되는 매출)과 주문 상태별·정산 항목 합계 — 토스쇼핑 파트너스의 같은 날 숫자와 비교해 주세요.
- · 쿠팡: 판매자배송 발주서 + 로켓그로스 주문을 결제일로 모아 날짜별 매출 후보(할인 전·후, 취소분 뺀 값, 로켓그로스 따로)와 판매량 — WING 비즈니스 인사이트 → 판매분석에서 같은 날짜의 "매출(원)"·"판매량"과 비교해 주세요.
+ · 쿠팡(윙): 판매자배송 발주서 + 로켓그로스 주문을 결제일로 모아 날짜별 매출 후보(할인 전·후, 취소분 뺀 값, 로켓그로스 따로)와 판매량 — WING 비즈니스 인사이트 → 판매분석에서 같은 날짜의 "매출(원)"·"판매량"과 비교해 주세요.
~
diff --git a/app/modules/performance/tests/test_performance.py b/app/modules/performance/tests/test_performance.py
index 188fb6d..6847695 100644
--- a/app/modules/performance/tests/test_performance.py
+++ b/app/modules/performance/tests/test_performance.py
@@ -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
diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md
index 807cfaf..cfabbb6 100644
--- a/docs/DEPLOYMENT.md
+++ b/docs/DEPLOYMENT.md
@@ -150,6 +150,18 @@ docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d performance_db
docker exec postgres-db psql -U postgres -d performance_db -c "SELECT code, sort_order, manual_input FROM perf_marketplaces ORDER BY sort_order;"
```
+## 실적 쇼핑몰 순서·신규 수동 입력 쇼핑몰 마이그레이션 (performance_db 003)
+
+003은 기존 `쿠팡` 이름을 `쿠팡(윙)` 으로 바꾸고, 수동 입력 전용 쇼핑몰 `쿠팡(로켓)`(`coupang_rocket`)·`애터미아자몰`(`atomy`)을
+`manual_input = TRUE` 로 추가하며, 순서를 카페24·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰 로
+바꾼다(기존 매출·인증정보 그대로, 다시 실행 가능). 002 뒤에 적용한다. 미적용이면 새 쇼핑몰 2곳만 화면에 안 나온다.
+
+```bash
+cd /opt/www/main
+docker exec postgres-db pg_dump -U postgres performance_db > ~/performance_db_before_003_$(date +%Y%m%d%H%M).sql
+docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d performance_db < scripts/sql/performance_db_003_marketplace_order.sql
+```
+
## 회의록 작업 등록 표 — 작업 칸 마이그레이션 (026)
026은 `goal_meeting_tasks.parent_task_id` 열만 추가한다(기존 값 그대로, 다시 실행 가능). 025 뒤에 적용한다. 미적용이면 작업 칸을 고를 때만 503 안내.
diff --git a/docs/PERFORMANCE_MODULE.md b/docs/PERFORMANCE_MODULE.md
index 4c63ae8..8a1d7b3 100644
--- a/docs/PERFORMANCE_MODULE.md
+++ b/docs/PERFORMANCE_MODULE.md
@@ -210,7 +210,11 @@
API 값. 대체는 `PerformanceDBStore.daily_amounts` 한 곳에서 해 실적 화면·회의록 머리 카드가 같은 숫자를 본다. 수수료는 그날 요율로 계산.
토글을 끄면 값은 남지만 집계에 쓰지 않는다. 매출 업데이트(동기화)는 수동 값을 지우지 않는다.
- 002 미적용: 읽기는 수동 값 없음으로 조용히 동작, 토글·저장은 503 안내.
-- 열 순서(002 + `registry.py`): 카페24 · 네이버 · 쿠팡 · 토스 · GS샵 · 11번가 · 오늘의집 · G마켓 · 카카오 · 롯데ON.
+- 열 순서(003 + `registry.py`): 카페24 · 네이버 · 쿠팡(윙) · 쿠팡(로켓) · 오늘의집 · G마켓 · 카카오 · GS샵 · 11번가 · 롯데ON · 토스 · 애터미아자몰.
+ 기존 `coupang`(WING API) 이름은 `쿠팡(윙)`.
+- **수동 입력 전용 쇼핑몰**(003, `adapters/manual.py` — `manual_only = True`): `쿠팡(로켓)`(`coupang_rocket`)·`애터미아자몰`(`atomy`).
+ API 가 없어 매출 업데이트(`sync_all`)에서 빠지고, 설정 화면에 인증 설정·연결 테스트 버튼이 없으며 연결 상태는 "수동 입력".
+ 수동 입력 토글은 늘 켜짐(화면 disabled, API 로 끄면 400). 매출은 일자별 표 날짜 칸에 직접 입력.
- 표 열 제목은 가운데·굵게·검정(`.perf-table thead th`).
### 연동 단계 체크리스트(쇼핑몰마다)
diff --git a/scripts/sql/performance_db_003_marketplace_order.sql b/scripts/sql/performance_db_003_marketplace_order.sql
new file mode 100644
index 0000000..074a9a1
--- /dev/null
+++ b/scripts/sql/performance_db_003_marketplace_order.sql
@@ -0,0 +1,33 @@
+-- =====================================================================
+-- performance_db 마이그레이션 003 — 쇼핑몰 열 순서 + 쿠팡(윙) 이름 + 수동 입력 전용 쇼핑몰 2곳
+-- =====================================================================
+-- 멱등(idempotent). 기존 데이터 삭제 없음. 002(manual_input) 적용 뒤에 실행.
+-- docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d performance_db \
+-- < scripts/sql/performance_db_003_marketplace_order.sql
+--
+-- 왜(2026-10-13 사용자 요청):
+-- 1) 기존 '쿠팡'(WING API — 판매자배송 + 로켓그로스) 이름을 '쿠팡(윙)' 으로.
+-- 2) 신규 쇼핑몰 '쿠팡(로켓)'(coupang_rocket)·'애터미아자몰'(atomy) — API 연동 없는 수동 입력 전용(manual_input = TRUE).
+-- 3) 열 순서: 카페24 · 네이버 · 쿠팡(윙) · 쿠팡(로켓) · 오늘의집 · G마켓 · 카카오 · GS샵 · 11번가 · 롯데ON · 토스 · 애터미아자몰.
+-- =====================================================================
+BEGIN;
+
+UPDATE perf_marketplaces SET name = '쿠팡(윙)' WHERE code = 'coupang' AND name = '쿠팡';
+
+INSERT INTO perf_marketplaces (code, name, sort_order, manual_input) VALUES
+ ('coupang_rocket', '쿠팡(로켓)', 35, TRUE),
+ ('atomy', '애터미아자몰', 110, TRUE)
+ON CONFLICT (code) DO NOTHING;
+-- 수동 입력 전용은 늘 켜 둔다(화면에서도 끌 수 없음)
+UPDATE perf_marketplaces SET manual_input = TRUE
+ WHERE code IN ('coupang_rocket', 'atomy') AND NOT manual_input;
+
+-- 열 순서(설정·실적 표 공통)
+UPDATE perf_marketplaces AS m SET sort_order = v.sort_order
+ FROM (VALUES ('cafe24', 10), ('naver', 20), ('coupang', 30), ('coupang_rocket', 35), ('ohouse', 40),
+ ('gmarket', 50), ('kakao', 60), ('gsshop', 70), ('elevenst', 80), ('lotteon', 90),
+ ('toss', 100), ('atomy', 110)) AS v(code, sort_order)
+ WHERE m.code = v.code AND m.sort_order <> v.sort_order;
+
+COMMIT;
+SELECT code, name, sort_order, manual_input FROM perf_marketplaces ORDER BY sort_order;
diff --git a/scripts/sql/performance_db_init.sql b/scripts/sql/performance_db_init.sql
index fac50aa..c3cfab6 100644
--- a/scripts/sql/performance_db_init.sql
+++ b/scripts/sql/performance_db_init.sql
@@ -72,17 +72,19 @@ CREATE TRIGGER trg_perf_marketplaces_updated
BEFORE UPDATE ON perf_marketplaces
FOR EACH ROW EXECUTE FUNCTION perf_set_updated_at();
-INSERT INTO perf_marketplaces (code, name, sort_order) VALUES
- ('cafe24', '카페24', 10),
- ('naver', '네이버 스마트스토어', 20),
- ('coupang', '쿠팡', 30),
- ('toss', '토스쇼핑', 40),
- ('gsshop', 'GS샵', 50),
- ('elevenst', '11번가', 60),
- ('ohouse', '오늘의집', 70),
- ('gmarket', 'G마켓', 80),
- ('kakao', '카카오', 90),
- ('lotteon', '롯데ON', 100)
+INSERT INTO perf_marketplaces (code, name, sort_order, manual_input) VALUES
+ ('cafe24', '카페24', 10, FALSE),
+ ('naver', '네이버 스마트스토어', 20, FALSE),
+ ('coupang', '쿠팡(윙)', 30, FALSE),
+ ('coupang_rocket', '쿠팡(로켓)', 35, TRUE), -- 수동 입력 전용(003)
+ ('ohouse', '오늘의집', 40, FALSE),
+ ('gmarket', 'G마켓', 50, FALSE),
+ ('kakao', '카카오', 60, FALSE),
+ ('gsshop', 'GS샵', 70, FALSE),
+ ('elevenst', '11번가', 80, FALSE),
+ ('lotteon', '롯데ON', 90, FALSE),
+ ('toss', '토스쇼핑', 100, FALSE),
+ ('atomy', '애터미아자몰', 110, TRUE) -- 수동 입력 전용(003)
ON CONFLICT (code) DO NOTHING;
-- ════════════════════════════════════════════════════════════