dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-15 17:48:46 +09:00
parent 72e4a0566c
commit 59ca55c8dd
6 changed files with 35 additions and 19 deletions

View File

@ -14,6 +14,7 @@ class PaymentDTO extends CommonDTO
public ?int $amount = null; public ?int $amount = null;
public ?string $billing = null; public ?string $billing = null;
public ?string $billing_at = null; public ?string $billing_at = null;
public ?int $billing_month = 0;
public ?string $pay = null; public ?string $pay = null;
public ?string $status = null; public ?string $status = null;

View File

@ -34,13 +34,17 @@ class PaymentEntity extends CommonEntity
{ {
return $this->attributes['billing_at']; 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']; return $this->attributes['pay'];
} }
public function getContent(): string|null public function getContent(): string|null
{ {
return $this->attributes['content'] ?? null; return $this->attributes['content'];
} }
public function getCountDueAt(): string public function getCountDueAt(): string
{ {

View File

@ -20,6 +20,7 @@ class PaymentForm extends CommonForm
$rule = "required|numeric"; $rule = "required|numeric";
break; break;
case "serverpartinfo_uid": case "serverpartinfo_uid":
case "billing_month":
$rule = "permit_empty|numeric"; $rule = "permit_empty|numeric";
break; break;
case "title": case "title":

View File

@ -15,23 +15,25 @@ class PaymentHelper extends CommonHelper
$forms = []; $forms = [];
array_shift($viewDatas['formOptions'][$field]['options']); //Radio 선택기는 첫번째 옵션제거해야 함 array_shift($viewDatas['formOptions'][$field]['options']); //Radio 선택기는 첫번째 옵션제거해야 함
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) { foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
$form_month = ""; $billing_month = "";
if ($key == PAYMENT['BILLING']['PREPAYMENT'] && array_key_exists('billing', $viewDatas['formDatas']) && $viewDatas['formDatas']['billing'] == PAYMENT['BILLING']['PREPAYMENT']) { if ($key == PAYMENT['BILLING']['PREPAYMENT']) { //선결제의 우우
$initalTitle = $viewDatas['formDatas']['title']; $initalTitle = $viewDatas['formDatas']['title'] ?? "";
$initalAmount = $viewDatas['formDatas']['amount']; $initalAmount = $viewDatas['formDatas']['amount'] ?? 0;
$initalBillingAt = $viewDatas['formDatas']['billing_at']; $initalPayMonth = $viewDatas['formDatas']['billing_month'] ?? "";
$initalBillingAt = $viewDatas['formDatas']['billing_at'] ?? "";
$months = ["" => "개월 선택"]; $months = ["" => "개월 선택"];
for ($i = 1; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
$months[$i] = "{$i}개월"; $months[$i] = "{$i}개월";
} }
$js_onChange = " $js_onChange = "
var originalText = '{$initalTitle}'; var originalText = '{$initalTitle}';
var originalAmount = parseInt({$initalAmount}); var originalAmount = parseInt({$initalAmount});
var originalBillingAt = '{$initalBillingAt}'; 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=\'title\']').value = originalText + ' '+payMonth + '개월';
document.querySelector('input[name=\'amount\']').value = originalAmount * month; document.querySelector('input[name=\'amount\']').value = originalAmount * payMonth;
// billing_at 날짜 계산 // billing_at 날짜 계산
var parts = originalBillingAt.split('-'); // 예: ['2025', '1', '25'] var parts = originalBillingAt.split('-'); // 예: ['2025', '1', '25']
// 1. Date 객체 생성 시 월(parts[1])에서 1을 빼줍니다. JavaScript의 월 인덱스는 0부터 시작하기 때문입니다 (0=1월, 1=2월...). // 1. Date 객체 생성 시 월(parts[1])에서 1을 빼줍니다. JavaScript의 월 인덱스는 0부터 시작하기 때문입니다 (0=1월, 1=2월...).
@ -44,21 +46,21 @@ class PaymentHelper extends CommonHelper
// 현재 월 인덱스에 선택된 개월 수를 더해야 합니다. // 현재 월 인덱스에 선택된 개월 수를 더해야 합니다.
// getMonth()는 현재 인덱스를 반환하며, month는 추가할 개월 수입니다. // getMonth()는 현재 인덱스를 반환하며, month는 추가할 개월 수입니다.
// (예: 1월(index 0)에 1개월(month 1) 추가 -> newDate.setMonth(0 + 1)) // (예: 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 사용 시 타임존 오류 발생 방지) // 3. YYYY-MM-DD 형식으로 다시 포맷팅 (toISOString 사용 시 타임존 오류 발생 방지)
var formattedDate = newDate.getFullYear() + '-' + var formattedDate = newDate.getFullYear() + '-' +
('0' + (newDate.getMonth() + 1)).slice(-2) + '-' + // 월을 1부터 시작하게 하고 2자리로 포맷 ('0' + (newDate.getMonth() + 1)).slice(-2) + '-' + // 월을 1부터 시작하게 하고 2자리로 포맷
('0' + newDate.getDate()).slice(-2); // 일을 2자리로 포맷 ('0' + newDate.getDate()).slice(-2); // 일을 2자리로 포맷
document.querySelector('input[name=\'billing_at\']').value = formattedDate; document.querySelector('input[name=\'billing_at\']').value = formattedDate;
"; ";
$dropdown_attrs = ['id' => 'prepayment_months', 'onChange' => $js_onChange]; $dropdown_attrs = ['id' => 'billing_month', 'onChange' => $js_onChange];
$form_month = form_dropdown('prepayment_month', $months, $viewDatas['prepayment_month'] ?? '', $dropdown_attrs); $billing_month = form_dropdown('billing_month', $months, $viewDatas['billing_month'] ?? '', $dropdown_attrs);
} }
$radio_attrs = ['id' => $field . '_' . $key]; $radio_attrs = ['id' => $field . '_' . $key];
if ($key == $value) { if ($key == $value) {
$radio_attrs['checked'] = true; $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); $form = implode(" ", $forms);
break; break;
@ -83,7 +85,11 @@ class PaymentHelper extends CommonHelper
$value = $viewDatas['entity']->getCountDueAt(); $value = $viewDatas['entity']->getCountDueAt();
break; break;
case 'amount': 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; break;
default: default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras); $value = parent::getFieldView($field, $value, $viewDatas, $extras);
@ -122,7 +128,10 @@ class PaymentHelper extends CommonHelper
]); ]);
break; break;
case 'paid': case 'paid':
$action = sprintf("<a href=\"/admin/payment/paid/%s\" class=\"btn btn-sm btn-warning\">%s</a>", $viewDatas['entity']->getPK(), $label ? $label : '결제'); $action = "<span class=\"btn btn-sm btn-success\">완료</span>";
if ($viewDatas['entity']->getStatus() === STATUS['UNPAID']) {
$action = sprintf("<a href=\"/admin/payment/paid/%s\" class=\"btn btn-sm btn-warning\">%s</a>", $viewDatas['entity']->getPK(), $label ? $label : '결제');
}
break; break;
default: default:
$action = parent::getListButton($action, $label, $viewDatas, $extras); $action = parent::getListButton($action, $label, $viewDatas, $extras);

