65 lines
2.8 KiB
PHP
65 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace lib\Controllers\DBMS\Client;
|
|
|
|
use lib\Services\MemberService;
|
|
use lib\Utils\Pagination;
|
|
|
|
class CouponController extends ClientController
|
|
{
|
|
private ?MemberService $_memberService = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->getView()->setPath('onetime');
|
|
} //
|
|
public function getMemberService(): MemberService
|
|
{
|
|
if ($this->_memberService === null) {
|
|
$this->_memberService = new MemberService();
|
|
}
|
|
return $this->_memberService;
|
|
}
|
|
//IdcCouponUseMK.jsp -> domain_coupon_use.php
|
|
//CLI 접속방법 : php index.php site/client/counpon
|
|
//WEB 접속방법 : http://localhost/site/client/coupon
|
|
public function index(array $params)
|
|
{
|
|
if (!array_key_exists('client_code', $params)) {
|
|
throw new \Exception("client_code 값이 정의되지 않았습니다.");
|
|
}
|
|
$client_code = $params['client_code'];
|
|
$client = $this->getClientService()->getEntityByCode($client_code);
|
|
if (!$client) {
|
|
throw new \Exception("[$client_code]에 해당하는 사용자정보가 존재하지 않습니다.");
|
|
}
|
|
$this->client = $client;
|
|
//전체 관리자정보(등록자)
|
|
$member_code = $params['member_code'];
|
|
$member = $this->getMemberService()->getEntityByCode($member_code);
|
|
if (!$member) {
|
|
throw new \Exception("[$member_code]에 해당하는 관리자정보가 존재하지 않습니다.");
|
|
}
|
|
$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->getRequest()->get('curPage') ?? 1);
|
|
$this->perPage = intval($params['perPage'] ?? $this->getRequest()->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__);
|
|
}
|
|
} //Class
|