shoppingmallv2 init...
This commit is contained in:
parent
9fae6d801c
commit
430767e7be
@ -155,8 +155,8 @@ define('URLS', [
|
|||||||
'Order' => '/front/order',
|
'Order' => '/front/order',
|
||||||
'addCart' => '/front/order/addCart',
|
'addCart' => '/front/order/addCart',
|
||||||
'cancelCart' => '/front/order/cancelCart',
|
'cancelCart' => '/front/order/cancelCart',
|
||||||
'cardPayment' => '/front/order/cardPayment',
|
'cardPayment' => '/front/order/payment/card',
|
||||||
'depositPayment' => '/front/order/depositPayment',
|
'depositPayment' => '/front/order/payment/deposit',
|
||||||
]);
|
]);
|
||||||
//SESSION 관련
|
//SESSION 관련
|
||||||
define('SESSION_NAMES', [
|
define('SESSION_NAMES', [
|
||||||
@ -166,7 +166,8 @@ define('SESSION_NAMES', [
|
|||||||
'CART' => 'cart'
|
'CART' => 'cart'
|
||||||
]);
|
]);
|
||||||
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
||||||
|
//월이용권 상품의 Category번호
|
||||||
|
define('RENTAL_PRODUCT_CATEGORYS', [5, 8]);
|
||||||
//인증 관련
|
//인증 관련
|
||||||
define('AUTH_ADAPTERS', [
|
define('AUTH_ADAPTERS', [
|
||||||
'Local' => [
|
'Local' => [
|
||||||
|
|||||||
@ -165,13 +165,12 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
|||||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||||
$routes->post('addCart', 'CartController::insert');
|
$routes->post('addCart', 'CartController::insert');
|
||||||
$routes->get('cancelCart/(:uuid)', 'CartController::delete/$1');
|
$routes->get('cancelCart/(:uuid)', 'CartController::delete/$1');
|
||||||
$routes->get('cardPayment/(:uuid)', 'CardController::update_form/$1', ['filter' => 'authFilter:user']);
|
$routes->group('payment', ['namespace' => 'App\Controllers\Front\Order\Payment', 'filter' => 'authFilter:user'], static function ($routes) {
|
||||||
$routes->post('cardPayment/(:uuid)', 'CardController::update/$1', ['filter' => 'authFilter:user']);
|
$routes->get('card/(:uuid)', 'CardController::update_form/$1');
|
||||||
$routes->get('depositPayment/(:uuid)', 'DepositController::update_form/$1', ['filter' => 'authFilter:user']);
|
$routes->post('card/(:uuid)', 'CardController::update/$1');
|
||||||
$routes->post('depositPayment/(:uuid)', 'DepositController::update/$1', ['filter' => 'authFilter:user']);
|
$routes->get('deposit/(:uuid)', 'DepositController::update_form/$1');
|
||||||
});
|
$routes->post('deposit/(:uuid)', 'DepositController::update/$1');
|
||||||
$routes->group('payment', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) {
|
});
|
||||||
$routes->get('', 'PaymentController::index');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class CartController extends OrderController
|
|||||||
{
|
{
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'insert':
|
case 'insert':
|
||||||
return $this->_product->type == DEFAULTS['STATUS'] ? ["product_uid", "quantity", "price", 'paymentday'] : ["product_uid", "quantity", "price"];
|
return ["product_uid", "quantity", "price", 'paymentday'];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
@ -39,10 +39,10 @@ class CartController extends OrderController
|
|||||||
break;
|
break;
|
||||||
case 'quantity':
|
case 'quantity':
|
||||||
case 'price':
|
case 'price':
|
||||||
$rules[$field] = "required|numeric";
|
$rules[$field] = "required|numeric";
|
||||||
break;
|
break;
|
||||||
case 'paymentday':
|
case 'paymentday':
|
||||||
$rules[$field] = $this->_product->type == DEFAULTS['STATUS'] ? "required|numeric" : "if_exist|numeric";
|
$rules[$field] = "if_exist|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rules = parent::getFieldRule($field, $rules, $action);
|
$rules = parent::getFieldRule($field, $rules, $action);
|
||||||
@ -64,14 +64,14 @@ class CartController extends OrderController
|
|||||||
{
|
{
|
||||||
$msg = "";
|
$msg = "";
|
||||||
try {
|
try {
|
||||||
//상품정보가져오기
|
|
||||||
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]);
|
|
||||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||||
//장바구니정보 검증
|
//장바구니정보 검증
|
||||||
$this->insert_validate();
|
$this->insert_validate();
|
||||||
|
//상품정보가져오기
|
||||||
|
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]);
|
||||||
//재고수 비교
|
//재고수 비교
|
||||||
if ($product->stock < $this->_viewDatas['fieldDatas']['quantity']) {
|
if ($product->stock < $this->_viewDatas['fieldDatas']['quantity']) {
|
||||||
throw new \Exception("구매수량이 너무 많습니다.\n구매수량:{$this->_viewDatas['fieldDatas']['quantity']}개, 남은 재고수량:{$entity->stock}개");
|
throw new \Exception("구매수량이 너무 많습니다.\n구매수량:{$this->_viewDatas['fieldDatas']['quantity']}개, 남은 재고수량:{$product->stock}개");
|
||||||
}
|
}
|
||||||
//구매 금액 비교
|
//구매 금액 비교
|
||||||
$price = $product->price * $this->_viewDatas['fieldDatas']['quantity'];
|
$price = $product->price * $this->_viewDatas['fieldDatas']['quantity'];
|
||||||
@ -80,7 +80,7 @@ class CartController extends OrderController
|
|||||||
}
|
}
|
||||||
//결제방식이 월이용권이면 결제일 확인
|
//결제방식이 월이용권이면 결제일 확인
|
||||||
$paymentDay = null;
|
$paymentDay = null;
|
||||||
if ($product->category_uid == DEFAULTS['STATUS']) {
|
if (in_array($product->category_uid, RENTAL_PRODUCT_CATEGORYS)) {
|
||||||
$paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
|
$paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
|
||||||
}
|
}
|
||||||
//Transaction 시작
|
//Transaction 시작
|
||||||
|
|||||||
@ -7,17 +7,13 @@ use CodeIgniter\HTTP\RequestInterface;
|
|||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
abstract class PaymentController extends OrderController
|
class PaymentController extends OrderController
|
||||||
{
|
{
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
parent::initController($request, $response, $logger);
|
parent::initController($request, $response, $logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function getFields(string $action = ""): array;
|
|
||||||
abstract public function getFieldFilters(): array;
|
|
||||||
abstract public function getFieldBatchFilters(): array;
|
|
||||||
|
|
||||||
//Update관련 (결제처리용)
|
//Update관련 (결제처리용)
|
||||||
protected function update_form_process($entity)
|
protected function update_form_process($entity)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class OrderModel extends BaseModel
|
|||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['product_uid'] = $entity->getPrimaryKey();
|
$formDatas['product_uid'] = $entity->getPrimaryKey();
|
||||||
//상품명을 복사해서 구매한 상품명에 넣기
|
//상품명을 복사해서 구매한 상품명에 넣기
|
||||||
$formDatas[$this->_model->getTitleField()] = $entity->getTitle();
|
$formDatas[$this->getTitleField()] = $entity->getTitle();
|
||||||
$formDatas['cost'] = $entity->price;
|
$formDatas['cost'] = $entity->price;
|
||||||
$formDatas['sale'] = 0;
|
$formDatas['sale'] = 0;
|
||||||
$formDatas['quantity'] = $quantity;
|
$formDatas['quantity'] = $quantity;
|
||||||
|
|||||||
@ -6,43 +6,70 @@
|
|||||||
<table class="form table table-bordered table-striped">
|
<table class="form table table-bordered table-striped">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||||
<tr></tr>
|
<tr>
|
||||||
<td class="label"><?= getFieldLabel_ProductHelper($field, $viewDatas) ?></td>
|
<td class="label"><?= getFieldLabel_ProductHelper($field, $viewDatas) ?></td>
|
||||||
<td class="column">
|
<td class="column">
|
||||||
<?= getFieldView_ProductHelper($field, $viewDatas['entity'], $viewDatas) ?>
|
<?= getFieldView_ProductHelper($field, $viewDatas['entity'], $viewDatas) ?>
|
||||||
<?= validation_show_error($field); ?>
|
<?= validation_show_error($field); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div style="text-align:center">
|
<?php if ($viewDatas['entity']->status == DEFAULTS['STATUS']) : ?>
|
||||||
<?php if ($viewDatas['entity']->status == DEFAULTS['STATUS']) : ?>
|
<?= form_open(URLS['addCart'], ['method' => 'post']) ?>
|
||||||
<?= form_open(URLS['addCart'], ['method' => 'post']) ?>
|
<?= form_hidden("product_uid", $viewDatas['entity']->getPrimaryKey()) ?>
|
||||||
<?= form_hidden("product_uid", $viewDatas['entity']->getPrimaryKey()) ?>
|
<input type="hidden" id="price" name="price" value="<?= ($viewDatas['entity']->price) * 1 ?>">
|
||||||
<input type="hidden" id="price" name="price" value="<?= ($viewDatas['entity']->price) * 1 ?>">
|
<?php
|
||||||
<?php
|
$quantityOptions = [DEFAULTS['EMPTY'] => "구매수량 선택"];
|
||||||
$quantityOptions = [DEFAULTS['EMPTY'] => "구매수량 선택"];
|
for ($i = 1; $i <= $viewDatas['entity']->stock; $i++) {
|
||||||
for ($i = 1; $i <= $viewDatas['entity']->stock; $i++) {
|
$quantityOptions[$i] = $i . "개";
|
||||||
$quantityOptions[$i] = $i . "개";
|
}
|
||||||
}
|
?>
|
||||||
?>
|
<table class="form table table-bordered table-striped" style="width:400px;">
|
||||||
구매 수량 : <?= form_dropdown('quantity', $quantityOptions, 1, ['onChange' => "cal_price(this.options[this.selectedIndex].value)"]); ?>
|
<tr>
|
||||||
구매 금액 : <span id="order_price"><?= number_format($viewDatas['entity']->price * 1) ?></span>원
|
<td class=" label" nowrap>구매금액</td>
|
||||||
<?= form_submit('', '최소:1 ~ 최대:' . $viewDatas['entity']->stock, array("class" => "btn btn-outline btn-primary")); ?>
|
<td class="column">
|
||||||
<?= form_close(); ?>
|
<span id="order_price"><?= number_format($viewDatas['entity']->price * 1) ?></span>원
|
||||||
<script>
|
</td>
|
||||||
function cal_price(quantity) {
|
<td rowspan="3">
|
||||||
var price = 0;
|
<?= form_submit('', '구매하기', array("class" => "btn btn-outline btn-primary")); ?>
|
||||||
price = <?= $viewDatas['entity']->price ?> * quantity;;
|
</td>
|
||||||
document.getElementById('price').value = price;
|
</tr>
|
||||||
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(price);
|
<tr>
|
||||||
|
<td class="label" nowrap>구매수량</td>
|
||||||
|
<td class="column">
|
||||||
|
<?= form_dropdown('quantity', $quantityOptions, old('quantity', 1), ['onChange' => "cal_price(this.options[this.selectedIndex].value)"]); ?>
|
||||||
|
<?= validation_show_error('quantity'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php if (in_array($viewDatas['category']->getPrimaryKey(), RENTAL_PRODUCT_CATEGORYS)) : ?>
|
||||||
|
<?php $paymentDayOptions = [DEFAULTS['EMPTY'] => "결제일 선택"];
|
||||||
|
for ($i = 1; $i <= 28; $i++) {
|
||||||
|
$paymentDayOptions[$i] = "매월 {$i}일";
|
||||||
}
|
}
|
||||||
</script>
|
?>
|
||||||
<?php else : ?>
|
<tr>
|
||||||
이제품은 현재[<?= lang('Product.STATUS.' . $viewDatas['entity']->status) ?>]입니다.
|
<td class="label" nowrap>결제일</td>
|
||||||
<?php endif ?>
|
<td class="column">
|
||||||
</div>
|
<?= form_dropdown('paymentday', $paymentDayOptions, old('paymentday', 25)) ?>
|
||||||
|
<?= validation_show_error('paymentday'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif ?>
|
||||||
|
</table>
|
||||||
|
<?= form_close(); ?>
|
||||||
|
<script>
|
||||||
|
function cal_price(quantity) {
|
||||||
|
var price = 0;
|
||||||
|
price = <?= $viewDatas['entity']->price ?> * quantity;;
|
||||||
|
document.getElementById('price').value = price;
|
||||||
|
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(price);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<?php else : ?>
|
||||||
|
이제품은 현재[<?= lang('Product.STATUS.' . $viewDatas['entity']->status) ?>]입니다.
|
||||||
|
<?php endif ?>
|
||||||
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
|
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
Loading…
Reference in New Issue
Block a user