From 0e72ca6428f8467a386b460e1d708c55fb5c56ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 2 Dec 2025 19:30:39 +0900 Subject: [PATCH] dbmsv4 init...2 --- app/Services/PaymentService.php | 48 ++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 4fd2201..6bf70cd 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -130,6 +130,22 @@ class PaymentService extends CommonService $this->getFormService()->setBatchjobFilters($batchjobFilters); $this->getFormService()->setBatchjobButtons($batchjobButtons); } + //총 미납건수, 금액 + final public function getUnPaids(string $group, array $where = []): array + { + $builder = $this->model->groupBy($group) + ->select("{$group},COUNT(uid) as cnt, SUM(amount) as amount") + ->where(['status' => STATUS['UNPAID']]) + ->where($where) + ->builder(); + // echo $builder->getCompiledSelect(false); //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false! + $unPaids = []; + foreach ($builder->get()->getResult() as $row) { + $unPaids[$row->$group] = ['cnt' => $row->cnt, 'amount' => $row->amount]; + } + return $unPaids; + } + //기본 기능부분 protected function getEntity_process(mixed $entity): PaymentEntity { @@ -159,20 +175,28 @@ class PaymentService extends CommonService parent::setSearchWord($word); } //추가기능 - //총 미납건수, 금액 - final public function getUnPaids(string $group, array $where = []): array + //일회성 입력용 + protected function create_process(array $formDatas): PaymentEntity { - $builder = $this->model->groupBy($group) - ->select("{$group},COUNT(uid) as cnt, SUM(amount) as amount") - ->where(['status' => STATUS['UNPAID']]) - ->where($where) - ->builder(); - // echo $builder->getCompiledSelect(false); //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false! - $unPaids = []; - foreach ($builder->get()->getResult() as $row) { - $unPaids[$row->$group] = ['cnt' => $row->cnt, 'amount' => $row->amount]; + if (!array_key_exists('serviceinfo_uid', $formDatas)) { + throw new RuntimeException(__METHOD__ . "에서 오류발생: 서비스가 정의되지 않았습니다."); } - return $unPaids; + $serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']); + $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID(); + $entity = parent::create_process($formDatas); + if (!$entity instanceof PaymentEntity) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + return $entity; + } + + protected function modify_process($entity, array $formDatas): PaymentEntity + { + $entity = parent::modify_process($entity, $formDatas); + if (!$entity instanceof PaymentEntity) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + return $entity; } //청구서 관련