dbmsv2 init...1
This commit is contained in:
parent
9bd48d3f00
commit
dccdc115c8
@ -5,10 +5,8 @@ namespace App\Controllers\Admin\Customer;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Libraries\LogCollector;
|
||||
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\PaymentService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
@ -5,7 +5,7 @@ namespace App\Services\Customer;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Helpers\Customer\ClientHelper;
|
||||
use App\Models\Customer\ClientModel;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\PaymentService;
|
||||
|
||||
class ClientService extends CustomerService
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ use App\Helpers\Customer\ServiceHelper;
|
||||
use App\Models\Customer\ServiceModel;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Traits\IPTrait;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\PaymentService;
|
||||
|
||||
class ServiceService extends CustomerService
|
||||
{
|
||||
|
||||
@ -7,7 +7,8 @@ use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Helpers\Equipment\ServerPartHelper;
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\Payment\CreatePayment;
|
||||
use App\Services\Payment\ModifyPayment;
|
||||
|
||||
class ServerPartService extends EquipmentService
|
||||
{
|
||||
@ -15,7 +16,8 @@ class ServerPartService extends EquipmentService
|
||||
private ?PartService $_partService = null;
|
||||
private ?IPService $_ipService = null;
|
||||
private ?CSService $_csService = null;
|
||||
private ?PaymentService $_paymentService = null;
|
||||
private ?CreatePayment $_creatPayment = null;
|
||||
private ?ModifyPayment $_modifyPayment = null;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new ServerPartModel(), new ServerPartHelper());
|
||||
@ -98,12 +100,22 @@ class ServerPartService extends EquipmentService
|
||||
return $this->_csService;
|
||||
}
|
||||
|
||||
final public function getPaymentService(): PaymentService
|
||||
final public function getPaymentService(string $action): CreatePayment|ModifyPayment
|
||||
{
|
||||
if (!$this->_paymentService) {
|
||||
$this->_paymentService = new PaymentService();
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
if (!$this->_modifyPayment) {
|
||||
$this->_modifyPayment = new ModifyPayment();
|
||||
}
|
||||
$paymentService = $this->_modifyPayment;
|
||||
break;
|
||||
default:
|
||||
if (!$this->_creatPayment) {
|
||||
$this->_creatPayment = new CreatePayment();
|
||||
}
|
||||
return $this->_creatPayment;
|
||||
}
|
||||
return $this->_paymentService;
|
||||
return $paymentService;
|
||||
}
|
||||
//partEntity 정보 추가
|
||||
protected function getEntity_process(mixed $entity): ServerPartEntity
|
||||
@ -228,7 +240,7 @@ class ServerPartService extends EquipmentService
|
||||
//부품정보 설정
|
||||
$entity = $this->setServerPart($entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
|
||||
//결제관련정보 설정
|
||||
$entity = $this->getPaymentService()->setServerPart($entity);
|
||||
$entity = $this->getPaymentService(__FUNCTION__)->setServerPart($entity);
|
||||
return $entity;
|
||||
}
|
||||
//수정
|
||||
@ -256,7 +268,7 @@ class ServerPartService extends EquipmentService
|
||||
$entity = $this->setServerPart($entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
|
||||
}
|
||||
//결제관련정보 정의
|
||||
$entity = $this->getPaymentService()->setServerPart($entity, ['action' => __FUNCTION__]);
|
||||
$entity = $this->getPaymentService(__FUNCTION__)->setServerPart($entity, ['action' => __FUNCTION__]);
|
||||
return $entity;
|
||||
}
|
||||
//삭제
|
||||
|
||||
24
app/Services/Payment/CreatePayment.php
Normal file
24
app/Services/Payment/CreatePayment.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Payment;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
|
||||
class CreatePayment extends PaymentService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
//서버연결정보용 등록
|
||||
protected function setServerPart_process(ServerPartEntity $serverPartEntity, ServiceEntity $serviceEntity, array $formDatas): serverPartEntity
|
||||
{
|
||||
$serverPartEntity = parent::setServerPart_process($serverPartEntity, $serviceEntity, $formDatas);
|
||||
//지급기한일 설정
|
||||
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
|
||||
$entity = $this->create($formDatas);
|
||||
return $serverPartEntity;
|
||||
}
|
||||
}
|
||||
30
app/Services/Payment/ModifyPayment.php
Normal file
30
app/Services/Payment/ModifyPayment.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Payment;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
|
||||
class ModifyPayment extends PaymentService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
//서버연결정보용 수정
|
||||
protected function setServerPart_process(ServerPartEntity $serverPartEntity, ServiceEntity $serviceEntity, array $formDatas): serverPartEntity
|
||||
{
|
||||
$serverPartEntity = parent::setServerPart_process($serverPartEntity, $serviceEntity, $formDatas);
|
||||
if (!array_key_exists('serverpartinfo_uid', $formDatas)) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류발생: 기존 결제정보가 지정되지 않았습니다.");
|
||||
}
|
||||
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK(), 'status' => STATUS['UNPAID']]);
|
||||
if (!$entity instanceof PaymentEntity) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
||||
}
|
||||
$entity = $this->modify($entity, $formDatas);
|
||||
return $serverPartEntity;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
namespace App\Services\Payment;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
@ -8,6 +8,7 @@ use App\Entities\PaymentEntity;
|
||||
use App\Helpers\PaymentHelper;
|
||||
use App\Interfaces\Equipment\ServerPartInterface;
|
||||
use App\Models\PaymentModel;
|
||||
use App\Services\CommonService;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\UserService;
|
||||
@ -116,7 +117,7 @@ class PaymentService extends CommonService implements ServerPartInterface
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
final public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
{
|
||||
$this->getModel()->orderBy('billing_at ASC');
|
||||
parent::setOrderBy($field, $value);
|
||||
@ -132,20 +133,23 @@ class PaymentService extends CommonService implements ServerPartInterface
|
||||
->get()->getResult();
|
||||
}
|
||||
//생성
|
||||
public function create(array $formDatas): PaymentEntity
|
||||
final public function create(array $formDatas): PaymentEntity
|
||||
{
|
||||
// 관리자 UID는 현재 인증된 사용자로 설정
|
||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
//수정
|
||||
public function modify(mixed $entity, array $formDatas): PaymentEntity
|
||||
final public function modify(mixed $entity, array $formDatas): PaymentEntity
|
||||
{
|
||||
// 관리자 UID는 현재 인증된 사용자로 설정
|
||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||
return parent::modify($entity, $formDatas);
|
||||
}
|
||||
//서버연결정보용 등록
|
||||
protected function setServerPart_process(ServerPartEntity $serverPartEntity, ServiceEntity $serviceEntity, array $formDatas): serverPartEntity
|
||||
{
|
||||
return $serverPartEntity;
|
||||
}
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): ServerPartEntity
|
||||
{
|
||||
if ($serverPartEntity->getServiceInfoUID() === null) {
|
||||
@ -156,13 +160,6 @@ class PaymentService extends CommonService implements ServerPartInterface
|
||||
if (!$serviceEntity) {
|
||||
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
|
||||
}
|
||||
//수정인경우 기존 결제정보 가져오기
|
||||
if (array_key_exists('action', $formDatas) && $formDatas['action'] === 'modify') {
|
||||
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK()]);
|
||||
if (!$entity instanceof PaymentEntity) {
|
||||
throw new \Exception("{$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
||||
}
|
||||
}
|
||||
//월비용인경우 서비스 제공가에 서버연결정보 제공가 합산금액으로 설정
|
||||
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
||||
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
|
||||
@ -179,17 +176,11 @@ class PaymentService extends CommonService implements ServerPartInterface
|
||||
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
|
||||
$formDatas['amount'] = $serverPartEntity->getAmount();
|
||||
$formDatas['billing'] = $serverPartEntity->getBilling();
|
||||
if (array_key_exists('action', $formDatas) && $formDatas['action'] === 'modify') {
|
||||
$this->modify($entity, $formDatas);
|
||||
} else {
|
||||
//생성일때만 지급기한일 설정
|
||||
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
|
||||
$this->create($formDatas);
|
||||
}
|
||||
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
|
||||
$serverPartEntity = $this->setServerPart_process($serverPartEntity, $serviceEntity, $formDatas);
|
||||
}
|
||||
return $serverPartEntity;
|
||||
}
|
||||
|
||||
//서비스정보용 등록
|
||||
public function service(ServiceEntity $serviceEntity, array $formDatas = []): ServiceEntity
|
||||
{
|
||||
Loading…
Reference in New Issue
Block a user