shoppingmallv2 init...

This commit is contained in:
최준흠git config git config --helpgit config --global user.name 최준흠 2023-08-12 12:50:20 +09:00
parent 91cd1a05ee
commit 71deae7b31
25 changed files with 88 additions and 666 deletions

View File

@ -234,11 +234,9 @@ define('CLASS_ICONS', [
'CATEGORY' => '<i class="bi bi-boxes"></i>',
'PRODUCT' => '<i class="bi bi-box2"></i>',
'ORDER' => '<i class="bi bi-clipboard-check"></i>',
'PAYMENT' => '<i class="bi bi-cash-coin"></i>',
'ECOMMERCE' => '<i class="bi bi-shop"></i>',
'CART' => '<i class="bi bi-cart4"></i>',
'CARD' => '<i class="bi bi-credit-card"></i>',
'DEPOSIT' => '<i class="bi bi-piggy-bank"></i>',
'DEPOSIT' => '<i class="bi bi-cash-coin"></i>',
]);
define('CLASS_TOP_BANNER', [
'USER' => '<img src="/images/banner/sub_visual1.jpg"/>',
@ -248,10 +246,8 @@ define('CLASS_TOP_BANNER', [
'CATEGORY' => '<img src="/images/banner/sub_visual1.jpg"/>',
'PRODUCT' => '<img src="/images/banner/sub_visual2.jpg"/>',
'ORDER' => '<img src="/images/banner/sub_visual3.jpg"/>',
'PAYMENT' => '<img src="/images/banner/sub_visual4.jpg"/>',
'ECOMMERCE' => '<img src="/images/banner/sub_visual1.jpg"/>',
'CART' => '<img src="/images/banner/sub_visual2.jpg"/>',
'CARD' => '<img src="/images/banner/sub_visual3.jpg"/>',
'CART' => '<img src="/images/banner/sub_visual4.jpg"/>',
'CARD' => '<img src="/images/banner/sub_visual4.jpg"/>',
'DEPOSIT' => '<img src="/images/banner/sub_visual4.jpg"/>',
]);
define('AUDIOS', [

View File

@ -41,10 +41,10 @@ $routes->group('ecommerce', ['namespace' => 'App\Controllers\Ecommerce'], functi
$routes->post('addCart', 'CartController::insert');
$routes->get('cancelCart', 'CartController::delete');
$routes->group('payment', ['namespace' => 'App\Controllers\Ecommerce\Payment', 'filter' => 'authFilter:user'], function ($routes) {
$routes->get('card', 'CardController::insert_form');
$routes->post('card', 'CardController::insert');
$routes->get('deposit', 'DepositController::insert_form');
$routes->post('deposit', 'DepositController::insert');
$routes->get('card/(:uuid)', 'CardController::update_form/$1');
$routes->post('card(:uuid)', 'CardController::update/$1');
$routes->get('deposit(:uuid)', 'DepositController::update_form/$1');
$routes->post('deposit(:uuid)', 'DepositController::update/$1');
});
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함

View File

@ -1,46 +0,0 @@
<?php
namespace App\Controllers\Admin;
use App\Models\PaymentModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class PaymentController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new PaymentModel();
$this->_viewDatas['className'] = 'Payment';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
final public function getFields(string $action = ""): array
{
switch ($action) {
case 'insert':
return ["TID", "ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
break;
case "index":
case "excel":
case "view":
return ["ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
break;
default:
return [];
break;
}
}
final public function getFieldFilters(): array
{
return [];
}
final public function getFieldBatchFilters(): array
{
return [];
}
//추가기능
}

View File

@ -2,16 +2,17 @@
namespace App\Controllers\Ecommerce\Payment;
use App\Entities\PaymentEntity;
use App\Libraries\Adapter\Payment\CookiePayment as PaymentAdapter;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Models\OrderModel;
class CardController extends PaymentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new OrderModel();
$this->_viewDatas['className'] = 'Card';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_viewDatas['className']);
@ -80,59 +81,22 @@ class CardController extends PaymentController
return $options;
}
//카드결제 Form
//Insert관련
protected function insert_form_process()
//카드결제처리
protected function update_process($entity)
{
parent::insert_form_process();
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => ['order_uid' => $this->_viewDatas['order']->getPrimaryKey()]];
}
public function insert_form()
{
try {
$uid = $this->request->getVar('order_uid') ?: throw new \Exception("주문번호가 지정되지 않았습니다.");
$this->_viewDatas = $this->init(__FUNCTION__);
$this->_viewDatas['order'] = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
$this->insert_form_process();
helper(['form']);
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/insert', ['viewDatas' => $this->_viewDatas]);
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
}
}
//PG사 카드결제처리
protected function insert_process()
{
//결제후 정보저장
//PG사 결제후 정보저장
$adapter = new PaymentAdapter();
$adapter->setDatas($this->_viewDatas['fieldDatas']);
$response = $adapter->execute();
echo var_export($response, true);
$entity = $this->getPaymentModel()->create($response);
//아래는 Order Complete처리용
parent::insert_process();
return $entity;
}
//카드결제
public function insert()
{
$msg = "";
try {
$this->_viewDatas = $this->init(__FUNCTION__);
$this->insert_validate();
$entity = $this->insert_process();
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}" . __FUNCTION__ . " 완료하였습니다.";
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
log_message("error", $e->getMessage());
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
} finally {
$this->_session->setFlashdata("return_message", $msg);
//결과저장용
$responses = array("status" => $this->_viewDatas['className']);
foreach ($response as $key => $value) {
array_push($responses, "{$key}:{$value}");
}
foreach ($this->_viewDatas['fieldDatas'] as $key => $value) {
array_push($responses, "{$key}:{$value}");
}
$this->_viewDatas['fieldDatas'] = $responses;
return parent::update_process($entity);
}
}

View File

@ -5,11 +5,13 @@ namespace App\Controllers\Ecommerce\Payment;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Models\OrderModel;
class DepositController extends PaymentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new OrderModel();
$this->_viewDatas['className'] = 'Deposit';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_viewDatas['className']);
@ -53,59 +55,27 @@ class DepositController extends PaymentController
return parent::getFieldBatchFilters();
}
//무통장입금결제Form
//Insert관련
protected function insert_form_process()
//무통장입금결제Form
protected function update_form_process($entity)
{
parent::insert_form_process();
parent::update_form_process($entity);
$this->_viewDatas['bank'] = [
"name" => getenv("payment.deposit.bank.name") ?: "은행명",
"account" => getenv("payment.deposit.bank.account") ?: "계좌번호",
"holder" => getenv("payment.deposit.bank.holder") ?: "예금주"
];
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => ['order_uid' => $this->_viewDatas['order']->getPrimaryKey()]];
}
public function insert_form()
{
try {
$uid = $this->request->getVar('order_uid') ?: throw new \Exception("주문번호가 지정되지 않았습니다.");
$this->_viewDatas = $this->init(__FUNCTION__);
$this->_viewDatas['order'] = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
$this->insert_form_process();
helper(['form']);
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/insert', ['viewDatas' => $this->_viewDatas]);
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
}
}
protected function insert_process()
//무통장입금결제처리
protected function update_process($entity)
{
//결제후 정보저장
$entity = $this->getPaymentModel()->create($this->_viewDatas['fieldDatas']);
//아래는 Order Complete처리용
parent::insert_process();
return $entity;
}
//카드결제
public function insert()
{
$msg = "";
try {
$this->_viewDatas = $this->init(__FUNCTION__);
$this->insert_validate();
$entity = $this->insert_process();
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}" . __FUNCTION__ . " 완료하였습니다.";
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
log_message("error", $e->getMessage());
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
} finally {
$this->_session->setFlashdata("return_message", $msg);
//결과저장용
$responses = array("status" => $this->_viewDatas['className']);
foreach ($this->_viewDatas['fieldDatas'] as $key => $value) {
array_push($responses, "{$key}:{$value}");
}
$this->_viewDatas['fieldDatas'] = $responses;
return parent::update_process($entity);
}
}

