feat:영업수수료 정산 마이그레이션 추가
- sales_commissions 테이블 생성 (영업수수료 정산) - sales_commission_details 테이블 생성 (상품별 수당 내역) - sales_tenant_managements 테이블에 입금 정보 컬럼 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 영업수수료 정산 테이블
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sales_commissions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('management_id')->comment('영업 관리 ID (sales_tenant_managements)');
|
||||
|
||||
// 입금 정보
|
||||
$table->enum('payment_type', ['deposit', 'balance'])->comment('입금 구분 (deposit:계약금, balance:잔금)');
|
||||
$table->decimal('payment_amount', 14, 2)->comment('입금액');
|
||||
$table->date('payment_date')->comment('입금일');
|
||||
|
||||
// 수당 계산 기준
|
||||
$table->decimal('base_amount', 14, 2)->comment('수당 계산 기준액 (가입비의 50%)');
|
||||
$table->decimal('partner_rate', 5, 2)->default(20.00)->comment('영업파트너 수당률 (%)');
|
||||
$table->decimal('manager_rate', 5, 2)->default(5.00)->comment('매니저 수당률 (%)');
|
||||
$table->decimal('partner_commission', 14, 2)->comment('영업파트너 수당액');
|
||||
$table->decimal('manager_commission', 14, 2)->comment('매니저 수당액');
|
||||
|
||||
// 지급 정보
|
||||
$table->date('scheduled_payment_date')->comment('지급예정일 (익월 10일)');
|
||||
$table->enum('status', ['pending', 'approved', 'paid', 'cancelled'])
|
||||
->default('pending')
|
||||
->comment('상태 (pending:대기, approved:승인, paid:지급완료, cancelled:취소)');
|
||||
$table->date('actual_payment_date')->nullable()->comment('실제 지급일');
|
||||
|
||||
// 대상자 정보
|
||||
$table->unsignedBigInteger('partner_id')->comment('영업파트너 ID (sales_partners)');
|
||||
$table->unsignedBigInteger('manager_user_id')->nullable()->comment('매니저 사용자 ID');
|
||||
|
||||
// 부가 정보
|
||||
$table->text('notes')->nullable()->comment('메모');
|
||||
$table->string('bank_reference', 100)->nullable()->comment('이체 참조번호');
|
||||
|
||||
// 승인 정보
|
||||
$table->unsignedBigInteger('approved_by')->nullable()->comment('승인자 ID');
|
||||
$table->timestamp('approved_at')->nullable()->comment('승인일시');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// 인덱스
|
||||
$table->index('tenant_id');
|
||||
$table->index('management_id');
|
||||
$table->index('partner_id');
|
||||
$table->index('manager_user_id');
|
||||
$table->index('payment_type');
|
||||
$table->index('payment_date');
|
||||
$table->index('scheduled_payment_date');
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sales_commissions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 영업수수료 상세 테이블 (상품별 수당 내역)
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sales_commission_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('commission_id')->comment('수수료 정산 ID');
|
||||
$table->unsignedBigInteger('contract_product_id')->comment('계약 상품 ID (sales_contract_products)');
|
||||
|
||||
// 상품별 수당 계산
|
||||
$table->decimal('registration_fee', 14, 2)->comment('상품 가입비');
|
||||
$table->decimal('base_amount', 14, 2)->comment('수당 계산 기준액 (가입비의 50%)');
|
||||
$table->decimal('partner_rate', 5, 2)->comment('영업파트너 수당률 (%)');
|
||||
$table->decimal('manager_rate', 5, 2)->comment('매니저 수당률 (%)');
|
||||
$table->decimal('partner_commission', 14, 2)->comment('영업파트너 수당액');
|
||||
$table->decimal('manager_commission', 14, 2)->comment('매니저 수당액');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// 인덱스 및 외래키
|
||||
$table->index('commission_id');
|
||||
$table->index('contract_product_id');
|
||||
|
||||
$table->foreign('commission_id')
|
||||
->references('id')
|
||||
->on('sales_commissions')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sales_commission_details');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 영업관리 테이블에 입금 정보 컬럼 추가
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('sales_tenant_managements', function (Blueprint $table) {
|
||||
// 계약금 정보
|
||||
$table->decimal('deposit_amount', 14, 2)->nullable()->after('membership_status')->comment('계약금');
|
||||
$table->date('deposit_paid_date')->nullable()->after('deposit_amount')->comment('계약금 입금일');
|
||||
$table->enum('deposit_status', ['pending', 'paid'])
|
||||
->default('pending')
|
||||
->after('deposit_paid_date')
|
||||
->comment('계약금 상태 (pending:대기, paid:입금완료)');
|
||||
|
||||
// 잔금 정보
|
||||
$table->decimal('balance_amount', 14, 2)->nullable()->after('deposit_status')->comment('잔금');
|
||||
$table->date('balance_paid_date')->nullable()->after('balance_amount')->comment('잔금 입금일');
|
||||
$table->enum('balance_status', ['pending', 'paid'])
|
||||
->default('pending')
|
||||
->after('balance_paid_date')
|
||||
->comment('잔금 상태 (pending:대기, paid:입금완료)');
|
||||
|
||||
// 총 가입비 (계약 상품 합계, 캐시용)
|
||||
$table->decimal('total_registration_fee', 14, 2)->nullable()->after('balance_status')->comment('총 가입비');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('sales_tenant_managements', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'deposit_amount',
|
||||
'deposit_paid_date',
|
||||
'deposit_status',
|
||||
'balance_amount',
|
||||
'balance_paid_date',
|
||||
'balance_status',
|
||||
'total_registration_fee',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user