dbmsv4 init...2
This commit is contained in:
parent
fba37415c4
commit
d94c03b672
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Entities\CommonEntity;
|
|
||||||
use CodeIgniter\HTTP\DownloadResponse;
|
use CodeIgniter\HTTP\DownloadResponse;
|
||||||
use CodeIgniter\HTTP\RedirectResponse;
|
use CodeIgniter\HTTP\RedirectResponse;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
|||||||
@ -176,28 +176,33 @@ class ServiceService extends CustomerService
|
|||||||
return $date->format('Y-m-d');
|
return $date->format('Y-m-d');
|
||||||
}
|
}
|
||||||
// 서비스금액관련처리
|
// 서비스금액관련처리
|
||||||
final public function getCalculatedAmount(int $serverinfo_uid, int $rack, int $line, int $sale): int
|
private function getCacluatedAmount(ServiceEntity $entity): int
|
||||||
{
|
{
|
||||||
$server_amount = service('equipment_serverservice')->getCalculatedAmount($serverinfo_uid);
|
//총 서비스금액 구하기
|
||||||
|
$server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID());
|
||||||
//기본:서버금액(서버비+서버파트(월비용))+상면비+회선비-할인액
|
//기본:서버금액(서버비+서버파트(월비용))+상면비+회선비-할인액
|
||||||
$amount = (int)$server_amount + $rack + $line - $sale;
|
$caculatedAmount = (int)$server_amount + $entity->getRack() + $entity->getLine() - $entity->getSale();
|
||||||
// echo "{$server_amount} + {$rack} + $line - {$sale} = {$amount}";
|
return $caculatedAmount;
|
||||||
// exit;
|
|
||||||
return $amount;
|
|
||||||
}
|
}
|
||||||
private function updateAmount(ServiceEntity $entity): ServiceEntity
|
final public function updateAmount(int $uid): ServiceEntity
|
||||||
{
|
{
|
||||||
|
$entity = $this->getEntity($uid);
|
||||||
|
if (!$entity instanceof ServiceEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid} 서비스 정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
$action = 'modify';
|
$action = 'modify';
|
||||||
$fields = ['amount'];
|
$fields = ['amount'];
|
||||||
$this->getFormService()->setFormFields($fields);
|
$this->getFormService()->setFormFields($fields);
|
||||||
$this->getFormService()->setFormRules($action, $fields);
|
$this->getFormService()->setFormRules($action, $fields);
|
||||||
$formDatas['amount'] = $this->getCalculatedAmount(
|
$formDatas['amount'] = $this->getCacluatedAmount($entity);
|
||||||
$entity->getServerInfoUID(),
|
$result = $this->model->update($entity->getPK(), $formDatas);
|
||||||
$entity->getRack(),
|
log_message('debug', $this->model->getLastQuery());
|
||||||
$entity->getLine(),
|
if ($result === false) {
|
||||||
$entity->getSale()
|
$errors = $this->model->errors();
|
||||||
);
|
$errorMsg = is_array($errors) ? implode(", ", $errors) : "서비스 금액설정 실패했습니다.";
|
||||||
return parent::modify_process($entity, $formDatas);
|
throw new RuntimeException(__METHOD__ . "에서 오류발생: " . $errorMsg);
|
||||||
|
}
|
||||||
|
return $this->getEntity($uid);
|
||||||
}
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
protected function getEntity_process(mixed $entity): ServiceEntity
|
protected function getEntity_process(mixed $entity): ServiceEntity
|
||||||
@ -218,10 +223,10 @@ class ServiceService extends CustomerService
|
|||||||
if (!$entity instanceof ServiceEntity) {
|
if (!$entity instanceof ServiceEntity) {
|
||||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||||
}
|
}
|
||||||
//서비스비용 설정
|
|
||||||
$entity = $this->updateAmount($entity);
|
|
||||||
//서버정보 연결
|
//서버정보 연결
|
||||||
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
|
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
|
||||||
|
//서비스비용 설정
|
||||||
|
$entity = $this->updateAmount($entity->getPK());
|
||||||
//결제정보 생성
|
//결제정보 생성
|
||||||
service('paymentservice')->createByService($entity);
|
service('paymentservice')->createByService($entity);
|
||||||
return $entity;
|
return $entity;
|
||||||
@ -239,14 +244,14 @@ class ServiceService extends CustomerService
|
|||||||
if (!$entity instanceof ServiceEntity) {
|
if (!$entity instanceof ServiceEntity) {
|
||||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||||
}
|
}
|
||||||
//서비스비용 설정
|
|
||||||
$entity = $this->updateAmount($entity);
|
|
||||||
//서버정보 연결 신규서버로 변경되었으면 신규서버 추가
|
//서버정보 연결 신규서버로 변경되었으면 신규서버 추가
|
||||||
if ($oldEntity->getServerInfoUID() !== $entity->getServerInfoUID()) {
|
if ($oldEntity->getServerInfoUID() !== $entity->getServerInfoUID()) {
|
||||||
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
|
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
|
||||||
}
|
}
|
||||||
//결제정보 수정
|
//서비스비용 설정
|
||||||
service('paymentservice')->modifyByService($entity);
|
$entity = $this->updateAmount($entity->getPK());
|
||||||
|
//결제정보 생성
|
||||||
|
service('paymentservice')->createByService($entity);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//List 검색용
|
//List 검색용
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use App\Forms\Equipment\ServerPartForm;
|
|||||||
use App\Entities\Part\PartEntity;
|
use App\Entities\Part\PartEntity;
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\CommonEntity;
|
use App\Entities\CommonEntity;
|
||||||
use App\DTOs\Equipment\ServerPartDTO;
|
use App\DTOs\Equipment\ServerPartDTO;
|
||||||
|
|
||||||
@ -132,6 +133,14 @@ class ServerPartService extends EquipmentService
|
|||||||
}
|
}
|
||||||
//해당 파트별 설정 수정
|
//해당 파트별 설정 수정
|
||||||
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
||||||
|
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
|
||||||
|
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) { //Billing형식이 Month이면 서비스 금액설정 호출
|
||||||
|
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
|
||||||
|
}
|
||||||
|
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) { //Billing형식이 Onetime이면 일회성결제 추가
|
||||||
|
service('paymentservice')->createByServerPart($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function modify_process($entity, array $formDatas): ServerPartEntity
|
protected function modify_process($entity, array $formDatas): ServerPartEntity
|
||||||
@ -144,7 +153,16 @@ class ServerPartService extends EquipmentService
|
|||||||
//해당 파트정보 Title 설정용
|
//해당 파트정보 Title 설정용
|
||||||
$formDatas['title'] = $partEntity->getTitle();
|
$formDatas['title'] = $partEntity->getTitle();
|
||||||
//서버파트 수정
|
//서버파트 수정
|
||||||
return parent::modify_process($entity, $formDatas);
|
$entity = parent::modify_process($entity, $formDatas);
|
||||||
|
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
|
||||||
|
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) { //Billing형식이 Month이면 서비스 금액설정 호출
|
||||||
|
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
|
||||||
|
}
|
||||||
|
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) { //Billing형식이 Onetime이면 일회성결제 추가
|
||||||
|
service('paymentservice')->modifyByServerPart($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function delete_process($entity): ServerPartEntity
|
protected function delete_process($entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
@ -166,7 +184,7 @@ class ServerPartService extends EquipmentService
|
|||||||
//해당 파트정보 가져오기
|
//해당 파트정보 가져오기
|
||||||
$partEntity = $this->getPartService($parttype)->getEntity($part['UID']);
|
$partEntity = $this->getPartService($parttype)->getEntity($part['UID']);
|
||||||
if (!$partEntity instanceof PartEntity) {
|
if (!$partEntity instanceof PartEntity) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: {$part['UID']} 서버 정보를 찾을수 없습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$part['UID']} 파트정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//서버파트정보 생성
|
//서버파트정보 생성
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
|
|||||||
@ -119,35 +119,6 @@ class ServerService extends EquipmentService
|
|||||||
$this->getFormService()->setIndexFilters($indexFilter);
|
$this->getFormService()->setIndexFilters($indexFilter);
|
||||||
$this->getFormService()->setBatchjobFilters($batchjobFilters);
|
$this->getFormService()->setBatchjobFilters($batchjobFilters);
|
||||||
}
|
}
|
||||||
//기본 기능부분
|
|
||||||
protected function getEntity_process(mixed $entity): ServerEntity
|
|
||||||
{
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
protected function create_process(array $formDatas): ServerEntity
|
|
||||||
{
|
|
||||||
$entity = parent::create_process($formDatas);
|
|
||||||
if (!$entity instanceof ServerEntity) {
|
|
||||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
|
||||||
}
|
|
||||||
//서버추가시 서버파트 자동추가용
|
|
||||||
service('part_ipservice')->attachToServer($entity);
|
|
||||||
service('part_switchservice')->attachToServer($entity);
|
|
||||||
service('equipment_serverpartservice')->attachToServer($entity);
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
protected function modify_process($entity, array $formDatas): ServerEntity
|
|
||||||
{
|
|
||||||
$entity = parent::modify_process($entity, $formDatas);
|
|
||||||
if (!$entity instanceof ServerEntity) {
|
|
||||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
//List 검색용
|
|
||||||
//FormFilter 조건절 처리
|
|
||||||
//검색어조건절처리
|
|
||||||
//추가기능
|
|
||||||
final public function getTotalServiceCount(array $where = []): array
|
final public function getTotalServiceCount(array $where = []): array
|
||||||
{
|
{
|
||||||
$totalCounts = [
|
$totalCounts = [
|
||||||
@ -217,9 +188,12 @@ class ServerService extends EquipmentService
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
//총서버금액
|
//총서버금액
|
||||||
public function getCalculatedAmount(int $uid): int
|
final public function getCacluatedAmount(int $uid): int
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($uid);
|
$entity = $this->getEntity($uid);
|
||||||
|
if (!$entity instanceof ServerEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid} 서버 정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
$serverPartService = service('equipment_serverpartservice');
|
$serverPartService = service('equipment_serverpartservice');
|
||||||
$caculatedAmount = $entity->getPrice();
|
$caculatedAmount = $entity->getPrice();
|
||||||
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart찾아서 월청구액에 합산한다.
|
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart찾아서 월청구액에 합산한다.
|
||||||
@ -228,6 +202,39 @@ class ServerService extends EquipmentService
|
|||||||
}
|
}
|
||||||
return $caculatedAmount;
|
return $caculatedAmount;
|
||||||
}
|
}
|
||||||
|
//기본 기능부분
|
||||||
|
protected function getEntity_process(mixed $entity): ServerEntity
|
||||||
|
{
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
protected function create_process(array $formDatas): ServerEntity
|
||||||
|
{
|
||||||
|
$entity = parent::create_process($formDatas);
|
||||||
|
if (!$entity instanceof ServerEntity) {
|
||||||
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||||
|
}
|
||||||
|
//서버추가시 서버파트 자동추가용
|
||||||
|
service('part_ipservice')->attachToServer($entity);
|
||||||
|
service('part_switchservice')->attachToServer($entity);
|
||||||
|
service('equipment_serverpartservice')->attachToServer($entity);
|
||||||
|
//Billing형식이 Month이면 서버쪽 금액설정 호출
|
||||||
|
if ($entity->getServiceInfoUID() !== null) {
|
||||||
|
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
protected function modify_process($entity, array $formDatas): ServerEntity
|
||||||
|
{
|
||||||
|
$entity = parent::modify_process($entity, $formDatas);
|
||||||
|
if (!$entity instanceof ServerEntity) {
|
||||||
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||||
|
}
|
||||||
|
//Billing형식이 Month이면 서버쪽 금액설정 호출
|
||||||
|
if ($entity->getServiceInfoUID() !== null) {
|
||||||
|
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
//List 검색용
|
//List 검색용
|
||||||
//FormFilter 조건절 처리
|
//FormFilter 조건절 처리
|
||||||
//검색어조건절처리
|
//검색어조건절처리
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user