dbmsv4 init...1
This commit is contained in:
parent
301b45ab9a
commit
76173ac564
@ -93,7 +93,7 @@ class App extends BaseConfig
|
||||
* strings (like currency markers, numbers, etc), that your program
|
||||
* should run under for this request.
|
||||
*/
|
||||
public string $defaultLocale = 'en';
|
||||
public string $defaultLocale = 'ko';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
|
||||
@ -29,7 +29,7 @@ class ServerPartEntity extends EquipmentEntity
|
||||
return $this->attributes['payment_uid'] ?? null;
|
||||
}
|
||||
//기본기능용
|
||||
public function getTotalAmount(): int
|
||||
public function getCalculatedAmount(): int
|
||||
{
|
||||
return $this->getAmount() * $this->getCnt();
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ abstract class PartEntity extends CommonEntity
|
||||
//기본기능용
|
||||
public function getCustomTitle(mixed $title = null): string
|
||||
{
|
||||
return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice()));
|
||||
return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice() . "원"));
|
||||
}
|
||||
final public function getPrice(): int
|
||||
{
|
||||
|
||||
@ -44,7 +44,7 @@ class BoardForm extends CommonForm
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -113,14 +113,14 @@ abstract class CommonForm
|
||||
return $this->_batchjobButtons;
|
||||
}
|
||||
//Validation용
|
||||
public function validate(array $formDatas): bool
|
||||
final public function validate(array $formDatas): bool
|
||||
{
|
||||
$validation = service('validation');
|
||||
$dynamicRules = [];
|
||||
foreach ($this->getFormRules() as $field => $rule) {
|
||||
//field별 추가 커스텀 룰 적용
|
||||
list($field, $rule) = $this->getValidationRule($field, $rule);
|
||||
$dynamicRules[$field] = $rule;
|
||||
$dynamicRules[$field] = ['rules' => $rule, 'label' => $this->getFormFields()[$field]];
|
||||
}
|
||||
$validation->setRules($dynamicRules);
|
||||
return $validation->run($formDatas);
|
||||
@ -203,7 +203,7 @@ abstract class CommonForm
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -46,18 +46,14 @@ class ServiceForm extends CustomerForm
|
||||
return $rule;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'serverinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = [
|
||||
'value' => $tempEntity->getPK(),
|
||||
'text' => $tempEntity->getCustomTitle(),
|
||||
'data-title' => $tempEntity->getCustomTitle(),
|
||||
'data-price' => $tempEntity->getPrice()
|
||||
];
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
|
||||
@ -69,7 +69,7 @@ class ServerForm extends EquipmentForm
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -42,14 +42,18 @@ class ServerPartForm extends EquipmentForm
|
||||
{
|
||||
return service('part_' . strtolower($type) . 'service');
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'part_uid':
|
||||
$tempOptions = [];
|
||||
foreach (SERVERPART['ALL_PARTTYPES'] as $type) {
|
||||
$partService = $this->getPartService($type);
|
||||
$tempOptions[$type] = [lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택"];
|
||||
$tempOptions[$type] = ["" => [
|
||||
'value' => "",
|
||||
'text' => lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택",
|
||||
]];
|
||||
foreach ($this->getFormOption_process($partService, $action, $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$type][$tempEntity->getPK()] = [
|
||||
'value' => $tempEntity->getPK(),
|
||||
@ -60,8 +64,6 @@ class ServerPartForm extends EquipmentForm
|
||||
}
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
// dd($formDatas);
|
||||
// dd($options);
|
||||
break;
|
||||
case 'serverinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
|
||||
@ -27,7 +27,7 @@ class IPForm extends PartForm
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -35,7 +35,7 @@ abstract class PartForm extends CommonForm
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -41,7 +41,7 @@ class PaymentForm extends CommonForm
|
||||
return $rule;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
|
||||
@ -47,41 +47,46 @@ abstract class CommonHelper
|
||||
* @param string $extra <select> 태그에 추가할 속성
|
||||
* @return string HTML <select> 태그
|
||||
*/
|
||||
final public function form_dropdown_custom(string $name = '', array $options = [], $selected = null, array $extras = []): string
|
||||
final public function form_dropdown_custom(string $name, array $options, mixed $selected, array $extras = []): string
|
||||
{
|
||||
// dd($options);
|
||||
//Extra처리
|
||||
$extra = "";
|
||||
foreach ($extras as $extras_key => $extras_value) {
|
||||
$extra .= " " . esc($extras_key) . '="' . esc($extras_value) . '"';
|
||||
}
|
||||
$select = '<select name="' . esc($name) . '"' . $extra . ">\n";
|
||||
// 선택된 값 처리
|
||||
$selected = is_array($selected) ? $selected : [$selected];
|
||||
foreach ($options as $key => $val) {
|
||||
// 💡 핵심 로직: $val이 배열인지 확인합니다.
|
||||
// 💡$val이 배열인지 확인합니다.-->배열일경우 옵션 처리
|
||||
if (is_array($val)) {
|
||||
// $val이 배열인 경우: 복합 옵션 (value, text, data-* 속성 포함)
|
||||
$optionValue = $val['value'] ?? $key; // value가 없으면 키 사용
|
||||
$optionText = $val['text'] ?? $optionValue;
|
||||
$optionAttributes = '';
|
||||
|
||||
// data-* 속성 추출 및 조합
|
||||
foreach ($val as $attrKey => $attrValue) {
|
||||
// 'value'와 'text'는 <option> 속성이 아니므로 제외
|
||||
if ($attrKey !== 'value' && $attrKey !== 'text') {
|
||||
$optionAttributes .= " " . esc($attrKey) . '="' . esc($attrValue) . '"';
|
||||
$optionAttributes .= sprintf(" %s=\"%s\"", esc($attrKey), esc($attrValue));
|
||||
}
|
||||
}
|
||||
$optionSelected = in_array($optionValue, $selected) ? ' selected="selected"' : '';
|
||||
$select .= '<option value="' . esc($optionValue) . '"' . $optionAttributes . $optionSelected . '>'
|
||||
. esc($optionText)
|
||||
. "</option>\n";
|
||||
$optionSelected = $optionValue == $selected ? ' selected="selected"' : '';
|
||||
$select .= sprintf(
|
||||
"<option value=\"%s\" %s %s>%s</option>",
|
||||
$optionValue,
|
||||
$optionAttributes,
|
||||
$optionSelected,
|
||||
esc($optionText)
|
||||
);
|
||||
} else {
|
||||
// $val이 배열이 아닌 경우: 일반 옵션 (기존 form_dropdown() 방식)
|
||||
$optionSelected = in_array($key, $selected) ? ' selected="selected"' : '';
|
||||
|
||||
$select .= '<option value="' . esc($key) . '"' . $optionSelected . '>'
|
||||
. esc($val)
|
||||
. "</option>\n";
|
||||
$optionSelected = $key == $selected ? ' selected="selected"' : '';
|
||||
$select .= sprintf(
|
||||
"<option value=\"%s\" %s></option>",
|
||||
$key,
|
||||
$optionSelected,
|
||||
esc($val)
|
||||
);
|
||||
}
|
||||
}
|
||||
$select .= "</select>\n";
|
||||
|
||||
@ -17,13 +17,6 @@ class ServiceHelper extends CustomerHelper
|
||||
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
break;
|
||||
case 'serverinfo_uid':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
|
||||
if (array_key_exists('extras', $viewDatas['formOptions'][$field])) {
|
||||
$extras = array_merge($extras, $viewDatas['formOptions'][$field]['extras']);
|
||||
}
|
||||
$form = $this->form_dropdown_custom($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
break;
|
||||
case 'clientinfo_uid':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
|
||||
@ -22,11 +22,10 @@ class ServerPartHelper extends EquipmentHelper
|
||||
case 'part_uid':
|
||||
// dd($viewDatas);
|
||||
$type = array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getType() : $viewDatas['formDatas']['type'];
|
||||
// echo "Type:" . $type;
|
||||
// dd($viewDatas['formOptions'][$field]['options'][$type]);
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
|
||||
if (array_key_exists('extras', $viewDatas['formOptions'][$field])) {
|
||||
$extras = array_merge($extras, $viewDatas['formOptions'][$field]['extras']);
|
||||
}
|
||||
$form = $this->form_dropdown_custom($field, $viewDatas['formOptions'][$field]['options'][$type], $value, $extras);
|
||||
break;
|
||||
default:
|
||||
|
||||
38
app/Language/ko/Validation.php
Normal file
38
app/Language/ko/Validation.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// app/Language/kr/Validation.php
|
||||
|
||||
return [
|
||||
// 여기서부터 각 Validation rule에 대한 메시지를 정의합니다.
|
||||
// {field}나 {param} 같은 플레이스홀더는 그대로 유지해야 합니다.
|
||||
|
||||
'required' => '{field} 필드는 필수 입력 항목입니다.',
|
||||
'isset' => '{field} 필드는 값이 반드시 있어야 합니다.',
|
||||
'valid_email' => '{field} 필드는 유효한 이메일 주소여야 합니다.',
|
||||
'valid_url' => '{field} 필드는 유효한 URL이어야 합니다.',
|
||||
'valid_date' => '{field} 필드는 유효한 날짜여야 합니다.',
|
||||
'valid_dates' => '{field} 필드는 유효한 날짜여야 합니다.',
|
||||
'valid_ip' => '{field} 필드는 유효한 IP 주소여야 합니다.',
|
||||
'valid_mac' => '{field} 필드는 유효한 MAC 주소여야 합니다.',
|
||||
'numeric' => '{field} 필드는 숫자만 포함해야 합니다.',
|
||||
'integer' => '{field} 필드는 정수여야 합니다.',
|
||||
'decimal' => '{field} 필드는 소수점 숫자여야 합니다.',
|
||||
'is_numeric' => '{field} 필드는 숫자 문자만 포함해야 합니다.',
|
||||
'regex_match' => '{field} 필드는 올바른 형식이어야 합니다.',
|
||||
'matches' => '{field} 필드가 {param} 필드와 일치하지 않습니다.',
|
||||
'differs' => '{field} 필드는 {param} 필드와 달라야 합니다.',
|
||||
'is_unique' => '{field} 필드는 고유한 값이어야 합니다.',
|
||||
'is_natural' => '{field} 필드는 숫자여야 합니다.',
|
||||
'is_natural_no_zero' => '{field} 필드는 0보다 큰 숫자여야 합니다.',
|
||||
'less_than' => '{field} 필드는 {param}보다 작아야 합니다.',
|
||||
'less_than_equal_to' => '{field} 필드는 {param}보다 작거나 같아야 합니다.',
|
||||
'greater_than' => '{field} 필드는 {param}보다 커야 합니다.',
|
||||
'greater_than_equal_to' => '{field} 필드는 {param}보다 크거나 같아야 합니다.',
|
||||
'error_prefix' => '',
|
||||
'error_suffix' => '',
|
||||
|
||||
// 길이(Length) 관련 rule 메시지
|
||||
'min_length' => '{field} 필드는 최소 {param}자 이상이어야 합니다.',
|
||||
'max_length' => '{field} 필드는 최대 {param}자 이하여야 합니다.',
|
||||
'exact_length' => '{field} 필드는 정확히 {param}자여야 합니다.',
|
||||
'in_list' => '{field} 필드는 다음 중 하나여야 합니다: {param}.',
|
||||
];
|
||||
@ -6,7 +6,7 @@ use App\Entities\Customer\PointEntity;
|
||||
|
||||
class PointModel extends CustomerModel
|
||||
{
|
||||
const TABLE = "couponinfo";
|
||||
const TABLE = "pointinfo";
|
||||
const PK = "uid";
|
||||
const TITLE = "title";
|
||||
protected $table = self::TABLE;
|
||||
|
||||
@ -75,7 +75,6 @@ class ServiceService extends CustomerService
|
||||
"billing_at",
|
||||
"status",
|
||||
'sale',
|
||||
'amount',
|
||||
"history",
|
||||
];
|
||||
$filters = [
|
||||
@ -127,41 +126,6 @@ class ServiceService extends CustomerService
|
||||
$this->getFormService()->setIndexFilters($indexFilter);
|
||||
$this->getFormService()->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): ServiceEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): ServiceEntity
|
||||
{
|
||||
$formDatas['code'] = $formDatas['site'] . "_s" . uniqid();
|
||||
$entity = parent::create_process($formDatas);
|
||||
if (!$entity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||
}
|
||||
//서비스추가시 호출
|
||||
service('equipment_serverservice')->attachToService($entity);
|
||||
service('paymentservice')->createByService($entity);
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($entity, array $formDatas): ServiceEntity
|
||||
{
|
||||
$oldEntity = clone $entity;
|
||||
$entity = parent::modify_process($entity, $formDatas);
|
||||
if (!$entity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||
}
|
||||
//서비스수정시 호출
|
||||
if ($oldEntity->getServerInfoUID() !== $entity->getServerInfoUID()) {
|
||||
service('equipment_serverservice')->detachFromService($oldEntity);
|
||||
service('equipment_serverservice')->attachToService($entity);
|
||||
}
|
||||
service('paymentservice')->modifyByService($oldEntity, $entity);
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
//추가 기능
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
final public function getNewServiceEntities(int $interval, string $status = STATUS['AVAILABLE']): array
|
||||
@ -206,13 +170,76 @@ class ServiceService extends CustomerService
|
||||
// 최종 결과 리턴 (YYYY-MM-DD)
|
||||
return $date->format('Y-m-d');
|
||||
}
|
||||
//서비스금액관련처리
|
||||
// public function setAmount(ServiceEntity $entity, int $calculatedServerAmount, string $callBack = "updateForService"): ServiceEntity
|
||||
// {
|
||||
// //기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)-할인액
|
||||
// $amount = $entity->getRack() + $entity->getLine() + $calculatedServerAmount - $entity->getSale();
|
||||
// //결제정보 반영
|
||||
// $paymentEntity = $this->getPaymentService()->$callBack($entity, $amount);
|
||||
// return $this->model->modify($entity, ['amount' => $amount, 'payment_uid' => $paymentEntity->getPK()]);
|
||||
// }
|
||||
// 서비스금액관련처리
|
||||
public function getCalculatedAmount(int $serverinfo_uid, int $rack, int $line, int $sale): int
|
||||
{
|
||||
$serverService = service('equipment_serverservice');
|
||||
//기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)-할인액
|
||||
return $rack + $line + $serverService->getCalculatedAmount($serverinfo_uid) - $sale;
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): ServiceEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): ServiceEntity
|
||||
{
|
||||
//필수항목검사
|
||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서버정보가 정의되지 않았습니다.');
|
||||
}
|
||||
//서비스코드생성
|
||||
$formDatas['code'] = $formDatas['site'] . "_s" . uniqid();
|
||||
//서비스 전체금액 구하기
|
||||
$formDatas['amount'] = $this->getCalculatedAmount(
|
||||
(int)$formDatas['serverinfo_uid'],
|
||||
(int)$formDatas['rack'],
|
||||
(int)$formDatas['line'],
|
||||
(int)$formDatas['sale']
|
||||
);
|
||||
//서비스 생성
|
||||
$entity = parent::create_process($formDatas);
|
||||
if (!$entity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||
}
|
||||
//서버정보 연결
|
||||
service('equipment_serverservice')->attachToService($entity);
|
||||
//결제정보 연결
|
||||
service('paymentservice')->attachToService($entity);
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($entity, array $formDatas): ServiceEntity
|
||||
{
|
||||
//필수항목검사
|
||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서버정보가 정의되지 않았습니다.');
|
||||
}
|
||||
//수정전 서비스정보를 currentEntity 복사해준다.
|
||||
if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
||||
//서버정보 해지처리
|
||||
service('equipment_serverservice')->detachFromService($entity);
|
||||
//결제정보 해지(삭제)처리
|
||||
service('paymentservice')->detachFromService($entity);
|
||||
//서비스 전체금액 구하기
|
||||
$formDatas['amount'] = $this->getCalculatedAmount(
|
||||
(int)$formDatas['serverinfo_uid'],
|
||||
(int)$formDatas['rack'],
|
||||
(int)$formDatas['line'],
|
||||
(int)$formDatas['sale']
|
||||
);
|
||||
}
|
||||
//서비스 수정
|
||||
$entity = parent::modify_process($entity, $formDatas);
|
||||
if (!$entity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||
}
|
||||
//서버정보 연결
|
||||
service('equipment_serverservice')->attachToService($entity);
|
||||
//결제정보 연결
|
||||
service('paymentservice')->attachToService($entity);
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
}
|
||||
|
||||
@ -216,32 +216,18 @@ class ServerService extends EquipmentService
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
// public function getCalculatedAmount(ServerEntity $entity): int
|
||||
// {
|
||||
// $caculatedAmount = $entity->getPrice();
|
||||
// //해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
|
||||
// foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
|
||||
// if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) { //월비용일때만 적용
|
||||
// $caculatedAmount += $serverPartEntity->getTotalAmount(); //단가*Cnt
|
||||
// }
|
||||
// }
|
||||
// return $caculatedAmount;
|
||||
// }
|
||||
// //결제관련처리
|
||||
// public function setAmount(ServerEntity $entity): ServerEntity
|
||||
// {
|
||||
// if ($entity->getServiceInfoUID() === null) {
|
||||
// throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의된 후에만 가능합니다.");
|
||||
// }
|
||||
// //서비스정보 반영
|
||||
// $serviceEntity = $this->getServiceService()->getEntity($entity->getServiceInfoUID());
|
||||
// if (!$serviceEntity instanceof ServiceEntity) {
|
||||
// throw new \Exception(__METHOD__ . "에서 오류발생: {$entity->getServiceInfoUID()} 서비스 정보를 찾을수 없습니다.");
|
||||
// }
|
||||
// $this->getServiceService()->setAmount($serviceEntity, $this->getCalculatedAmount($entity));
|
||||
// return $entity;
|
||||
// }
|
||||
|
||||
//총서버금액
|
||||
public function getCalculatedAmount(int $uid): int
|
||||
{
|
||||
$entity = $this->getEntity($uid);
|
||||
$serverPartService = service('equipment_serverpartservice');
|
||||
$caculatedAmount = $entity->getPrice();
|
||||
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart찾아서 월청구액에 합산한다.
|
||||
foreach ($serverPartService->getEntities(['serverinfo_uid' => $entity->getPK(), 'billing' => PAYMENT['BILLING']['MONTH']]) as $serverPartEntity) {
|
||||
$caculatedAmount += $serverPartEntity->getCalculatedAmount(); //단가*Cnt
|
||||
}
|
||||
return $caculatedAmount;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
@ -255,6 +241,8 @@ class ServerService extends EquipmentService
|
||||
//서비스관련
|
||||
public function attachToService(ServiceEntity $serviceEntity): void
|
||||
{
|
||||
//서버정보 가져오기
|
||||
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
|
||||
@ -262,10 +250,12 @@ class ServerService extends EquipmentService
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
parent::modify_process($serviceEntity, $formDatas);
|
||||
parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
public function detachFromService(ServiceEntity $serviceEntity): void
|
||||
{
|
||||
//서버정보 가져오기
|
||||
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = NULL;
|
||||
$formDatas["clientinfo_uid"] = NULL;
|
||||
@ -273,6 +263,6 @@ class ServerService extends EquipmentService
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
parent::modify_process($serviceEntity, $formDatas);
|
||||
parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,17 +2,18 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use RuntimeException;
|
||||
use DateTime;
|
||||
use App\Models\PaymentModel;
|
||||
use App\Helpers\PaymentHelper;
|
||||
use App\Forms\PaymentForm;
|
||||
use App\Entities\PaymentEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\DTOs\PaymentDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
use App\Forms\PaymentForm;
|
||||
use App\Helpers\PaymentHelper;
|
||||
use App\Models\PaymentModel;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
|
||||
class PaymentService extends CommonService
|
||||
{
|
||||
@ -134,70 +135,6 @@ class PaymentService extends CommonService
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
//기본 일회성 입력
|
||||
protected function create_process(array $formDatas): PaymentEntity
|
||||
{
|
||||
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서비스정보가 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('title', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제 제목이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('amount', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구금액이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('billing', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구방법이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('billing_at', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급기한일이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('pay', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급방법이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('status', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제상태가 정의되지 않았습니다.');
|
||||
}
|
||||
//서비스 정보 가져오기
|
||||
$serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']);
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생: {$formDatas['serviceinfo_uid']} 서비스정보를 찾을수 없습니다.");
|
||||
}
|
||||
//서버파트정보 생성
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
|
||||
$formDatas['amount'] = $serviceEntity->getAmount();
|
||||
$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
|
||||
{
|
||||
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서비스정보가 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('title', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제 제목이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('amount', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구금액이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('billing', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구방법이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('billing_at', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급기한일이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('pay', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급방법이 정의되지 않았습니다.');
|
||||
}
|
||||
if (!array_key_exists('status', $formDatas)) {
|
||||
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제상태가 정의되지 않았습니다.');
|
||||
}
|
||||
return parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setFilter(string $field, mixed $filter_value): void
|
||||
@ -272,16 +209,18 @@ class PaymentService extends CommonService
|
||||
}
|
||||
|
||||
//서비스관련
|
||||
public function createByService(ServiceEntity $serviceEntity): void
|
||||
public function attachToService(ServiceEntity $serviceEntity): void
|
||||
{
|
||||
//서버파트정보 생성
|
||||
//결제정보 생성
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
|
||||
$formDatas['title'] = sprintf(
|
||||
"%s %s 서비스비용",
|
||||
$serviceEntity->getTitle(),
|
||||
DateTime::createFromFormat('Y-m-d', $serviceEntity->getBillingAt())->format('Y년 m월')
|
||||
);
|
||||
$formDatas['amount'] = $serviceEntity->getAmount();
|
||||
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
||||
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
||||
$formDatas['pay'] = PAYMENT['PAY']['ACCOUNT'];
|
||||
@ -291,35 +230,17 @@ class PaymentService extends CommonService
|
||||
$this->getFormService()->setFormRules('create', $fields);
|
||||
$this->create_process($formDatas);
|
||||
}
|
||||
public function modifyByService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity): void
|
||||
public function detachFromService(ServiceEntity $serviceEntity): void
|
||||
{
|
||||
//수정 전 서비스정보와 수정후 서비스정보의 결제일이 다를경우 수정 전 서비스정보의 결제일을 기준으로 결제정보를 찾은 후 수정 후 정보로 변경한다.
|
||||
$billing_at = $serviceEntity->getBillingAt();
|
||||
if ($oldServiceEntity->getBillingAt() !== $serviceEntity->getBillingAt()) {
|
||||
$billing_at = $oldServiceEntity->getBillingAt();
|
||||
}
|
||||
//기존 Entity가져오기
|
||||
$entity = $this->getEntity(['serviceinifo_uid' => $serviceEntity->getPK(), 'billing_at' => $billing_at]);
|
||||
//서비스정보의 지급기한일과 같은 결제정보 가져오기
|
||||
$entity = $this->getEntity(['serviceinifo_uid' => $serviceEntity->getPK(), 'billing_at' => $serviceEntity->getBillingAt()]);
|
||||
if (!$entity) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류발생: 해당하는 결제정보을 찾을수 없습니다.");
|
||||
}
|
||||
|
||||
//이미 지불이 완료된 결제정보인 경우
|
||||
//결제가 완료된 경우라면 처리불가
|
||||
if ($entity->getStatus() === STATUS['PAID']) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류발생: 해당하는 결제정보는 이미 결제처리가 완료되어 수정이 불가합니다.");
|
||||
}
|
||||
|
||||
//서버파트정보 생성
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas['title'] = sprintf(
|
||||
"%s %s 서비스비용",
|
||||
$serviceEntity->getTitle(),
|
||||
DateTime::createFromFormat('Y-m-d', $serviceEntity->getBillingAt())->format('Y년 m월')
|
||||
);
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
$this->modify_process($entity, $formDatas);
|
||||
$this->delete_process($entity->getPK());
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<?php $serverPartCellDatas['entity'] = $entity ?>
|
||||
<?php $htmls[$type][] = [
|
||||
'view' => $serverPartCellDatas['helper']->getFieldView($type, $entity->getPK(), $serverPartCellDatas),
|
||||
'amount' => $entity->getTotalAmount(),
|
||||
'amount' => $entity->getCalculatedAmount(),
|
||||
'entity' => $entity
|
||||
] ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
0
getFormFields())
Normal file
0
getFormFields())
Normal file
0
getValidationRule($field
Normal file
0
getValidationRule($field
Normal file
0
run($formDatas)
Normal file
0
run($formDatas)
Normal file
Loading…
Reference in New Issue
Block a user