236 lines
8.6 KiB
PHP
236 lines
8.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Seeders;
|
||
|
|
|
||
|
|
use Illuminate\Database\Seeder;
|
||
|
|
use Illuminate\Support\Facades\DB;
|
||
|
|
|
||
|
|
class QuoteFormulaItemSeeder extends Seeder
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 견적수식 품목 시드 데이터
|
||
|
|
* 견적서에 들어갈 품목 마스터
|
||
|
|
*/
|
||
|
|
public function run(): void
|
||
|
|
{
|
||
|
|
// 수식 ID 맵 조회
|
||
|
|
$formulas = DB::table('quote_formulas')
|
||
|
|
->whereIn('variable', [
|
||
|
|
'GR_AUTO_SELECT',
|
||
|
|
'CASE_AUTO_SELECT',
|
||
|
|
'MOTOR_AUTO_SELECT',
|
||
|
|
'CTRL_AUTO_SELECT',
|
||
|
|
'EDGE_QTY',
|
||
|
|
'INSP_FEE',
|
||
|
|
])
|
||
|
|
->pluck('id', 'variable')
|
||
|
|
->toArray();
|
||
|
|
|
||
|
|
$items = [];
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 1. 가이드레일 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['GR_AUTO_SELECT'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['GR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-GR-2438',
|
||
|
|
'item_name' => '가이드레일 2438',
|
||
|
|
'specification' => '2438mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '2',
|
||
|
|
'unit_price_formula' => '35000',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['GR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-GR-3000',
|
||
|
|
'item_name' => '가이드레일 3000',
|
||
|
|
'specification' => '3000mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '2',
|
||
|
|
'unit_price_formula' => '42000',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['GR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-GR-3600',
|
||
|
|
'item_name' => '가이드레일 3600',
|
||
|
|
'specification' => '3600mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '2',
|
||
|
|
'unit_price_formula' => '50000',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 2. 케이스(셔터박스) 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['CASE_AUTO_SELECT'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CASE_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CASE-1219',
|
||
|
|
'item_name' => '케이스 1219',
|
||
|
|
'specification' => '1219mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '85000',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CASE_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CASE-2438',
|
||
|
|
'item_name' => '케이스 2438',
|
||
|
|
'specification' => '2438mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '120000',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CASE_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CASE-3000',
|
||
|
|
'item_name' => '케이스 3000',
|
||
|
|
'specification' => '3000mm',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '150000',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 3. 모터(개폐전동기) 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['MOTOR_AUTO_SELECT'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-MOTOR-150',
|
||
|
|
'item_name' => '개폐전동기 150kg',
|
||
|
|
'specification' => '150kg',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '280000',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-MOTOR-300',
|
||
|
|
'item_name' => '개폐전동기 300kg',
|
||
|
|
'specification' => '300kg',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '380000',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-MOTOR-400',
|
||
|
|
'item_name' => '개폐전동기 400kg',
|
||
|
|
'specification' => '400kg',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '480000',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 4. 제어기 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['CTRL_AUTO_SELECT'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CTRL-EMB',
|
||
|
|
'item_name' => '매립형 제어기',
|
||
|
|
'specification' => '매립형',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '65000',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CTRL-EXP',
|
||
|
|
'item_name' => '노출형 제어기',
|
||
|
|
'specification' => '노출형',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '55000',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
|
||
|
|
'item_code' => 'PT-CTRL-INT',
|
||
|
|
'item_name' => '일체형 제어기',
|
||
|
|
'specification' => '모터일체형',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => '45000',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 5. 마구리 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['EDGE_QTY'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['EDGE_QTY'],
|
||
|
|
'item_code' => 'PT-EDGE-STD',
|
||
|
|
'item_name' => '마구리 날개',
|
||
|
|
'specification' => '표준형',
|
||
|
|
'unit' => 'EA',
|
||
|
|
'quantity_formula' => 'EDGE_QTY',
|
||
|
|
'unit_price_formula' => '12000',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==============================
|
||
|
|
// 6. 검사비 품목
|
||
|
|
// ==============================
|
||
|
|
if (isset($formulas['INSP_FEE'])) {
|
||
|
|
$items = array_merge($items, [
|
||
|
|
[
|
||
|
|
'formula_id' => $formulas['INSP_FEE'],
|
||
|
|
'item_code' => 'SV-INSP-STD',
|
||
|
|
'item_name' => '제품 검사비',
|
||
|
|
'specification' => '표준 검사',
|
||
|
|
'unit' => '식',
|
||
|
|
'quantity_formula' => '1',
|
||
|
|
'unit_price_formula' => 'INSP_FEE',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 데이터 삽입
|
||
|
|
foreach ($items as $item) {
|
||
|
|
DB::table('quote_formula_items')->updateOrInsert(
|
||
|
|
[
|
||
|
|
'formula_id' => $item['formula_id'],
|
||
|
|
'item_code' => $item['item_code'],
|
||
|
|
],
|
||
|
|
array_merge($item, [
|
||
|
|
'created_at' => now(),
|
||
|
|
'updated_at' => now(),
|
||
|
|
])
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->command->info('QuoteFormulaItemSeeder: '.count($items).'개 품목 생성 완료');
|
||
|
|
}
|
||
|
|
}
|