From ab02a23babd4c34e67aea8796180769b3c9a073d Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Wed, 17 Sep 2025 18:34:28 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Database/dbmsv2_test1.sql | 8 +-- app/Helpers/Equipment/ServerPartHelper.php | 8 +++ app/Language/en/Equipment/ServerPart.php | 12 +++-- app/Services/Customer/PaymentService.php | 19 +------ app/Services/Customer/ServiceService.php | 56 +++++++++++++------- app/Services/Equipment/PartService.php | 3 +- app/Services/Equipment/ServerPartService.php | 26 +++++++-- 7 files changed, 79 insertions(+), 53 deletions(-) diff --git a/app/Database/dbmsv2_test1.sql b/app/Database/dbmsv2_test1.sql index 23e0499..b77f224 100644 --- a/app/Database/dbmsv2_test1.sql +++ b/app/Database/dbmsv2_test1.sql @@ -278,7 +278,7 @@ CREATE TABLE `partinfo` ( LOCK TABLES `partinfo` WRITE; /*!40000 ALTER TABLE `partinfo` DISABLE KEYS */; -INSERT INTO `partinfo` VALUES (1,'CPU1','CPU','Xeon E5530 2.4Ghz 4Core',50000,100,'available','2025-09-05 01:27:05','2025-09-04 04:54:34',NULL),(2,'CPU2','CPU','Xeon E5540 2.4Ghz 4Core',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(3,'CPU3','CPU','Xeon X5560 2.8Ghz 8Core',80000,100,'available','2025-09-05 00:05:26','2025-09-04 04:54:34',NULL),(4,'CPU4','CPU','Xeon X5650 2.6Ghz 12Core',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(5,'CPU5','CPU','Xeon E5-2690v2 2.6Ghz 12Core',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(6,'CPU6','CPU','Xeon E5-2690v4 3.0Ghz 20Core',150000,100,'available','2025-09-05 00:04:09','2025-09-04 04:54:34',NULL),(7,'RAM7','RAM','2G',20000,100,'available','2025-09-05 01:27:05','2025-09-04 04:54:34',NULL),(8,'RAM8','RAM','4G',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(9,'RAM9','RAM','8G',40000,100,'available','2025-09-05 00:05:26','2025-09-04 04:54:34',NULL),(10,'RAM10','RAM','16G',60000,100,'available','2025-09-05 00:04:09','2025-09-04 04:54:34',NULL),(11,'RAM11','RAM','32G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(12,'RAM12','RAM','64G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(13,'DISK13','DISK','SATA 128G',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(14,'DISK14','DISK','SATA 256G',70000,100,'available','2025-09-05 01:27:05','2025-09-04 04:54:34',NULL),(15,'DISK15','DISK','SATA 512G',90000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(16,'DISK16','DISK','SAS 128G',60000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(17,'DISK17','DISK','SAS 256G',80000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(18,'DISK18','DISK','SAS 512G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(19,'DISK19','DISK','SSD 128G',60000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(20,'DISK20','DISK','SSD 256G',80000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(21,'DISK21','DISK','SSD 512G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(22,'DISK22','DISK','SSD 1T',120000,100,'available','2025-09-05 00:04:09','2025-09-04 04:54:34',NULL),(23,'DISK23','DISK','SSD 2T',150000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(24,'DISK24','DISK','NVME 512G',120000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(25,'DISK25','DISK','NVME 1T',150000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(26,'DISK26','DISK','NVME 2T',180000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(27,'OS27','OS','Windows 10',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(28,'OS28','OS','Windows 11',20000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(29,'OS29','OS','Windows NT 2008R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(30,'OS30','OS','Windows NT 2012R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(31,'OS31','OS','Windows NT 2016R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(32,'OS32','OS','Windows NT 2019R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(33,'OS33','OS','CentOS 7',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(34,'OS34','OS','CentOS 8',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(35,'OS35','OS','CentOS 9',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(36,'OS36','OS','Ununtu 20.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(37,'OS37','OS','Ununtu 21.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(38,'OS38','OS','Ununtu 22.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(39,'DB39','DB','Windows MSSQL 2008',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(40,'DB40','DB','Windows MSSQL 2012',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(41,'DB41','DB','Mysql',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(42,'DB42','DB','Postgress',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(43,'SOFTWARE43','SOFTWARE','닷디펜더',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(44,'SOFTWARE44','SOFTWARE','딥파인더',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL); +INSERT INTO `partinfo` VALUES (1,'CPU1','CPU','Xeon E5530 2.4Ghz 4Core',50000,99,'available','2025-09-17 07:48:14','2025-09-04 04:54:34',NULL),(2,'CPU2','CPU','Xeon E5540 2.4Ghz 4Core',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(3,'CPU3','CPU','Xeon X5560 2.8Ghz 8Core',80000,98,'available','2025-09-17 07:49:12','2025-09-04 04:54:34',NULL),(4,'CPU4','CPU','Xeon X5650 2.6Ghz 12Core',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(5,'CPU5','CPU','Xeon E5-2690v2 2.6Ghz 12Core',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(6,'CPU6','CPU','Xeon E5-2690v4 3.0Ghz 20Core',150000,100,'available','2025-09-05 00:04:09','2025-09-04 04:54:34',NULL),(7,'RAM7','RAM','2G',20000,98,'available','2025-09-17 07:49:35','2025-09-04 04:54:34',NULL),(8,'RAM8','RAM','4G',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(9,'RAM9','RAM','8G',40000,100,'available','2025-09-05 00:05:26','2025-09-04 04:54:34',NULL),(10,'RAM10','RAM','16G',60000,99,'available','2025-09-17 07:47:54','2025-09-04 04:54:34',NULL),(11,'RAM11','RAM','32G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(12,'RAM12','RAM','64G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(13,'DISK13','DISK','SATA 128G',50000,97,'available','2025-09-17 08:09:06','2025-09-04 04:54:34',NULL),(14,'DISK14','DISK','SATA 256G',70000,100,'available','2025-09-05 01:27:05','2025-09-04 04:54:34',NULL),(15,'DISK15','DISK','SATA 512G',90000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(16,'DISK16','DISK','SAS 128G',60000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(17,'DISK17','DISK','SAS 256G',80000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(18,'DISK18','DISK','SAS 512G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(19,'DISK19','DISK','SSD 128G',60000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(20,'DISK20','DISK','SSD 256G',80000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(21,'DISK21','DISK','SSD 512G',100000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(22,'DISK22','DISK','SSD 1T',120000,100,'available','2025-09-05 00:04:09','2025-09-04 04:54:34',NULL),(23,'DISK23','DISK','SSD 2T',150000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(24,'DISK24','DISK','NVME 512G',120000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(25,'DISK25','DISK','NVME 1T',150000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(26,'DISK26','DISK','NVME 2T',180000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(27,'OS27','OS','Windows 10',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(28,'OS28','OS','Windows 11',20000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(29,'OS29','OS','Windows NT 2008R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(30,'OS30','OS','Windows NT 2012R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(31,'OS31','OS','Windows NT 2016R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(32,'OS32','OS','Windows NT 2019R2',30000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(33,'OS33','OS','CentOS 7',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(34,'OS34','OS','CentOS 8',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(35,'OS35','OS','CentOS 9',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(36,'OS36','OS','Ununtu 20.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(37,'OS37','OS','Ununtu 21.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(38,'OS38','OS','Ununtu 22.04',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(39,'DB39','DB','Windows MSSQL 2008',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(40,'DB40','DB','Windows MSSQL 2012',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(41,'DB41','DB','Mysql',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(42,'DB42','DB','Postgress',10000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(43,'SOFTWARE43','SOFTWARE','닷디펜더',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL),(44,'SOFTWARE44','SOFTWARE','딥파인더',50000,100,'available',NULL,'2025-09-04 04:54:34',NULL); /*!40000 ALTER TABLE `partinfo` ENABLE KEYS */; UNLOCK TABLES; @@ -422,7 +422,7 @@ CREATE TABLE `serverpartinfo` ( KEY `FK_serviceinfo_TO_serverpartinfo` (`serviceinfo_uid`), CONSTRAINT `FK_serverinfo_TO_serverpartinfo` FOREIGN KEY (`serverinfo_uid`) REFERENCES `serverinfo` (`uid`), CONSTRAINT `FK_serviceinfo_TO_serverpartinfo` FOREIGN KEY (`serviceinfo_uid`) REFERENCES `serviceinfo` (`uid`) -) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 COMMENT='서버파트정보'; +) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8 COMMENT='서버파트정보'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -431,7 +431,7 @@ CREATE TABLE `serverpartinfo` ( LOCK TABLES `serverpartinfo` WRITE; /*!40000 ALTER TABLE `serverpartinfo` DISABLE KEYS */; -INSERT INTO `serverpartinfo` VALUES (4,NULL,6,4,NULL,'CPU','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(5,NULL,10,4,NULL,'RAM','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(6,NULL,22,4,NULL,'DISK','',0,2,NULL,NULL,'2025-09-05 00:04:09'),(7,NULL,3,5,NULL,'CPU','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(8,NULL,9,5,NULL,'RAM','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(9,NULL,14,5,NULL,'DISK','',0,3,'RAID5',NULL,'2025-09-05 00:05:26'),(13,NULL,5,6,NULL,'CPU','',0,10,NULL,'2025-09-05 07:37:42','2025-09-05 07:36:21'),(14,NULL,7,6,NULL,'RAM','base',0,10,'','2025-09-11 03:57:23','2025-09-05 07:36:21'),(15,NULL,26,6,NULL,'DISK','',0,10,'RAID10',NULL,'2025-09-05 07:36:21'),(16,NULL,10,6,NULL,'RAM','onetime',100000,2,NULL,NULL,'2025-09-05 07:38:22'),(17,NULL,14,6,NULL,'DISK','month',10000,2,'RAID1',NULL,'2025-09-05 07:39:26'),(25,NULL,25,4,8,'SWITCH','base',0,1,NULL,NULL,'2025-09-08 08:13:09'),(26,NULL,1,11,9,'CPU','base',100000,2,'','2025-09-11 04:48:29','2025-09-09 03:39:10'),(28,NULL,510,12,5,'SWITCH','base',0,1,NULL,NULL,'2025-09-16 07:48:19'),(29,NULL,259,12,5,'IP','base',0,1,NULL,NULL,'2025-09-16 07:48:37'),(30,NULL,7,11,9,'RAM','base',20000,1,NULL,NULL,'2025-09-16 09:22:24'),(34,NULL,14,11,9,'DISK','base',70000,1,NULL,NULL,'2025-09-17 00:11:51'),(35,69,15,11,9,'DISK','base',90000,1,NULL,NULL,'2025-09-17 00:17:26'),(38,193,14,10,11,'DISK','onetime',70000,1,NULL,NULL,'2025-09-17 01:21:42'); +INSERT INTO `serverpartinfo` VALUES (4,NULL,6,4,NULL,'CPU','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(5,NULL,10,4,NULL,'RAM','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(6,NULL,22,4,NULL,'DISK','',0,2,NULL,NULL,'2025-09-05 00:04:09'),(7,NULL,3,5,NULL,'CPU','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(8,NULL,9,5,NULL,'RAM','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(9,NULL,14,5,NULL,'DISK','',0,3,'RAID5',NULL,'2025-09-05 00:05:26'),(13,NULL,5,6,NULL,'CPU','',0,10,NULL,'2025-09-05 07:37:42','2025-09-05 07:36:21'),(14,NULL,7,6,NULL,'RAM','base',0,10,'','2025-09-11 03:57:23','2025-09-05 07:36:21'),(15,NULL,26,6,NULL,'DISK','',0,10,'RAID10',NULL,'2025-09-05 07:36:21'),(16,NULL,10,6,NULL,'RAM','onetime',100000,2,NULL,NULL,'2025-09-05 07:38:22'),(17,NULL,14,6,NULL,'DISK','month',10000,2,'RAID1',NULL,'2025-09-05 07:39:26'),(25,NULL,25,4,8,'SWITCH','base',0,1,NULL,NULL,'2025-09-08 08:13:09'),(26,NULL,1,11,9,'CPU','base',100000,2,'','2025-09-11 04:48:29','2025-09-09 03:39:10'),(28,NULL,510,12,5,'SWITCH','base',0,1,NULL,NULL,'2025-09-16 07:48:19'),(29,NULL,259,12,5,'IP','base',0,1,NULL,NULL,'2025-09-16 07:48:37'),(30,NULL,7,11,9,'RAM','base',20000,1,NULL,NULL,'2025-09-16 09:22:24'),(34,NULL,14,11,9,'DISK','base',70000,1,NULL,NULL,'2025-09-17 00:11:51'),(35,69,15,11,9,'DISK','base',90000,1,NULL,NULL,'2025-09-17 00:17:26'),(38,193,14,10,11,'DISK','onetime',70000,1,NULL,NULL,'2025-09-17 01:21:42'),(40,585,13,12,5,'DISK','base',50000,1,NULL,NULL,'2025-09-17 07:47:19'),(41,585,10,12,5,'RAM','base',60000,1,NULL,NULL,'2025-09-17 07:47:54'),(42,585,1,12,5,'CPU','base',50000,1,NULL,NULL,'2025-09-17 07:48:14'),(43,NULL,3,13,NULL,'CPU','base',80000,2,NULL,NULL,'2025-09-17 07:49:12'),(44,NULL,7,13,NULL,'RAM','base',20000,2,NULL,NULL,'2025-09-17 07:49:35'),(45,NULL,13,13,NULL,'DISK','base',50000,2,'RAID1',NULL,'2025-09-17 08:09:06'); /*!40000 ALTER TABLE `serverpartinfo` ENABLE KEYS */; UNLOCK TABLES; @@ -592,4 +592,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2025-09-17 14:44:52 +-- Dump completed on 2025-09-17 17:09:24 diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php index 0428a78..442fec4 100644 --- a/app/Helpers/Equipment/ServerPartHelper.php +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -57,6 +57,14 @@ class ServerPartHelper extends EquipmentHelper $attributes = ['data-price' => 'getPrice']; $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); break; + case 'extra': + if (array_key_exists('type', $viewDatas['control']['form_datas']) && $viewDatas['control']['form_datas']['type'] === 'DISK') { + $options = ["" => lang("{$viewDatas['class_path']}.label.{$field}") . " 선택", ...lang("{$viewDatas['class_path']}.EXTRA.{$viewDatas['control']['form_datas']['type']}")]; + $form = form_dropdown($field, $options, $value, $extras); + } else { + $form = parent::getFieldForm($field, $value, $viewDatas, $extras);; + } + break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); break; diff --git a/app/Language/en/Equipment/ServerPart.php b/app/Language/en/Equipment/ServerPart.php index 1b18b85..92a93a1 100644 --- a/app/Language/en/Equipment/ServerPart.php +++ b/app/Language/en/Equipment/ServerPart.php @@ -32,10 +32,12 @@ return [ "CS" => "CS", ], "EXTRA" => [ - 'RAID0' => "RAID0", - 'RAID1' => "RAID1", - 'RAID5' => "RAID5", - 'RAID6' => "RAID6", - 'RAID10' => "RAID10", + 'DISK' => [ + 'RAID0' => "RAID0", + 'RAID1' => "RAID1", + 'RAID5' => "RAID5", + 'RAID6' => "RAID6", + 'RAID10' => "RAID10", + ], ], ]; diff --git a/app/Services/Customer/PaymentService.php b/app/Services/Customer/PaymentService.php index fda3843..1089d5f 100644 --- a/app/Services/Customer/PaymentService.php +++ b/app/Services/Customer/PaymentService.php @@ -3,6 +3,7 @@ namespace App\Services\Customer; use App\Entities\Customer\PaymentEntity; +use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\ServerPartEntity; use App\Helpers\Customer\PaymentHelper; use App\Models\Customer\PaymentModel; @@ -93,24 +94,6 @@ class PaymentService extends CustomerService } return $options; } - //서비스 설정 - public function setServerPart(ServerPartEntity $serverPartEntity): PaymentEntity - { - if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) { - if ($serverPartEntity->getServiceInfoUID() === null) { - throw new \Exception("일회성 부품 추가는 서비스정보가 정의된 후에만 가능합니다."); - } - } - $formDatas = []; - $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); - $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); - $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); - $formDatas['title'] = sprintf("[%s] 부품정보 설정", $serverPartEntity->getPartEntity()->getTitle()); - $formDatas['amount'] = $serverPartEntity->getAmount(); - $formDatas['billing'] = $serverPartEntity->getBilling(); - $formDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리 - return $this->create($formDatas); - } //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index 1b2dba2..23e7cfc 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -3,6 +3,7 @@ namespace App\Services\Customer; use App\Entities\Customer\ClientEntity; +use App\Entities\Customer\PaymentEntity; use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\ServerEntity; use App\Entities\UserEntity; @@ -206,11 +207,18 @@ class ServiceService extends CustomerService throw new \Exception("서버가 지정되지 않았습니다."); } $entity = parent::create($formDatas); - return $entity->setServerEntity($this->getServerService()->setService( - $entity, - $formDatas['serverinfo_uid'], - STATUS['OCCUPIED'] - )); + $entity = $entity->setServerEntity($this->getServerService()->setService($entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED'])); + // 결제정보에 추가한다. + $paymentDatas = []; + $paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID(); + $paymentDatas['serviceinfo_uid'] = $entity->getPK(); + $paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID(); + $paymentDatas['title'] = sprintf("[%s] 서비스", $entity->getServerEntity()->getTitle()); + $paymentDatas['amount'] = $entity->getAmount(); + $paymentDatas['billing'] = PAYMENT['BILLING']['MONTH']; + $paymentDatas['billing_at'] = $entity->getBillingAt(); + $this->getPaymentService()->create($paymentDatas); + return $entity; } //수정 public function modify(mixed $entity, array $formDatas): ServiceEntity @@ -220,21 +228,33 @@ class ServiceService extends CustomerService } //기존서버정보 사용가능으로 설정 if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { - $entity = $this->getServerService()->setService( - $entity, - $entity->getServerEntity()->getPK(), - STATUS['AVAILABLE'] - ); + $this->getServerService()->setService($entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE']); } //서비스 정보수정 $entity = parent::modify($entity, $formDatas); //신규서버정보 사용중으로 설정 if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { - $entity = $this->getServerService()->setService( - $entity, - $formDatas['serverinfo_uid'], - STATUS['OCCUPIED'] - ); + $entity->setServerEntity($this->getServerService()->setService($entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED'])); + } + //수정된 정보중 서버,결제일,청구액이 바뀐경우 결제정보에서 미납인경우 수정해준다. + if ( + $entity->getServerInfoUID() !== $formDatas['serverinfo_uid'] || + $entity->getBillingAt() !== $formDatas['billing_at'] || + $entity->getAmount() !== $formDatas['amount'] + ) { + $paymentEntity = $this->getPaymentService()->getEntity(['serviceinfo_uid' => $entity->getPK(), 'status' => STATUS['UNPAID']]); + if (!($paymentEntity instanceof PaymentEntity)) { + throw new \Exception("{$entity->getPK()}에 해당하는 미결제정보를 찾을수 없습니다."); + } + $paymentDatas = []; + $paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID(); + $paymentDatas['serviceinfo_uid'] = $entity->getPK(); + $paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID(); + $paymentDatas['title'] = sprintf("[%s] 서비스", $entity->getServerEntity()->getTitle()); + $paymentDatas['amount'] = $entity->getAmount(); + $paymentDatas['billing'] = PAYMENT['BILLING']['MONTH']; + $paymentDatas['billing_at'] = $entity->getBillingAt(); + $this->getPaymentService()->modify($paymentEntity, $paymentDatas); } return $entity; } @@ -242,11 +262,7 @@ class ServiceService extends CustomerService public function delete(mixed $entity): ServiceEntity { //기존서버정보 사용가능으로 설정 - $entity = $this->getServerService()->setService( - $entity, - $entity->getServerEntity()->getPK(), - STATUS['AVAILABLE'] - ); + $this->getServerService()->setService($entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE']); return parent::delete($entity); } //History diff --git a/app/Services/Equipment/PartService.php b/app/Services/Equipment/PartService.php index 4e0ef6d..1fe65d5 100644 --- a/app/Services/Equipment/PartService.php +++ b/app/Services/Equipment/PartService.php @@ -6,8 +6,9 @@ use App\Entities\Equipment\PartEntity; use App\Entities\Equipment\ServerPartEntity; use App\Helpers\Equipment\PartHelper; use App\Models\Equipment\PartModel; +use App\Interfaces\Equipment\ServerPartInterface; -class PartService extends EquipmentService +class PartService extends EquipmentService implements ServerPartInterface { public function __construct() { diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index 27b3486..efdae99 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -210,8 +210,23 @@ class ServerPartService extends EquipmentService $entity = $entity->setPartEntity( $this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED']) ); - //일회성인경우 결제정보에 추가한다. - $this->getPaymentService()->setServerPart($entity); + //기본 부품이 아닌경우 결제정보에 추가한다. + if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) { + if ($entity->getBilling() === PAYMENT['BILLING']['ONETIME']) { + if ($entity->getServiceInfoUID() === null) { + throw new \Exception("일회성 부품 추가는 서비스정보가 정의된 후에만 가능합니다."); + } + } + $paymentDatas = []; + $paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID(); + $paymentDatas['serviceinfo_uid'] = $entity->getServiceInfoUID(); + $paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID(); + $paymentDatas['title'] = sprintf("[%s] 부품정보", $entity->getPartEntity()->getTitle()); + $paymentDatas['amount'] = $entity->getAmount(); + $paymentDatas['billing'] = $entity->getBilling(); + $paymentDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리 + $this->getPaymentService()->create($paymentDatas); + } return $entity; } //수정 @@ -235,9 +250,10 @@ class ServerPartService extends EquipmentService //기존 정보변경 $entity = parent::modify($entity, $formDatas); //부품연결정보에 부품정보 정의 - return $entity->setPartEntity( - $this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED']) - ); + if ($entity->getPartUID() != $formDatas['part_uid']) { + $entity->setPartEntity($this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED'])); + } + return $entity; } //삭제 public function delete(mixed $entity): ServerPartEntity