shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-11 18:37:22 +09:00
parent d8c8743dd4
commit c3d837d18e
32 changed files with 667 additions and 257 deletions

View File

@ -152,6 +152,10 @@ define('URLS', [
'LOGIN' => '/front/user/login',
'SIGNUP' => '/front/user/signup',
'LOGOUT' => '/front/user/logout',
'addCart' => '/ecommerce/addCart',
'cancelCart' => '/ecommerce/cancelCart',
'paymentCard' => '/ecommerce/paymentCard',
'depositPayment' => '/ecommerce/depositPayment',
]);
//SESSION 관련
define('SESSION_NAMES', [
@ -231,6 +235,7 @@ define('CLASS_ICONS', [
'PRODUCT' => '<i class="bi bi-box2"></i>',
'ORDER' => '<i class="bi bi-cart4"></i>',
'PAYMENT' => '<i class="bi bi-cash-coin"></i>',
'ECOMMERCE' => '<i class="bi bi-shop"></i>',
]);
define('AUDIOS', [
'Alram_GetEmail' => '<object width=0 height=0 data="/sound/jarvis_email.mp3" type="audio/mpeg"></object>',

View File

@ -38,8 +38,12 @@ $routes->get('/', 'Home::index');
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
});
$routes->group('ecommerce', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->post('addCart', 'EcommerceController::addCart');
$routes->get('cancelCart', 'EcommerceController::cancelCart');
$routes->post('addCart', 'CartController::insert');
$routes->get('cancelCart', 'CartController::delete');
$routes->get('paymentCard/(:uuid)', 'EcommerceController::cardPayment_form/$1', ['filter' => 'authFilter:user']);
$routes->post('paymentCard/(:uuid)', 'EcommerceController::cardPayment/$1', ['filter' => 'authFilter:user']);
$routes->get('depositPayment/(:uuid)', 'EcommerceController::depositPayment_form/$1', ['filter' => 'authFilter:user']);
$routes->post('depositPayment/(:uuid)', 'EcommerceController::depositPayment/$1', ['filter' => 'authFilter:user']);
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
@ -167,9 +171,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
});
$routes->group('payment', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) {
$routes->get('', 'PaymentController::index');
$routes->get('card/(:uuid)', 'PaymentController::card_form/$1');
$routes->post('card/(:uuid)', 'PaymentController::card/$1');
$routes->get('deposit/(:uuid)', 'PaymentController::deposit_form/$1');
});
});
/*

View File

@ -40,6 +40,10 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
$routes->group('ecommerce', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->post('addCart', 'EcommerceController::addCart');
$routes->get('cancelCart', 'EcommerceController::cancelCart');
$routes->get('paymentCard/(:uuid)', 'EcommerceController::cardPayment_form/$1', ['filter' => 'authFilter:user']);
$routes->post('paymentCard/(:uuid)', 'EcommerceController::cardPayment/$1', ['filter' => 'authFilter:user']);
$routes->get('depositPayment/(:uuid)', 'EcommerceController::depositPayment_form/$1', ['filter' => 'authFilter:user']);
$routes->post('depositPayment/(:uuid)', 'EcommerceController::depositPayment/$1', ['filter' => 'authFilter:user']);
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
@ -165,6 +169,9 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
$routes->get('', 'OrderController::index');
$routes->get('view/(:uuid)', 'OrderController::view/$1');
});
$routes->group('payment', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) {
$routes->get('', 'PaymentController::index');
});
});
/*
* --------------------------------------------------------------------

View File

@ -2,11 +2,11 @@
namespace App\Controllers\Admin;
use App\Controllers\Trait\UpDownloadTrait;
use App\Models\BoardModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Controllers\Trait\UpDownloadTrait;
class BoardController extends AdminController
{
@ -14,8 +14,9 @@ class BoardController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new BoardModel();
$this->_viewDatas['className'] = 'Board';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array

View File

@ -15,8 +15,9 @@ class CategoryController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new CategoryModel();
$this->_viewDatas['className'] = 'Category';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
@ -72,7 +73,7 @@ class CategoryController extends AdminController
// $categorys = array_reverse($categorys); //중분류의 경우 나중에 넣은것이 먼저되므로 reverse해서 처리
foreach ($categorys as $category) {
$viewDatas = [
'className' => $this->_model->getClassName(),
'className' => $this->_viewDatas['className'],
'category' => $category,
'parent_category' => $old_category,
'sibling_categorys' => $categorys

View File

@ -12,8 +12,9 @@ class OrderController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new OrderModel();
$this->_viewDatas['className'] = 'Order';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
final public function getFields(string $action = ""): array

View File

@ -14,8 +14,9 @@ class ProductController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new ProductModel();
$this->_viewDatas['className'] = 'Product';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
@ -64,9 +65,9 @@ class ProductController extends AdminController
if ($this->_viewDatas['fieldDatas']['cost'] < $this->_viewDatas['fieldDatas']['sale']) {
throw new \Exception(sprintf(
"%s가[%s] %s[%s]보다 작습니다.",
lang($this->_model->getClassName() . '.label.cost'),
lang($this->_viewDatas['className'] . '.label.cost'),
number_format($this->_viewDatas['fieldDatas']['cost']),
lang($this->_model->getClassName() . '.label.sale'),
lang($this->_viewDatas['className'] . '.label.sale'),
number_format($this->_viewDatas['fieldDatas']['sale']),
));
}

View File

@ -12,8 +12,9 @@ class SitepageController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new SitepageModel();
$this->_viewDatas['className'] = 'Sitepage';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array

View File

@ -12,8 +12,9 @@ class UserController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new UserModel();
$this->_viewDatas['className'] = 'User';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{

View File

@ -12,8 +12,9 @@ class UserSNSController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new UserSNSModel();
$this->_viewDatas['className'] = 'UserSNS';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{

View File

@ -60,10 +60,9 @@ abstract class BaseController extends Controller
$this->_session = \Config\Services::session();
$this->_viewDatas['layout'] = LAYOUTS['empty'];
$this->_viewDatas['session'] = $this->_session;
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
$this->_viewDatas['className'] = $this->_model->getClassName();
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_model->getClassName())];
helper($this->_model->getClassName());
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
helper($this->_viewDatas['className']);
//사용자 기본 Role 지정
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
@ -78,10 +77,52 @@ abstract class BaseController extends Controller
abstract public function getFields(string $action): array;
abstract public function getFieldFilters(): array;
//Field별 Rule용
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
default:
$rules[$field] = $this->_model->getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
final public function getFieldRules(array $fields, string $action = ""): array
{
$rules = array();
foreach ($fields as $field) {
$rules = $this->getFieldRule($field, $rules, $action);
}
return $rules;
}
public function getFieldBatchFilters(): array
{
return $this->getFieldFilters();
}
//Field별 Form Option용
public function getFieldFormOption(string $field): array
{
switch ($field) {
default:
$options = $this->_model->getFieldFOrmOption($field);
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
final public function getFieldFormOptions(array $fields): array
{
$fieldFormOptions = array();
foreach ($fields as $field) {
if (!is_string($field)) {
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
}
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
}
return $fieldFormOptions;
}
//Field별 Form Datas 처리용
protected function getFieldFormData(string $field, $entity = null): array
{
@ -108,10 +149,10 @@ abstract class BaseController extends Controller
break;
}
$this->_viewDatas['fields'] = $fields ?: $this->getFields($action);
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action);
$this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action);
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
$this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']);
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
return $this->_viewDatas;
}
@ -547,7 +588,7 @@ abstract class BaseController extends Controller
//Header용
$column = 'A';
foreach ($viewDatas['fields'] as $field) {
$sheet->setCellValue($column++ . '1', lang($this->_model->getClassName() . '.label.' . $field));
$sheet->setCellValue($column++ . '1', lang($this->_viewDatas['className'] . '.label.' . $field));
}
//본문용
$line = 2;

View File

@ -1,91 +1,61 @@
<?php
namespace App\Controllers;
namespace App\Controllers\Ecommerce;
use App\Entities\PaymentEntity;
use App\Models\OrderModel;
use App\Models\PaymentModel;
use App\Models\ProductModel;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class EcommerceController extends Controller
class CartController extends EcommerceController
{
/**
* Instance of the main Request object.
*
* @var CLIRequest|IncomingRequest
*/
protected $request;
/**
* An array of helpers to be loaded automatically upon
* class instantiation. These helpers will be available
* to all other controllers that extend BaseController.
*
* @var array
*/
protected $helpers = ['Common'];
/**
* Be sure to declare properties for any property fetch you initialized.
* The creation of dynamic property is deprecated in PHP 8.2.
*/
// protected $session;
/**
* Constructor.
*/
private $_session = null;
private $_viewDatas = array();
private $_orderModel = null;
private $_productModel = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_viewDatas['className'] = 'Cart';
parent::initController($request, $response, $logger);
$this->_session = \Config\Services::session();
$this->_viewDatas['title'] = '장바구니';
$this->_viewDatas['session'] = $this->_session;
}
private function getOrderModel()
{
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
}
private function getProductModel()
{
return $this->_productModel = $this->_productModel ?: new ProductModel();
}
//주문정보 확인
private function addCart_validate()
public function getFields(string $action = ""): array
{
//fieldData Rule 검사
if (!$this->validate($this->_viewDatas['fieldRules'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
$fields = ["product_uid", "quantity", "price"];
switch ($action) {
default:
return $fields;
break;
}
//fieldData 적용
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
}
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "product_uid":
case "quantity":
case "price":
$rules = $this->getOrderModel()->getFieldRules($field, $rules, $action);
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
public function getFieldFilters(): array
{
return [];
}
public function getFieldBatchFilters(): array
{
return parent::getFieldBatchFilters();
}
//주문(장바구니담기)
public function addCart()
public function insert()
{
$msg = "";
try {
$this->_viewDatas['fields'] = ["product_uid", "quantity", "price"];
$this->_viewDatas['fieldRules'] = $this->getOrderModel()->getFieldRules($this->_viewDatas['fields']);
$this->_viewDatas = $this->init(__FUNCTION__);
//Transaction 시작
$this->getOrderModel()->transStart();
//장바구니정보 검증
$this->addCart_validate();
$this->insert_validate();
//상품정보 가져오기
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]);
//재고수 비교
@ -134,7 +104,7 @@ class EcommerceController extends Controller
}
//주문취소(uid -> order_uid)
public function cancelCart($uid)
public function delete($uid)
{
$msg = "";
try {

View File

@ -0,0 +1,41 @@
<?php
namespace App\Controllers\Ecommerce;
use App\Controllers\BaseController;
use App\Models\OrderModel;
use App\Models\ProductModel;
use App\Models\UserModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
abstract class EcommerceController extends BaseController
{
private $_userModel = null;
private $_orderModel = null;
private $_productModel = null;
protected $_session = null;
protected $_viewPath = '';
protected $_viewDatas = array();
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_session = \Config\Services::session();
$this->_viewPath .= 'ecommerce/';
$this->_viewDatas['control'] = 'front';
$this->_viewDatas['layout'] = LAYOUTS['front'];
}
final protected function getUserModel()
{
return $this->_userModel = $this->_userModel ?: new UserModel();
}
final protected function getOrderModel()
{
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
}
final protected function getProductModel()
{
return $this->_productModel = $this->_productModel ?: new ProductModel();
}
}

View File

@ -0,0 +1,137 @@
<?php
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;
class CardController extends PaymentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{
switch ($action) {
case 'insert':
return ["order_uid", "card_quota", "card_number", "card_expiration", "email", "mobile"];
break;
default:
return [];
break;
}
}
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "order_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 "card_quota":
$rules[$field] = 'required|in_list[00,01]';
break;
case "card_number":
$rules[$field] = 'required|regex_match[/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}/]';
break;
case "card_expiration":
$rules[$field] = 'required|regex_match[/^[1-12]{2}-[0-9]{4}/]';
break;
case "email":
$rules[$field] = 'required|valid_email';
break;
case "mobile":
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
public function getFieldFilters(): array
{
return ['card_quota'];
}
public function getFieldBatchFilters(): array
{
return parent::getFieldBatchFilters();
}
//Field별 Form Option용
public function getFieldFormOption(string $field): array
{
switch ($field) {
case 'card_quota':
$options = lang($this->_viewDatas['className'] . '.CARD_QUOTA');
break;
default:
$options = parent::getFieldFormOption($field);
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
//카드결제 Form
//Insert관련
protected function 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->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
$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()
{
//결제후 정보저장
$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);
}
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace App\Controllers\Ecommerce\Payment;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class DepositController extends PaymentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_viewDatas['className'] = 'Deposit';
parent::initController($request, $response, $logger);
}
public function getFields(string $action = ""): array
{
switch ($action) {
case 'insert':
return ["order_uid", "email", "mobile"];
break;
default:
return [];
break;
}
}
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "order_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 "email":
$rules[$field] = 'required|valid_email';
break;
case "mobile":
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
public function getFieldFilters(): array
{
return [];
}
public function getFieldBatchFilters(): array
{
return parent::getFieldBatchFilters();
}
//무통장입금결제Form
//Insert관련
protected function insert_form_process()
{
$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->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/deposit', ['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()
{
//결제후 정보저장
$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);
}
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Controllers\Ecommerce\Payment;
use App\Controllers\Ecommerce\EcommerceController;
use App\Entities\PaymentEntity;
use App\Models\CategoryModel;
use App\Models\PaymentModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
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)
{
parent::initController($request, $response, $logger);
$this->_viewPath .= 'payment/';
//Default 회원정보 Category
$this->_category = DEFAULTS['PAYMENT_CATEGORY'];
$this->_category ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
$this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]);
$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();
}
protected function insert_process()
{
//Order 테이블에 결제완료 처리
$this->getOrderModel()->paymentCompleted();
}
}

