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