dbmsv3 init...1

This commit is contained in:
choi.jh 2025-10-13 14:57:04 +09:00
parent ead109480b
commit 7e0b413a6b
16 changed files with 173 additions and 69 deletions

View File

@ -66,7 +66,7 @@ class ServerController extends EquipmentController
protected function modify_form_process(mixed $entity): ServerEntity protected function modify_form_process(mixed $entity): ServerEntity
{ {
$ips = []; $ips = [];
foreach ($this->getService()->getIPService()->getEntities('ip = "' . $entity->getIP() . '" OR status = "' . STATUS['AVAILABLE'] . '"') as $ipEntity) { foreach ($this->getService()->getIPService()->getEntities(['status' => STATUS['AVAILABLE']]) as $ipEntity) {
$ips[] = $ipEntity->getTitle(); $ips[] = $ipEntity->getTitle();
} }
$this->ips = $ips; $this->ips = $ips;

View File

@ -133,7 +133,7 @@ class SearchController extends AdminController
$this->getService()->setFormOptions(); $this->getService()->setFormOptions();
helper(['form']); helper(['form']);
//Return Url정의 //Return Url정의
$this->getService()->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$entities = $this->index_process(); $entities = $this->index_process();
$this->total_count = count($entities); $this->total_count = count($entities);
$this->page_options = []; $this->page_options = [];

View File

@ -49,7 +49,7 @@ class UserController extends AdminController
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]); $result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break; break;
case 'profile_modify': case 'profile_modify':
$this->getMyLogService()->save($this->getService()->getClassName(), $this->getService()->getAction(), $message, $this->getService()->getMyAuth()->getUIDByAuthInfo()); $this->getMyLogService()->save($this->getService()->getClassName(), $this->getService()->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
$result = $this->view($this->entity->getPK()); $result = $this->view($this->entity->getPK());
break; break;
default: default:

View File

@ -29,13 +29,13 @@ abstract class AuthController extends CommonController
if ($this->request->getMethod() === 'POST') { if ($this->request->getMethod() === 'POST') {
return redirect()->back()->withInput()->with('error', $message); return redirect()->back()->withInput()->with('error', $message);
} }
return redirect()->to($this->getService()->getMyAuth()->popPreviousUrl())->with('error', $message); return redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
} }
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
switch ($this->getService()->getAction()) { switch ($this->getService()->getAction()) {
case 'create': //Login처리 case 'create': //Login처리
$result = redirect()->to($this->getService()->getMyAuth()->popPreviousUrl())->with('error', $message); $result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
break; break;
default: default:
$result = parent::getResultSuccess($message, $actionTemplate); $result = parent::getResultSuccess($message, $actionTemplate);

View File

@ -20,6 +20,7 @@ use Psr\Log\LoggerInterface;
abstract class CommonController extends BaseController abstract class CommonController extends BaseController
{ {
private $_myAuth = null;
private ?MyLogService $_myLogService = null; private ?MyLogService $_myLogService = null;
private $_viewDatas = []; private $_viewDatas = [];
abstract public function getService(): mixed; abstract public function getService(): mixed;
@ -28,10 +29,10 @@ abstract class CommonController extends BaseController
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
$this->isLoggedIn = false; $this->isLoggedIn = false;
$this->uri = $request->getUri(); $this->uri = $request->getUri();
if ($this->getService()->getMyAuth()->isLoggedIn()) { if ($this->getMyAuth()->isLoggedIn()) {
$this->isLoggedIn = true; $this->isLoggedIn = true;
$this->myAuthName = $this->getService()->getMyAuth()->getNameByAuthInfo(); $this->myAuthName = $this->getMyAuth()->getNameByAuthInfo();
$this->myAuthUID = $this->getService()->getMyAuth()->getUIDByAuthInfo(); $this->myAuthUID = $this->getMyAuth()->getUIDByAuthInfo();
} }
} }
final public function __get($name) final public function __get($name)
@ -45,6 +46,13 @@ abstract class CommonController extends BaseController
{ {
$this->_viewDatas[$name] = $value; $this->_viewDatas[$name] = $value;
} }
final public function getMyAuth(): mixed
{
if (!$this->_myAuth) {
$this->_myAuth = service('myauth');
}
return $this->_myAuth;
}
final protected function getViewDatas(): array final protected function getViewDatas(): array
{ {
return $this->_viewDatas; return $this->_viewDatas;
@ -88,11 +96,11 @@ abstract class CommonController extends BaseController
//Process Result처리 //Process Result처리
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse
{ {
// $this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getService()->getMyAuth()->getUIDByAuthInfo()); // $this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
if ($this->request->getMethod() === 'POST') { if ($this->request->getMethod() === 'POST') {
return redirect()->back()->withInput()->with('error', $message); return redirect()->back()->withInput()->with('error', $message);
} }
return redirect()->to($this->getService()->getMyAuth()->popPreviousUrl())->with('error', $message); return redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
} }
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
@ -100,7 +108,7 @@ abstract class CommonController extends BaseController
switch ($this->getService()->getControlDatas('action')) { switch ($this->getService()->getControlDatas('action')) {
case 'create': case 'create':
case 'modify': case 'modify':
// $this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getService()->getMyAuth()->getUIDByAuthInfo()); // $this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
$result = $this->view($this->entity->getPK()); $result = $this->view($this->entity->getPK());
break; break;
case 'create_form': case 'create_form':
@ -121,7 +129,7 @@ abstract class CommonController extends BaseController
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]); $result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break; break;
default: default:
$result = redirect()->to($this->getService()->getMyAuth()->popPreviousUrl())->with('error', $message); $result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
break; break;
} }
return $result; return $result;
@ -493,7 +501,7 @@ abstract class CommonController extends BaseController
$this->getService()->setControlDatas('batchjob_buttions', $this->getService()->getBatchjobButtons()); $this->getService()->setControlDatas('batchjob_buttions', $this->getService()->getBatchjobButtons());
helper(['form']); helper(['form']);
//Return Url정의 //Return Url정의
$this->getService()->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
//조건절 처리 //조건절 처리
$this->index_condition_process(); $this->index_condition_process();
//TotalCount (SoftDelete적용이 되려면 countAllResults를 사용해야함) //TotalCount (SoftDelete적용이 되려면 countAllResults를 사용해야함)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
<?php
namespace App\Interfaces;
use App\Entities\PaymentEntity;
interface PaymentInterface
{
public function setPayment(string $action, PaymentEntity $paymentEntity, array $formDatas): PaymentEntity;
}

View File

@ -66,6 +66,7 @@ class AccountModel extends CustomerModel
{ {
// 관리자 UID는 현재 인증된 사용자로 설정 // 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
// dd($formDatas);
return parent::modify($entity, $formDatas); return parent::modify($entity, $formDatas);
} }
} }