View File

@ -11,9 +11,10 @@ class BoardController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new BoardModel($this->getFields());
$this->_model = new BoardModel();
$this->_viewDatas['className'] = 'Board';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{

View File

@ -11,9 +11,10 @@ class OrderController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new OrderModel($this->getFields());
$this->_model = new OrderModel();
$this->_viewDatas['className'] = 'Order';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
//Default 회원정보 Category
$this->_category = DEFAULTS['ORDER_CATEGORY'];
$this->isRole('index');

View File

@ -2,38 +2,24 @@
namespace App\Controllers\Front;
use App\Entities\PaymentEntity;
use App\Libraries\Adapter\Payment\CookiePayment as PaymentAdapter;
use App\Models\OrderModel;
use App\Models\PaymentModel;
use App\Models\UserModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class PaymentController extends FrontController
{
private $_userModel = null;
private $_orderModel = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new PaymentModel($this->getFields());
$this->_model = new PaymentModel();
$this->_viewDatas['className'] = 'Payment';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
//Default 회원정보 Category
$this->_category = DEFAULTS['PAYMENT_CATEGORY'];
$this->isRole('index');
}
private function getUserModel()
{
return $this->_userModel = $this->_userModel ?: new UserModel();
}
private function getOrderModel()
{
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
}
final public function getFields(string $action = ""): array
{
switch ($action) {
@ -60,93 +46,4 @@ class PaymentController extends FrontController
}
//추가기능
//결제(uid -> order_uid)
private function card_init()
{
$this->_viewDatas['fields'] = [
"card_quota", "card_number", "card_expiration", "card_email", "card_mobile"
];
$this->_viewDatas['fieldRules'] = [
'card_quota' => 'required|in_list[00,01]',
'card_number' => 'required|regex_match[/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}/]',
'card_expiration' => 'required|regex_match[/^[1-12]{2}-[0-9]{4}/]',
'card_email' => 'required|valid_email',
'card_mobile' => 'required|regex_match[/^^[0-9]{3}-[0-9]{4}-[0-9]{4}/]',
];
$this->_viewDatas['fieldFilters'] = ['card_quota'];
$this->_viewDatas['fieldFormOptions']['card_quota'] = lang($this->_model->getClassName() . '.CARD_QUOTA');
}
public function card_form($uid)
{
try {
$this->card_init();
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
$this->_viewDatas['order'] = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
helper(['form']);
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/card', ['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 card_validate()
{
//fieldData Rule 검사
if (!$this->validate($this->_viewDatas['fieldRules'])) {
throw new \Exception("결제정보의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
}
//fieldData 적용
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
}
}
//처리
private function card_process(): PaymentEntity
{
//결제후 정보저장
$adapter = new PaymentAdapter();
$response = $adapter->execute();
echo var_export($response, true);
return $this->_model->create($response);
}
public function card($uid)
{
$msg = "";
try {
$this->card_init();
$this->card_validate();
$entity = $this->card_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);
}
}
public function deposit_form($uid)
{
try {
$this->_viewDatas['bank'] = [
"name" => getenv("payment.deposit.bank.name") ?: "은행명",
"account" => getenv("payment.deposit.bank.account") ?: "계좌번호",
"holder" => getenv("payment.deposit.bank.holder") ?: "예금주"
];
$this->_viewDatas['order'] = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/deposit', ['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());
}
}
}

View File

@ -11,9 +11,10 @@ class ProductController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new ProductModel($this->getFields());
$this->_model = new ProductModel();
$this->_viewDatas['className'] = 'Product';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{

View File

@ -11,9 +11,10 @@ class SitepageController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new SitepageModel($this->getFields());
$this->_model = new SitepageModel();
$this->_viewDatas['className'] = 'Sitepage';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{

View File

@ -14,8 +14,9 @@ class UserController extends FrontController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new UserModel();
$this->_viewDatas['className'] = 'User';
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
$this->_viewPath .= strtolower($this->_viewDatas['className']);
$this->initAdapters();
//Default 회원정보 Category

View File

@ -0,0 +1,103 @@
<?php
function getFieldLabel_EcommerceHelper($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_EcommerceHelper($field, $value, array $viewDatas, array $attributes = array())
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
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 'email':
return form_input($field, $viewDatas['user']->email);
break;
case 'mobile':
return form_input($field, $viewDatas['user']->mobile);
break;
default:
return form_input($field, $value);
break;
}
} //
function getFieldView_EcommerceHelper($field, $entity, array $viewDatas)
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
default:
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
break;
}
} //
function getFieldFilter_EcommerceHelper($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_EcommerceHelper($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_EcommerceHelper($field, $entity, array $viewDatas): string
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
default:
return sprintf("<td>%s</td>", getFieldView_EcommerceHelper($field, $entity, $viewDatas));
break;
}
} //