View File

@ -12,7 +12,6 @@ use Psr\Log\LoggerInterface;
abstract class PaymentController extends EcommerceController
{
private $_paymentModel = null;
private $_categoryModel = null;
protected $_category = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
@ -27,24 +26,45 @@ abstract class PaymentController extends EcommerceController
$this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]);
}
final protected function getPaymentModel()
{
return $this->_paymentModel = $this->_paymentModel ?: new PaymentModel();
}
final protected function getCategoryModel()
{
return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel();
}
//insert관련
protected function insert_form_process()
//Update관련
public function update_form($uid)
{
parent::insert_form_process();
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
try {
$this->_viewDatas = $this->init(__FUNCTION__);
$entity = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
$this->_viewDatas['entity'] = $this->update_form_process($entity);
helper(['form']);
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
}
}
protected function insert_process()
//결제처리
public function update($uid)
{
//Order 테이블에 결제완료 처리
$this->getOrderModel()->paymentCompleted();
$msg = "";
try {
$this->_viewDatas = $this->init(__FUNCTION__);
$entity = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
$this->update_validate($entity);
$entity = $this->update_process($entity);
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 결제가 완료하였습니다.";
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
$msg = "{$this->_viewDatas['title']}에서 결제를 실패하였습니다.\n" . $e->getMessage();
log_message("error", $e->getMessage());
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
} finally {
$this->_session->setFlashdata("return_message", $msg);
}
}
}