View File

@ -9,7 +9,6 @@ use App\Services\UserService;
abstract class CommonService abstract class CommonService
{ {
private $_myAuth = null;
private $_model = null; private $_model = null;
private $_helper = null; private $_helper = null;
private $_classNames = []; private $_classNames = [];
@ -23,13 +22,6 @@ abstract class CommonService
} }
abstract public function getFormFields(): array; abstract public function getFormFields(): array;
abstract public function getFormFilters(): array; abstract public function getFormFilters(): array;
final public function getMyAuth(): mixed
{
if (!$this->_myAuth) {
$this->_myAuth = service('myauth');
}
return $this->_myAuth;
}
final public function getHelper(): mixed final public function getHelper(): mixed
{ {
if (!$this->_helper) { if (!$this->_helper) {

View File

@ -4,10 +4,12 @@ namespace App\Services\Customer;
use App\Entities\Customer\AccountEntity; use App\Entities\Customer\AccountEntity;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\PaymentEntity;
use App\Helpers\Customer\AccountHelper; use App\Helpers\Customer\AccountHelper;
use App\Interfaces\PaymentInterface;
use App\Models\Customer\AccountModel; use App\Models\Customer\AccountModel;
class AccountService extends CustomerService class AccountService extends CustomerService implements PaymentInterface
{ {
private ?ClientService $_clientService = null; private ?ClientService $_clientService = null;
public function __construct() public function __construct()
@ -46,6 +48,27 @@ class AccountService extends CustomerService
} }
return $this->_clientService; return $this->_clientService;
} }
public function setPayment(string $action, PaymentEntity $paymentEntity, array $paymentDatas): PaymentEntity
{
switch ($action) {
case 'create':
$this->create([
'clientinfo_uid' => $paymentEntity->getClientInfoUID(),
'bank' => null,
'title' => "[결제차감] {$paymentEntity->getTitle()}",
'issue_at' => date('Y-m-d H:i:s'),
'alias' => array_key_exists('alias', $paymentDatas) ? $paymentDatas['alias'] : null,
'amount' => $paymentEntity->getAmount(),
'status' => STATUS['WIDTHDRAWAL'],
]);
break;
// case 'update':
// case 'delete':
default:
throw new \Exception(__METHOD__ . "에서 오류발생: {$action}는 지원하지 않는 기능입니다.");
}
return $paymentEntity;
}
//기본 기능부분 //기본 기능부분
//고객예치금처리 //고객예치금처리

View File

@ -140,6 +140,7 @@ class ClientService extends CustomerService
throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다."); throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다.");
// break; // break;
} }
// dd([$field => $amount]);
return parent::modify($entity, [$field => $amount]); return parent::modify($entity, [$field => $amount]);
} }
//기본 기능부분 //기본 기능부분

