From d0e7d6bbd238db8b282e7f879bc241633233b81e Mon Sep 17 00:00:00 2001 From: thug0bin Date: Fri, 27 Feb 2026 16:42:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=EC=A1=B0=EC=A0=9C=20=EC=9D=B4=EB=A0=A5=20=EB=B1=83?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PM_BASE.CD_PERSON에서 전화번호로 CUSCODE 매칭 - PS_main에서 조제 기록 유무 확인 - 조제 기록 있으면 녹색 '💊 환자' 뱃지 - 조제 기록 없으면 회색 '일반' 뱃지 --- backend/app.py | 28 +++++++++++++++++++++++++++- backend/templates/admin.html | 10 +++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/backend/app.py b/backend/app.py index 01354a1..1d67a33 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1854,12 +1854,38 @@ def admin(): """) recent_users_raw = cursor.fetchall() - # 시간을 KST로 변환 + # 시간을 KST로 변환 + 조제 이력 확인 recent_users = [] + + # MSSQL 세션 (조제 이력 확인용) + try: + mssql_session = db_manager.get_session('PM_PRES') + except: + mssql_session = None + for user in recent_users_raw: user_dict = dict(user) user_dict['created_at'] = utc_to_kst_str(user['created_at']) user_dict['kakao_verified_at'] = utc_to_kst_str(user['kakao_verified_at']) if user['kakao_verified_at'] else None + + # 조제 이력 확인 (MSSQL) + user_dict['has_prescription'] = False + if mssql_session and user['phone']: + try: + phone_clean = user['phone'].replace('-', '').replace(' ', '') + pres_check = mssql_session.execute(text(""" + SELECT TOP 1 p.CusCode + FROM PM_BASE.dbo.CD_PERSON p + INNER JOIN PS_main ps ON p.CUSCODE = ps.CusCode + WHERE REPLACE(REPLACE(p.PHONE, '-', ''), ' ', '') = :phone + OR REPLACE(REPLACE(p.PHONE2, '-', ''), ' ', '') = :phone + OR REPLACE(REPLACE(p.TEL_NO, '-', ''), ' ', '') = :phone + """), {'phone': phone_clean}).fetchone() + if pres_check: + user_dict['has_prescription'] = True + except Exception as e: + logging.warning(f"조제 이력 확인 실패 (user {user['id']}): {e}") + recent_users.append(user_dict) # 최근 적립 내역 (50건) diff --git a/backend/templates/admin.html b/backend/templates/admin.html index 60aa84d..8c29a67 100644 --- a/backend/templates/admin.html +++ b/backend/templates/admin.html @@ -472,7 +472,8 @@ 전화번호 포인트 가입일 - 인증 + 카카오 + 조제 @@ -490,6 +491,13 @@ 미인증 {% endif %} + + {% if user.has_prescription %} + 💊 환자 + {% else %} + 일반 + {% endif %} + {% endfor %}