diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 27c4ff5..b85f463 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -155,8 +155,8 @@ define('URLS', [ 'Order' => '/front/order', 'addCart' => '/front/order/addCart', 'cancelCart' => '/front/order/cancelCart', - 'cardPayment' => '/front/order/cardPayment', - 'depositPayment' => '/front/order/depositPayment', + 'cardPayment' => '/front/order/payment/card', + 'depositPayment' => '/front/order/payment/deposit', ]); //SESSION 관련 define('SESSION_NAMES', [ @@ -166,7 +166,8 @@ define('SESSION_NAMES', [ 'CART' => 'cart' ]); define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']); - +//월이용권 상품의 Category번호 +define('RENTAL_PRODUCT_CATEGORYS', [5, 8]); //인증 관련 define('AUTH_ADAPTERS', [ 'Local' => [ diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f11ca07..926a1d3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -165,13 +165,12 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('view/(:uuid)', 'OrderController::view/$1'); $routes->post('addCart', 'CartController::insert'); $routes->get('cancelCart/(:uuid)', 'CartController::delete/$1'); - $routes->get('cardPayment/(:uuid)', 'CardController::update_form/$1', ['filter' => 'authFilter:user']); - $routes->post('cardPayment/(:uuid)', 'CardController::update/$1', ['filter' => 'authFilter:user']); - $routes->get('depositPayment/(:uuid)', 'DepositController::update_form/$1', ['filter' => 'authFilter:user']); - $routes->post('depositPayment/(:uuid)', 'DepositController::update/$1', ['filter' => 'authFilter:user']); - }); - $routes->group('payment', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) { - $routes->get('', 'PaymentController::index'); + $routes->group('payment', ['namespace' => 'App\Controllers\Front\Order\Payment', 'filter' => 'authFilter:user'], static function ($routes) { + $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'); + }); }); }); /* diff --git a/app/Controllers/Front/Order/CartController.php b/app/Controllers/Front/Order/CartController.php index 39168ef..4ea4d01 100644 --- a/app/Controllers/Front/Order/CartController.php +++ b/app/Controllers/Front/Order/CartController.php @@ -24,7 +24,7 @@ class CartController extends OrderController { switch ($action) { case 'insert': - return $this->_product->type == DEFAULTS['STATUS'] ? ["product_uid", "quantity", "price", 'paymentday'] : ["product_uid", "quantity", "price"]; + return ["product_uid", "quantity", "price", 'paymentday']; break; default: return []; @@ -39,10 +39,10 @@ class CartController extends OrderController break; case 'quantity': case 'price': - $rules[$field] = "required|numeric"; + $rules[$field] = "required|numeric"; break; case 'paymentday': - $rules[$field] = $this->_product->type == DEFAULTS['STATUS'] ? "required|numeric" : "if_exist|numeric"; + $rules[$field] = "if_exist|numeric"; break; default: $rules = parent::getFieldRule($field, $rules, $action); @@ -64,14 +64,14 @@ class CartController extends OrderController { $msg = ""; try { - //상품정보가져오기 - $product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]); $this->_viewDatas = $this->init(__FUNCTION__); //장바구니정보 검증 $this->insert_validate(); + //상품정보가져오기 + $product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]); //재고수 비교 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']; @@ -80,7 +80,7 @@ class CartController extends OrderController } //결제방식이 월이용권이면 결제일 확인 $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("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다."); } //Transaction 시작 diff --git a/app/Controllers/Front/Order/Payment/PaymentController.php b/app/Controllers/Front/Order/Payment/PaymentController.php index fa9f36d..712f822 100644 --- a/app/Controllers/Front/Order/Payment/PaymentController.php +++ b/app/Controllers/Front/Order/Payment/PaymentController.php @@ -7,17 +7,13 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -abstract class PaymentController extends OrderController +class PaymentController extends OrderController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); } - abstract public function getFields(string $action = ""): array; - abstract public function getFieldFilters(): array; - abstract public function getFieldBatchFilters(): array; - //Update관련 (결제처리용) protected function update_form_process($entity) { diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index b4c3941..d5faaf1 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -97,7 +97,7 @@ class OrderModel extends BaseModel $formDatas = []; $formDatas['product_uid'] = $entity->getPrimaryKey(); //상품명을 복사해서 구매한 상품명에 넣기 - $formDatas[$this->_model->getTitleField()] = $entity->getTitle(); + $formDatas[$this->getTitleField()] = $entity->getTitle(); $formDatas['cost'] = $entity->price; $formDatas['sale'] = 0; $formDatas['quantity'] = $quantity; diff --git a/app/Views/front/product/view.php b/app/Views/front/product/view.php index a9ddca4..b7201ee 100644 --- a/app/Views/front/product/view.php +++ b/app/Views/front/product/view.php @@ -6,43 +6,70 @@
| = getFieldLabel_ProductHelper($field, $viewDatas) ?> | -- = getFieldView_ProductHelper($field, $viewDatas['entity'], $viewDatas) ?> - = validation_show_error($field); ?> - | +
| = getFieldLabel_ProductHelper($field, $viewDatas) ?> | ++ = getFieldView_ProductHelper($field, $viewDatas['entity'], $viewDatas) ?> + = validation_show_error($field); ?> + |