View File

@ -137,15 +137,24 @@ function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): strin
break;
case 'status':
if ($value == DEFAULTS['STATUS']) {
return sprintf("<td><div class=\"payment_card\">%s</div><div class=\"payment_deposit\">%s</div></td>", anchor(
'/front/payment/card/' . $entity->getPrimaryKey(),
"카드결제",
["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"]
), anchor(
'/front/payment/deposit/' . $entity->getPrimaryKey(),
"무통장입금",
["class" => "btn btn-sm btn-info btn-circle", "style" => "color:white", "target" => "_self"]
));
return sprintf(
"<td nowrap class=\"text-start\"><div class=\"payment\">%s</div><div class=\"payment\">%s</div><div class=\"payment\">%s</div></td>",
anchor(
URLS['paymentCard'] . '/' . $entity->getPrimaryKey(),
"카드결제",
["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"]
),
anchor(
URLS['depositPayment'] . '/' . $entity->getPrimaryKey(),
"무통장입금",
["class" => "btn btn-sm btn-info btn-circle", "style" => "color:white", "target" => "_self"]
),
anchor(
current_url() . '/delete/' . $entity->getPrimaryKey(),
ICONS['DELETE'] . '주문취소',
["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]
)
);
} else {
return sprintf("<td>%s</td>", getFieldView_OrderHelper($field, $entity, $viewDatas));
}

View File

@ -0,0 +1,15 @@
<?php
return [
'title' => "결제 정보",
'label' => [
'card_quota' => '카드할부',
'card_number' => '카드번호',
'card_expiration' => '유효기간',
'email' => '이메일',
'mobile' => '휴대폰(인증용)',
],
"CARD_QUOTA" => [
"00" => "일시불",
"01" => "1개월",
]
];

View File

@ -1,6 +1,6 @@
<?php
return [
'title' => "결제 정보",
'title' => "쇼핑몰정보",
'label' => [
'uid' => "결제ID",
'TID' => "PG거래번호",
@ -18,14 +18,5 @@ return [
'ETC5' => "결제입력값",
'updated_at' => "수정일",
'created_at' => "작성일",
'card_quota' => '카드할부',
'card_number' => '카드번호',
'card_expiration' => '유효기간',
'card_email' => '이메일',
'card_mobile' => '휴대폰(인증용)',
],
"CARD_QUOTA" => [
"00" => "일시불",
"01" => "1개월",
]
];

View File

@ -38,26 +38,29 @@ class CookiePayment extends Payment
$adapter->setHeader("ApiKey", getenv("payment.card.pay2.apikey") ?: "COOKIEPAY에서 발급받은 연동키");
$adapter->setHeader("TOKEN", $this->getToken());
$adapter->setURL(getenv("payment.card.pay2.url") ?: "{요청도메인}/keyin/payment");
$adapter->setDatas(array(
'API_ID' => 'COOKIEPAY에서 발급받은 가맹점연동 ID',
'ORDERNO' => '주문번호',
'PRODUCTNAME' => '상품명',
'AMOUNT' => '결제금액',
'BUYERNAME' => '고객명',
'BUYEREMAIL' => '고객 E-MAIL',
'CARDNO' => '카드번호',
'EXPIREDT' => '카드유효기간',
'PRODUCTCODE' => '상품코드',
'BUYERID' => '고객 ID',
'BUYERADDRESS' => '고객 주소',
'BUYERPHONE' => '고객 휴대폰번호',
'QUOTA' => '할부개월',
'ETC1' => '추가필드 1',
'ETC2' => '추가필드 2',
'ETC3' => '추가필드 3',
'ETC4' => '추가필드 4',
'ETC5' => '추가필드 5',
));
$datas = $this->getDatas();
// array(
// 'API_ID' => 'COOKIEPAY에서 발급받은 가맹점연동 ID',
// 'ORDERNO' => '주문번호',
// 'PRODUCTNAME' => '상품명',
// 'AMOUNT' => '결제금액',
// 'BUYERNAME' => '고객명',
// 'BUYEREMAIL' => '고객 E-MAIL',
// 'CARDNO' => '카드번호',
// 'EXPIREDT' => '카드유효기간',
// 'PRODUCTCODE' => '상품코드',
// 'BUYERID' => '고객 ID',
// 'BUYERADDRESS' => '고객 주소',
// 'BUYERPHONE' => '고객 휴대폰번호',
// 'QUOTA' => '할부개월',
// 'ETC1' => '추가필드 1',
// 'ETC2' => '추가필드 2',
// 'ETC3' => '추가필드 3',
// 'ETC4' => '추가필드 4',
// 'ETC5' => '추가필드 5',
// )
$adapter->setDatas($datas);
return $adapter->execute();
}
}

