From 597d24eb19621aa21402f1da6155185c478a5ab5 Mon Sep 17 00:00:00 2001 From: pro Date: Tue, 27 Jan 2026 15:03:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=EB=B0=94=EB=A1=9C=EB=B9=8C=20=EA=B3=BC?= =?UTF-8?q?=EA=B8=88=EA=B4=80=EB=A6=AC=20=ED=85=8C=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - barobill_subscriptions: 월정액 구독 관리 - barobill_billing_records: 과금 내역 기록 - barobill_monthly_summaries: 월별 집계 테이블 Co-Authored-By: Claude Opus 4.5 --- ...00_create_barobill_subscriptions_table.php | 46 ++++++++++++++++ ..._create_barobill_billing_records_table.php | 52 ++++++++++++++++++ ...reate_barobill_monthly_summaries_table.php | 53 +++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 database/migrations/2026_01_27_150000_create_barobill_subscriptions_table.php create mode 100644 database/migrations/2026_01_27_150100_create_barobill_billing_records_table.php create mode 100644 database/migrations/2026_01_27_150200_create_barobill_monthly_summaries_table.php diff --git a/database/migrations/2026_01_27_150000_create_barobill_subscriptions_table.php b/database/migrations/2026_01_27_150000_create_barobill_subscriptions_table.php new file mode 100644 index 0000000..ebcd126 --- /dev/null +++ b/database/migrations/2026_01_27_150000_create_barobill_subscriptions_table.php @@ -0,0 +1,46 @@ +id(); + $table->foreignId('member_id')->comment('바로빌 회원사 ID'); + $table->enum('service_type', ['bank_account', 'card', 'hometax']) + ->comment('서비스 유형: bank_account=계좌조회, card=카드내역, hometax=홈텍스'); + $table->unsignedInteger('monthly_fee')->default(0)->comment('월정액 금액 (원)'); + $table->date('started_at')->comment('구독 시작일'); + $table->date('ended_at')->nullable()->comment('구독 종료일 (null=진행중)'); + $table->boolean('is_active')->default(true)->comment('활성 상태'); + $table->text('memo')->nullable()->comment('메모'); + $table->timestamps(); + $table->softDeletes(); + + // 인덱스 + $table->index(['member_id', 'service_type']); + $table->index(['is_active', 'service_type']); + + // 외래키 + $table->foreign('member_id') + ->references('id') + ->on('barobill_members') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('barobill_subscriptions'); + } +}; diff --git a/database/migrations/2026_01_27_150100_create_barobill_billing_records_table.php b/database/migrations/2026_01_27_150100_create_barobill_billing_records_table.php new file mode 100644 index 0000000..1023eec --- /dev/null +++ b/database/migrations/2026_01_27_150100_create_barobill_billing_records_table.php @@ -0,0 +1,52 @@ +id(); + $table->foreignId('member_id')->comment('바로빌 회원사 ID'); + $table->string('billing_month', 7)->comment('과금 월 (YYYY-MM)'); + $table->enum('service_type', ['tax_invoice', 'bank_account', 'card', 'hometax']) + ->comment('서비스 유형'); + $table->enum('billing_type', ['subscription', 'usage']) + ->comment('과금 유형: subscription=월정액, usage=건별'); + $table->unsignedInteger('quantity')->default(1)->comment('수량 (월정액=1, 건별=사용건수)'); + $table->unsignedInteger('unit_price')->default(0)->comment('단가 (원)'); + $table->unsignedInteger('total_amount')->default(0)->comment('총액 (원)'); + $table->date('billed_at')->comment('과금일'); + $table->text('description')->nullable()->comment('설명'); + $table->timestamps(); + + // 인덱스 + $table->index(['member_id', 'billing_month']); + $table->index(['billing_month', 'service_type']); + $table->index(['billing_month', 'billing_type']); + $table->index('billed_at'); + + // 중복 방지 (같은 월, 같은 서비스, 같은 과금유형) + $table->unique(['member_id', 'billing_month', 'service_type', 'billing_type'], 'billing_unique'); + + // 외래키 + $table->foreign('member_id') + ->references('id') + ->on('barobill_members') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('barobill_billing_records'); + } +}; diff --git a/database/migrations/2026_01_27_150200_create_barobill_monthly_summaries_table.php b/database/migrations/2026_01_27_150200_create_barobill_monthly_summaries_table.php new file mode 100644 index 0000000..00b2b63 --- /dev/null +++ b/database/migrations/2026_01_27_150200_create_barobill_monthly_summaries_table.php @@ -0,0 +1,53 @@ +id(); + $table->foreignId('member_id')->comment('바로빌 회원사 ID'); + $table->string('billing_month', 7)->comment('과금 월 (YYYY-MM)'); + + // 월정액 항목별 + $table->unsignedInteger('bank_account_fee')->default(0)->comment('계좌조회 월정액'); + $table->unsignedInteger('card_fee')->default(0)->comment('카드내역 월정액'); + $table->unsignedInteger('hometax_fee')->default(0)->comment('홈텍스 월정액'); + $table->unsignedInteger('subscription_total')->default(0)->comment('월정액 합계'); + + // 건별 사용량 + $table->unsignedInteger('tax_invoice_count')->default(0)->comment('세금계산서 발행 건수'); + $table->unsignedInteger('tax_invoice_amount')->default(0)->comment('세금계산서 과금액'); + $table->unsignedInteger('usage_total')->default(0)->comment('건별 사용 합계'); + + // 총합계 + $table->unsignedInteger('grand_total')->default(0)->comment('총합계'); + + $table->timestamps(); + + // 인덱스 + $table->unique(['member_id', 'billing_month']); + $table->index('billing_month'); + + // 외래키 + $table->foreign('member_id') + ->references('id') + ->on('barobill_members') + ->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('barobill_monthly_summaries'); + } +};