dbmsv4 init...3
This commit is contained in:
parent
72e4a0566c
commit
59ca55c8dd
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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":
|
||||
|
||||
@ -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 = "<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;
|
||||
default:
|
||||
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
||||
|
||||
@ -23,6 +23,7 @@ class PaymentModel extends CommonModel
|
||||
"amount",
|
||||
"billing",
|
||||
"billing_at",
|
||||
"billing_month",
|
||||
"pay",
|
||||
"status",
|
||||
"updated_at"
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user