View File

@ -6,11 +6,22 @@ use App\Libraries\Adapter\Adapter;
abstract class Payment extends Adapter
{
private $_datas = array();
protected function __construct($debug = false)
{
parent::__construct($debug);
}
abstract protected function execute_process(): object;
//결제용 데이터
final public function setDatas(array $datas)
{
$this->_datas = $datas;
}
final public function getDatas(): array
{
return $this->_datas;
}
final public function execute(): object
{
return $this->execute_process();

View File

@ -56,7 +56,7 @@ abstract class BaseModel extends Model
$this->_session = \Config\Services::session();
$this->_validation = \Config\Services::validation();
}
final public function getClassName()
final protected function getClassName()
{
return $this->_className;
}
@ -155,17 +155,17 @@ abstract class BaseModel extends Model
return $options;
}
//Field별 Form Option용
final public function getFieldFormOptions(array $fields): array
{
$fieldFormOptions = array();
foreach ($fields as $field) {
if (!is_string($field)) {
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
}
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
}
return $fieldFormOptions;
}
// final public function getFieldFormOptions(array $fields): array
// {
// $fieldFormOptions = array();
// foreach ($fields as $field) {
// if (!is_string($field)) {
// throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
// }
// $fieldFormOptions[$field] = $this->getFieldFormOption($field);
// }
// return $fieldFormOptions;
// }
final public function getUUID()
{

View File

@ -15,15 +15,15 @@
</tr>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_PaymentHelper($field, $viewDatas) ?></td>
<td class="label"><?= getFieldLabel_EcommerceHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_PaymentHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
<?= getFieldForm_EcommerceHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '결제', array("class" => "btn btn-outline btn-primary")); ?></td>
<td valign="bottom" colspan="2"><?= form_submit('', '카드결제', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
<?= form_close(); ?>

View File

@ -3,6 +3,7 @@
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<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">
<tr>
<td class="label">상품명</td>
@ -24,6 +25,15 @@
<td class="label">예금주</td>
<td class="column"><?= $viewDatas['bank']['holder'] ?></td>
</tr>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_EcommerceHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_EcommerceHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="2">
설명문......
@ -32,6 +42,12 @@
설명문......
</td>
</tr>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '무통장입금', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
<?= form_close(); ?>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</table>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div>

View File

@ -1,4 +1,4 @@
<?= form_open("ecommerce/addCart", ['method' => 'post']) ?>
<?= form_open(URLS['addCart'], ['method' => 'post']) ?>
<?= form_hidden("product_uid", $viewDatas['entity']->getPrimaryKey()) ?>
<input type="hidden" id="price" name="price" value="<?= ($viewDatas['entity']->price) * 1 ?>">
<?php