feat(dispatch): SPX 로고(svg) + 출고 엑셀 상품명 DB 조회
- spx.svg 추가(택배사 SPX 로고). courier 로고 슬러그 spx 가 사용 - 출고 엑셀 상품이름을 아이템코드(seller_sku)로 itemcode_db 에서 조회해 채움 · malaysia_itemcode.name_map(single_items+set_items) 재사용 · 변형 접미사(_숫자) 제거 후 재조회, 못 찾으면 파싱된 상품명 폴백 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,21 @@ def _data_dir(request: Request) -> Path:
|
||||
return Path(getattr(request.app.state, "data_dir", Path("app/data")))
|
||||
|
||||
|
||||
def _itemcode_name_map(request: Request) -> dict[str, str]:
|
||||
"""itemcode_db {코드(대문자): 상품명}. 미설정/실패 시 빈 dict.
|
||||
|
||||
malaysia 모듈의 읽기 전용 리더(single_items + set_items)를 재사용한다.
|
||||
"""
|
||||
reader = getattr(request.app.state, "malaysia_itemcode", None)
|
||||
if reader is None or not getattr(reader, "enabled", False):
|
||||
return {}
|
||||
try:
|
||||
return reader.name_map()
|
||||
except Exception: # noqa: BLE001 — 다운로드를 막지 않는다.
|
||||
logger.exception("itemcode name_map 조회 실패")
|
||||
return {}
|
||||
|
||||
|
||||
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
|
||||
@@ -335,13 +350,17 @@ async def batch_download(
|
||||
count += 1
|
||||
|
||||
# 취합 출고 엑셀(발송날짜/고객/주소/상품/택배 등)을 생성해 함께 넣는다.
|
||||
# 상품이름은 아이템코드로 itemcode_db 에서 조회해 채운다.
|
||||
parcels = st.list_parcels(batch_id=batch_id)
|
||||
name_map = _itemcode_name_map(request)
|
||||
xlsx_name = export.export_filename(
|
||||
dispatch_date=batch.get("dispatch_date", ""),
|
||||
platform=batch.get("platform", ""),
|
||||
)
|
||||
try:
|
||||
xlsx_bytes = export.build_workbook_bytes(batch=batch, parcels=parcels)
|
||||
xlsx_bytes = export.build_workbook_bytes(
|
||||
batch=batch, parcels=parcels, name_map=name_map
|
||||
)
|
||||
zf.writestr(xlsx_name, xlsx_bytes)
|
||||
count += 1
|
||||
except Exception: # noqa: BLE001 — 엑셀 생성 실패해도 원본 다운로드는 살린다.
|
||||
|
||||
Reference in New Issue
Block a user