From 59ca55c8dd124b9e19129b0a290a4b37c4dfff0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 15 Dec 2025 17:48:46 +0900 Subject: [PATCH] dbmsv4 init...3 --- app/DTOs/PaymentDTO.php | 1 + app/Entities/PaymentEntity.php | 8 +++++-- app/Forms/PaymentForm.php | 1 + app/Helpers/PaymentHelper.php | 39 ++++++++++++++++++++------------- app/Models/PaymentModel.php | 1 + app/Services/PaymentService.php | 4 ++-- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/app/DTOs/PaymentDTO.php b/app/DTOs/PaymentDTO.php index 935eaee..65c59cc 100644 --- a/app/DTOs/PaymentDTO.php +++ b/app/DTOs/PaymentDTO.php @@ -14,6 +14,7 @@ class PaymentDTO extends CommonDTO public ?int $amount = null; public ?string $billing = null; public ?string $billing_at = null; + public ?int $billing_month = 0; public ?string $pay = null; public ?string $status = null; diff --git a/app/Entities/PaymentEntity.php b/app/Entities/PaymentEntity.php index 8f124c9..c053017 100644 --- a/app/Entities/PaymentEntity.php +++ b/app/Entities/PaymentEntity.php @@ -34,13 +34,17 @@ class PaymentEntity extends CommonEntity { return $this->attributes['billing_at']; } - public function getPay(): string|null + public function getBillingMonth(): int + { + return $this->attributes['billing_month'] ?? 0; + } + public function getPay(): string { return $this->attributes['pay']; } public function getContent(): string|null { - return $this->attributes['content'] ?? null; + return $this->attributes['content']; } public function getCountDueAt(): string { diff --git a/app/Forms/PaymentForm.php b/app/Forms/PaymentForm.php index 53eca88..7b9d972 100644 --- a/app/Forms/PaymentForm.php +++ b/app/Forms/PaymentForm.php @@ -20,6 +20,7 @@ class PaymentForm extends CommonForm $rule = "required|numeric"; break; case "serverpartinfo_uid": + case "billing_month": $rule = "permit_empty|numeric"; break; case "title": diff --git a/app/Helpers/PaymentHelper.php b/app/Helpers/PaymentHelper.php index 87e0eb9..5c8ca77 100644 --- a/app/Helpers/PaymentHelper.php +++ b/app/Helpers/PaymentHelper.php @@ -15,23 +15,25 @@ class PaymentHelper extends CommonHelper $forms = []; array_shift($viewDatas['formOptions'][$field]['options']); //Radio 선택기는 첫번째 옵션제거해야 함 foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) { - $form_month = ""; - if ($key == PAYMENT['BILLING']['PREPAYMENT'] && array_key_exists('billing', $viewDatas['formDatas']) && $viewDatas['formDatas']['billing'] == PAYMENT['BILLING']['PREPAYMENT']) { - $initalTitle = $viewDatas['formDatas']['title']; - $initalAmount = $viewDatas['formDatas']['amount']; - $initalBillingAt = $viewDatas['formDatas']['billing_at']; + $billing_month = ""; + if ($key == PAYMENT['BILLING']['PREPAYMENT']) { //선결제의 우우 + $initalTitle = $viewDatas['formDatas']['title'] ?? ""; + $initalAmount = $viewDatas['formDatas']['amount'] ?? 0; + $initalPayMonth = $viewDatas['formDatas']['billing_month'] ?? ""; + $initalBillingAt = $viewDatas['formDatas']['billing_at'] ?? ""; $months = ["" => "개월 선택"]; - for ($i = 1; $i <= 12; $i++) { + for ($i = 2; $i <= 12; $i++) { $months[$i] = "{$i}개월"; } $js_onChange = " var originalText = '{$initalTitle}'; var originalAmount = parseInt({$initalAmount}); var originalBillingAt = '{$initalBillingAt}'; - var month = parseInt(this.options[this.selectedIndex].value) || 1; // 숫자가 아니면 1로 처리 + var originalPayMonth = '{$initalPayMonth}'; + var payMonth = parseInt(this.options[this.selectedIndex].value) || 1; // 숫자가 아니면 1로 처리 // 선택된 개월 수에 따라 제목과 금액 결제일 업데이트 - document.querySelector('input[name=\'title\']').value = originalText + ' '+month + '개월'; - document.querySelector('input[name=\'amount\']').value = originalAmount * month; + document.querySelector('input[name=\'title\']').value = originalText + ' '+payMonth + '개월'; + document.querySelector('input[name=\'amount\']').value = originalAmount * payMonth; // billing_at 날짜 계산 var parts = originalBillingAt.split('-'); // 예: ['2025', '1', '25'] // 1. Date 객체 생성 시 월(parts[1])에서 1을 빼줍니다. JavaScript의 월 인덱스는 0부터 시작하기 때문입니다 (0=1월, 1=2월...). @@ -44,21 +46,21 @@ class PaymentHelper extends CommonHelper // 현재 월 인덱스에 선택된 개월 수를 더해야 합니다. // getMonth()는 현재 인덱스를 반환하며, month는 추가할 개월 수입니다. // (예: 1월(index 0)에 1개월(month 1) 추가 -> newDate.setMonth(0 + 1)) - newDate.setMonth(newDate.getMonth() + month); + newDate.setMonth(newDate.getMonth() + payMonth); // 3. YYYY-MM-DD 형식으로 다시 포맷팅 (toISOString 사용 시 타임존 오류 발생 방지) var formattedDate = newDate.getFullYear() + '-' + ('0' + (newDate.getMonth() + 1)).slice(-2) + '-' + // 월을 1부터 시작하게 하고 2자리로 포맷 ('0' + newDate.getDate()).slice(-2); // 일을 2자리로 포맷 document.querySelector('input[name=\'billing_at\']').value = formattedDate; "; - $dropdown_attrs = ['id' => 'prepayment_months', 'onChange' => $js_onChange]; - $form_month = form_dropdown('prepayment_month', $months, $viewDatas['prepayment_month'] ?? '', $dropdown_attrs); + $dropdown_attrs = ['id' => 'billing_month', 'onChange' => $js_onChange]; + $billing_month = form_dropdown('billing_month', $months, $viewDatas['billing_month'] ?? '', $dropdown_attrs); } $radio_attrs = ['id' => $field . '_' . $key]; if ($key == $value) { $radio_attrs['checked'] = true; } - $forms[] = form_radio($field, $key, false, $radio_attrs) . $label . " " . $form_month; + $forms[] = form_radio($field, $key, false, $radio_attrs) . $label . " " . $billing_month; } $form = implode(" ", $forms); break; @@ -83,7 +85,11 @@ class PaymentHelper extends CommonHelper $value = $viewDatas['entity']->getCountDueAt(); break; case 'amount': - $value = number_format($value) . "원"; + $value = sprintf("%s%s", number_format($value), $viewDatas['entity']->getPay() == 'coupon' ? "개" : "원"); + break; + case 'billing': + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + $value .= $viewDatas['entity']->getBilling() === 'prepayment' ? "/" . $viewDatas['entity']->getBillingMonth() . "개월" : ""; break; default: $value = parent::getFieldView($field, $value, $viewDatas, $extras); @@ -122,7 +128,10 @@ class PaymentHelper extends CommonHelper ]); break; case 'paid': - $action = sprintf("%s", $viewDatas['entity']->getPK(), $label ? $label : '결제'); + $action = "완료"; + if ($viewDatas['entity']->getStatus() === STATUS['UNPAID']) { + $action = sprintf("%s", $viewDatas['entity']->getPK(), $label ? $label : '결제'); + } break; default: $action = parent::getListButton($action, $label, $viewDatas, $extras); diff --git a/app/Models/PaymentModel.php b/app/Models/PaymentModel.php index f29d3f1..e1e0323 100644 --- a/app/Models/PaymentModel.php +++ b/app/Models/PaymentModel.php @@ -23,6 +23,7 @@ class PaymentModel extends CommonModel "amount", "billing", "billing_at", + "billing_month", "pay", "status", "updated_at" diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 9888006..4dcefa9 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -79,7 +79,7 @@ class PaymentService extends CommonService $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; $batchjobFilters = ['status']; - $actionButtons = ['view' => ICONS['SEARCH'], 'paid' => '결제', 'delete' => ICONS['DELETE']]; + $actionButtons = ['paid' => '결제', 'view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']]; $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; switch ($action) { case 'create': @@ -115,7 +115,6 @@ class PaymentService extends CommonService 'amount', 'billing_at', 'pay', - 'status', 'updated_at', 'countdown', 'user_uid', @@ -130,6 +129,7 @@ class PaymentService extends CommonService $this->getFormService()->setIndexFilters($indexFilter); $this->getFormService()->setActionButtons($actionButtons); $this->getFormService()->setBatchjobFilters($batchjobFilters); + $this->getFormService()->setBatchjobButtons($batchjobButtons); } //총 미납건수, 금액 final public function getUnPaids(string $group, array $where = []): array