From cc5d0e55f20cbcb83b88de48e21a2a0aafe6a7f0 Mon Sep 17 00:00:00 2001 From: GA Pro Date: Wed, 13 May 2026 00:49:30 +0900 Subject: [PATCH] =?UTF-8?q?feat(db):=20V28=20=EC=B0=A8=EB=93=B1=20?= =?UTF-8?q?=ED=99=98=EC=88=98=20=EB=A3=B0=20(=ED=95=B4=EC=95=BD=20?= =?UTF-8?q?=EA=B2=BD=EA=B3=BC=EC=9B=94=EB=B3=84=20=ED=99=98=EC=88=98=20?= =?UTF-8?q?=EB=B9=84=EC=9C=A8)=20(=EB=8F=84=EB=A9=94=EC=9D=B8=20P1-3-a)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 도메인 P1 세번째 항목 — 차등 환수. DB 스키마/데이터만. 신규 테이블 chargeback_grade: - (months_from, months_to) 범위형 룰 - product_category NULL=ALL (상품별 차등 가능) - effective_from/to 개정 이력 추적 - CHECK 제약: months_from >= 0 AND months_to >= months_from 기존 V3 chargeback_rule(계약별 일반 룰)과 별개 — 단계별 환수 비율 전담. 기본 데이터 (2024-01-01, NULL=ALL, 표준 5단계): - 1~12개월: 100% (계약 후 1년 이내 해약) - 13~24개월: 50% - 25~36개월: 25% - 37~84개월: 10% - 85개월 이상: 0% (환수 면제, 분급 7년 종료 후) 인덱스: - (product_category, months_from, effective_from DESC) 환수율 조회 --- .../db/migration/V28__차등환수룰.sql | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ga-common/src/main/resources/db/migration/V28__차등환수룰.sql diff --git a/ga-common/src/main/resources/db/migration/V28__차등환수룰.sql b/ga-common/src/main/resources/db/migration/V28__차등환수룰.sql new file mode 100644 index 0000000..ede117f --- /dev/null +++ b/ga-common/src/main/resources/db/migration/V28__차등환수룰.sql @@ -0,0 +1,38 @@ +-- V28: 차등 환수 룰 (chargeback_grade — 해약 경과월별 단계별 환수 비율) +-- 기존 chargeback_rule(V3)은 계약별 일반 룰 — 본 테이블은 해약 시점별 차등 비율 마스터 + +-- ============================================================ +-- 1. chargeback_grade — 해약 경과월별 환수 비율 마스터 +-- ============================================================ + +CREATE TABLE chargeback_grade ( + grade_id BIGSERIAL PRIMARY KEY, + product_category VARCHAR(30), -- NULL = ALL 상품 + months_from INT NOT NULL, -- 해약 경과월 시작 (이상) + months_to INT, -- 해약 경과월 종료 (이하), NULL = 무한대 + chargeback_percent NUMERIC(5,2) NOT NULL, -- 환수율 % + effective_from DATE NOT NULL, + effective_to DATE, -- NULL = 현재 유효 + is_active BOOLEAN NOT NULL DEFAULT TRUE, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + created_by BIGINT, + updated_at TIMESTAMP, + updated_by BIGINT, + CHECK (months_from >= 0 AND (months_to IS NULL OR months_to >= months_from)) +); + +CREATE INDEX idx_cbg_category_months ON chargeback_grade(product_category, months_from, effective_from DESC); + +-- ============================================================ +-- 2. 기본 데이터 (2024-01-01, NULL=ALL 상품, 표준 차등 환수 룰) +-- ============================================================ + +INSERT INTO chargeback_grade + (product_category, months_from, months_to, chargeback_percent, effective_from) +VALUES + (NULL, 1, 12, 100, '2024-01-01'), -- 1~12개월: 전액 환수 + (NULL, 13, 24, 50, '2024-01-01'), -- 13~24개월: 50% + (NULL, 25, 36, 25, '2024-01-01'), -- 25~36개월: 25% + (NULL, 37, 84, 10, '2024-01-01'), -- 37~84개월: 10% + (NULL, 85, NULL, 0, '2024-01-01') -- 85개월 이상: 환수 없음 +ON CONFLICT DO NOTHING;