dbms_primeidc_init...1

This commit is contained in:
최준흠 2025-04-17 11:15:33 +09:00
parent c67e28c2c9
commit e52dfb3bda
7 changed files with 393 additions and 2 deletions

View File

@ -0,0 +1,183 @@
<?php
namespace lib\Controllers\DBMS\Client;
use lib\Services\HistoryService;
use lib\Services\MemberService;
use lib\Services\OnetimeService;
use lib\Utils\Pagination;
class PointController extends ClientController
{
private ?OnetimeService $_onetimeService = null;
private ?HistoryService $_historyService = null;
private ?MemberService $_memberService = null;
public function __construct()
{
parent::__construct();
$this->getView()->setPath('point');
} //
public function getMemberService(): MemberService
{
if ($this->_memberService === null) {
$this->_memberService = new MemberService();
}
return $this->_memberService;
}
public function getOnetimeService(): OnetimeService
{
if ($this->_onetimeService === null) {
$this->_onetimeService = new OnetimeService();
}
return $this->_onetimeService;
}
public function getHistoryService(): HistoryService
{
if ($this->_historyService === null) {
$this->_historyService = new HistoryService();
}
return $this->_historyService;
}
//IdcCouponListMK.jsp -> IdcPointListMK.jsp 신규추가가
//CLI 접속방법 : php index.php site/client/point/index
//WEB 접속방법 : http://localhost/site/client/point/index
public function index(array $params)
{
//쿠폰내역
$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->getServiceService()->getEntitiesForCoupon($this->curPage, $this->perPage);
$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__);
}
//IdcCouponUseMK.jsp -> domain_coupon_use.php
//CLI 접속방법 : php index.php site/client/counpon/client/client_code/코드
//WEB 접속방법 : http://localhost/site/client/coupon/client/client_code/코드
public function client(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;
//전체 관리자정보(등록자)
if (!array_key_exists('mkid', $params)) {
throw new \Exception("mkid 값이 정의되지 않았습니다.");
}
$member_code = $params['mkid'];
$member = $this->getMemberService()->getEntityByCode($member_code);
if (!$member) {
throw new \Exception("[$member_code]에 해당하는 관리자정보가 존재하지 않습니다.");
}
$this->member = $member;
//쿠폰내역
$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->getServiceService()->getEntitiesForCoupon($this->curPage, $this->perPage, $client_code);
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
return $this->render(__FUNCTION__);
}
//IdcCouponBuyMK.jsp -> domain_coupon_buy.php
//CLI 접속방법 : php index.php site/client/counpon/insert_form
//WEB 접속방법 : http://localhost/site/client/coupon/insert_form
public function insert_form(array $params)
{
if (!array_key_exists('service_code', $params)) {
throw new \Exception("service_code 값이 정의되지 않았습니다.");
}
$service_code = $params['service_code'];
$service = $this->getServiceService()->getEntityByCode($service_code);
if (!$service) {
throw new \Exception("[$service_code]에 해당하는 서비스정보가 존재하지 않습니다.");
}
$this->service = $service;
//사용자정보
$client = $this->getClientService()->getEntityByCode($service->getClientCode());
if (!$client) {
throw new \Exception("[{$service->getClientCode()}]에 해당하는 사용자정보가 존재하지 않습니다.");
}
$this->client = $client;
//전체 관리자정보(등록자)
if (!array_key_exists('mkid', $params)) {
throw new \Exception("mkid 값이 정의되지 않았습니다.");
}
$member_code = $params['mkid'];
$member = $this->getMemberService()->getEntityByCode($member_code);
if (!$member) {
throw new \Exception("[$member_code]에 해당하는 관리자정보가 존재하지 않습니다.");
}
$this->member = $member;
$this->today = date("Y-m-d");
return $this->render(__FUNCTION__);
}
//IdcCouponBuyMK.jsp -> domain_coupon_buy.php
//CLI 접속방법 : php index.php site/client/counpon/insert_form
//WEB 접속방법 : http://localhost/site/client/coupon/insert_form
public function insert(array $params)
{
if (!array_key_exists('service_code', $params)) {
throw new \Exception("service_code 값이 정의되지 않았습니다.");
}
$service_code = $params['service_code'];
$service = $this->getServiceService()->getEntityByCode($service_code);
if (!$service) {
throw new \Exception("[$service_code]에 해당하는 서비스정보가 존재하지 않습니다.");
}
//사용자정보
$client = $this->getClientService()->getEntityByCode($service->getClientCode());
if (!$client) {
throw new \Exception("[{$service->getClientCode()}]에 해당하는 사용자정보가 존재하지 않습니다.");
}
//전체 관리자정보(등록자)
if (!array_key_exists('mkid', $params)) {
throw new \Exception("mkid 값이 정의되지 않았습니다.");
}
$member_code = $params['mkid'];
$member = $this->getMemberService()->getEntityByCode($member_code);
if (!$member) {
throw new \Exception("[$member_code]에 해당하는 관리자정보가 존재하지 않습니다.");
}
//onetime_sub 도메인 구매 수량
$coupon = $this->request->get('coupon');
if (! $coupon || $coupon < 1) {
throw new \Exception("도메인 구매 수량 값이 정의되지 않았거나, 도메인 구매 수량은 1개 이상이어야 합니다.");
}
//onetime_note 도메인 구매 수량
$note = $this->request->get('note');
if (!$note) {
throw new \Exception("도메인 리스트 값이 정의되지 않았습니다.");
}
//onetime_case 사용용도
$onetime_case = $this->request->get('onetime_case') ?? 'point';
//onetime_request_date 사용일
$onetime_request_date = $this->request->get('onetime_request_date') ?? date("Y-m-d");
try {
$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()->commit();
return $this->redirect->to(DBMS_SITE_URL . "/IdcCouponUseMK.cup?client_code=" . $service->getClientCode());
} catch (\Exception $e) {
$this->getServiceService()->rollback();
return $this->redirect->back()->withInput()->with('error', ['message' => '쿠폰 사용에 실패하였습니다.:' . $e->getMessage()]);
}
}
} //Class

