From e439bfffdac1951273b55785485a106b47622905 Mon Sep 17 00:00:00 2001 From: pro Date: Thu, 29 Jan 2026 15:02:07 +0900 Subject: [PATCH] =?UTF-8?q?feat:=EC=98=81=EC=97=85=20=EC=83=81=ED=92=88?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20DB=20=EC=8A=A4=ED=82=A4=EB=A7=88=20?= =?UTF-8?q?=EB=B0=8F=20=EC=8B=9C=EB=8D=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sales_product_categories: 상품 카테고리 테이블 - sales_products: 영업 상품 테이블 - sales_contract_products: 계약별 선택 상품 테이블 - SalesProductSeeder: 제조업체 8개, 공사업체 3개 상품 초기 데이터 Co-Authored-By: Claude Opus 4.5 --- ...29_150000_create_sales_products_tables.php | 74 +++++++ database/seeders/SalesProductSeeder.php | 201 ++++++++++++++++++ 2 files changed, 275 insertions(+) create mode 100644 database/migrations/2026_01_29_150000_create_sales_products_tables.php create mode 100644 database/seeders/SalesProductSeeder.php diff --git a/database/migrations/2026_01_29_150000_create_sales_products_tables.php b/database/migrations/2026_01_29_150000_create_sales_products_tables.php new file mode 100644 index 0000000..43061bc --- /dev/null +++ b/database/migrations/2026_01_29_150000_create_sales_products_tables.php @@ -0,0 +1,74 @@ +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'); + } +}; diff --git a/database/seeders/SalesProductSeeder.php b/database/seeders/SalesProductSeeder.php new file mode 100644 index 0000000..d043734 --- /dev/null +++ b/database/seeders/SalesProductSeeder.php @@ -0,0 +1,201 @@ +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개 상품)'); + } +}