- internal_code DB 저장 → 프론트에서 선택한 제품 그대로 주문 - 기존 장바구니 백업/복구로 사용자 장바구니 보존 - 수인약품 submit_order() 수정 (체크박스 제외 방식) - 테스트 파일 정리 및 문서 추가
72 lines
2.5 KiB
Python
72 lines
2.5 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()
|
|
|
|
# 기존 장바구니 확인
|
|
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_count = cart0['total_items']
|
|
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}")
|
|
|
|
# 장바구니 확인
|
|
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_count = len([c for c in existing_codes if c in remaining_codes])
|
|
|
|
if cart2['total_items'] == existing_count and preserved_count == existing_count:
|
|
print(f'\n🎉 성공! 마그밀만 주문됨, 기존 {existing_count}개 품목 모두 복원!')
|
|
elif cart2['total_items'] == 0:
|
|
print('\n⚠️ 모든 품목 주문됨 - 선별 주문 실패')
|
|
else:
|
|
print(f'\n🤔 결과: 기존 {existing_count}개 중 {preserved_count}개 복원, 현재 {cart2["total_items"]}개')
|
|
else:
|
|
print('\n❌ 새 품목 담기 실패')
|