dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-17 18:46:48 +09:00
parent ab02a23bab
commit 97762c858b

View File

@ -4,9 +4,10 @@ namespace App\Controllers\Admin\Customer;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\PaymentEntity; use App\Entities\Customer\PaymentEntity;
use App\Entities\Customer\ServiceEntity;
use App\Libraries\LogCollector; use App\Libraries\LogCollector;
use App\Services\Customer\ClientService;
use App\Services\Customer\ClientService;
use App\Services\Customer\PaymentService; use App\Services\Customer\PaymentService;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
@ -75,16 +76,7 @@ class PaymentController extends CustomerController
return parent::modify_process($entity, $formDatas); return parent::modify_process($entity, $formDatas);
} }
//Invoice 관련 //Invoice 관련
private function getOwnersForInvoice(ClientEntity $clientEntity): array private function invoice_process(): array
{
$temps = [
'name' => $clientEntity->getName(),
'total_amount' => 0,
'services' => []
];
return $temps;
}
private function invoice_process(): void
{ {
//변경할 UIDS //변경할 UIDS
$uids = $this->request->getPost('batchjob_uids[]'); $uids = $this->request->getPost('batchjob_uids[]');
@ -96,20 +88,24 @@ class PaymentController extends CustomerController
//기존 Entity 가져오기 //기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid); $entity = $this->getService()->getEntity($uid);
if (!$entity) { if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 결제정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 {$uid}에 대한 결제정보를 찾을수 없습니다.");
} }
//entities에 고객 설정 //entities에 고객 설정
$clientEntity = $this->getClientService()->getEntity($entity->getCode()); $clientEntity = $this->getClientService()->getEntity($entity->getClientInfoUID());
if (!$clientEntity) { if (!$clientEntity instanceof ClientEntity) {
LogCollector::debug(__METHOD__ . "에서 {$entity->getCode()}에 대한 고객정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 {$entity->getClientInfoUID()}에 대한 고객정보를 찾을수 없습니다.");
} }
if (!array_key_exists($clientEntity->getPK(), $entities)) { if (!array_key_exists($clientEntity->getPK(), $entities)) {
$entities[$clientEntity->getPK()] = $this->getOwnersForInvoice($clientEntity); $entities[$clientEntity->getPK()] = [
'name' => $clientEntity->getName(),
'total_amount' => 0,
'services' => []
];
} }
//entities에 서비스 설정 //entities에 서비스 설정
$serviceEntity = $this->getServiceService()->getEntity($entity->getServiceUid()); $serviceEntity = $this->getServiceService()->getEntity($entity->getServiceUid());
if (!$serviceEntity) { if (!$serviceEntity instanceof ServiceEntity) {
LogCollector::debug(__METHOD__ . "에서 {$entity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 {$entity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다.");
} }
if (!array_key_exists($serviceEntity->getPK(), $entities[$clientEntity->getPK()]['services'])) { if (!array_key_exists($serviceEntity->getPK(), $entities[$clientEntity->getPK()]['services'])) {
$entities[$clientEntity->getPK()]['services'][$serviceEntity->getPK()] = [ $entities[$clientEntity->getPK()]['services'][$serviceEntity->getPK()] = [
@ -122,7 +118,7 @@ class PaymentController extends CustomerController
$entities[$clientEntity->getPK()]['total_amount'] += $entity->getAmount(); $entities[$clientEntity->getPK()]['total_amount'] += $entity->getAmount();
} }
// dd($entities); // dd($entities);
$this->entities = $entities; return $entities;
} }
public function invoice(): RedirectResponse|string public function invoice(): RedirectResponse|string
{ {
@ -131,7 +127,7 @@ class PaymentController extends CustomerController
$this->getService()->setFormFields(); $this->getService()->setFormFields();
$this->getService()->setFormFilters(); $this->getService()->setFormFilters();
$this->getService()->setFormRules(); $this->getService()->setFormRules();
$this->invoice_process(); $this->entities = $this->invoice_process();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->getResultFail($e->getMessage()); return $this->getResultFail($e->getMessage());