fix(performance): GS샵 매출 = supGiveAmt(협력사 지급액) — 협력사 포털 주문 통계 금액과 같은 항목
- 9월 실데이터: 6호세트 포털 176,715 ÷ 9 = 19,635 = API supGiveAmt(판매가 23,100·고객 결제 20,330), 7호세트 45,900 × 85%, 주부체험 9,900 × 90% — 상품마다 GS 수수료율이 달라 판매가로는 못 맞춤 - 9/1~9/29 지급액 4,972,689 vs 포털 순주문 4,823,074(주문일↔매출인식일 차이) - 이미 GS 수수료를 뺀 금액이라 GS샵 수수료율은 0% 로 둔다(문서·어댑터 설명) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,10 +20,13 @@
|
||||
**주문일 기준 조회 API 는 없다**(V3 문서에 주문 조회 없음) — 협력사 포털 주문 통계(총주문금액, 주문일)와는 기준이 달라
|
||||
날짜별로 똑같이 맞출 수 없다.
|
||||
|
||||
매출 규칙(주문 통계의 금액도 할인 후 고객 결제 기준 — 7호세트 195,075 ÷ 5 = 39,015 = 45,900 × 85%):
|
||||
매출 규칙 — 협력사 포털 주문 통계의 금액 = **supGiveAmt(협력사 지급액)**(2026-09-30, 9월 실데이터로 확인):
|
||||
미라미라클 6호세트 포털 176,715 ÷ 9 = 19,635 = API 줄 supGiveAmt 19,635(판매가 23,100·고객 결제 20,330),
|
||||
7호세트 39,015 = 45,900 × 85%, 주부체험 세트 8,910 = 9,900 × 90% — 상품마다 GS 수수료율이 달라 판매가 × 요율로는 못 맞춘다.
|
||||
9/1~9/29: 지급액 4,972,689 / 포털 순주문 4,823,074(차이는 주문일 ↔ 매출인식일 기준 차이·취소분).
|
||||
- 매출 내역 한 줄 = 사건 하나(`gs:{ordNo}-{ordItemNo}-{ordType}-{saleAwareDt}`), 날짜 = 매출인식일.
|
||||
- 금액 = custChrAmt(할인 후 고객 결제금액), 배송비 제외(네이버와 같은 기준). ordType 이 SALE 이 아니면(취소·반품 등)
|
||||
음수로(RETURN). 할인 = dcTotAmt. 기간을 통째로 다시 받는다(replace_range).
|
||||
- 금액 = supGiveAmt, 배송비 제외. 이미 GS 수수료를 뺀 금액이라 **실적 설정의 GS샵 수수료율은 0%** 로 둔다.
|
||||
ordType 이 SALE 이 아니면(취소·반품 등) 음수로(RETURN). 할인 = dcTotAmt. 기간을 통째로 다시 받는다(replace_range).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -235,12 +238,12 @@ class GsshopAdapter(MarketplaceAdapter):
|
||||
yield {**r, "_day": day, "_id": base if n == 0 else f"{base}-{n + 1}"}
|
||||
|
||||
def normalize_order(self, r: dict[str, Any]) -> list[SaleEvent]:
|
||||
"""매출 내역 한 줄 → SALE(ordType=SALE) 또는 RETURN(그 밖, 음수). 금액 = custChrAmt(할인 후 고객 결제금액)."""
|
||||
"""매출 내역 한 줄 → SALE(ordType=SALE) 또는 RETURN(그 밖, 음수). 금액 = supGiveAmt(협력사 지급액 — 포털 주문 통계 금액)."""
|
||||
oid, day = str(r.get("ordNo") or ""), r.get("_day")
|
||||
if not oid or day is None:
|
||||
return []
|
||||
kind = str(r.get("ordType") or "SALE").upper()
|
||||
amount = abs(_won(r.get("custChrAmt")))
|
||||
amount = abs(_won(r.get("supGiveAmt")))
|
||||
is_sale = kind == "SALE"
|
||||
return [SaleEvent(
|
||||
event_type="SALE" if is_sale else "RETURN", external_event_id=f"{EVENT_PREFIX}{r['_id']}",
|
||||
@@ -248,7 +251,7 @@ class GsshopAdapter(MarketplaceAdapter):
|
||||
payment_date=day if is_sale else None, amount=amount if is_sale else -amount,
|
||||
product_name=str(r.get("prdNm") or "")[:200], quantity=abs(_won(r.get("chrQty"))),
|
||||
discount_amount=abs(_won(r.get("dcTotAmt"))), order_status=kind[:50],
|
||||
raw={"salePrice": _won(r.get("salePrice")), "supGiveAmt": _won(r.get("supGiveAmt")),
|
||||
raw={"salePrice": _won(r.get("salePrice")), "custChrAmt": _won(r.get("custChrAmt")),
|
||||
"orgOrdNo": str(r.get("orgOrdNo") or ""), "prdCd": str(r.get("prdCd") or "")},
|
||||
)]
|
||||
|
||||
@@ -286,18 +289,19 @@ class GsshopAdapter(MarketplaceAdapter):
|
||||
continue
|
||||
got[key] = rows
|
||||
probes.append({**row, "ok": True, "count": len(rows), "fields": field_summary([_strs(r) for r in rows])})
|
||||
# 날짜별 현재 규칙 매출(custChrAmt, SALE 아닌 줄은 음수) — 협력사 포털 매출 화면과 나란히 비교
|
||||
# 날짜별 현재 규칙 매출(supGiveAmt, SALE 아닌 줄은 음수) — 협력사 포털 매출 화면과 나란히 비교
|
||||
days = []
|
||||
d = day
|
||||
while d <= to:
|
||||
sales = [r for r in got.get("sales", []) if _yyyymmdd(r.get("saleAwareDt")) == d]
|
||||
ret = [r for r in sales if str(r.get("ordType") or "SALE").upper() != "SALE"]
|
||||
amt = sum(abs(_won(r.get("custChrAmt"))) for r in sales if r not in ret) - sum(abs(_won(r.get("custChrAmt"))) for r in ret)
|
||||
amt = sum(abs(_won(r.get("supGiveAmt"))) for r in sales if r not in ret) - sum(abs(_won(r.get("supGiveAmt"))) for r in ret)
|
||||
days.append({"date": d.isoformat(), "orders": len({str(r.get("ordNo")) for r in sales if r not in ret}),
|
||||
"amount": amt, "claimed": sum(abs(_won(r.get("custChrAmt"))) for r in ret),
|
||||
"amount": amt, "claimed": sum(abs(_won(r.get("supGiveAmt"))) for r in ret),
|
||||
"ship": sum(_won(r.get("salePrice")) for r in got.get("shipping", [])
|
||||
if _yyyymmdd(r.get("saleAwareDt")) == d)})
|
||||
d += timedelta(days=1)
|
||||
return {"date": day.isoformat(), "to": to.isoformat(), "probes": probes, "days": days,
|
||||
"day_cols": {"claimed": "그중 취소·반품(음수로 반영)", "ship": "배송비(참고, 매출 제외)"},
|
||||
"rule": "매출인식일 기준 매출 내역 custChrAmt(할인 후 고객 결제금액) 합, SALE 이 아닌 줄은 빼기, 배송비 제외"}
|
||||
"rule": "매출인식일 기준 매출 내역 supGiveAmt(협력사 지급액 = 포털 주문 통계 금액) 합, SALE 이 아닌 줄은 빼기, "
|
||||
"배송비 제외. 주문 통계는 주문일 기준이라 날마다 같지는 않고 기간이 길수록 가까워진다"}
|
||||
|
||||
Reference in New Issue
Block a user