pharmacy-pos-qr-system/backend/test_temp_save2.py
thug0bin a672c7a2a0 feat(order): 지오영/수인 선택적 주문 + 장바구니 보존 기능
- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문
- 기존 장바구니 백업/복구로 사용자 장바구니 보존
- 수인약품 submit_order() 수정 (체크박스 제외 방식)
- 테스트 파일 정리 및 문서 추가
2026-03-06 23:26:44 +09:00

73 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
"""방안 1: 재고 있는 품목으로 테스트"""
import sys; sys.path.insert(0, '.'); import wholesale_path
import importlib
import wholesale.sooin
importlib.reload(wholesale.sooin)
from wholesale import SooinSession
SooinSession._instance = None
s = SooinSession()
s.login()
s.clear_cart()
# 재고 있는 품목 검색
print('=== 1. 재고 확인 ===')
r1 = s.search_products('코자정')
r2 = s.search_products('라식스')
p1 = r1['items'][0]
p2 = r2['items'][0]
print(f"코자정: 재고 {p1['stock']}")
print(f"라식스: 재고 {p2['stock']}")
# 기존 품목 담기 (코자정 - 나중에 복원할 것)
print('\n=== 2. 기존 품목 (코자정) 담기 ===')
s.add_to_cart(p1['internal_code'], qty=1, price=p1['price'], stock=p1['stock'])
# 새 품목 담기 (라식스 - 주문할 것)
print('=== 3. 새 품목 (라식스) 담기 ===')
s.add_to_cart(p2['internal_code'], qty=1, price=p2['price'], stock=p2['stock'])
cart = s.get_cart()
print(f"현재 장바구니: {cart['total_items']}")
for item in cart['items']:
print(f" - {item['product_name'][:30]}")
# === 선별 주문 ===
print('\n' + '='*50)
print('=== 라식스만 주문! ===')
print('='*50)
# 기존 품목 저장
existing = [{'ic': p1['internal_code'], 'qty': 1, 'price': p1['price'], 'stock': p1['stock'], 'name': p1['name']}]
print(f"\n저장: {p1['name']}")
# 장바구니 비우기
print('장바구니 비우기...')
s.clear_cart()
# 라식스만 담기
print('라식스만 담기...')
s.add_to_cart(p2['internal_code'], qty=1, price=p2['price'], stock=p2['stock'])
# 주문
print('주문 전송...')
result = s.submit_order()
print(f"결과: {result}")
# 복원
print('\n코자정 복원...')
for e in existing:
s.add_to_cart(e['ic'], qty=e['qty'], price=e['price'], stock=e['stock'])
# 최종 확인
final = s.get_cart()
print(f"\n=== 최종 장바구니: {final['total_items']}개 ===")
for item in final['items']:
print(f" - {item['product_name'][:30]}")
if final['total_items'] == 1:
print('\n🎉 성공! 라식스만 주문됨, 코자정 복원됨!')