fix: 품목 바코드 조회 개선

- CD_GOODS.Barcode가 없으면 CD_ITEM_UNIT_MEMBER에서 조회
- 중복 제거 로직 추가 (drug_code 기준)
This commit is contained in:
thug0bin 2026-03-02 17:29:16 +09:00
parent 0e954ac749
commit 007b37e6c6

View File

@ -5070,7 +5070,7 @@ def api_admin_pos_live_detail(order_no):
mssql_conn = mssql_engine.raw_connection()
cursor = mssql_conn.cursor()
# 품목 상세 조회 (바코드 포함)
# 품목 상세 조회 (바코드 포함 - CD_GOODS 또는 CD_ITEM_UNIT_MEMBER에서)
cursor.execute("""
SELECT
S.DrugCode AS drug_code,
@ -5078,7 +5078,9 @@ def api_admin_pos_live_detail(order_no):
S.SL_NM_item AS quantity,
S.SL_NM_cost_a AS unit_price,
S.SL_TOTAL_PRICE AS total_price,
G.Barcode AS barcode
COALESCE(NULLIF(G.Barcode, ''),
(SELECT TOP 1 CD_CD_BARCODE FROM PM_DRUG.dbo.CD_ITEM_UNIT_MEMBER WHERE DrugCode = S.DrugCode)
) AS barcode
FROM SALE_SUB S
LEFT JOIN PM_DRUG.dbo.CD_GOODS G ON S.DrugCode = G.DrugCode
WHERE S.SL_NO_order = ?
@ -5087,9 +5089,14 @@ def api_admin_pos_live_detail(order_no):
rows = cursor.fetchall()
items = []
seen_drugs = set() # 중복 제거용
for row in rows:
drug_code = row[0]
if drug_code in seen_drugs:
continue
seen_drugs.add(drug_code)
items.append({
'drug_code': row[0],
'drug_code': drug_code,
'product_name': row[1],
'quantity': int(row[2]) if row[2] else 0,
'unit_price': float(row[3]) if row[3] else 0,