feat: 프로젝트 초기 구조 설정
- PyQt5 POS 판매 조회 GUI (Phase 1 완료) - Flask API 서버 스켈레톤 (Phase 2 준비) - SQLite 마일리지 DB 스키마 설계 - 프로젝트 문서 및 README 추가 - 기본 디렉터리 구조 생성 Phase 1: POS 판매 내역 조회 GUI 완료 Phase 2: QR 토큰 생성 및 마일리지 적립 (예정) Phase 3: 카카오 로그인 연동 (예정) Phase 4: 마일리지 시스템 완성 (예정) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
81
backend/db/mileage_schema.sql
Normal file
81
backend/db/mileage_schema.sql
Normal file
@@ -0,0 +1,81 @@
|
||||
-- SQLite 마일리지 데이터베이스 스키마
|
||||
-- pharmacy-pos-qr-system/backend/db/mileage_schema.sql
|
||||
|
||||
-- 1. 사용자 테이블 (카카오 로그인 계정)
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
nickname VARCHAR(100),
|
||||
profile_image_url VARCHAR(500),
|
||||
email VARCHAR(200),
|
||||
is_email_verified BOOLEAN DEFAULT FALSE,
|
||||
phone VARCHAR(20),
|
||||
mileage_balance INTEGER DEFAULT 0,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- 2. 외부 로그인 매핑 테이블
|
||||
CREATE TABLE IF NOT EXISTS customer_identities (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
provider VARCHAR(20) NOT NULL,
|
||||
provider_user_id VARCHAR(100) NOT NULL,
|
||||
provider_data TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
UNIQUE(provider, provider_user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_identities_user ON customer_identities(user_id);
|
||||
|
||||
-- 3. 영수증 QR 토큰 테이블
|
||||
CREATE TABLE IF NOT EXISTS claim_tokens (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id VARCHAR(20) NOT NULL,
|
||||
pharmacy_id VARCHAR(20),
|
||||
token_hash VARCHAR(64) NOT NULL,
|
||||
total_amount INTEGER NOT NULL,
|
||||
claimable_points INTEGER NOT NULL,
|
||||
expires_at DATETIME NOT NULL,
|
||||
claimed_at DATETIME,
|
||||
claimed_by_user_id INTEGER,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (claimed_by_user_id) REFERENCES users(id),
|
||||
UNIQUE(transaction_id),
|
||||
UNIQUE(token_hash)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tokens_hash ON claim_tokens(token_hash);
|
||||
CREATE INDEX IF NOT EXISTS idx_tokens_expires ON claim_tokens(expires_at);
|
||||
|
||||
-- 4. 마일리지 원장 테이블
|
||||
CREATE TABLE IF NOT EXISTS mileage_ledger (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
transaction_id VARCHAR(20),
|
||||
points INTEGER NOT NULL,
|
||||
balance_after INTEGER NOT NULL,
|
||||
reason VARCHAR(50) NOT NULL,
|
||||
description TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
UNIQUE(transaction_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ledger_user ON mileage_ledger(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_ledger_transaction ON mileage_ledger(transaction_id);
|
||||
|
||||
-- 5. POS 고객 연결 테이블
|
||||
CREATE TABLE IF NOT EXISTS pos_customer_links (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
pharmacy_id VARCHAR(20),
|
||||
cuscode VARCHAR(10),
|
||||
customer_name VARCHAR(50),
|
||||
linked_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
is_active BOOLEAN DEFAULT TRUE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
UNIQUE(user_id, pharmacy_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_links_cuscode ON pos_customer_links(cuscode);
|
||||
Reference in New Issue
Block a user