View File

@ -23,6 +23,7 @@ class PaymentModel extends CommonModel
"amount", "amount",
"billing", "billing",
"billing_at", "billing_at",
"billing_month",
"pay", "pay",
"status", "status",
"updated_at" "updated_at"

View File

@ -79,7 +79,7 @@ class PaymentService extends CommonService
$filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay'];
$indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay'];
$batchjobFilters = ['status']; $batchjobFilters = ['status'];
$actionButtons = ['view' => ICONS['SEARCH'], 'paid' => '결제', 'delete' => ICONS['DELETE']]; $actionButtons = ['paid' => '결제', 'view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
$batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행'];
switch ($action) { switch ($action) {
case 'create': case 'create':
@ -115,7 +115,6 @@ class PaymentService extends CommonService
'amount', 'amount',
'billing_at', 'billing_at',
'pay', 'pay',
'status',
'updated_at', 'updated_at',
'countdown', 'countdown',
'user_uid', 'user_uid',
@ -130,6 +129,7 @@ class PaymentService extends CommonService
$this->getFormService()->setIndexFilters($indexFilter); $this->getFormService()->setIndexFilters($indexFilter);
$this->getFormService()->setActionButtons($actionButtons); $this->getFormService()->setActionButtons($actionButtons);
$this->getFormService()->setBatchjobFilters($batchjobFilters); $this->getFormService()->setBatchjobFilters($batchjobFilters);
$this->getFormService()->setBatchjobButtons($batchjobButtons);
} }
//총 미납건수, 금액 //총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array final public function getUnPaids(string $group, array $where = []): array