From 97762c858b5dfe879f9f4fbd431413252e389dfc Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Wed, 17 Sep 2025 18:46:48 +0900 Subject: [PATCH] dbmsv2 init...1 --- .../Admin/Customer/PaymentController.php | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/app/Controllers/Admin/Customer/PaymentController.php b/app/Controllers/Admin/Customer/PaymentController.php index 5205b0a..9e8c5df 100644 --- a/app/Controllers/Admin/Customer/PaymentController.php +++ b/app/Controllers/Admin/Customer/PaymentController.php @@ -4,9 +4,10 @@ namespace App\Controllers\Admin\Customer; use App\Entities\Customer\ClientEntity; use App\Entities\Customer\PaymentEntity; +use App\Entities\Customer\ServiceEntity; use App\Libraries\LogCollector; -use App\Services\Customer\ClientService; +use App\Services\Customer\ClientService; use App\Services\Customer\PaymentService; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; @@ -75,16 +76,7 @@ class PaymentController extends CustomerController return parent::modify_process($entity, $formDatas); } //Invoice 관련 - private function getOwnersForInvoice(ClientEntity $clientEntity): array - { - $temps = [ - 'name' => $clientEntity->getName(), - 'total_amount' => 0, - 'services' => [] - ]; - return $temps; - } - private function invoice_process(): void + private function invoice_process(): array { //변경할 UIDS $uids = $this->request->getPost('batchjob_uids[]'); @@ -96,20 +88,24 @@ class PaymentController extends CustomerController //기존 Entity 가져오기 $entity = $this->getService()->getEntity($uid); if (!$entity) { - LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 결제정보를 찾을수 없습니다."); + throw new \Exception(__METHOD__ . "에서 {$uid}에 대한 결제정보를 찾을수 없습니다."); } //entities에 고객 설정 - $clientEntity = $this->getClientService()->getEntity($entity->getCode()); - if (!$clientEntity) { - LogCollector::debug(__METHOD__ . "에서 {$entity->getCode()}에 대한 고객정보를 찾을수 없습니다."); + $clientEntity = $this->getClientService()->getEntity($entity->getClientInfoUID()); + if (!$clientEntity instanceof ClientEntity) { + throw new \Exception(__METHOD__ . "에서 {$entity->getClientInfoUID()}에 대한 고객정보를 찾을수 없습니다."); } if (!array_key_exists($clientEntity->getPK(), $entities)) { - $entities[$clientEntity->getPK()] = $this->getOwnersForInvoice($clientEntity); + $entities[$clientEntity->getPK()] = [ + 'name' => $clientEntity->getName(), + 'total_amount' => 0, + 'services' => [] + ]; } //entities에 서비스 설정 $serviceEntity = $this->getServiceService()->getEntity($entity->getServiceUid()); - if (!$serviceEntity) { - LogCollector::debug(__METHOD__ . "에서 {$entity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다."); + if (!$serviceEntity instanceof ServiceEntity) { + throw new \Exception(__METHOD__ . "에서 {$entity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다."); } if (!array_key_exists($serviceEntity->getPK(), $entities[$clientEntity->getPK()]['services'])) { $entities[$clientEntity->getPK()]['services'][$serviceEntity->getPK()] = [ @@ -122,7 +118,7 @@ class PaymentController extends CustomerController $entities[$clientEntity->getPK()]['total_amount'] += $entity->getAmount(); } // dd($entities); - $this->entities = $entities; + return $entities; } public function invoice(): RedirectResponse|string { @@ -131,7 +127,7 @@ class PaymentController extends CustomerController $this->getService()->setFormFields(); $this->getService()->setFormFilters(); $this->getService()->setFormRules(); - $this->invoice_process(); + $this->entities = $this->invoice_process(); return $this->getResultSuccess(); } catch (\Exception $e) { return $this->getResultFail($e->getMessage());