From a813ea810cfc814179f851cc84778a91339cb3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Fri, 11 Apr 2025 11:54:50 +0900 Subject: [PATCH] dbms_primeidc_init...1 --- .../DBMS/Client/CouponController.php | 34 +++---------------- .../DBMS/Client/DashboardController.php | 2 +- .../DBMS/Client/MemoController.php | 3 +- .../DBMS/Client/OnetimeController.php | 10 +++--- extdbms/lib/Services/CommonService.php | 16 ++++++++- extdbms/lib/Services/OnetimeService.php | 14 ++++++++ extdbms/lib/Services/ServiceService.php | 17 ++++++++-- .../lib/Views/dbms/client/onetime/coupon.php | 3 +- .../src/idc/IdcCuponFrontController.java | 2 +- 9 files changed, 59 insertions(+), 42 deletions(-) diff --git a/extdbms/lib/Controllers/DBMS/Client/CouponController.php b/extdbms/lib/Controllers/DBMS/Client/CouponController.php index fb27bed..5a70ed6 100644 --- a/extdbms/lib/Controllers/DBMS/Client/CouponController.php +++ b/extdbms/lib/Controllers/DBMS/Client/CouponController.php @@ -64,17 +64,9 @@ class CouponController extends ClientController } $this->member = $member; //쿠폰내역 - $this->getServiceService()->getModel()->where("client_code", $client_code); - $this->getServiceService()->getModel()->whereNotIn("service_line", ['vpn', 'test', 'soloLine', 'substitution']); - //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 continue() - $this->getServiceService()->getModel()->setContinue(true); - $this->total = $this->getServiceService()->getCount(); - //limit, offset 설정 $this->curPage = intval($params['curPage'] ?? $this->request->get('curPage') ?? 1); $this->perPage = intval($params['perPage'] ?? $this->request->get('perPage') ?? VIEW_LIST_PERPAGE); - $this->getServiceService()->getModel()->limit($this->perPage); - $this->getServiceService()->getModel()->offset(($this->curPage - 1) * $this->perPage); - $this->services = $this->getServiceService()->getEntities(); + [$this->total, $this->services] = $this->getServiceService()->getEntitiesByClient($this->curPage, $this->perPage, $client_code); $this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage); $total_coupon = 0; foreach ($this->services as $service) { @@ -114,24 +106,6 @@ class CouponController extends ClientController } $this->member = $member; $this->today = date("Y-m-d"); - //쿠폰내역 - $this->getServiceService()->getModel()->where("client_code", $service->getClientCode()); - $this->getServiceService()->getModel()->whereNotIn("service_line", ['vpn', 'test', 'soloLine', 'substitution']); - //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 continue() - $this->getServiceService()->getModel()->setContinue(true); - $this->total = $this->getServiceService()->getCount(); - //limit, offset 설정 - $this->curPage = intval($params['curPage'] ?? $this->request->get('curPage') ?? 1); - $this->perPage = intval($params['perPage'] ?? $this->request->get('perPage') ?? VIEW_LIST_PERPAGE); - $this->getServiceService()->getModel()->limit($this->perPage); - $this->getServiceService()->getModel()->offset(($this->curPage - 1) * $this->perPage); - $this->services = $this->getServiceService()->getEntities(); - $this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage); - $total_coupon = 0; - foreach ($this->services as $service) { - $total_coupon += $service->getCoupon(); - } - $this->total_coupon = $total_coupon; return $this->render(__FUNCTION__); } @@ -178,17 +152,17 @@ class CouponController extends ClientController //onetime_request_date 사용일 $onetime_request_date = $this->request->get('onetime_request_date') ?? date("Y-m-d"); try { - $this->getServiceService()->getModel()->setTransaction(true); + $this->getServiceService()->beginTransaction(); //서비스쿠폰 갯수 수정 $this->getServiceService()->useCouponForDomain($service, $coupon); //쿠폰 사용내역 onetime에 등록 $this->getOnetimeService()->useCouponForDomain($service, $client, $member, $onetime_case, $coupon, $note, $onetime_request_date); //쿠폰 사용내역 history에 등록 $this->getHistoryService()->useCouponForDomain($service, $client, $onetime_case, $coupon, $note, $onetime_request_date);; - $this->getServiceService()->getModel()->commit(); + $this->getServiceService()->commit(); return $this->redirect->to(DBMS_SITE_URL . "/IdcCouponUseMK.cup?client_code=" . $this->client->getClientCode()); } catch (\PDOException $e) { - $this->getServiceService()->getModel()->rollback(); + $this->getServiceService()->rollback(); return $this->redirect->back()->withInput()->with('error', ['message' => '쿠폰 사용에 실패하였습니다.:' . $e->getMessage()]); } } diff --git a/extdbms/lib/Controllers/DBMS/Client/DashboardController.php b/extdbms/lib/Controllers/DBMS/Client/DashboardController.php index f915dab..70c17d1 100644 --- a/extdbms/lib/Controllers/DBMS/Client/DashboardController.php +++ b/extdbms/lib/Controllers/DBMS/Client/DashboardController.php @@ -37,7 +37,7 @@ class DashboardController extends ClientController $dashboard[$service_line] = $this->getServiceService()->getServiceLineCountByClient($client_code, $service_line); } //foreach //서비스상태별(정상,정지,해지등) - $dashboard['coupon'] = intval($this->getServiceService()->getCouponCountByClient($client_code)); + $dashboard['coupon'] = intval($this->getServiceService()->getCouponTotalCountByClient($client_code)); $this->dashboard = $dashboard; $this->client_code = $client_code; return $this->render(__FUNCTION__); diff --git a/extdbms/lib/Controllers/DBMS/Client/MemoController.php b/extdbms/lib/Controllers/DBMS/Client/MemoController.php index 845f353..608efae 100644 --- a/extdbms/lib/Controllers/DBMS/Client/MemoController.php +++ b/extdbms/lib/Controllers/DBMS/Client/MemoController.php @@ -35,8 +35,7 @@ class MemoController extends ClientController throw new \Exception("client_code 값이 정의되지 않았습니다."); } $client_code = $params['client_code']; - $this->getClientService()->getModel()->where("Client_Code", $client_code); - $entity = $this->getClientService()->getEntity(); + $entity = $this->getClientService()->getEntityByCode($client_code); if (!$entity) { throw new \Exception("[$client_code]에 해당하는 사용자정보가 존재하지 않습니다."); } diff --git a/extdbms/lib/Controllers/DBMS/Client/OnetimeController.php b/extdbms/lib/Controllers/DBMS/Client/OnetimeController.php index 2dbb84d..35c47bb 100644 --- a/extdbms/lib/Controllers/DBMS/Client/OnetimeController.php +++ b/extdbms/lib/Controllers/DBMS/Client/OnetimeController.php @@ -4,6 +4,7 @@ namespace lib\Controllers\DBMS\Client; use lib\Services\MemberService; use lib\Services\OnetimeService; +use lib\Utils\Pagination; class OnetimeController extends ClientController { @@ -35,10 +36,11 @@ class OnetimeController extends ClientController public function coupon() { //쿠폰내역 - $this->getOnetimeService()->getModel()->like(["onetime_case" => "%domain%"]); - $this->getOnetimeService()->getModel()->orderBy("onetime_request_date", "DESC"); - $this->entities = $this->getOnetimeService()->getEntities(); - //해당 고객정보 + $this->curPage = intval($params['curPage'] ?? $this->request->get('curPage') ?? 1); + $this->perPage = intval($params['perPage'] ?? $this->request->get('perPage') ?? VIEW_LIST_PERPAGE); + [$this->total, $this->services] = $this->getOnetimeService()->getEntitiesForDomainCoupon($this->curPage, $this->perPage); + $this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage); + //전체 고객정보 $this->clients = $this->getClientService()->getEntities(); //전체 관리자정보(등록자) $this->members = $this->getMemberService()->getEntities(); diff --git a/extdbms/lib/Services/CommonService.php b/extdbms/lib/Services/CommonService.php index 87f8b33..7ad83f7 100644 --- a/extdbms/lib/Services/CommonService.php +++ b/extdbms/lib/Services/CommonService.php @@ -13,7 +13,7 @@ abstract class CommonService extends Core } // abstract public function getModelClass(): string; abstract public function getEntityClass(): string; - final public function getModel(): mixed + final protected function getModel(): mixed { if ($this->_model === null) { $modelClass = $this->getModelClass(); @@ -57,4 +57,18 @@ abstract class CommonService extends Core } return $insertId; } // + + //transaction관련련 + final public function beginTransaction(): void + { + $this->getModel()->beginTransaction(); + } + final public function commit(): void + { + $this->getModel()->commit(); + } + final public function rollBack(): void + { + $this->getModel()->rollBack(); + } } //Class diff --git a/extdbms/lib/Services/OnetimeService.php b/extdbms/lib/Services/OnetimeService.php index 5a9e5c9..d42aeac 100644 --- a/extdbms/lib/Services/OnetimeService.php +++ b/extdbms/lib/Services/OnetimeService.php @@ -42,6 +42,20 @@ class OnetimeService extends CommonService return $this->getCount(); } + //Coupon 리스트 + public function getEntitiesForDomainCoupon(int $curPage, int $perPage): array + { + $this->getModel()->like(["onetime_case", "%domain%"]); + $this->getModel()->orderBy("onetime_request_date", "DESC"); + //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 continue() + $this->getModel()->setContinue(true); + $total = $this->getCount(); + //limit, offset 설정 + $this->getModel()->limit($perPage); + $this->getModel()->offset(($curPage - 1) * $perPage); + return [$total, $this->getEntities()]; + } + //도메인쿠폰 사용용 public function useCouponForDomain(ServiceEntity $service, ClientEntity $client, MemberEntity $member, string $onetime_case, int $coupon, string $note, string $onetime_request_date): bool { diff --git a/extdbms/lib/Services/ServiceService.php b/extdbms/lib/Services/ServiceService.php index 3d9433d..5f031ba 100644 --- a/extdbms/lib/Services/ServiceService.php +++ b/extdbms/lib/Services/ServiceService.php @@ -34,6 +34,20 @@ class ServiceService extends CommonService $this->getModel()->where('service_code', $key); return $this->getEntity(); } + //사용자별 서비스리스트트 + public function getEntitiesByClient(int $curPage, int $perPage, string $client_code): array + { + $this->getModel()->where("client_code", $client_code); + $this->getModel()->whereNotIn("service_line", ['vpn', 'test', 'solo', 'substitution', 'event']); + //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 continue() + $this->getModel()->setContinue(true); + $total = $this->getCount(); + //limit, offset 설정 + $this->getModel()->limit($perPage); + $this->getModel()->offset(($curPage - 1) * $perPage); + return [$total, $this->getEntities()]; + } + //최근 $day일간 신규서비스 카운트 public function getLatestCount(int $day, array $excepts): int|string { @@ -114,13 +128,12 @@ class ServiceService extends CommonService return $this->getCount(); } //사용자별용 서비스 쿠폰 카운트 - public function getCouponCountByClient(string $client_code): int + public function getCouponTotalCountByClient(string $client_code): int { $this->getModel()->where("client_code", "{$client_code}"); $this->getModel()->whereNotIn("service_line", ['vpn', 'test', 'solo', 'substitution', 'event']); return $this->getCount("SUM(coupon) as cnt"); } - //도메인쿠폰 사용용 public function useCouponForDomain(ServiceEntity $service, int $coupon): bool { diff --git a/extdbms/lib/Views/dbms/client/onetime/coupon.php b/extdbms/lib/Views/dbms/client/onetime/coupon.php index b2ce551..cda685b 100644 --- a/extdbms/lib/Views/dbms/client/onetime/coupon.php +++ b/extdbms/lib/Views/dbms/client/onetime/coupon.php @@ -31,4 +31,5 @@ - \ No newline at end of file + +
pagination->render(DBMS_SITE_URL . "/IdcDomainBuyListMK.cup", ['curPage' => $this->curPage, 'perPage' => $this->perPage]) ?>
\ No newline at end of file diff --git a/idcproject/src/idc/IdcCuponFrontController.java b/idcproject/src/idc/IdcCuponFrontController.java index 40f8a34..8af14e1 100644 --- a/idcproject/src/idc/IdcCuponFrontController.java +++ b/idcproject/src/idc/IdcCuponFrontController.java @@ -93,7 +93,7 @@ public class IdcCuponFrontController extends HttpServlet { viewPage="DefaultPage.jsp"; } //NEW 도메인 구매 목록 조회 - MK - if(cmdURI.equals("/IdcDomainBuyListMK.cup")) + if(cmdURI.equals("/.cup")) { cmd = new IdcCuponListCmd(); cmd.execute(request, response);