PharmQ SaaS 구독 서비스 관리 시스템 완전 구현
📋 기획 및 설계: - PharmQ SaaS 서비스 기획서 작성 - 구독 서비스 라인업 정의 (클라우드PC, AI CCTV, CRM) - DB 스키마 설계 및 API 아키텍처 설계 🗄️ 데이터베이스 구조: - service_products: 서비스 상품 마스터 테이블 - pharmacy_subscriptions: 약국별 구독 현황 테이블 - subscription_usage_logs: 서비스 이용 로그 테이블 - billing_history: 결제 이력 테이블 - 샘플 데이터 자동 생성 (21개 구독, 월 118만원 매출) 🔧 백엔드 API 구현: - 구독 현황 통계 API (/api/subscriptions/stats) - 약국별 구독 조회 API (/api/pharmacies/subscriptions) - 구독 상세 정보 API (/api/pharmacy/{id}/subscriptions) - 구독 생성/해지 API (/api/subscriptions) 🖥️ 프론트엔드 UI 구현: - 대시보드 구독 현황 카드 (월 매출, 구독 수, 구독률 등) - 약국 목록에 구독 상태 아이콘 및 월 구독료 표시 - 약국 상세 페이지 구독 서비스 섹션 추가 - 실시간 구독 생성/해지 기능 구현 ✨ 주요 특징: - 서비스별 색상 코딩 및 이모지 아이콘 시스템 - 실시간 업데이트 (구독 생성/해지 즉시 반영) - 반응형 디자인 (모바일/태블릿 최적화) - 툴팁 기반 상세 정보 표시 📊 현재 구독 현황: - 총 월 매출: ₩1,180,000 - 구독 약국: 10/14개 (71.4%) - AI CCTV: 6개 약국, CRM: 10개 약국, 클라우드PC: 5개 약국 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,37 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 구독 서비스 현황 -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="fas fa-box text-success"></i> 구독 서비스 현황
|
||||
</h5>
|
||||
<a href="/subscriptions" class="btn btn-outline-success btn-sm">
|
||||
<i class="fas fa-cog"></i> 관리하기
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row" id="subscription-stats">
|
||||
<!-- 구독 통계가 여기에 로드됩니다 -->
|
||||
<div class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 서비스별 구독 현황 -->
|
||||
<div class="row mt-4" id="service-breakdown">
|
||||
<!-- 서비스별 상세 정보가 여기에 로드됩니다 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- 실시간 알림 -->
|
||||
<div class="col-lg-6 mb-4">
|
||||
@@ -291,9 +322,132 @@ function updateAlerts() {
|
||||
.catch(error => console.error('Alert update failed:', error));
|
||||
}
|
||||
|
||||
// 구독 현황 로드
|
||||
function loadSubscriptionStats() {
|
||||
fetch('/api/subscriptions/stats')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.success) {
|
||||
updateSubscriptionDisplay(result.data);
|
||||
} else {
|
||||
console.error('구독 통계 로드 실패:', result.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('구독 통계 API 오류:', error);
|
||||
showSubscriptionError();
|
||||
});
|
||||
}
|
||||
|
||||
function updateSubscriptionDisplay(data) {
|
||||
// 전체 구독 통계 카드 생성
|
||||
const statsHtml = `
|
||||
<div class="col-lg-3 col-md-6 mb-3">
|
||||
<div class="card" style="background: linear-gradient(135deg, #38b2ac 0%, #2c7a7b 100%); color: white;">
|
||||
<div class="card-body text-center">
|
||||
<div class="stat-number">₩${data.total_revenue.toLocaleString()}</div>
|
||||
<div class="stat-label">
|
||||
<i class="fas fa-won-sign"></i> 월 총 매출
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6 mb-3">
|
||||
<div class="card" style="background: linear-gradient(135deg, #805ad5 0%, #6b46c1 100%); color: white;">
|
||||
<div class="card-body text-center">
|
||||
<div class="stat-number">${data.total_subscriptions}</div>
|
||||
<div class="stat-label">
|
||||
<i class="fas fa-clipboard-list"></i> 총 구독 수
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6 mb-3">
|
||||
<div class="card" style="background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); color: white;">
|
||||
<div class="card-body text-center">
|
||||
<div class="stat-number">${data.subscribed_pharmacies}/${data.total_pharmacies}</div>
|
||||
<div class="stat-label">
|
||||
<i class="fas fa-store"></i> 구독 약국
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-6 mb-3">
|
||||
<div class="card" style="background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); color: white;">
|
||||
<div class="card-body text-center">
|
||||
<div class="stat-number">${data.subscription_rate}%</div>
|
||||
<div class="stat-label">
|
||||
<i class="fas fa-percentage"></i> 구독률
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('subscription-stats').innerHTML = statsHtml;
|
||||
|
||||
// 서비스별 구독 현황
|
||||
const serviceIconMap = {
|
||||
'CLOUD_PC': '💻',
|
||||
'AI_CCTV': '📷',
|
||||
'CRM': '📊'
|
||||
};
|
||||
|
||||
const serviceColorMap = {
|
||||
'CLOUD_PC': '#4f46e5',
|
||||
'AI_CCTV': '#0891b2',
|
||||
'CRM': '#ca8a04'
|
||||
};
|
||||
|
||||
let servicesHtml = '';
|
||||
data.services.forEach(service => {
|
||||
const icon = serviceIconMap[service.code] || '📦';
|
||||
const color = serviceColorMap[service.code] || '#6b7280';
|
||||
const percentage = data.total_pharmacies > 0 ? Math.round(service.count / data.total_pharmacies * 100) : 0;
|
||||
|
||||
servicesHtml += `
|
||||
<div class="col-lg-4 col-md-6 mb-3">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<div class="me-3" style="font-size: 2rem;">${icon}</div>
|
||||
<div class="flex-grow-1">
|
||||
<h6 class="mb-1">${service.name}</h6>
|
||||
<div class="progress mb-1" style="height: 8px;">
|
||||
<div class="progress-bar" style="background-color: ${color}; width: ${percentage}%"></div>
|
||||
</div>
|
||||
<small class="text-muted">${service.count}개 약국 구독 (${percentage}%)</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<strong style="color: ${color};">₩${service.revenue.toLocaleString()}/월</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
document.getElementById('service-breakdown').innerHTML = servicesHtml;
|
||||
}
|
||||
|
||||
function showSubscriptionError() {
|
||||
document.getElementById('subscription-stats').innerHTML = `
|
||||
<div class="col-12 text-center text-muted py-4">
|
||||
<i class="fas fa-exclamation-triangle fa-3x mb-3"></i>
|
||||
<p>구독 현황을 불러오는 중 오류가 발생했습니다.</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// 페이지 로드 시 구독 현황 로드
|
||||
loadSubscriptionStats();
|
||||
|
||||
// 통계 업데이트 (10초마다 - 더 자주)
|
||||
setInterval(updateStats, 10000);
|
||||
// 알림 업데이트 (30초마다)
|
||||
setInterval(updateAlerts, 30000);
|
||||
// 구독 현황 업데이트 (60초마다)
|
||||
setInterval(loadSubscriptionStats, 60000);
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user