View File

@ -1,49 +0,0 @@
<?php
namespace App\Controllers\Front;
use App\Models\PaymentModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class PaymentController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new PaymentModel();
$this->_viewDatas['className'] = 'Payment';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_viewDatas['className']);
//Default 회원정보 Category
$this->_category = DEFAULTS['PAYMENT_CATEGORY'];
$this->isRole('index');
}
final public function getFields(string $action = ""): array
{
switch ($action) {
case 'insert':
return ["TID", "ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
break;
case "index":
case "excel":
case "view":
return ["ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
break;
default:
return [];
break;
}
}
final public function getFieldFilters(): array
{
return [];
}
final public function getFieldBatchFilters(): array
{
return [];
}
//추가기능
}

View File

@ -145,36 +145,13 @@ CREATE TABLE shoppingmall.tw_order (
cost int(10) UNSIGNED NOT NULL COMMENT '구매원가',
sale int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '할인가',
price int(10) UNSIGNED NOT NULL COMMENT '결제액',
response text NULL COMMENT '결제처리결과',
quantity varchar(255) NOT NULL COMMENT '수량',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 결제하기, unuse: 주문취소, paid:결제완료 등등',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 결제하기, unuse: 주문취소, deposit:무통장입금, paid:결제완료 등등',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (product_uid) REFERENCES tw_product (uid),
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='Order 정보';
DROP TABLE IF EXISTS shoppingmall.tw_payment;
CREATE TABLE shoppingmall.tw_payment (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
TID varchar(20) NOT NULL COMMENT 'PG사 결제 거래고유번호 (전표출력 및 결제취소에 사용됩니다)',
ORDERNO varchar(50) NOT NULL COMMENT '주문번호',
AMOUNT int(10) UNSIGNED NOT NULL COMMENT '결제 된 금액',
QUOTA varchar(2) NOT NULL COMMENT '카드 할부결제시 할부기간 (00:일시불, 01:1개월)',
ACCEPTNO varchar(10) NOT NULL COMMENT '승인번호',
ACCEPTDATE varchar(20) NOT NULL COMMENT '승인일시',
RESULTCODE varchar(4) NOT NULL COMMENT '결제결과코드',
RESULTMSG varchar(100) NOT NULL COMMENT '결제결과메세지',
ETC1 varchar(100) NULL COMMENT '결제 요청시 입력한 값',
ETC2 varchar(100) NULL COMMENT '결제 요청시 입력한 값',
ETC3 varchar(100) NULL COMMENT '결제 요청시 입력한 값',
ETC4 varchar(100) NULL COMMENT '결제 요청시 입력한 값',
ETC5 varchar(100) NULL COMMENT '결제 요청시 입력한 값',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid),
UNIQUE KEY (tid),
CONSTRAINT FOREIGN KEY (orderno) REFERENCES tw_order (uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='Payment 정보';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='Order 정보';

View File

@ -1,19 +0,0 @@
<?php
namespace App\Entities;
class PaymentEntity extends BaseEntity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
//기본기능
final public function getTitle(): string
{
return $this->attributes['buyername'];
}
//추가기능
}

View File

@ -1,191 +0,0 @@
<?php
function getFieldLabel_PaymentHelper($field, array $viewDatas): string
{
$attributes = [];
switch ($field) {
default:
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
$attributes = ['style="color:red";'];
}
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
break;
}
}
//header.php에서 getFieldForm_Helper사용
function getFieldForm_PaymentHelper($field, $value, array $viewDatas, array $attributes = array())
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'product_uid':
case 'user_uid':
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
// }
// return implode("&nbsp;", $checkboxs);
break;
case 'title':
case 'name':
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
break;
case 'passwd':
return sprintf(
"%s %s %s",
form_password($field, DEFAULTS['EMPTY']),
lang("{$viewDatas['className']}.label.confirmpassword"),
form_password('confirmpassword', DEFAULTS['EMPTY']),
);
break;
case 'content':
case 'head':
case 'tail':
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
break;
case 'upload_file':
case 'board_file':
return form_upload($field);
break;
case 'view_cnt':
return form_input($field, $value, ['type' => 'number']);
break;
case "status":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
break;
case 'updated_at':
case 'created_at':
return form_input($field, $value, ['class' => 'calender']);
break;
case 'card_quota':
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
break;
case 'card_number':
return sprintf(
"%s-%s-%s-%s",
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4])
);
break;
case 'card_expiration':
$months = [];
for ($i = 1; $i <= 12; $i++) {
$months[$i] = "{$i}";
}
$start = date('Y');
$end = date('Y', strtotime(date("Y") . ' + 10 year'));
$years = [];
for ($i = $start; $i <= $end; $i++) {
$years[$i] = "{$i}";
}
return sprintf(
"%s월 %s년",
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']),
form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']),
);
break;
case 'card_email':
return form_input($field, $viewDatas['user']->email);
break;
case 'card_mobile':
return form_input($field, $viewDatas['user']->mobile);
break;
default:
return form_input($field, $value);
break;
}
} //
function getFieldView_PaymentHelper($field, $entity, array $viewDatas)
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'cost':
case 'price':
case 'sale':
return number_format(!$value ? 0 : $value) . "";
break;
case 'stock':
case 'view_cnt':
return number_format(!$value ? 0 : $value);
break;
case 'content':
return html_entity_decode($value);
break;
case 'updated_at':
case 'created_at':
return $value ? str_split($value, 10)[0] : "";
break;
default:
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
break;
}
} //
function getFieldFilter_PaymentHelper($field, $value, array $viewDatas)
{
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
} //
function getFieldIndex_Column_PaymentHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
if ($field == $viewDatas['order_field']) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
}
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
$viewDatas['uri']->addQuery('order_field', $field);
$viewDatas['uri']->addQuery('order_value', $value);
$columnData = anchor($viewDatas['uri'], $label);
switch ($field) {
default:
return sprintf("<th>%s</th>", $columnData);
break;
}
} //
//Front용
function getFieldIndex_Row_PaymentHelper($field, $entity, array $viewDatas): string
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'title':
case 'name':
return sprintf(
"<td>%s</td>",
anchor(
current_url() . '/view/' . $entity->getPrimaryKey(),
$value,
["target" => "_self"]
)
);
break;
default:
return sprintf("<td>%s</td>", getFieldView_PaymentHelper($field, $entity, $viewDatas));
break;
}
} //
//Admin용
function getFieldIndex_Row_PaymentHelper_Admin($field, $entity, array $viewDatas): string
{
switch ($field) {
default:
if (in_array($field, $viewDatas['fieldFilters'])) {
$attributes["onChange"] = sprintf(
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
current_url(),
$entity->getPrimaryKey(),
$field,
$field
);
return sprintf("<td>%s</td>", getFieldForm_PaymentHelper($field, $entity->$field, $viewDatas, $attributes));
}
return getFieldIndex_Row_PaymentHelper($field, $entity, $viewDatas);
break;
}
} //

