fix(cupang): 밀크런 출고리스트를 구글 드라이브 엑셀(.xlsx) 파일에 기록

- 출고리스트 문서(1J74op7lBZOgE27p4R28I3RWsv0EtXdii)는 구글 시트가 아니라 드라이브에 올린 .xlsx 라
  Sheets API 로는 쓸 수 없었다 → app/integrations/drive_xlsx.py 추가: 내려받아 openpyxl 로 고친 뒤
  같은 파일 id 에 다시 올림(GoogleSheetsWriter 와 같은 메서드, lock 블록 = 내려받기·올리기 1번씩)
- 올리기 직전 파일 version 이 바뀌었으면 덮어쓰지 않고 처음부터 다시(최대 3번)
- router._sheet_target: 드라이브에서 형식을 보고 xlsx/구글 시트 writer 선택, CUPANG_SHEET_ID 기본값 = 위 파일
  (출고리스트 작성 팝업과 분배 확정·출고 삭제 동기화 모두 적용)
- 팝업 문구 "구글 시트" → "출고리스트 엑셀", cupang-outbound.js 캐시 버전 올림
- 테스트: 가짜 Drive 에 진짜 xlsx 를 두고 덧붙이기·양식 생성·충돌 재시도·시트 삭제·범위 읽기·writer 선택

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 15:12:11 +09:00
parent e63734c984
commit 2f31604c4e
9 changed files with 591 additions and 42 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ const server = http.createServer(function (req, res) {
req.on("end", function () {
const body = JSON.parse(raw);
posts.push(body);
if (body.center === "실패센터") return json(res, 502, { detail: "구글 시트에 기록하지 못했습니다(HttpError). 잠시 후 다시 시도해 주세요." });
if (body.center === "실패센터") return json(res, 502, { detail: "출고리스트 파일에 기록하지 못했습니다(HttpError). 잠시 후 다시 시도해 주세요." });
json(res, 200, { ok: true, title: "20261026(월)", first_row: 10, last_row: 11, line_count: body.lines.length,
url: "https://docs.google.com/spreadsheets/d/x/edit#gid=1", created: false });
});
@@ -156,7 +156,7 @@ async function pickDate(page, inputId, typed) {
await page.locator(".cpg-ol-qty").first().fill("5");
await page.locator("#cpg-ol-submit").click();
await page.waitForFunction(() => !document.getElementById("cpg-ol-error").hidden);
assert.match(await page.locator("#cpg-ol-error").innerText(), /구글 시트에 기록하지 못했습니다/);
assert.match(await page.locator("#cpg-ol-error").innerText(), /출고리스트 파일에 기록하지 못했습니다/);
assert.ok(await page.locator("#cpg-ol-dlg").isVisible(), "실패하면 입력 유지");
assert.equal(posts[1].center, "실패센터");
assert.equal(posts[1].ship_method, "택배");