feat: 도매상 API 통합 및 스키마 업데이트
- wholesale 패키지 연동 (SooinSession, GeoYoungSession) - Flask Blueprint 분리 (sooin_api.py, geoyoung_api.py) - order_context 스키마 확장 (wholesaler_id, internal_code 등) - 수인약품 개별 취소 기능 (cancel_item, restore_item) - 문서 추가: WHOLESALE_API_INTEGRATION.md - 테스트 스크립트들
This commit is contained in:
60
backend/test_cart.py
Normal file
60
backend/test_cart.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""장바구니 추가 테스트 (실제 주문 X)"""
|
||||
import json
|
||||
import sys
|
||||
sys.path.insert(0, r'c:\Users\청춘약국\source\pharmacy-pos-qr-system\backend')
|
||||
from sooin_api import SooinSession
|
||||
|
||||
print("=" * 60)
|
||||
print("수인약품 API 장바구니 테스트")
|
||||
print("=" * 60)
|
||||
|
||||
session = SooinSession()
|
||||
|
||||
# 1. 로그인
|
||||
print("\n1. 로그인...")
|
||||
if not session.login():
|
||||
print("❌ 로그인 실패")
|
||||
sys.exit(1)
|
||||
print("✅ 로그인 성공!")
|
||||
|
||||
# 2. 장바구니 비우기
|
||||
print("\n2. 장바구니 비우기...")
|
||||
result = session.clear_cart()
|
||||
print(f" 결과: {'성공' if result['success'] else '실패'}")
|
||||
|
||||
# 3. 제품 검색
|
||||
print("\n3. 제품 검색 (KD코드: 073100220 - 코자정)...")
|
||||
products = session.search_products('073100220', 'kd_code')
|
||||
print(f" 검색 결과: {len(products)}개")
|
||||
for p in products:
|
||||
print(f" - {p['product_name']} ({p['specification']}) 재고: {p['stock']} 단가: {p['unit_price']:,}원")
|
||||
print(f" 내부코드: {p['internal_code']}")
|
||||
|
||||
# 4. 장바구니 추가
|
||||
if products:
|
||||
print("\n4. 장바구니 추가 (첫 번째 제품, 1개)...")
|
||||
product = products[1] # 30T 선택
|
||||
result = session.add_to_cart(
|
||||
internal_code=product['internal_code'],
|
||||
quantity=1,
|
||||
stock=product['stock'],
|
||||
price=product['unit_price']
|
||||
)
|
||||
print(f" 결과: {json.dumps(result, ensure_ascii=False, indent=2)}")
|
||||
|
||||
# 5. 장바구니 조회
|
||||
print("\n5. 장바구니 조회...")
|
||||
cart = session.get_cart()
|
||||
print(f" 장바구니: {cart['total_items']}개 품목, {cart['total_amount']:,}원")
|
||||
for item in cart['items']:
|
||||
print(f" - {item['product_name']}: {item['quantity']}개 ({item['amount']:,}원)")
|
||||
|
||||
# 6. 장바구니 비우기 (정리)
|
||||
print("\n6. 장바구니 비우기 (정리)...")
|
||||
result = session.clear_cart()
|
||||
print(f" 결과: {'성공' if result['success'] else '실패'}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("테스트 완료! (실제 주문은 하지 않았습니다)")
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user