View File

@ -18,7 +18,7 @@ return [
"STATUS" => [
"use" => "장바구니",
"unuse" => "주문취소",
"confirm" => "주문완료",
"paid" => "결제완료"
"Deposit" => "무통장입금",
"Card" => "카드결제"
]
];

View File

@ -1,22 +0,0 @@
<?php
return [
'title' => "쇼핑몰정보",
'label' => [
'uid' => "결제ID",
'TID' => "PG거래번호",
'ORDERNO' => "주문번호",
'AMOUNT' => "결제금액",
'QUOTA' => "카드할부",
'ACCEPTNO' => "승인번호",
'ACCEPTDATE' => "승인일시",
'RESULTCODE' => "결과코드",
'RESULTMSG' => "결과메세지",
'ETC1' => "결제입력값",
'ETC2' => "결제입력값",
'ETC3' => "결제입력값",
'ETC4' => "결제입력값",
'ETC5' => "결제입력값",
'updated_at' => "수정일",
'created_at' => "작성일",
],
];

View File

@ -1,106 +0,0 @@
<?php
namespace App\Models;
use App\Entities\PaymentEntity;
class PaymentModel extends BaseModel
{
private $_product_options = null;
protected $table = "tw_payment";
protected $returnType = PaymentEntity::class;
protected $useSoftDeletes = true;
public function __construct()
{
parent::__construct('Payment');
$this->allowedFields = [...$this->allowedFields, 'product_uid', "user_uid", "name", "cost", "sale", "quantity", "price", "status"];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
}
final public function getTitleField(): string
{
return 'name';
}
public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case 'product_uid':
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
break;
case $this->getTitleField():
$rules[$field] = "required|trim|string";
break;
case 'cost':
case 'quantity':
case 'price':
$rules[$field] = "required|numeric";
break;
case 'sale':
$rules[$field] = "if_exist|numeric";
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
//Field별 Form Option용
public function getFieldFormOption(string $field): array
{
switch ($field) {
case 'product_uid':
if (is_null($this->_product_options)) {
$productModel = new productModel();
$this->_product_options = $productModel->getOptions();
}
$options = $this->_product_options;
break;
default:
return parent::getFieldFormOption($field);
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
public function getEntity($conditions): PaymentEntity
{
return parent::getEntity($conditions);
}
public function create(array $formDatas): PaymentEntity
{
return $this->create_process(new PaymentEntity(), $formDatas);
}
public function modify(PaymentEntity $entity, array $formDatas): PaymentEntity
{
return $this->modify_process($entity, $formDatas);
}
//Index관련
public function setIndexWordFilter(string $word)
{
if ($word !== DEFAULTS['EMPTY']) {
parent::setIndexWordFilter($word);
$this->orLike($this->getTitleField(), $word, "both");
}
}
//장바구니에 넣기
public function addCart(array $formDatas): PaymentEntity
{
$orderFormDatas = [];
$orderFormDatas[$this->getTitleField()] = $formDatas[$this->getTitleField()];
$orderFormDatas['product_uid'] = $formDatas['product_uid'];
$orderFormDatas['cost'] = $formDatas['price'];
$orderFormDatas['sale'] = 0;
$orderFormDatas['quantity'] = $formDatas['quantity'];
$orderFormDatas['price'] = ($orderFormDatas['cost'] - $orderFormDatas['sale']) * $orderFormDatas['quantity'];
// echo var_export($orderFormDatas);
// exit;
return $this->create_process(new PaymentEntity(), $orderFormDatas);
}
//장바구니에 빼기
public function cancelCart(PaymentEntity $entity)
{
return $this->delete($entity->getPrimaryKey());
}
}

View File

@ -1,32 +0,0 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div class="top">
<?= $this->include('templates/admin/index_head') ?>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><?= getFieldIndex_Column_PaymentHelper($field, $viewDatas) ?><?php endforeach ?>
</tr>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td nowrap>
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<?= getFieldIndex_Row_PaymentHelper_Admin($field, $entity, $viewDatas) ?>
<?php endforeach ?>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</tbody>
</table>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -1,7 +1,7 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div id="content">>
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-hover table-striped">
@ -15,9 +15,9 @@
</tr>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_CardHelper($field, $viewDatas) ?></td>
<td class="label"><?= getFieldLabel_BoardHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_CardHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
<?= getFieldForm_BoardHelper($field, old($field, $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']), $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>

View File

@ -1,34 +0,0 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
<div class="top">
<?= $this->include('templates/front/index_head') ?>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><?= getFieldIndex_Column_PaymentHelper($field, $viewDatas) ?><?php endforeach ?>
</tr>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td nowrap>
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<?= getFieldIndex_Row_PaymentHelper($field, $entity, $viewDatas) ?>
<?php endforeach ?>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</tbody>
</table>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -6,9 +6,6 @@
<div class="sibling active">
<a href="http://localhost:8080/front/order?category=11" target="_self">주문정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/payment?category=12" target="_self">결제정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/user?category=22" target="_self">사용자정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 9 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 8 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">개인정보</div>
@ -6,11 +6,8 @@
<div class="sibling ">
<a href="http://localhost:8080/front/order?category=11" target="_self">주문정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/payment?category=12" target="_self">결제정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling active">
<a href="http://localhost:8080/front/user?category=22" target="_self">사용자정보</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 9 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 8 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 14 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 13 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">Support</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/board?category=4" target="_self">자료실</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 14 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 13 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 15 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 14 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">Support</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/board?category=4" target="_self">자료실</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 15 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 14 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 12 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 11 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">네트워크</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/product?category=6" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 12 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 11 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 13 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 12 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">네트워크</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/product?category=6" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 13 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 12 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 10 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 9 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">서버</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/product?category=9" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 10 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 9 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -1,4 +1,4 @@
<!-- DEBUG-VIEW START 11 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW START 10 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">서버</div>
@ -10,4 +10,4 @@
<a href="http://localhost:8080/front/product?category=9" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 11 APPPATH\Views\admin\category\leftmenu_template.php -->
<!-- DEBUG-VIEW ENDED 10 APPPATH\Views\admin\category\leftmenu_template.php -->