View File

@ -4,10 +4,12 @@ namespace App\Services\Customer;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\CouponEntity; use App\Entities\Customer\CouponEntity;
use App\Entities\PaymentEntity;
use App\Helpers\Customer\CouponHelper; use App\Helpers\Customer\CouponHelper;
use App\Interfaces\PaymentInterface;
use App\Models\Customer\CouponModel; use App\Models\Customer\CouponModel;
class CouponService extends CustomerService class CouponService extends CustomerService implements PaymentInterface
{ {
public function __construct() public function __construct()
{ {
@ -34,6 +36,26 @@ class CouponService extends CustomerService
{ {
return ['status']; return ['status'];
} }
public function setPayment(string $action, PaymentEntity $paymentEntity, array $paymentDatas): PaymentEntity
{
switch ($action) {
case 'create':
$this->create([
'clientinfo_uid' => $paymentEntity->getClientInfoUID(),
'bank' => null,
'title' => "[결제차감] {$paymentEntity->getTitle()}",
'alias' => array_key_exists('alias', $paymentDatas) ? $paymentDatas['alias'] : null,
'amount' => $paymentEntity->getAmount(),
'status' => STATUS['WIDTHDRAWAL'],
]);
break;
// case 'update':
// case 'delete':
default:
throw new \Exception(__METHOD__ . "에서 오류발생: {$action}는 지원하지 않는 기능입니다.");
}
return $paymentEntity;
}
//기본 기능부분 //기본 기능부분
//고객예치금처리 //고객예치금처리

View File

@ -4,10 +4,12 @@ namespace App\Services\Customer;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\PointEntity; use App\Entities\Customer\PointEntity;
use App\Entities\PaymentEntity;
use App\Helpers\Customer\PointHelper; use App\Helpers\Customer\PointHelper;
use App\Interfaces\PaymentInterface;
use App\Models\Customer\PointModel; use App\Models\Customer\PointModel;
class PointService extends CustomerService class PointService extends CustomerService implements PaymentInterface
{ {
private ?ClientService $_clientService = null; private ?ClientService $_clientService = null;
public function __construct() public function __construct()
@ -42,6 +44,26 @@ class PointService extends CustomerService
} }
return $this->_clientService; return $this->_clientService;
} }
public function setPayment(string $action, PaymentEntity $paymentEntity, array $paymentDatas): PaymentEntity
{
switch ($action) {
case 'create':
$this->create([
'clientinfo_uid' => $paymentEntity->getClientInfoUID(),
'bank' => null,
'title' => "[결제차감] {$paymentEntity->getTitle()}",
'alias' => array_key_exists('alias', $paymentDatas) ? $paymentDatas['alias'] : null,
'amount' => $paymentEntity->getAmount(),
'status' => STATUS['WIDTHDRAWAL'],
]);
break;
// case 'update':
// case 'delete':
default:
throw new \Exception(__METHOD__ . "에서 오류발생: {$action}는 지원하지 않는 기능입니다.");
}
return $paymentEntity;
}
//기본 기능부분 //기본 기능부분
private function setBalance(array $formDatas): void private function setBalance(array $formDatas): void
{ {

View File

@ -221,6 +221,7 @@ class ServerService extends EquipmentService implements ServiceInterface
if ($entity->getServiceInfoUID() !== null && $entity->getType() !== "alternative") { if ($entity->getServiceInfoUID() !== null && $entity->getType() !== "alternative") {
$this->getServiceService()->setAmount($this->getServiceService()->getEntity($entity->getServiceInfoUID())); $this->getServiceService()->setAmount($this->getServiceService()->getEntity($entity->getServiceInfoUID()));
} }
//IP정보 수정
if ($oldEntity->getIP() !== null) { //기존 서버정보에 IP가 정의되어 있으면 if ($oldEntity->getIP() !== null) { //기존 서버정보에 IP가 정의되어 있으면
$oldEntity = $this->getIPService()->setServer('delete', $oldEntity, []); $oldEntity = $this->getIPService()->setServer('delete', $oldEntity, []);
} }

View File

@ -133,9 +133,12 @@ class IPService extends PartService implements ServerInterface
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: IP상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: IP상태가 설정되지 않았습니다.");
} }
//IP정보가져와서 있으면 수정 //IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity(['ip' => $serverEntity->getIP()]); $entity = $this->getEntity(['ip' => $serverEntity->getIP()]);
if ($entity instanceof IPEntity) { if ($entity instanceof IPEntity) {
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: {$entity->getIP()}는 사용중인 IP입니다.");
}
$entity = parent::modify($entity, $formDatas); $entity = parent::modify($entity, $formDatas);
} }
break; break;
@ -174,16 +177,16 @@ class IPService extends PartService implements ServerInterface
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: IP상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: IP상태가 설정되지 않았습니다.");
} }
//공백 값이 아니면 //IP정보가져오기
if (!$serverPartEntity->getPartUID()) { $entity = $this->getEntity($serverPartEntity->getPartUID());
//IP정보가져오기 if (!$entity instanceof IPEntity) {
$entity = $this->getEntity($serverPartEntity->getPartUID()); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
if (!$entity instanceof IPEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
}
//IP정보 수정
$entity = parent::modify($entity, $formDatas);
} }
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":{$action}에서 오류발생: {$entity->getIP()}는 사용중인 IP입니다.");
}
//IP정보 수정
$entity = parent::modify($entity, $formDatas);
break; break;
case 'delete': //반드시 serverPartEntity 사용해야함 case 'delete': //반드시 serverPartEntity 사용해야함
$formDatas = []; $formDatas = [];