View File

@ -30,4 +30,8 @@ class ClientEntity extends Entity
{
return $this->Client_Note;
}
public function getPoint(): string
{
return $this->Client_Poinit;
}
} //Class

View File

@ -0,0 +1,44 @@
<h3>고객명 : <a href="/serviceDetail.sev?client_code=<?= $this->client->getClientCode() ?>"><?= $this->client->getTitle() ?></a> / 쿠폰발급대상 : <?= count($this->services) ?> 대 / 전체 남은 수량 : <?= $this->total_coupon; ?> 개</h3>
<div class="table-responsive" id="table">
<input type="hidden" id="token">
<table class="table table-bordered table-hover table-striped" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">No</th>
<th style="text-align:center;">서비스코드</th>
<th style="text-align:center;">장비명</th>
<th style="text-align:center;">서버IP</th>
<th style="text-align:center;">서비스개시일</th>
<th style="text-align:center;">회선종류</th>
<th style="text-align:center;">쿠폰 누적수</th>
<th style="text-align:center;">쿠폰 잔량수</th>
<th style="text-align:center;">쿠폰 사용수</th>
<th style="text-align:center;">사용</th>
</tr>
</thead>
<tbody>
<?php $i = 0; ?>
<?php foreach ($this->services as $service) { ?>
<?php $num = count($this->services) - $i; ?>
<tr>
<td><?= $num ?></td>
<td><a href="/serviceDetailSolo.sev?client_code=<?= $service->getClientCode() ?>&service_code=<?= $service->getServiceCode() ?>"><?= $service->getServiceCode() ?></td>
<td><?= $service->getServerCode() ?></td>
<td><?= $service->service_ip ?></td>
<td><?= $service->service_open_date ?></td>
<td><?= $service->service_line ?></td>
<td><?= $service->getCoupon() + $service->getUsedCoupon() ?></td>
<td onclick="location.href='/IdcCouponBuyMK.cup?service_code=<?= $service->getServiceCode() ?>&mkid=<?= $this->member->getPK() ?>'" style=" cursor: pointer;"><?= $service->getCoupon() ?></td>
<td><?= $service->getUsedCoupon() ?></td>
<?php if (!$service->getCoupon()) { ?>
<td><a href="/IdcCouponBuyMK.cup?service_code=<?= $service->getServiceCode() ?>&mkid=<?= $this->member->getPK() ?>">사용완료</a></td>
<?php } else { ?>
<td><a href="/IdcCouponBuyMK.cup?service_code=<?= $service->getServiceCode() ?>&mkid=<?= $this->member->getPK() ?>">사용하기</a></td>
<?php } ?>
</tr>
<?php $i++; ?>
<?php } ?>
</tbody>
</table>
</div>
<div align='center'><?= $this->pagination->render(DBMS_SITE_URL . "/IdcCouponUseMK.cup", ['client_code' => $this->client->getClientCode(), 'member_code' => $this->member->getPK(), 'curPage' => $this->curPage, 'perPage' => $this->perPage]) ?></div>

View File

