dbmsv2 init...1
This commit is contained in:
parent
93c9ba201e
commit
8ca711f32b
File diff suppressed because one or more lines are too long
@ -163,7 +163,7 @@ abstract class CommonModel extends Model
|
|||||||
var_export($this->errors(), true),
|
var_export($this->errors(), true),
|
||||||
$this->getLastQuery()
|
$this->getLastQuery()
|
||||||
);
|
);
|
||||||
LogCollector::debug($message);
|
log_message('error', $message);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
//Model별 returntype형의 Entity 호출
|
//Model별 returntype형의 Entity 호출
|
||||||
@ -199,7 +199,7 @@ abstract class CommonModel extends Model
|
|||||||
__METHOD__,
|
__METHOD__,
|
||||||
var_export($this->errors(), true)
|
var_export($this->errors(), true)
|
||||||
);
|
);
|
||||||
LogCollector::debug($message);
|
log_message('error', $message);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -300,28 +300,28 @@ abstract class CommonService
|
|||||||
//생성
|
//생성
|
||||||
public function create(array $formDatas): mixed
|
public function create(array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$entity = $this->getModel()->create($formDatas);
|
$entity = $this->getEntity_process($this->getModel()->create($formDatas));
|
||||||
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["CREATED"] . ":");
|
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["CREATED"] . ":");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): mixed
|
public function modify(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
$entity = $this->getEntity_process($this->getModel()->modify($entity, $formDatas));
|
||||||
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//단일작업
|
//단일작업
|
||||||
public function toggle(mixed $entity, array $formDatas): mixed
|
public function toggle(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
$entity = $this->getEntity_process($this->getModel()->modify($entity, $formDatas));
|
||||||
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//일괄처리작업
|
//일괄처리작업
|
||||||
public function batchjob(mixed $entity, array $formDatas): mixed
|
public function batchjob(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
$entity = $this->getEntity_process($this->getModel()->modify($entity, $formDatas));
|
||||||
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
// LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,15 @@ use App\Entities\Equipment\ServerEntity;
|
|||||||
use App\Entities\PaymentEntity;
|
use App\Entities\PaymentEntity;
|
||||||
use App\Helpers\Customer\ServiceHelper;
|
use App\Helpers\Customer\ServiceHelper;
|
||||||
use App\Models\Customer\ServiceModel;
|
use App\Models\Customer\ServiceModel;
|
||||||
use App\Services\Customer\Service\ServerService;
|
|
||||||
use App\Services\Customer\Service\PaymentService;
|
use App\Services\Customer\Service\PaymentService;
|
||||||
|
use App\Services\Customer\Service\ServerService;
|
||||||
|
use App\Services\Equipment\ServerPartService;
|
||||||
|
|
||||||
class ServiceService extends CustomerService
|
class ServiceService extends CustomerService
|
||||||
{
|
{
|
||||||
private ?ServerService $_serverService = null;
|
private ?ServerService $_serverService = null;
|
||||||
private ?PaymentService $_paymentService = null;
|
private ?PaymentService $_paymentService = null;
|
||||||
|
private ?ServerPartService $_serverPartService = null;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(new ServiceModel(), new ServiceHelper());
|
parent::__construct(new ServiceModel(), new ServiceHelper());
|
||||||
@ -101,7 +103,7 @@ class ServiceService extends CustomerService
|
|||||||
throw new \Exception(__METHOD__ . "에서 형식오류:ServiceEntity만 허용됩니다.");
|
throw new \Exception(__METHOD__ . "에서 형식오류:ServiceEntity만 허용됩니다.");
|
||||||
}
|
}
|
||||||
//서버정보 정의
|
//서버정보 정의
|
||||||
$serverEntity = $this->getServerService()->getEntity(['serviceinfo_uid' => $entity->getPK()]);
|
$serverEntity = $this->getServerService()->getEntity($entity->getServerInfoUID());
|
||||||
if ($serverEntity instanceof ServerEntity) {
|
if ($serverEntity instanceof ServerEntity) {
|
||||||
$entity->setServerEntity($serverEntity);
|
$entity->setServerEntity($serverEntity);
|
||||||
}
|
}
|
||||||
@ -128,6 +130,13 @@ class ServiceService extends CustomerService
|
|||||||
}
|
}
|
||||||
return $this->_serverService;
|
return $this->_serverService;
|
||||||
}
|
}
|
||||||
|
final public function getServerPartService(): ServerPartService
|
||||||
|
{
|
||||||
|
if (!$this->_serverPartService) {
|
||||||
|
$this->_serverPartService = new ServerPartService();
|
||||||
|
}
|
||||||
|
return $this->_serverPartService;
|
||||||
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
public function getFormOption(string $field, array $options = []): array
|
public function getFormOption(string $field, array $options = []): array
|
||||||
{
|
{
|
||||||
@ -213,6 +222,21 @@ class ServiceService extends CustomerService
|
|||||||
) WHERE billing_at = ? AND status = ?";
|
) WHERE billing_at = ? AND status = ?";
|
||||||
return $this->getModel()->query($sql, [$billing_at, $status]);
|
return $this->getModel()->query($sql, [$billing_at, $status]);
|
||||||
}
|
}
|
||||||
|
final public function getCaculatedAmount(int $uid): int
|
||||||
|
{
|
||||||
|
$entity = $this->getEntity($uid);
|
||||||
|
if (!$entity instanceof ServiceEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 서비스정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
$total_amount = $entity->getAmount(); //기본:상면비+회선비+서버금액(price)
|
||||||
|
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
|
||||||
|
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getServerEntity()->getPK()]) as $serverPartEntity) {
|
||||||
|
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
||||||
|
$total_amount += $serverPartEntity->getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $total_amount;
|
||||||
|
}
|
||||||
//기본기능
|
//기본기능
|
||||||
//Action 기능
|
//Action 기능
|
||||||
private function action_process(ServiceEntity $entity, string $action): ServiceEntity
|
private function action_process(ServiceEntity $entity, string $action): ServiceEntity
|
||||||
@ -221,7 +245,6 @@ class ServiceService extends CustomerService
|
|||||||
$entity = $this->getServerService()->$action($entity);
|
$entity = $this->getServerService()->$action($entity);
|
||||||
$entity = $this->getPaymentService()->$action($entity);
|
$entity = $this->getPaymentService()->$action($entity);
|
||||||
//결제정보PK정의
|
//결제정보PK정의
|
||||||
dd($entity);
|
|
||||||
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
|
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
@ -229,28 +252,25 @@ class ServiceService extends CustomerService
|
|||||||
public function create(array $formDatas): ServiceEntity
|
public function create(array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
throw new \Exception("서버가 지정되지 않았습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서버가 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
//신규등록(월청구액 전달값 그대로 사용)
|
//신규등록(월청구액 전달값 그대로 사용)
|
||||||
$entity = $this->getEntity(parent::create($formDatas)->getPK());
|
$entity = parent::create($formDatas);
|
||||||
//후처리작업
|
//후처리작업
|
||||||
return $this->action_process($entity, __FUNCTION__ . 'Service');
|
return $this->action_process($entity, __FUNCTION__ . 'Service');
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
|
||||||
throw new \Exception("서버가 지정되지 않았습니다.");
|
|
||||||
}
|
|
||||||
//기존 서버정보 해지
|
//기존 서버정보 해지
|
||||||
if ($entity->getServerEntity()->getPK() !== $formDatas['serverinfo_uid']) {
|
if (array_key_exists('serverinfo_uid', $formDatas) && $entity->getServerEntity()->getPK() != $formDatas['serverinfo_uid']) {
|
||||||
$entity->getServerService()->deleteService($entity);
|
$entity->getServerService()->deleteService($entity);
|
||||||
}
|
}
|
||||||
//수정작업(월청구액계산 확인 후 서비스정보에 수정)
|
//수정작업(월청구액계산 확인 후 서비스정보에 수정)
|
||||||
$entity = $this->getEntity(parent::modify(
|
$entity = parent::modify(
|
||||||
$entity,
|
$entity,
|
||||||
['amount' => $this->getServerService()->getTotalAmount($entity->getServerEntity()->getPK())]
|
['amount' => $this->getCaculatedAmount($entity->getPK())]
|
||||||
)->getPK());
|
);
|
||||||
//후처리작업
|
//후처리작업
|
||||||
return $this->action_process($entity, __FUNCTION__ . 'Service');
|
return $this->action_process($entity, __FUNCTION__ . 'Service');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,6 @@ class ServerService extends EquipmentService
|
|||||||
public function getFormFields(): array
|
public function getFormFields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"clientinfo_uid",
|
|
||||||
"serviceinfo_uid",
|
|
||||||
"code",
|
"code",
|
||||||
"type",
|
"type",
|
||||||
"title",
|
"title",
|
||||||
@ -34,8 +32,6 @@ class ServerService extends EquipmentService
|
|||||||
public function getFormFilters(): array
|
public function getFormFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"clientinfo_uid",
|
|
||||||
"serviceinfo_uid",
|
|
||||||
"type",
|
"type",
|
||||||
"title",
|
"title",
|
||||||
"status"
|
"status"
|
||||||
@ -91,21 +87,6 @@ class ServerService extends EquipmentService
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final public function getTotalAmount(int $uid): int
|
|
||||||
{
|
|
||||||
$entity = $this->getEntity($uid);
|
|
||||||
if (!$entity instanceof ServerEntity) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 서버정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$total_amount = $entity->getPrice(); //서버금액(price)
|
|
||||||
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
|
|
||||||
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
|
|
||||||
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
|
||||||
$total_amount += $serverPartEntity->getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $total_amount;
|
|
||||||
}
|
|
||||||
//create용 장비코드 마지막번호 가져오기
|
//create용 장비코드 마지막번호 가져오기
|
||||||
final public function getLastestCode(string $format, int $default): string
|
final public function getLastestCode(string $format, int $default): string
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user