View File

@ -2,6 +2,7 @@
namespace App\Services; namespace App\Services;
use App\Entities\Customer\AccountEntity;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity; use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\ServerPartEntity;
@ -13,6 +14,8 @@ use App\Models\PaymentModel;
use App\Services\CommonService; use App\Services\CommonService;
use App\Services\Customer\AccountService; use App\Services\Customer\AccountService;
use App\Services\Customer\ClientService; use App\Services\Customer\ClientService;
use App\Services\Customer\CouponService;
use App\Services\Customer\PointService;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerPartService;
use App\Services\UserService; use App\Services\UserService;
@ -23,6 +26,9 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
private ?ClientService $_clientService = null; private ?ClientService $_clientService = null;
private ?ServiceService $_serviceService = null; private ?ServiceService $_serviceService = null;
private ?ServerPartService $_serverPartService = null; private ?ServerPartService $_serverPartService = null;
private ?AccountService $_accountService = null;
private ?CouponService $_couponService = null;
private ?PointService $_pointService = null;
public function __construct() public function __construct()
{ {
parent::__construct(new PaymentModel(), new PaymentHelper()); parent::__construct(new PaymentModel(), new PaymentHelper());
@ -68,7 +74,7 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
} }
final public function getBatchjobFields(): array final public function getBatchjobFields(): array
{ {
return ['pay', 'status']; return ['pay'];
} }
final public function getBatchjobButtons(): array final public function getBatchjobButtons(): array
{ {
@ -105,6 +111,27 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
} }
return $this->_serverPartService; return $this->_serverPartService;
} }
final public function getAccountService(): AccountService
{
if (!$this->_accountService) {
$this->_accountService = new AccountService();
}
return $this->_accountService;
}
final public function getCouponService(): CouponService
{
if (!$this->_couponService) {
$this->_couponService = new CouponService();
}
return $this->_couponService;
}
final public function getPointService(): PointService
{
if (!$this->_pointService) {
$this->_pointService = new PointService();
}
return $this->_pointService;
}
//총 미납건수, 금액 //총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array final public function getUnPaids(string $group, array $where = []): array
{ {
@ -223,35 +250,29 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
//일괄처리작업(결제작업) //일괄처리작업(결제작업)
public function batchjob(mixed $entity, array $formDatas): mixed public function batchjob(mixed $entity, array $formDatas): mixed
{ {
//고객정보
$userEntity = $this->getClientService()->getEntity($entity->getClientInfoUID());
if (!$userEntity instanceof ClientEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 고객정보[{$entity->getClientInfoUID()}]를 찾을수 없습니다.");
}
if (!array_key_exists('pay', $formDatas)) { if (!array_key_exists('pay', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 결제상태(pay) 정보가 없습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: 결제상태(pay) 정보가 없습니다.");
} }
//결제 완료 처리 후 추가정보 처리
$formDatas['status'] = STATUS['PAID'];
$entity = parent::batchjob($entity, $formDatas);
switch ($formDatas['pay']) { switch ($formDatas['pay']) {
case PAYMENT['PAY']['ACCOUNT']: case PAYMENT['PAY']['ACCOUNT']:
//예치금 출금처리 //예치금 출금 등록처리 후 결제정보 반환
if ($userEntity->getAccountBalance() < $entity->getAmount()) { $entity = $this->getAccountService()->setPayment('create', $entity, []);
throw new \Exception(__METHOD__ . "에서 오류발생: 고객[{$userEntity->getName()}]의 예치금이 부족합니다.({$userEntity->getAccountBalance()} < {$entity->getAmount()})");
}
break; break;
case PAYMENT['PAY']['COUPON']: case PAYMENT['PAY']['COUPON']:
//쿠폰 출금처리 //쿠폰 사용 등록처리 후 결제정보 반환
if ($userEntity->getCouponBalance() < 1) { $entity = $this->getCouponService()->setPayment('create', $entity, []);
throw new \Exception(__METHOD__ . "에서 오류발생: 고객[{$userEntity->getName()}]의 쿠폰이 부족합니다.({$userEntity->getCouponBalance()} < 1)");
}
break; break;
case PAYMENT['PAY']['POINT']: case PAYMENT['PAY']['POINT']:
//포인트 출금 등록처리 후 결제정보 반환
$entity = $this->getCouponService()->setPayment('create', $entity, []);
break; break;
default: default:
throw new \Exception(__METHOD__ . "에서 오류발생: 알수없는 결제방법(pay)입니다."); throw new \Exception(__METHOD__ . "에서 오류발생: 알수없는 결제방법(pay)입니다.");
// break; // break;
} }
//결제처리완료
$entity = parent::batchjob($entity, $formDatas);
return $entity; return $entity;
} }
//List 검색용 //List 검색용