@ -0,0 +1,37 @@
<div class="table-responsive" id="table">
<input type="hidden" id="token">
<table class="table table-bordered table-hover table-striped" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">No</th>
<th style="text-align:center;">서비스코드</th>
<th style="text-align:center;">장비명</th>
<th style="text-align:center;">서버IP</th>
<th style="text-align:center;">서비스개시일</th>
<th style="text-align:center;">회선종류</th>
<th style="text-align:center;">쿠폰 누적수</th>
<th style="text-align:center;">쿠폰 잔량수</th>
<th style="text-align:center;">쿠폰 사용수</th>
</tr>
</thead>
<tbody>
<?php $i = 0; ?>
<?php foreach ($this->services as $service) { ?>
<?php $num = count($this->services) - $i; ?>
<tr>
<td><?= $num ?></td>
<td><a href="/serviceDetailSolo.sev?client_code=<?= $service->getClientCode() ?>&service_code=<?= $service->getServiceCode() ?>"><?= $service->getServiceCode() ?></td>
<td><?= $service->getServerCode() ?></td>
<td><?= $service->service_ip ?></td>
<td><?= $service->service_open_date ?></td>
<td><?= $service->service_line ?></td>
<td><?= $service->getCoupon() + $service->getUsedCoupon() ?></td>
<td><?= $service->getCoupon() ?></td>
<td><?= $service->getUsedCoupon() ?></td>
</tr>
<?php $i++; ?>
<?php } ?>
</tbody>
</table>
</div>
<div align='center'><?= $this->pagination->render(DBMS_SITE_URL . "/IdcCouponListMK.cup", ['curPage' => $this->curPage, 'perPage' => $this->perPage]) ?></div>

View File

@ -0,0 +1,55 @@
<div class="table-responsive">
<form method="post" action="<?= DBMS_SITE_HOST ?>/dbms/client/coupon/insert/service_code/<?= $this->service->getServiceCode() ?>/mkid/<?= $this->member->getPK() ?>">
<table class="table table-bordered table-hover table-striped">
<thead></thead>
<tbody>
<tr>
<td>고객명</td>
<td colspan="5"><?= $this->client->getTitle() ?></td>
</tr>
<tr>
<td>서비스코드</td>
<td colspan="5"><?= $this->service->getServiceCode() ?></td>
</tr>
<tr>
<td>장비번호</td>
<td colspan="5"><?= $this->service->getServerCode() ?></td>
</tr>
<tr>
<td>도메인 구매 수량</td>
<td colspan="5">
<select name="coupon" id="coupon">
<?php for ($i = 1; $i < $this->service->getCoupon(); $i++) { ?>
<option value="<?= $i ?>"><?= $i ?>개</option>
<?php } ?>
</select> (개별 서버에 할당된 남은 쿠폰 수량 : <?= $this->service->getCoupon() ?>)
</td>
</tr>
<tr>
<td>서비스 금액</td>
<td colspan="3">도메인 쿠폰 사용</td>
</tr>
<tr>
<td>도메인 신청일</td>
<td><?= $this->today ?></td>
<td>쿠폰 사용일</td>
<td colspan="3"><?= $this->today ?></td>
</tr>
<tr>
<td>도메인 리스트</td>
<td colspan="5"><textarea cols="100" rows="4" type="text" name="note" id="note"></textarea>
<br>(공백을 허용하지 않습니다. 예제처럼 붙여쓰기 하세요 / 예제 : test.com/123.com/idcjp.jp)
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="6">
<input class="btn btn-outline btn-primary" type="submit" value="저장하기">
<input class="btn btn-outline btn-default" type="button" value="취소" onclick="location.href='/IdcCouponUseMK.cup?client_code=<?= $this->service->getClientCode() ?>'">
</td>
</tr>
</tfoot>
</table>
</form>
</div>

View File

@ -57,8 +57,7 @@ $(function()
<h4><i class="fa fa-desktop fa-fw"></i> 도메인 쿠폰 리스트</h4>
</div>
<div class="panel-body">
<c:import url="${phpurl}/dbms/client/coupon/index" />
<c:import url="${phpurl}/dbms/client/coupon/index" />
</div>
<!-- panel-body -->
</div>

View File

@ -0,0 +1,69 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% pageContext.setAttribute("phpurl",request.getScheme()+"://"+request.getServerName()); %>
<script src="IDC/js/setToken.js"></script>
<script>
var tableToExcel = (function(){
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})();
</script>
<script type="text/javascript">
$(function()
{
//사용버튼/삭제
$(".useCup").click(function()
{
var result = $(this).attr("val");
if(result>0)
window.location = $(this).attr("value")+"&token="+$("#token").val();
else
alert("사용할 쿠폰이 없습니다.");
});
//삭제, 수정
$(".delBtn").click(function()
{
var temp= $(this).parents("tr").find("input");
var a="&cupon_request_date="+$(temp[0]).val();
var b="&cupon_current="+$(temp[1]).val();
var c="&cupon_use="+$(temp[2]).val();
var d="&cupon_result="+$(temp[3]).val();
if($(temp[4]).prop("checked"))
{
e="&server_upgrade=o"
}
if($(temp[5]).prop("checked"))
{
e="&server_upgrade=x"
}
var f="&cupon_end_date="+$(temp[6]).val();
var g="&cupon_note="+$(temp[7]).val();
window.location = $(this).attr("value")+"&token="+$("#token").val()+a+b+c+d+e+f+g;
});
});
</script>
<!-- 여기가 본 페이지이다 -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h4><i class="fa fa-desktop fa-fw"></i> 포인트 리스트</h4>
</div>
<div class="panel-body">
<c:import url="${phpurl}/dbms/client/point/index" />
</div>
<!-- panel-body -->
</div>
<!-- panel panel-default -->
</div>
<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->