feat:영업 상품관리 DB 스키마 및 시더 추가
- sales_product_categories: 상품 카테고리 테이블 - sales_products: 영업 상품 테이블 - sales_contract_products: 계약별 선택 상품 테이블 - SalesProductSeeder: 제조업체 8개, 공사업체 3개 상품 초기 데이터 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// 상품 카테고리 테이블
|
||||
Schema::create('sales_product_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code', 50)->unique()->comment('카테고리 코드 (manufacturing, construction)');
|
||||
$table->string('name', 100)->comment('카테고리명 (제조 업체, 공사 업체)');
|
||||
$table->text('description')->nullable()->comment('설명');
|
||||
$table->string('base_storage', 20)->default('100GB')->comment('기본 제공 용량');
|
||||
$table->integer('display_order')->default(0)->comment('표시 순서');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
// 상품 테이블
|
||||
Schema::create('sales_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->constrained('sales_product_categories')->comment('카테고리 FK');
|
||||
$table->string('code', 50)->comment('상품 코드');
|
||||
$table->string('name', 100)->comment('상품명');
|
||||
$table->text('description')->nullable()->comment('프로그램 타입/설명');
|
||||
$table->decimal('development_fee', 15, 2)->default(0)->comment('개발비 (가입비)');
|
||||
$table->decimal('subscription_fee', 15, 2)->default(0)->comment('월 구독료');
|
||||
$table->decimal('commission_rate', 5, 2)->default(25.00)->comment('수당 비율 (%)');
|
||||
$table->boolean('allow_flexible_pricing')->default(true)->comment('재량권 허용');
|
||||
$table->boolean('is_required')->default(false)->comment('필수 선택 여부');
|
||||
$table->integer('display_order')->default(0)->comment('표시 순서');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['category_id', 'code'], 'uk_category_code');
|
||||
});
|
||||
|
||||
// 계약별 선택 상품 테이블
|
||||
Schema::create('sales_contract_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained('tenants')->comment('테넌트 FK');
|
||||
$table->foreignId('management_id')->constrained('sales_tenant_managements')->comment('영업관리 FK');
|
||||
$table->foreignId('category_id')->constrained('sales_product_categories')->comment('선택한 카테고리');
|
||||
$table->foreignId('product_id')->constrained('sales_products')->comment('선택한 상품');
|
||||
$table->decimal('development_fee', 15, 2)->nullable()->comment('적용된 개발비 (협상 가능)');
|
||||
$table->decimal('subscription_fee', 15, 2)->nullable()->comment('적용된 구독료');
|
||||
$table->decimal('discount_rate', 5, 2)->default(0)->comment('할인율 (%)');
|
||||
$table->text('notes')->nullable()->comment('비고');
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->comment('등록자');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['tenant_id', 'category_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sales_contract_products');
|
||||
Schema::dropIfExists('sales_products');
|
||||
Schema::dropIfExists('sales_product_categories');
|
||||
}
|
||||
};
|
||||
201
database/seeders/SalesProductSeeder.php
Normal file
201
database/seeders/SalesProductSeeder.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 영업 상품 초기 데이터 시더
|
||||
*/
|
||||
class SalesProductSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
DB::transaction(function () {
|
||||
// 기존 데이터 삭제
|
||||
DB::table('sales_contract_products')->delete();
|
||||
DB::table('sales_products')->delete();
|
||||
DB::table('sales_product_categories')->delete();
|
||||
|
||||
// 카테고리 생성
|
||||
$categories = [
|
||||
[
|
||||
'code' => 'MANUFACTURER',
|
||||
'name' => '제조업체 솔루션',
|
||||
'description' => '제조업 전용 SAM 솔루션 상품군',
|
||||
'base_storage' => '100GB',
|
||||
'display_order' => 1,
|
||||
],
|
||||
[
|
||||
'code' => 'CONSTRUCTION',
|
||||
'name' => '공사업체 솔루션',
|
||||
'description' => '공사/시공업 전용 SAM 솔루션 상품군',
|
||||
'base_storage' => '50GB',
|
||||
'display_order' => 2,
|
||||
],
|
||||
];
|
||||
|
||||
$categoryIds = [];
|
||||
foreach ($categories as $category) {
|
||||
$categoryIds[$category['code']] = DB::table('sales_product_categories')->insertGetId([
|
||||
...$category,
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// 제조업체 상품 (8개)
|
||||
$manufacturerProducts = [
|
||||
[
|
||||
'code' => 'MFG_BASIC',
|
||||
'name' => 'SAM 기본 패키지',
|
||||
'description' => '생산관리, 재고관리, 주문관리 기본 기능 포함',
|
||||
'development_fee' => 3000000,
|
||||
'subscription_fee' => 150000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => true,
|
||||
'display_order' => 1,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_PRODUCTION',
|
||||
'name' => '생산관리 모듈',
|
||||
'description' => '작업지시, 공정관리, 생산실적 관리',
|
||||
'development_fee' => 1500000,
|
||||
'subscription_fee' => 80000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 2,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_INVENTORY',
|
||||
'name' => '재고관리 모듈',
|
||||
'description' => '입출고 관리, 재고실사, 로트 추적',
|
||||
'development_fee' => 1200000,
|
||||
'subscription_fee' => 60000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 3,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_QUALITY',
|
||||
'name' => '품질관리 모듈',
|
||||
'description' => '수입검사, 공정검사, 출하검사',
|
||||
'development_fee' => 1000000,
|
||||
'subscription_fee' => 50000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 4,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_ESTIMATE',
|
||||
'name' => '견적관리 모듈',
|
||||
'description' => '견적 수식 관리, 자동 계산, 견적서 생성',
|
||||
'development_fee' => 800000,
|
||||
'subscription_fee' => 40000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 5,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_ACCOUNTING',
|
||||
'name' => '회계관리 모듈',
|
||||
'description' => '매출/매입 관리, 세금계산서, 자금일보',
|
||||
'development_fee' => 1500000,
|
||||
'subscription_fee' => 100000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 6,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_MOBILE',
|
||||
'name' => '모바일 앱',
|
||||
'description' => '현장용 모바일 앱 (iOS/Android)',
|
||||
'development_fee' => 500000,
|
||||
'subscription_fee' => 30000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => false,
|
||||
'is_required' => false,
|
||||
'display_order' => 7,
|
||||
],
|
||||
[
|
||||
'code' => 'MFG_CUSTOM',
|
||||
'name' => '커스터마이징',
|
||||
'description' => '고객 맞춤 개발 (별도 협의)',
|
||||
'development_fee' => 0,
|
||||
'subscription_fee' => 0,
|
||||
'commission_rate' => 20,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 8,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($manufacturerProducts as $product) {
|
||||
DB::table('sales_products')->insert([
|
||||
'category_id' => $categoryIds['MANUFACTURER'],
|
||||
...$product,
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// 공사업체 상품 (3개)
|
||||
$constructionProducts = [
|
||||
[
|
||||
'code' => 'CON_BASIC',
|
||||
'name' => 'SAM 공사관리 패키지',
|
||||
'description' => '현장관리, 공사진행, 자재관리 기본 기능',
|
||||
'development_fee' => 2000000,
|
||||
'subscription_fee' => 100000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => true,
|
||||
'display_order' => 1,
|
||||
],
|
||||
[
|
||||
'code' => 'CON_FIELD',
|
||||
'name' => '현장관리 모듈',
|
||||
'description' => '현장 일지, 사진 관리, 공정 관리',
|
||||
'development_fee' => 1000000,
|
||||
'subscription_fee' => 50000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => true,
|
||||
'is_required' => false,
|
||||
'display_order' => 2,
|
||||
],
|
||||
[
|
||||
'code' => 'CON_MOBILE',
|
||||
'name' => '모바일 현장앱',
|
||||
'description' => '현장 기사용 모바일 앱',
|
||||
'development_fee' => 500000,
|
||||
'subscription_fee' => 30000,
|
||||
'commission_rate' => 25,
|
||||
'allow_flexible_pricing' => false,
|
||||
'is_required' => false,
|
||||
'display_order' => 3,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($constructionProducts as $product) {
|
||||
DB::table('sales_products')->insert([
|
||||
'category_id' => $categoryIds['CONSTRUCTION'],
|
||||
...$product,
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
$this->command->info('✅ 영업 상품 초기 데이터 생성 완료 (2개 카테고리, 11개 상품)');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user