diff --git a/backend/check_order.py b/backend/check_order.py new file mode 100644 index 0000000..82eb654 --- /dev/null +++ b/backend/check_order.py @@ -0,0 +1,6 @@ +import requests +res = requests.get('http://localhost:7001/api/geoyoung/order-detail/DA2603-0255533', timeout=120) +data = res.json() +print('items:', len(data.get('items', []))) +for item in data.get('items', []): + print(f" {item.get('product_name')[:20]}: qty={item.get('quantity')}, order_qty={item.get('order_qty')}, amount={item.get('amount')}") diff --git a/backend/check_spec.py b/backend/check_spec.py new file mode 100644 index 0000000..37596b5 --- /dev/null +++ b/backend/check_spec.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +import requests + +geo = requests.get('http://localhost:7001/api/geoyoung/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120).json() + +print("품목별 spec 필드 확인:") +for kd, info in geo.get('by_kd_code', {}).items(): + print(f" spec='{info['spec']}' | {info['product_name'][:30]}") diff --git a/backend/check_stilnox.py b/backend/check_stilnox.py new file mode 100644 index 0000000..77d36ca --- /dev/null +++ b/backend/check_stilnox.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +import requests + +# 지오영 확인 +geo = requests.get('http://localhost:7001/api/geoyoung/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120).json() +print("=== 지오영 ===") +for kd, info in geo.get('by_kd_code', {}).items(): + if '스틸' in info['product_name'] or '녹스' in info['product_name']: + print(f" {info['product_name']}: {info['boxes']}박스, {info['units']}개") + +# 수인 확인 +sooin = requests.get('http://localhost:7001/api/sooin/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120).json() +print("\n=== 수인약품 ===") +for kd, info in sooin.get('by_kd_code', {}).items(): + if '스틸' in info['product_name'] or '녹스' in info['product_name']: + print(f" {info['product_name']}: {info['boxes']}박스, {info['units']}개") + +if not any('스틸' in info['product_name'] for info in sooin.get('by_kd_code', {}).values()): + print(" (없음)") diff --git a/backend/check_summary.py b/backend/check_summary.py new file mode 100644 index 0000000..ee65763 --- /dev/null +++ b/backend/check_summary.py @@ -0,0 +1,9 @@ +import requests +res = requests.get('http://localhost:7001/api/geoyoung/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120) +data = res.json() +print('success:', data.get('success')) +print('order_count:', data.get('order_count')) +print('total_products:', data.get('total_products')) +print() +for kd, info in list(data.get('by_kd_code', {}).items()): + print(f"{kd}: boxes={info['boxes']}, units={info['units']}, {info['product_name'][:20]}") diff --git a/backend/geoyoung_api.py b/backend/geoyoung_api.py index 35cec4b..a9df943 100644 --- a/backend/geoyoung_api.py +++ b/backend/geoyoung_api.py @@ -596,12 +596,33 @@ def api_geoyoung_orders_by_kd(): start_date = request.args.get('start_date', today).strip() end_date = request.args.get('end_date', today).strip() - def parse_spec(spec: str) -> int: - """규격에서 수량 추출 (30T → 30, 100C → 100)""" - if not spec: - return 1 - match = re.search(r'(\d+)', spec) - return int(match.group(1)) if match else 1 + def parse_spec(spec: str, product_name: str = '') -> int: + """ + 규격에서 수량 추출 (30T → 30, 100C → 100) + + 우선순위: + 1. spec에서 T/C/P/D 단위 숫자 (예: 14T → 14) + 2. product_name에서 T/C/P/D 단위 숫자 + 3. spec의 첫 번째 숫자 (fallback) + """ + combined = f"{spec} {product_name}" + + # T/C/P/D 단위가 붙은 숫자 우선 추출 (예: 14T, 100C, 30P, 140D) + qty_match = re.search(r'(\d+)\s*[TCPD]\b', combined, re.IGNORECASE) + if qty_match: + return int(qty_match.group(1)) + + # 없으면 spec의 첫 번째 숫자 (mg, ml 등 용량일 수 있음 - 기본값 1) + if spec: + num_match = re.search(r'(\d+)', spec) + if num_match: + val = int(num_match.group(1)) + # mg, ml 같은 용량 단위면 수량 1로 처리 + if re.search(r'\d+\s*(mg|ml|g)\b', spec, re.IGNORECASE): + return 1 + return val + + return 1 try: session = get_geo_session() @@ -638,7 +659,7 @@ def api_geoyoung_orders_by_kd(): product_name = item.get('product_name', '') spec = item.get('spec', '') quantity = item.get('quantity', 0) or item.get('order_qty', 0) - per_unit = parse_spec(spec) + per_unit = parse_spec(spec, product_name) total_units = quantity * per_unit if kd_code not in kd_summary: