feat(performance): 카페24 매출 대조 — 채널별 PC/모바일 주문 분리 + 결제수단별 표
- 주문 채널별 표에 PC 주문 / 모바일 주문(주문의 order_from_mobile 기준 — PC 채널이어도 휴대폰 주문은 모바일) 건수·결제합계, 카페24 열(자체몰) 합계 줄 - 결제수단별 표(카페24 열 주문의 payment_method_name 조합별 주문수·결제합계·비중) - 대조 카드를 설정 화면 가로 전체 폭으로(넓은 표가 잘리지 않게), 자체몰 채널 이름 정리(PC) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ EVENT_PREFIX = "c24:"
|
||||
# (실데이터 확인 2026-09-30: mobile=모바일웹, NCHECKOUT=네이버페이, KAKAOPAY=톡체크아웃).
|
||||
# 이 주문들은 카페24 자체몰 매출이다. 비교는 소문자로.
|
||||
SELF_CHANNELS: dict[str, str] = {
|
||||
"": "자체몰", "self": "자체몰(PC)", "cafe24": "자체몰", "mobile": "모바일웹", "mobile_d": "모바일앱",
|
||||
"": "기본", "self": "PC", "cafe24": "PC", "mobile": "모바일웹", "mobile_d": "모바일앱",
|
||||
"ncheckout": "네이버페이", "kakaopay": "톡체크아웃",
|
||||
}
|
||||
|
||||
@@ -339,18 +339,31 @@ class Cafe24Adapter(MarketplaceAdapter):
|
||||
"market_id": key or "(없음)", "label": SELF_CHANNELS.get(_key(mid), ""), "names": set(),
|
||||
"kind": kind, "target": target_code(mid, place),
|
||||
"orders": 0, "total": 0, "refund_count": 0, "refund_amount": 0,
|
||||
# 기기 — 주문의 order_from_mobile(T=모바일에서 주문). PC 채널(self)에도 모바일 주문이 섞여 있다.
|
||||
"pc_orders": 0, "pc_total": 0, "mobile_orders": 0, "mobile_total": 0,
|
||||
})
|
||||
|
||||
groups = {"self": empty(), "market": empty()}
|
||||
by_channel: dict[str, dict[str, Any]] = {}
|
||||
by_payment: dict[str, dict[str, Any]] = {} # 결제수단 조합별(카페24 열 주문만)
|
||||
unpaid = 0
|
||||
for o in self.paid_orders(ctx, day, day):
|
||||
if o.get("paid") != "T":
|
||||
unpaid += 1
|
||||
continue
|
||||
ch = channel(o.get("market_id"), o.get("order_place_id"))
|
||||
total = order_total(o)
|
||||
ch["orders"] += 1
|
||||
ch["total"] += order_total(o)
|
||||
ch["total"] += total
|
||||
dev = "mobile" if str(o.get("order_from_mobile") or "").upper() == "T" else "pc"
|
||||
ch[f"{dev}_orders"] += 1
|
||||
ch[f"{dev}_total"] += total
|
||||
if ch["target"] == "cafe24":
|
||||
names = [str(n) for n in (o.get("payment_method_name") or o.get("payment_method") or []) if n]
|
||||
pkey = " + ".join(names) or "(없음)"
|
||||
pm = by_payment.setdefault(pkey, {"method": pkey, "orders": 0, "total": 0})
|
||||
pm["orders"] += 1
|
||||
pm["total"] += total
|
||||
for n in (o.get("order_place_name"), o.get("order_place_id")):
|
||||
if n:
|
||||
ch["names"].add(str(n))
|
||||
@@ -378,5 +391,6 @@ class Cafe24Adapter(MarketplaceAdapter):
|
||||
key=lambda v: v["total"], reverse=True)
|
||||
return {"date": day.isoformat(), "orders": groups, "refunds": refunds, "unpaid_orders": unpaid,
|
||||
"by_channel": channels_out,
|
||||
"by_payment": sorted(by_payment.values(), key=lambda v: v["total"], reverse=True),
|
||||
"formula": "결제합계 = 상품구매금액 + 배송비 − 할인(" + ", ".join(DISCOUNT_FIELDS) +
|
||||
") − 쿠폰(" + ", ".join(COUPON_FIELDS) + ")"}
|
||||
|
||||
Reference in New Issue
Block a user