fix(order): 지오영 internal_code 있으면 검색 스킵
- 프론트에서 이미 선택한 품목의 internal_code 사용 - 검색 없이 바로 add_to_cart 호출 - 재고 불일치 문제 해결
This commit is contained in:
parent
268f5bce8f
commit
f48e657e12
@ -287,21 +287,28 @@ def submit_geoyoung_order(order: dict, dry_run: bool, cart_only: bool = True) ->
|
||||
|
||||
geo_session = get_geo_session()
|
||||
|
||||
# 1단계: 모든 품목을 장바구니에 담기 (full_order, auto_confirm=False)
|
||||
# 1단계: 모든 품목을 장바구니에 담기
|
||||
for item in items:
|
||||
kd_code = item.get('kd_code') or item.get('drug_code')
|
||||
order_qty = item['order_qty']
|
||||
spec = item.get('specification', '')
|
||||
item_internal_code = item.get('internal_code') # 프론트에서 이미 선택한 품목
|
||||
result = {}
|
||||
|
||||
try:
|
||||
# 장바구니에만 담기 (주문 확정은 나중에 한번에)
|
||||
if item_internal_code:
|
||||
# internal_code가 있으면 검색 없이 바로 장바구니 추가!
|
||||
result = geo_session.add_to_cart(item_internal_code, order_qty)
|
||||
if result.get('success'):
|
||||
result['product'] = {'internal_code': item_internal_code, 'name': item.get('product_name', '')}
|
||||
else:
|
||||
# internal_code 없으면 검색 후 장바구니 추가
|
||||
result = geo_session.full_order(
|
||||
kd_code=kd_code,
|
||||
quantity=order_qty,
|
||||
specification=spec if spec else None,
|
||||
check_stock=True,
|
||||
auto_confirm=False, # 장바구니만!
|
||||
auto_confirm=False,
|
||||
memo=f"자동주문 - {item.get('product_name', '')}"
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user