Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f57f5d15e | |||
| 4cd349c3a1 | |||
| 5e9c1dac88 | |||
| 282ee559e0 | |||
| 1096fd68ab | |||
| 8bd62fbf6d | |||
| 9229d269c9 |
@@ -126,6 +126,11 @@ CUSTOMER_ORDER_LIST_URL=/orderlist/
|
||||
# 미설정 시 카페24 기본 도메인(https://<mall_id>.cafe24.com)으로 대체된다.
|
||||
# CAFE24_SHOP_URL=https://www.miras.co.kr
|
||||
#
|
||||
# 멀티쇼핑몰 번호(쉼표). 옵션/품목 팝업에서 바꾼 품목 진열·판매를 이 쇼핑몰 모두에 같은 값으로
|
||||
# 보낸다(추가금액·자체코드는 기본몰 1 만). 번호는 카페24 관리자 → 멀티쇼핑몰 관리에서 확인.
|
||||
# 미설정 시 1(기본몰)만.
|
||||
# CAFE24_SHOP_NOS=1,2,3
|
||||
#
|
||||
# 카페24 읽기 지연 유예시간(분). 카페24 관리자 API 는 PUT 뒤 한동안 GET 에서 예전
|
||||
# 값을 돌려준다. 이 시간 안에 우리가 쓴 값이 있으면, GET 이 그 이전 값을 돌려줘도
|
||||
# 마지막 쓰기(revision·스냅샷)를 화면·적용 기준으로 삼는다. 지나면 카페24 값을 믿는다.
|
||||
|
||||
@@ -486,7 +486,7 @@ VARIANT_UNKNOWN = "unknown" # 요청이 도달했을 수 있으나 응답을
|
||||
|
||||
|
||||
def update_variants(
|
||||
client: Cafe24Client, product_no: int, requests: list[dict[str, Any]]
|
||||
client: Cafe24Client, product_no: int, requests: list[dict[str, Any]], *, shop_no: int = 1
|
||||
) -> list[dict[str, Any]]:
|
||||
"""여러 품목 부분 수정 — **행별 결과**를 돌려준다(요청 순서 그대로).
|
||||
|
||||
@@ -506,7 +506,7 @@ def update_variants(
|
||||
continue
|
||||
try:
|
||||
payload = client.put(
|
||||
f"/admin/products/{no}/variants", json={"shop_no": 1, "requests": chunk}, product_no=no
|
||||
f"/admin/products/{no}/variants", json={"shop_no": int(shop_no), "requests": chunk}, product_no=no
|
||||
)
|
||||
except Cafe24Error as exc:
|
||||
status = VARIANT_UNKNOWN if getattr(exc, "maybe_applied", False) else VARIANT_FAILED
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
- HTML 편집기에서 `<img>` 태그에 마우스를 올리면 태그를 오렌지색으로 칠하고 화면 오른쪽에 폭 500px·창 높이로 파일명과 미리보기(상대 경로는 `CAFE24_SHOP_URL` 루트 기준, 색칠 한도 `HL_LIMIT` 초과 소스는 미동작).
|
||||
- HTML 편집기에서 커서가 `<img>` 태그 안 어디에 있든 Ctrl+↑/↓ 로 `src` 파일명(`.jpg`/`.gif`/`.png`) 번호 변경. 없음 → `_2` → `_3` …, 이미 `_숫자` 면 다음 숫자부터. 내릴 때는 원래 번호(없었으면 원래 이름) 아래로 안 감 — 다른 편집이 끼거나 다른 이미지로 옮기면 그때 번호가 새 원래 번호.
|
||||
- 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지, 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매) 수정.
|
||||
품목 진열·판매는 `CAFE24_SHOP_NOS`(예 1,2,3)의 모든 멀티쇼핑몰에 같은 값으로 보냄(추가금액 등은 기본몰만).
|
||||
- 대표이미지는 `POST /admin/products/{no}/images` 에 base64 data URI + `image_upload_type=A`.
|
||||
NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨.
|
||||
- 옵션/품목 팝업 「판매 가격」 열: 기본 정보 판매가 + 추가금액을 보여주고, 입력하면 추가금액을 역산(`cafe24-options.js` `bindSalePrice`). 저장되는 값은 추가금액뿐.
|
||||
- 옵션/품목 팝업 옵션값 이름·자체 품목코드·추가금액·판매 가격 칸: Enter·↓ 아래 행, ↑ 위 행 같은 열로 이동(한글 조합 중에는 이동 안 함).
|
||||
- 옵션/품목 팝업(단일 옵션 화면) 「모바일 스와이프 복사(코드)」: `// 상품명` + `"품목코드": "/web/…썸네일 경로",` 줄들을 클립보드로
|
||||
(`cafe24-options.js` `swipeCode` — 행에 지금 보이는 썸네일 기준, 도메인/CDN 은 떼고 `/web/` 부터).
|
||||
「모바일 스와이프 복사(이름)」은 키가 품목코드 대신 옵션값 이름(`swipeCode(tbody, true)`, 품목코드 있는 행만).
|
||||
|
||||
@@ -42,6 +42,15 @@ def read_lag_grace_minutes() -> int:
|
||||
return store.parse_grace_minutes(os.getenv("CAFE24_READ_LAG_GRACE_MIN"))
|
||||
|
||||
|
||||
def shop_nos() -> list[int]:
|
||||
"""품목 진열·판매를 함께 맞출 멀티쇼핑몰 번호. `CAFE24_SHOP_NOS`(예: 1,2,3), 기본 [1]."""
|
||||
import os # noqa: WPS433
|
||||
|
||||
from . import store # noqa: WPS433
|
||||
|
||||
return store.parse_shop_nos(os.getenv("CAFE24_SHOP_NOS"))
|
||||
|
||||
|
||||
def require_user(request: Request) -> dict[str, Any]:
|
||||
from app.main import get_current_user_record # noqa: WPS433
|
||||
from app.store import has_module # noqa: WPS433
|
||||
|
||||
@@ -37,7 +37,7 @@ from app.integrations.cafe24 import Cafe24Error, build_cafe24_api, products
|
||||
from app.timezone import now_kst
|
||||
|
||||
from . import store, writes
|
||||
from .common import read_lag_grace_minutes, require_store
|
||||
from .common import read_lag_grace_minutes, require_store, shop_nos
|
||||
from .routes_products import load_product, locked_json, remember_write
|
||||
|
||||
logger = logging.getLogger("cafe24.product_info")
|
||||
@@ -636,6 +636,7 @@ def variants_update(
|
||||
"failed": {code: 사유}, "unknown": {code: 사유}}
|
||||
100건 묶음 중 일부가 실패해도 성공한 행은 성공으로 기록·표시한다(화면이 그 행을
|
||||
다시 보내지 않게). 하나도 반영되지 않았으면 502.
|
||||
진열·판매는 `CAFE24_SHOP_NOS` 의 다른 쇼핑몰에도 같은 값으로 보낸다 — 실패는 "shop_failed".
|
||||
"""
|
||||
st, user = require_store(request)
|
||||
actor = str(user.get("email") or "")
|
||||
@@ -673,9 +674,26 @@ def variants_update(
|
||||
failed[code] = result["error"]
|
||||
record_error = _save_snapshot_safe(st, product_no, "variants", by_code) if by_code else ""
|
||||
|
||||
# 멀티쇼핑몰: 진열·판매는 쇼핑몰마다 따로라 기본몰(1)에 반영된 행의 진열·판매만
|
||||
# 다른 쇼핑몰에도 똑같이 보낸다. 추가금액(통화가 다름)·자체코드·순서는 보내지 않는다.
|
||||
flags = [
|
||||
{"variant_code": code, **{k: sent[code][k] for k in ("display", "selling") if k in sent[code]}}
|
||||
for code in by_code if {"display", "selling"} & set(sent.get(code) or {})
|
||||
]
|
||||
shop_failed: dict[str, str] = {}
|
||||
for shop in (shop_nos()[1:] if flags else []):
|
||||
bad = [r for r in products.update_variants(api.client, product_no, flags, shop_no=shop)
|
||||
if r["status"] != products.VARIANT_OK]
|
||||
if bad:
|
||||
shop_failed[str(shop)] = f"{len(bad)}건 — {bad[0]['error']}"
|
||||
|
||||
detail = "; ".join(
|
||||
f"{code}: " + ", ".join(f"{k}={v}" for k, v in patch.items()) for code, patch in by_code.items()
|
||||
)
|
||||
if flags and len(shop_nos()) > 1:
|
||||
detail = f"[진열·판매 쇼핑몰 {','.join(map(str, shop_nos()))}] " + detail
|
||||
if shop_failed:
|
||||
detail += " / 다른 쇼핑몰 실패: " + "; ".join(f"{s}번 {e}" for s, e in shop_failed.items())
|
||||
if failed or unknown:
|
||||
detail = (f"성공 {len(by_code)} / 실패 {len(failed)} / 결과 모름 {len(unknown)} — " + detail)
|
||||
first = next(iter({**failed, **unknown}.values()), "")
|
||||
@@ -696,5 +714,6 @@ def variants_update(
|
||||
"updated": {code: _variant_view({"variant_code": code, **patch}) for code, patch in by_code.items()},
|
||||
"failed": failed,
|
||||
"unknown": unknown,
|
||||
"shop_failed": shop_failed,
|
||||
"record_warning": record_error,
|
||||
}
|
||||
|
||||
@@ -506,6 +506,15 @@ WRITE_REVISION_TYPES: tuple[str, ...] = (REVISION_MANUAL, REVISION_SCHEDULED, RE
|
||||
DEFAULT_READ_LAG_GRACE_MIN = 360
|
||||
|
||||
|
||||
def parse_shop_nos(value: object) -> list[int]:
|
||||
"""`CAFE24_SHOP_NOS`("1,2,3") → [1, 2, 3]. 기본 쇼핑몰 1 은 항상 맨 앞, 잘못된 값은 버린다."""
|
||||
out = [1]
|
||||
for part in str(value or "").replace(" ", "").split(","):
|
||||
if part.isdigit() and int(part) > 0 and int(part) not in out:
|
||||
out.append(int(part))
|
||||
return out
|
||||
|
||||
|
||||
def parse_grace_minutes(value: object, default: int = DEFAULT_READ_LAG_GRACE_MIN) -> int:
|
||||
try:
|
||||
minutes = int(str(value or "").strip())
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/static/cafe24-options.js?v=20261106b"></script>
|
||||
<script src="/static/cafe24-options.js?v=20261110c"></script>
|
||||
<script>
|
||||
(function () {
|
||||
var pane = document.getElementById("cf24-editor-pane");
|
||||
|
||||
@@ -396,6 +396,8 @@ class FakeCafe24:
|
||||
self._variant_puts += 1
|
||||
if self.fail_variant_chunk and self._variant_puts == self.fail_variant_chunk:
|
||||
raise self.variant_error or Cafe24ApiError("품목 수정 거절", status=422)
|
||||
if (json or {}).get("shop_no", 1) != 1: # 다른 쇼핑몰 — 기본몰 상태는 그대로
|
||||
return {"variants": [dict(r) for r in (json or {}).get("requests") or []]}
|
||||
out = []
|
||||
for r in (json or {}).get("requests") or []:
|
||||
for var in self.variants:
|
||||
|
||||
@@ -1086,6 +1086,11 @@ def test_resolve_description_accepts_iso_created_at():
|
||||
assert (html, state) == ("NEW", store.SYNC_PENDING)
|
||||
|
||||
|
||||
def test_parse_shop_nos():
|
||||
assert store.parse_shop_nos(None) == [1]
|
||||
assert store.parse_shop_nos("2, 3,1,x,0,3") == [1, 2, 3]
|
||||
|
||||
|
||||
def test_parse_grace_minutes():
|
||||
assert store.parse_grace_minutes("30") == 30
|
||||
assert store.parse_grace_minutes("") == store.DEFAULT_READ_LAG_GRACE_MIN
|
||||
|
||||
@@ -309,6 +309,48 @@
|
||||
function amountPlain(v) { return String(parseInt(String(v || "0").replace(/,/g, ""), 10) || 0); }
|
||||
function norm(s) { return String(s || "").replace(/\s+/g, "").toLowerCase(); }
|
||||
|
||||
// 판매 가격 칸 = 기본 정보 판매가 + 추가금액. 화면 계산용이고 저장되는 값은 추가금액뿐이다.
|
||||
function basePrice() {
|
||||
var el = root.querySelector('#cf24-basic-form [name="price"]');
|
||||
return parseInt(amountPlain(el && el.value), 10);
|
||||
}
|
||||
function salePrice(amount) { return String(basePrice() + parseInt(amountPlain(amount), 10)); }
|
||||
function salePriceCell(amount) {
|
||||
return '<td class="cf24-v-amount"><input type="text" class="cf24-sale-price" inputmode="numeric" value="' + salePrice(amount) + '" /></td>';
|
||||
}
|
||||
|
||||
function bindSalePrice(tbody) {
|
||||
// capture: 불러오기·입력 복원이 보내는 input 이벤트는 버블링하지 않는다.
|
||||
tbody.addEventListener("input", function (e) {
|
||||
var tr = e.target.closest("tr");
|
||||
var sale = tr.querySelector(".cf24-sale-price");
|
||||
var amount = tr.querySelector('[name="additional_amount"]');
|
||||
if (e.target === sale) {
|
||||
sale.value = sale.value.replace(/\D/g, "");
|
||||
amount.value = sale.value ? String(parseInt(sale.value, 10) - basePrice()) : "0";
|
||||
amount.dispatchEvent(new Event("input")); // 변경 표시
|
||||
} else if (e.target === amount && document.activeElement !== sale) {
|
||||
sale.value = salePrice(amount.value);
|
||||
}
|
||||
}, true);
|
||||
tbody.addEventListener("focusout", function (e) {
|
||||
if (!e.target.classList.contains("cf24-sale-price")) return;
|
||||
e.target.value = salePrice(e.target.closest("tr").querySelector('[name="additional_amount"]').value);
|
||||
});
|
||||
tbody.addEventListener("keydown", function (e) {
|
||||
// isComposing: 한글 조합 중 Enter 는 글자 확정용이다 — 여기서 옮기면 글자가 깨지거나 두 칸 내려간다.
|
||||
if (e.isComposing || !e.target.matches('[name="option_text"], [name="custom_variant_code"], [name="additional_amount"], .cf24-sale-price')) return;
|
||||
var down = e.key === "Enter" || e.key === "ArrowDown";
|
||||
if (!down && e.key !== "ArrowUp") return;
|
||||
e.preventDefault();
|
||||
var tr = e.target.closest("tr")[down ? "nextElementSibling" : "previousElementSibling"];
|
||||
if (!tr) return;
|
||||
var next = tr.cells[e.target.closest("td").cellIndex].querySelector('input[type="text"]');
|
||||
next.focus();
|
||||
next.select();
|
||||
});
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
화면 분기
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
@@ -380,6 +422,7 @@
|
||||
: '<span class="cf24-muted">저장 시 부여</span>') + "</td>" +
|
||||
'<td class="cf24-v-code"><input type="text" name="custom_variant_code" maxlength="40" value="' + esc(variant ? variant.custom_variant_code : "") + '" /></td>' +
|
||||
'<td class="cf24-v-amount"><input type="text" name="additional_amount" inputmode="numeric" value="' + esc(amountPlain(variant ? variant.additional_amount : "0")) + '" /></td>' +
|
||||
salePriceCell(variant ? variant.additional_amount : "0") +
|
||||
'<td class="cf24-v-flag">' + toggleBtn("display", variant ? !!variant.display : true) + "</td>" +
|
||||
'<td class="cf24-v-flag">' + toggleBtn("selling", variant ? !!variant.selling : true) + "</td>" +
|
||||
'<td class="cf24-u-del">' + (awaiting ? "" : '<button type="button" class="cf24-u-remove" title="' + (isNewRow ? "행 삭제" : "품목 삭제 (카페24에 바로 반영)") + '">✕</button>') + "</td>" +
|
||||
@@ -406,7 +449,7 @@
|
||||
"</div>" +
|
||||
'<div class="cf24-u-tablewrap"><table class="cf24-variants cf24-u-table"><thead><tr>' +
|
||||
'<th class="cf24-u-drag"></th><th class="cf24-u-thumb">썸네일</th><th>옵션값 이름</th><th class="cf24-v-syscode">품목코드</th>' +
|
||||
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th>' +
|
||||
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-amount">판매 가격</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th>' +
|
||||
"</tr></thead><tbody id=\"cf24-u-body\">";
|
||||
rows.forEach(function (r, i) { html += rowHtml(r, canDrag, i); });
|
||||
if (isNew) html += rowHtml({ index: null, value: null, variant: null }, true, null);
|
||||
@@ -436,6 +479,7 @@
|
||||
var tbody = body.querySelector("#cf24-u-body");
|
||||
var msg = body.querySelector("#cf24-u-msg");
|
||||
trackDirty(wrap);
|
||||
bindSalePrice(tbody);
|
||||
bindToggles(tbody);
|
||||
bindCopy(tbody);
|
||||
bindThumbUploads(tbody, msg);
|
||||
@@ -844,10 +888,15 @@
|
||||
setMsg(msg, "품목 " + patches.length + "건 반영 중…", "");
|
||||
return apiJson("PUT", "/cafe24/products/" + no + "/variants", { rows: patches });
|
||||
});
|
||||
var shopWarn = "";
|
||||
chain
|
||||
.then(function () { return load(); })
|
||||
.then(function (data) {
|
||||
var bad = Object.keys((data && data.shop_failed) || {});
|
||||
if (bad.length) shopWarn = " 단, 다른 쇼핑몰(" + bad.join(", ") + "번) 진열/판매 반영 실패: " + data.shop_failed[bad[0]];
|
||||
return load();
|
||||
})
|
||||
.then(function () {
|
||||
setMsg(body.querySelector("#cf24-u-msg"), "카페24에 반영했습니다.", "is-ok");
|
||||
setMsg(body.querySelector("#cf24-u-msg"), "카페24에 반영했습니다." + shopWarn, shopWarn ? "is-err" : "is-ok");
|
||||
})
|
||||
.catch(function (err) {
|
||||
setMsg(msg, "실패: " + err.message + " — 화면을 다시 불러옵니다.", "is-err");
|
||||
@@ -964,7 +1013,7 @@
|
||||
html += '<p class="cf24-muted">품목이 아직 조회되지 않았습니다. 잠시 뒤 창을 닫았다 다시 여세요.</p>';
|
||||
} else {
|
||||
html += '<div class="cf24-variants-wrap"><table class="cf24-variants"><thead><tr><th class="cf24-v-imgcol"></th><th>옵션</th><th class="cf24-v-syscode">품목코드</th>' +
|
||||
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th></tr></thead><tbody>';
|
||||
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-amount">판매 가격</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th></tr></thead><tbody>';
|
||||
variants.forEach(function (v) {
|
||||
var label = v.options.map(function (o) { return o.value; }).join(" / ") || v.variant_code;
|
||||
html += '<tr class="cf24-v-item" data-code="' + esc(v.variant_code) + '">' +
|
||||
@@ -973,6 +1022,7 @@
|
||||
'<td class="cf24-v-syscode"><button type="button" class="cf24-v-copy" data-copy-text="' + esc(v.variant_code) + '">' + esc(v.variant_code) + "</button></td>" +
|
||||
'<td class="cf24-v-code"><input type="text" name="custom_variant_code" maxlength="40" value="' + esc(v.custom_variant_code) + '" /></td>' +
|
||||
'<td class="cf24-v-amount"><input type="text" name="additional_amount" inputmode="numeric" value="' + esc(amountPlain(v.additional_amount)) + '" /></td>' +
|
||||
salePriceCell(v.additional_amount) +
|
||||
'<td class="cf24-v-flag">' + toggleBtn("display", !!v.display) + "</td><td class=\"cf24-v-flag\">" + toggleBtn("selling", !!v.selling) + "</td>" +
|
||||
'<td class="cf24-u-del"><button type="button" class="cf24-u-remove" data-code="' + esc(v.variant_code) + '" title="품목 삭제 (카페24에 바로 반영)">✕</button></td></tr>';
|
||||
});
|
||||
@@ -990,6 +1040,7 @@
|
||||
var wrap = body.querySelector(".cf24-variants-wrap");
|
||||
if (wrap) {
|
||||
trackDirty(wrap);
|
||||
bindSalePrice(wrap.querySelector("tbody"));
|
||||
bindToggles(wrap);
|
||||
bindCopy(wrap);
|
||||
body.querySelector("#cf24-var-save").addEventListener("click", function () { saveMultiVariants(wrap); });
|
||||
|
||||
@@ -482,6 +482,11 @@ cafe24_oauth_tokens 저장
|
||||
`quantity`, `image`…). `PUT /admin/products/{no}/variants` body `{"shop_no":1,
|
||||
"requests":[{variant_code, custom_variant_code, additional_amount, display, selling…}]}`
|
||||
1회 100건(초과 시 나눠 보냄). 재고(`quantity`)는 이 화면에서 건드리지 않는다.
|
||||
- **멀티쇼핑몰 진열·판매**(2026-11-10): 품목 진열·판매는 쇼핑몰(`shop_no`)마다 따로다. 화면은
|
||||
기본몰(1) 값을 보여 주고, 저장하면 기본몰에 반영된 행의 **진열·판매만** `CAFE24_SHOP_NOS`
|
||||
(예 `1,2,3`)의 다른 쇼핑몰에도 같은 값으로 PUT 한다. 추가금액(통화가 다름)·자체코드·순서는
|
||||
기본몰만. 다른 쇼핑몰 실패는 응답 `shop_failed`·감사 기록에 남기고 화면에 경고(기본몰 반영은 유지).
|
||||
쇼핑몰 목록 API(`/admin/shops`)는 `mall.read_store` 권한이 필요해 쓰지 않고 번호를 환경변수로 받는다.
|
||||
- "옵션별 상품 이름" 은 옵션값(`option_text`)이고, "옵션별 썸네일" 은 `option_image_file`
|
||||
(+ `option_link_image` 에도 같은 경로) 이며,
|
||||
화면의 옵션값 썸네일은 **`option_image_file` → `option_link_image` → 그 옵션값을 가진
|
||||
@@ -569,6 +574,7 @@ CAFE24_REDIRECT_URI=https://dbx.no1king.freeddns.org/cafe24/oauth/callback
|
||||
CAFE24_API_VERSION=2026-03-01
|
||||
CAFE24_TOKEN_SECRET=<openssl rand -hex 32>
|
||||
CAFE24_SHOP_URL=https://www.miras.co.kr # 선택 — 다이렉트 주소용 커스텀 도메인
|
||||
CAFE24_SHOP_NOS=1,2,3 # 선택 — 품목 진열·판매를 같이 맞출 멀티쇼핑몰 번호(기본 1)
|
||||
|
||||
# 디자인 보관함 FTP (OAuth 와 별개 계정) — 모바일 스와이프 / PC·모바일 상품상세
|
||||
CAFE24_FTP_HOST=miraskitchen.ftp.cafe24.com # 선택 — 미설정 시 {mall_id}.ftp.cafe24.com
|
||||
|
||||
@@ -492,6 +492,30 @@ def test_route_09_variants_partial_success():
|
||||
assert resp.status_code == 502
|
||||
|
||||
|
||||
def test_route_09b_display_selling_to_all_shops(monkeypatch):
|
||||
monkeypatch.setenv("CAFE24_SHOP_NOS", "1,2,3")
|
||||
no, cafe = _new_product()
|
||||
created = _create_options(no, ["A", "B"])
|
||||
a, b = (v["variant_code"] for v in created["variants"])
|
||||
cafe.calls.clear()
|
||||
resp = req("PUT", f"/cafe24/products/{no}/variants", json={"rows": [
|
||||
{"variant_code": a, "display": "off", "additional_amount": "500"},
|
||||
{"variant_code": b, "custom_variant_code": "X1"}]})
|
||||
assert resp.status_code == 200, resp.text
|
||||
assert resp.json()["shop_failed"] == {}
|
||||
puts = [c[2] for c in cafe.calls if c[0] == "PUT" and c[1].endswith("/variants")]
|
||||
assert [p["shop_no"] for p in puts] == [1, 2, 3]
|
||||
# 다른 쇼핑몰엔 진열·판매만, 진열/판매를 안 바꾼 행(b)은 안 보낸다
|
||||
assert puts[1]["requests"] == puts[2]["requests"] == [{"variant_code": a, "display": "F"}]
|
||||
# 다른 쇼핑몰 실패는 경고로만(기본몰 반영은 성공)
|
||||
cafe._variant_puts = 0
|
||||
cafe.fail_variant_chunk = 2
|
||||
resp = req("PUT", f"/cafe24/products/{no}/variants", json={"rows": [{"variant_code": a, "selling": "off"}]})
|
||||
cafe.fail_variant_chunk = 0
|
||||
assert resp.status_code == 200 and resp.json()["ok"]
|
||||
assert list(resp.json()["shop_failed"]) == ["2"]
|
||||
|
||||
|
||||
def test_route_10_rename_with_lagging_variants_keeps_rows():
|
||||
no, cafe = _new_product()
|
||||
created = _create_options(no, ["Black", "Red"])
|
||||
|
||||
Reference in New Issue
Block a user