feat(카페24): 옵션/품목 팝업에 재고관리·재고 수량·품절표시 설정
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨.
|
||||
- 옵션/품목 팝업 「판매 가격」 열: 기본 정보 판매가 + 추가금액을 보여주고, 입력하면 추가금액을 역산(`cafe24-options.js` `bindSalePrice`). 저장되는 값은 추가금액뿐.
|
||||
- 기본 정보에서 판매가를 바꾸면 같은 잠금 안에서 품목 추가금액을 (옛 판매가 − 새 판매가)만큼 옮겨 품목 판매 가격을 유지(`_keep_variant_sale_prices`, `store.shift_additional_amounts`). 공급가·소비자가는 품목과 무관. 판매가는 이미 반영됐으므로 품목 조정 실패는 화면 메시지(`variants_error`)로만.
|
||||
- 옵션/품목 팝업 옵션값 이름·자체 품목코드·추가금액·판매 가격 칸: Enter·↓ 아래 행, ↑ 위 행 같은 열로 이동(한글 조합 중에는 이동 안 함).
|
||||
- 옵션/품목 팝업 「재고관리」(use_inventory)·「재고」(quantity)·「품절표시」(display_soldout) 열: 같은 PUT variants 로 기본몰에만 보냄(재고는 쇼핑몰 공통).
|
||||
- 옵션/품목 팝업 옵션값 이름·자체 품목코드·추가금액·판매 가격·재고 칸: Enter·↓ 아래 행, ↑ 위 행 같은 열로 이동(한글 조합 중에는 이동 안 함).
|
||||
- 옵션/품목 팝업(단일 옵션 화면) 「모바일 스와이프 복사(코드)」: `// 상품명` + `"품목코드": "/web/…썸네일 경로",` 줄들을 클립보드로
|
||||
(`cafe24-options.js` `swipeCode` — 행에 지금 보이는 썸네일 기준, 도메인/CDN 은 떼고 `/web/` 부터).
|
||||
「모바일 스와이프 복사(이름)」은 키가 품목코드 대신 옵션값 이름(`swipeCode(tbody, true)`, 품목코드 있는 행만).
|
||||
|
||||
@@ -257,6 +257,7 @@ def _variant_view(v: dict[str, Any]) -> dict[str, Any]:
|
||||
"selling": products._flag(v.get("selling")), # noqa: SLF001
|
||||
"quantity": v.get("quantity"),
|
||||
"use_inventory": products._flag(v.get("use_inventory"), default=False), # noqa: SLF001
|
||||
"display_soldout": products._flag(v.get("display_soldout"), default=False), # noqa: SLF001
|
||||
"image": str(v.get("image") or ""),
|
||||
}
|
||||
|
||||
@@ -664,7 +665,7 @@ def variants_update(
|
||||
product_no: int,
|
||||
payload: dict[str, Any] = Body(default_factory=dict),
|
||||
) -> dict[str, Any]:
|
||||
"""품목 여러 건의 자체코드 · 추가금액 · 진열 · 판매를 한 번에 바꾼다 — **행별 결과**.
|
||||
"""품목 여러 건의 자체코드 · 추가금액 · 진열 · 판매 · 재고(사용·수량·품절표시)를 한 번에 바꾼다 — **행별 결과**.
|
||||
|
||||
응답 {"ok": 전부 성공?, "partial": 일부만?, "updated": {code: 반영된 값},
|
||||
"failed": {code: 사유}, "unknown": {code: 사유}}
|
||||
@@ -697,7 +698,8 @@ def variants_update(
|
||||
code = result["variant_code"]
|
||||
if result["status"] == products.VARIANT_OK:
|
||||
patch = dict(sent.get(code) or {})
|
||||
for key in ("custom_variant_code", "additional_amount", "display", "selling", "display_order"):
|
||||
for key in ("custom_variant_code", "additional_amount", "display", "selling", "display_order",
|
||||
"use_inventory", "display_soldout", "quantity"):
|
||||
value = (result.get("variant") or {}).get(key)
|
||||
if value is not None:
|
||||
patch[key] = value
|
||||
|
||||
@@ -1106,9 +1106,17 @@ def build_variant_updates(rows: list[dict]) -> list[dict]:
|
||||
amount = parse_additional_amount(row["additional_amount"])
|
||||
if amount is not None:
|
||||
item["additional_amount"] = amount
|
||||
for flag in ("display", "selling"):
|
||||
for flag in ("display", "selling", "use_inventory", "display_soldout"):
|
||||
if row.get(flag) is not None:
|
||||
item[flag] = "T" if parse_tristate(row[flag]) else "F"
|
||||
if row.get("quantity") is not None and str(row["quantity"]).strip() != "":
|
||||
try:
|
||||
qty = int(str(row["quantity"]).strip().replace(",", ""))
|
||||
except ValueError:
|
||||
raise ValueError("재고 수량은 숫자여야 합니다.") from None
|
||||
if not 0 <= qty <= ADDITIONAL_AMOUNT_MAX:
|
||||
raise ValueError("재고 수량은 0 이상이어야 합니다.")
|
||||
item["quantity"] = qty
|
||||
# 진열 순서(1~300) — 카페24 문서: 조합형 옵션 품목에만. 화면의 드래그 정렬이 보낸다.
|
||||
if row.get("display_order") is not None:
|
||||
try:
|
||||
|
||||
@@ -1353,6 +1353,18 @@ def test_build_variant_updates():
|
||||
pass
|
||||
else:
|
||||
raise AssertionError("bad code accepted")
|
||||
# 재고관리 사용 · 수량 · 품절표시
|
||||
assert store.build_variant_updates([
|
||||
{"variant_code": "P000000R000A", "use_inventory": "on", "quantity": "1,200", "display_soldout": "off"},
|
||||
{"variant_code": "P000000R000B", "quantity": ""}, # 빈 수량 → 변경 없음
|
||||
]) == [{"variant_code": "P000000R000A", "use_inventory": "T", "display_soldout": "F", "quantity": 1200}]
|
||||
for bad in ("-1", "x"):
|
||||
try:
|
||||
store.build_variant_updates([{"variant_code": "P000000R000A", "quantity": bad}])
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
raise AssertionError(bad)
|
||||
# 드래그 정렬 → display_order (1~300)
|
||||
assert store.build_variant_updates([{"variant_code": "P000000R000A", "display_order": "3"}]) == [
|
||||
{"variant_code": "P000000R000A", "display_order": 3}
|
||||
|
||||
Reference in New Issue
Block a user