feat(order): 지오영/수인 선택적 주문 + 장바구니 보존 기능
- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
This commit is contained in:
83
backend/test_geo_selective_final2.py
Normal file
83
backend/test_geo_selective_final2.py
Normal file
@@ -0,0 +1,83 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""지오영 선별 주문 최종 테스트 2"""
|
||||
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()
|
||||
|
||||
# 기존 장바구니 확인
|
||||
print('=== 0. 기존 장바구니 확인 ===')
|
||||
cart0 = g.get_cart()
|
||||
print(f"기존 품목: {cart0['total_items']}개")
|
||||
for item in cart0['items']:
|
||||
print(f" - {item['product_name'][:30]} (code: {item.get('product_code')})")
|
||||
|
||||
existing_codes = [item.get('product_code') for item in cart0['items']]
|
||||
|
||||
# 새 품목 담기 (타이레놀)
|
||||
print('\n=== 1. 새 품목 (게보린) 담기 ===')
|
||||
result = g.full_order(
|
||||
kd_code='게보린',
|
||||
quantity=1,
|
||||
specification=None,
|
||||
check_stock=True,
|
||||
auto_confirm=False # 장바구니만
|
||||
)
|
||||
print(f"결과: {result.get('success')}, {result.get('message', result.get('error'))}")
|
||||
|
||||
new_code = result.get('product', {}).get('internal_code') if result.get('success') else None
|
||||
print(f"새 품목 internal_code: {new_code}")
|
||||
|
||||
if not new_code:
|
||||
# 다른 품목 시도
|
||||
print('\n=== 1-2. 다른 품목 (판피린) 시도 ===')
|
||||
result = g.full_order(
|
||||
kd_code='판피린',
|
||||
quantity=1,
|
||||
specification=None,
|
||||
check_stock=True,
|
||||
auto_confirm=False
|
||||
)
|
||||
print(f"결과: {result.get('success')}, {result.get('message', result.get('error'))}")
|
||||
new_code = result.get('product', {}).get('internal_code') if result.get('success') else None
|
||||
|
||||
# 장바구니 확인
|
||||
print('\n=== 2. 장바구니 확인 ===')
|
||||
cart1 = g.get_cart()
|
||||
print(f"현재 품목: {cart1['total_items']}개")
|
||||
for item in cart1['items']:
|
||||
print(f" - {item['product_name'][:30]} (code: {item.get('product_code')})")
|
||||
|
||||
# 선별 주문: 새 품목만!
|
||||
if new_code:
|
||||
print('\n=== 3. 선별 주문 (새 품목만!) ===')
|
||||
print(f"주문할 코드: [{new_code}]")
|
||||
|
||||
confirm_result = g.submit_order_selective([new_code])
|
||||
print(f"결과: {confirm_result}")
|
||||
|
||||
# 최종 장바구니 확인
|
||||
print('\n=== 4. 최종 장바구니 ===')
|
||||
cart2 = g.get_cart()
|
||||
print(f"남은 품목: {cart2['total_items']}개")
|
||||
for item in cart2['items']:
|
||||
print(f" - {item['product_name'][:30]}")
|
||||
|
||||
# 기존 품목이 모두 남아있는지 확인
|
||||
remaining_codes = [item.get('product_code') for item in cart2['items']]
|
||||
preserved = all(code in remaining_codes for code in existing_codes if code)
|
||||
|
||||
if preserved and cart2['total_items'] == len(existing_codes):
|
||||
print('\n🎉 성공! 새 품목만 주문됨, 기존 품목 모두 복원!')
|
||||
elif cart2['total_items'] == 0:
|
||||
print('\n⚠️ 모든 품목 주문됨 - 선별 주문 실패')
|
||||
else:
|
||||
print(f'\n🤔 결과: 기존 {len(existing_codes)}개 중 {len([c for c in existing_codes if c in remaining_codes])}개 복원')
|
||||
else:
|
||||
print('\n❌ 새 품목 담기 실패')
|
||||
Reference in New Issue
Block a user