dbms_init...1

This commit is contained in:
choi.jh 2025-06-18 09:57:13 +09:00
parent 94dc5c933f
commit e437c1e3cd
3 changed files with 13 additions and 33 deletions

View File

@ -59,29 +59,4 @@ class ServiceModel extends CustomerModel
} }
return $rule; return $rule;
} }
//다음 달로 결제일을 연장합니다.
public function extendPaymentDate(int $uid): mixed
{
$sql = "UPDATE ? SET billing_at = IF(
DAY(billing_at) = DAY(LAST_DAY(billing_at)),
LAST_DAY(DATE_ADD(billing_at, INTERVAL 1 MONTH)),
DATE_ADD(billing_at, INTERVAL 1 MONTH))
WHERE uid = ? AND status = ?";
$sql = $this->setQuery($sql)
->setParameter(1, $this->getTableName())
->setParameter(2, $uid)
->setParameter(3, DEFAULTS['STATUS'])
->getSQL();
if (!$sql) {
throw new \Exception("SQL문이 생성되지 않았습니다.");
}
if (!$this->isValidQuery($sql)) {
throw new \Exception("SQL문이 유효하지 않습니다: " . $sql);
}
// 쿼리 실행
if (!$this->execute($sql)) {
throw new \Exception("SQL문 실행에 실패했습니다: " . $sql);
}
return $this->query($sql);
}
} }

View File

@ -71,7 +71,7 @@ abstract class CommonService
} }
return $this->setRelatedEntity($entity); return $this->setRelatedEntity($entity);
} }
public function findAllDatas(array $columns = ['*']): mixed protected function findAllDatas(array $columns = ['*']): mixed
{ {
return $this->getModel()->select(implode(',', $columns))->findAll(); return $this->getModel()->select(implode(',', $columns))->findAll();
} }

View File

@ -78,24 +78,29 @@ class ServiceService extends CustomerService
{ {
return $this->_searchIP; return $this->_searchIP;
} }
public function findAllDatas(array $columns = ['*']): mixed protected function findAllDatas(array $columns = ['*']): mixed
{ {
$ip = $this->getSearchIp(); $ip = $this->getSearchIp();
if ($ip) { if ($ip) {
$sql = "SELECT serviceinfo.* FROM serviceinfo $sql = "SELECT serviceinfo.* FROM serviceinfo
LEFT JOIN serviceinfo_items ON serviceinfo.uid = serviceinfo_items.serviceinfo_uid LEFT JOIN serviceinfo_items ON serviceinfo.uid = serviceinfo_items.serviceinfo_uid
WHERE serviceinfo_items.item_type='IP' WHERE serviceinfo_items.item_type = ?
AND serviceinfo_items.item_uid IN (SELECT uid FROM ipinfo WHERE ip='{$ip}')"; AND serviceinfo_items.item_uid IN (SELECT uid FROM ipinfo WHERE ip = ?)";
return $this->getModel()->query($sql)->getResult(ServiceEntity::class); return $this->getModel()->query($sql, ['IP', $ip])->getResult(ServiceEntity::class);
} }
return parent::findAllDatas($columns); return parent::findAllDatas($columns);
} }
//기본 기능부분 //기본 기능부분
//다음 달로 결제일을 연장합니다. //다음 달로 결제일을 연장합니다.
public function extendPaymentDate(ServiceEntity $entity): void public function extendBillingAt(ServiceEntity $entity): bool
{ {
$this->getModel()->extendPaymentDate($entity->getPK()); $sql = "UPDATE serviceinfo SET billing_at =
IF(DAY(billing_at) > DAY(LAST_DAY(billing_at)),
LAST_DAY(DATE_ADD(billing_at, INTERVAL 1 MONTH)),
DATE_ADD(billing_at, INTERVAL 1 MONTH)
) WHERE uid = ?";
return $this->getModel()->query($sql, [$entity->getPK()]);
} }
public function create(array $formDatas, mixed $entity = null): ServiceEntity public function create(array $formDatas, mixed $entity = null): ServiceEntity
{ {