- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""지오영 선별 주문 테스트"""
|
|
import sys; sys.path.insert(0, '.'); import wholesale_path
|
|
|
|
import importlib
|
|
import wholesale.geoyoung
|
|
importlib.reload(wholesale.geoyoung)
|
|
from wholesale import GeoYoungSession
|
|
|
|
GeoYoungSession._instance = None
|
|
g = GeoYoungSession()
|
|
g.login()
|
|
g.clear_cart()
|
|
|
|
# 재고 있는 품목 검색
|
|
print('=== 1. 재고 확인 ===')
|
|
r1 = g.search_products('라식스')
|
|
r2 = g.search_products('코자정')
|
|
|
|
if not r1.get('items') or not r2.get('items'):
|
|
print('품목을 찾을 수 없습니다')
|
|
exit()
|
|
|
|
p1 = r1['items'][0]
|
|
p2 = r2['items'][0]
|
|
print(f"라식스: {p1['name']}, 재고 {p1.get('stock', '?')}, code: {p1['internal_code']}")
|
|
print(f"코자정: {p2['name']}, 재고 {p2.get('stock', '?')}, code: {p2['internal_code']}")
|
|
|
|
# 기존 품목 담기 (라식스 - 나중에 복원할 것)
|
|
print('\n=== 2. 기존 품목 (라식스) 담기 ===')
|
|
g.add_to_cart(p1['internal_code'], quantity=1)
|
|
|
|
# 새 품목 담기 (코자정 - 주문할 것)
|
|
print('=== 3. 새 품목 (코자정) 담기 ===')
|
|
g.add_to_cart(p2['internal_code'], quantity=1)
|
|
|
|
cart = g.get_cart()
|
|
print(f"현재 장바구니: {cart['total_items']}개")
|
|
for item in cart['items']:
|
|
code = item.get('product_code') or item.get('internal_code', '?')
|
|
print(f" - {item['product_name'][:30]} (code: {code})")
|
|
|
|
# === 선별 주문 ===
|
|
print('\n' + '='*50)
|
|
print('=== 코자정만 주문! ===')
|
|
print('='*50)
|
|
|
|
# 코자정의 internal_code만 전달
|
|
print(f"\n주문할 internal_code: [{p2['internal_code']}]")
|
|
result = g.submit_order_selective([p2['internal_code']])
|
|
print(f"결과: {result}")
|
|
|
|
# 최종 확인
|
|
final = g.get_cart()
|
|
print(f"\n=== 최종 장바구니: {final['total_items']}개 ===")
|
|
for item in final['items']:
|
|
print(f" - {item['product_name'][:30]}")
|
|
|
|
if final['total_items'] == 1 and '라식스' in final['items'][0]['product_name']:
|
|
print('\n🎉 성공! 코자정만 주문됨, 라식스 복원됨!')
|
|
elif final['total_items'] == 0:
|
|
print('\n⚠️ 둘 다 주문됨 - 선별 주문 실패')
|
|
else:
|
|
print(f'\n🤔 예상 외 결과: {final["total_items"]}개 남음')
|