feat(order): 지오영/수인 선택적 주문 + 장바구니 보존 기능
- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
This commit is contained in:
81
backend/test_temp_save.py
Normal file
81
backend/test_temp_save.py
Normal file
@@ -0,0 +1,81 @@
|
||||
# -*- 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('코자정')
|
||||
p1 = r1['items'][0]
|
||||
s.add_to_cart(p1['internal_code'], qty=1, price=p1['price'], stock=p1['stock'])
|
||||
print(f"기존 품목: {p1['name']}")
|
||||
|
||||
print('\n=== 2. 새 품목 (디카맥스) 담기 ===')
|
||||
r2 = s.search_products('디카맥스')
|
||||
p2 = r2['items'][0]
|
||||
s.add_to_cart(p2['internal_code'], qty=1, price=p2['price'], stock=p2['stock'])
|
||||
print(f"새 품목: {p2['name']}")
|
||||
|
||||
# 장바구니 확인
|
||||
cart = s.get_cart()
|
||||
print(f"\n현재 장바구니: {cart['total_items']}개")
|
||||
|
||||
# === 선별 주문 시작 ===
|
||||
print('\n' + '='*50)
|
||||
print('=== 선별 주문: 디카맥스만 주문 ===')
|
||||
print('='*50)
|
||||
|
||||
# 3. 기존 품목 정보 저장
|
||||
print('\n3. 기존 품목 정보 저장')
|
||||
existing_items = []
|
||||
for item in cart['items']:
|
||||
# 디카맥스는 제외 (이번에 주문할 품목)
|
||||
if '디카맥스' not in item['product_name']:
|
||||
existing_items.append({
|
||||
'internal_code': item['internal_code'],
|
||||
'quantity': item['quantity'],
|
||||
'price': item['unit_price'],
|
||||
'name': item['product_name']
|
||||
})
|
||||
print(f" 저장: {item['product_name']}")
|
||||
|
||||
# 4. 장바구니 비우기
|
||||
print('\n4. 장바구니 비우기')
|
||||
s.clear_cart()
|
||||
|
||||
# 5. 주문할 품목만 다시 담기
|
||||
print('\n5. 디카맥스만 다시 담기')
|
||||
s.add_to_cart(p2['internal_code'], qty=1, price=p2['price'], stock=p2['stock'])
|
||||
|
||||
# 6. 주문
|
||||
print('\n6. 주문!')
|
||||
result = s.submit_order()
|
||||
print(f"결과: {result}")
|
||||
|
||||
# 7. 기존 품목 복원
|
||||
print('\n7. 기존 품목 복원')
|
||||
for item in existing_items:
|
||||
s.add_to_cart(item['internal_code'], qty=item['quantity'], price=item['price'], stock=999)
|
||||
print(f" 복원: {item['name']}")
|
||||
|
||||
# 8. 최종 확인
|
||||
print('\n=== 8. 최종 장바구니 ===')
|
||||
final_cart = s.get_cart()
|
||||
print(f"품목 수: {final_cart['total_items']}")
|
||||
for item in final_cart['items']:
|
||||
print(f" - {item['product_name']}")
|
||||
|
||||
if final_cart['total_items'] == 1 and '코자정' in final_cart['items'][0]['product_name']:
|
||||
print('\n🎉 성공! 디카맥스만 주문되고 코자정은 복원됨!')
|
||||
else:
|
||||
print('\n❌ 실패')
|
||||
Reference in New Issue
Block a user