shoppingmallv2 init...
This commit is contained in:
parent
f808e73638
commit
ebc9e478db
@ -152,10 +152,10 @@ define('URLS', [
|
||||
'LOGIN' => '/front/user/login',
|
||||
'SIGNUP' => '/front/user/signup',
|
||||
'LOGOUT' => '/front/user/logout',
|
||||
'addCart' => '/ecommerce/addCart',
|
||||
'cancelCart' => '/ecommerce/cancelCart',
|
||||
'paymentCard' => '/ecommerce/payment/card',
|
||||
'paymentDeposit' => '/ecommerce/payment/deposit',
|
||||
'addCart' => '/front/order/addCart',
|
||||
'cancelCart' => '/front/order/cancelCart',
|
||||
'cardPayment' => '/front/order/cardPayment',
|
||||
'depositPayment' => '/front/order/depositPayment',
|
||||
]);
|
||||
//SESSION 관련
|
||||
define('SESSION_NAMES', [
|
||||
|
||||
@ -37,16 +37,6 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
$routes->group('ecommerce', ['namespace' => 'App\Controllers\Ecommerce'], function ($routes) {
|
||||
$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/(: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에 선언한 이름이어야 함
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
@ -170,9 +160,15 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
});
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->group('order', ['namespace' => 'App\Controllers\Front\Order'], static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$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');
|
||||
|
||||
@ -37,14 +37,6 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}
|
||||
$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->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) {
|
||||
$routes->get('/', 'Home::index');
|
||||
@ -131,6 +123,9 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'OrderController::batchjob`');
|
||||
});
|
||||
$routes->group('payment', static function ($routes) {
|
||||
$routes->get('', 'PaymentController::index');
|
||||
});
|
||||
});
|
||||
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
|
||||
$routes->group('user', static function ($routes) {
|
||||
@ -165,9 +160,15 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
});
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->group('order', ['namespace' => 'App\Controllers\Front\Order'], static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
$routes->post('addCart', 'CartController::insert');
|
||||
$routes->get('cancelCart', 'CartController::delete');
|
||||
$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');
|
||||
|
||||
@ -13,10 +13,13 @@ class BoardController extends AdminController
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BoardModel();
|
||||
$this->_viewDatas['className'] = 'Board';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);;
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
|
||||
@ -14,10 +14,13 @@ class CategoryController extends AdminController
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new CategoryModel();
|
||||
$this->_viewDatas['className'] = 'Category';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
|
||||
@ -11,10 +11,13 @@ class OrderController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new OrderModel();
|
||||
$this->_viewDatas['className'] = 'Order';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
final public function getFields(string $action = ""): array
|
||||
|
||||
@ -13,10 +13,13 @@ class ProductController extends AdminController
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new ProductModel();
|
||||
$this->_viewDatas['className'] = 'Product';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
|
||||
@ -11,10 +11,13 @@ class SitepageController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new SitepageModel();
|
||||
$this->_viewDatas['className'] = 'Sitepage';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
|
||||
@ -11,10 +11,13 @@ class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new UserModel();
|
||||
$this->_viewDatas['className'] = 'User';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
|
||||
@ -11,10 +11,13 @@ class UserSNSController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new UserSNSModel();
|
||||
$this->_viewDatas['className'] = 'UserSNS';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
|
||||
@ -60,9 +60,6 @@ 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->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
//사용자 기본 Role 지정
|
||||
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?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 $_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['ORDER_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 getCategoryModel()
|
||||
{
|
||||
return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel();
|
||||
}
|
||||
|
||||
//Update관련
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
$entity = parent::update_form_process($entity);
|
||||
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
||||
return $entity;
|
||||
}
|
||||
final public function update_form($uid)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
//결제처리
|
||||
public function update($uid)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,10 +11,13 @@ class BoardController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BoardModel();
|
||||
$this->_viewDatas['className'] = 'Board';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Ecommerce\Payment;
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
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
|
||||
class CardController extends OrderController
|
||||
{
|
||||
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']);
|
||||
$this->_viewDatas['className'] = 'Card';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
@ -1,26 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Ecommerce;
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\ProductModel;
|
||||
|
||||
class CartController extends EcommerceController
|
||||
class CartController extends OrderController
|
||||
{
|
||||
private $_productModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_viewDatas['className'] = 'Cart';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['className'] = 'Cart';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
final protected function getProductModel()
|
||||
{
|
||||
return $this->_productModel = $this->_productModel ?: new ProductModel();
|
||||
}
|
||||
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["product_uid", "quantity", "price"];
|
||||
switch ($action) {
|
||||
case 'update':
|
||||
return ["product_uid", "quantity", "price"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -30,7 +43,7 @@ class CartController extends EcommerceController
|
||||
case "product_uid":
|
||||
case "quantity":
|
||||
case "price":
|
||||
$rules = $this->getOrderModel()->getFieldRule($field, $rules, $action);
|
||||
$rules = $this->_model->getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
@ -54,7 +67,7 @@ class CartController extends EcommerceController
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
//Transaction 시작
|
||||
$this->getOrderModel()->transStart();
|
||||
$this->_model->transStart();
|
||||
//장바구니정보 검증
|
||||
$this->insert_validate();
|
||||
//상품정보 가져오기
|
||||
@ -71,16 +84,16 @@ class CartController extends EcommerceController
|
||||
// echo var_export($this->_viewDatas['fieldDatas']);
|
||||
// exit;
|
||||
//상품명을 복사해서 구매한 상품명에 넣기
|
||||
$this->_viewDatas['fieldDatas'][$this->getOrderModel()->getTitleField()] = $product->getTitle();
|
||||
$this->_viewDatas['fieldDatas'][$this->_model->getTitleField()] = $product->getTitle();
|
||||
//주문추가
|
||||
$entity = $this->getOrderModel()->addCart($this->_viewDatas['fieldDatas']);
|
||||
$entity = $this->_model->addCart($this->_viewDatas['fieldDatas']);
|
||||
//상품재고감소
|
||||
$product = $this->getProductModel()->addCart($product, $this->_viewDatas['fieldDatas']['quantity']);
|
||||
//주문정보 세션에 넣기
|
||||
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
|
||||
$this->_session->set(SESSION_NAMES['CART'], [...$order_uids, $entity->getPrimaryKey()]);
|
||||
//Transaction Commit
|
||||
$this->getOrderModel()->transComplete();
|
||||
$this->_model->transComplete();
|
||||
$msg = sprintf(
|
||||
"%s\n 상품명:%s\n 상품갯수:%s개, 구매금액:%s원\n 장바구니에 담았습니다.",
|
||||
$this->_viewDatas['title'],
|
||||
@ -91,7 +104,7 @@ class CartController extends EcommerceController
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getOrderModel()->transRollback();
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$msg = sprintf(
|
||||
"%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s",
|
||||
@ -110,14 +123,14 @@ class CartController extends EcommerceController
|
||||
$msg = "";
|
||||
try {
|
||||
//주문정보 가져오기
|
||||
$entity = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
//Transaction 시작
|
||||
$this->getOrderModel()->transStart();
|
||||
$this->_model->transStart();
|
||||
//주문취소
|
||||
if (!$this->getOrderModel()->cancelCart($entity)) {
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->getOrderModel()->getLastQuery());
|
||||
log_message("error", implode("\n", $this->getOrderModel()->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->getOrderModel()->errors(), true));
|
||||
if (!$this->_model->cancelCart($entity)) {
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
log_message("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
//상품정보 가져오기
|
||||
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->product_uid]);
|
||||
@ -133,12 +146,12 @@ class CartController extends EcommerceController
|
||||
}
|
||||
$this->_session->set(SESSION_NAMES['CART'], $temps);
|
||||
//Transaction Commit
|
||||
$this->getOrderModel()->transComplete();
|
||||
$this->_model->transComplete();
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()} {$entity->quantity}개의 주문을 취소하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getOrderModel()->transRollback();
|
||||
$this->_model->transRollback();
|
||||
$msg = sprintf(
|
||||
"%s에서 다음 오류로 인해 주문취소를 실패하였습니다.\n%s",
|
||||
$this->_viewDatas['title'],
|
||||
@ -1,20 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Ecommerce\Payment;
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\OrderModel;
|
||||
|
||||
class DepositController extends PaymentController
|
||||
class DepositController extends OrderController
|
||||
{
|
||||
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']);
|
||||
$this->_viewDatas['className'] = 'Deposit';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
129
app/Controllers/Front/Order/OrderController.php
Normal file
129
app/Controllers/Front/Order/OrderController.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
use App\Models\OrderModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Controllers\Front\FrontController;
|
||||
use App\Models\UserModel;
|
||||
|
||||
class OrderController extends FrontController
|
||||
{
|
||||
private $_userModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new OrderModel();
|
||||
$this->_viewDatas['className'] = 'Order';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
//Default 회원정보 Category
|
||||
$this->_category = DEFAULTS['ORDER_CATEGORY'];
|
||||
$this->isRole('index');
|
||||
}
|
||||
|
||||
final protected function getUserModel()
|
||||
{
|
||||
return $this->_userModel = $this->_userModel ?: new UserModel();
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["product_uid", "cost", "sale", "quantity", "price", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
case "view":
|
||||
return ['name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ['product_uid', "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
//Update관련 (결제처리용)
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
$entity = parent::update_form_process($entity);
|
||||
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
||||
return $entity;
|
||||
}
|
||||
final public function update_form($uid)
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$entity = $this->_model->getEntity([$this->_model->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());
|
||||
}
|
||||
}
|
||||
public function update($uid)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$entity = $this->_model->getEntity([$this->_model->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관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//세션에 Cart정보(order_uids)가 있으면
|
||||
$uids = $this->_session->get(SESSION_NAMES['CART']) ?: array('NONE');
|
||||
//또는 Login했으면 사용자정보(user_uid)에 맞는 Order정보 가져오기
|
||||
if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
||||
if (count($uids)) {
|
||||
$this->_model->orWhereIn('uid', $uids);
|
||||
}
|
||||
} elseif (count($uids)) {
|
||||
$this->_model->whereIn('uid', $uids);
|
||||
}
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\OrderModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class OrderController extends FrontController
|
||||
{
|
||||
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->_viewDatas['className']);
|
||||
//Default 회원정보 Category
|
||||
$this->_category = DEFAULTS['ORDER_CATEGORY'];
|
||||
$this->isRole('index');
|
||||
}
|
||||
|
||||
final public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["product_uid", "cost", "sale", "quantity", "price", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
case "view":
|
||||
return ['name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getFieldFilters(): array
|
||||
{
|
||||
return ['product_uid', "status"];
|
||||
}
|
||||
final public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//세션에 Cart정보(order_uids)가 있으면
|
||||
$uids = $this->_session->get(SESSION_NAMES['CART']) ?: array('NONE');
|
||||
//또는 Login했으면 사용자정보(user_uid)에 맞는 Order정보 가져오기
|
||||
if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
||||
if (count($uids)) {
|
||||
$this->_model->orWhereIn('uid', $uids);
|
||||
}
|
||||
} elseif (count($uids)) {
|
||||
$this->_model->whereIn('uid', $uids);
|
||||
}
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
@ -11,10 +11,13 @@ class ProductController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new ProductModel();
|
||||
$this->_viewDatas['className'] = 'Product';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
|
||||
@ -11,10 +11,13 @@ class SitepageController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new SitepageModel();
|
||||
$this->_viewDatas['className'] = 'Sitepage';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
|
||||
@ -13,10 +13,13 @@ class UserController extends FrontController
|
||||
private $_adapters = array();
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new UserModel();
|
||||
$this->_viewDatas['className'] = 'User';
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
$this->initAdapters();
|
||||
//Default 회원정보 Category
|
||||
|
||||
@ -138,12 +138,12 @@ function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): strin
|
||||
return sprintf(
|
||||
"<div class=\"payment\">%s</div><div class=\"payment\">%s</div>",
|
||||
anchor(
|
||||
URLS['paymentCard'] . '/' . $entity->getPrimaryKey(),
|
||||
URLS['cardPayment'] . '/' . $entity->getPrimaryKey(),
|
||||
"카 드 결 제",
|
||||
["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"]
|
||||
),
|
||||
anchor(
|
||||
URLS['paymentDeposit'] . '/' . $entity->getPrimaryKey(),
|
||||
URLS['depositPayment'] . '/' . $entity->getPrimaryKey(),
|
||||
"무통장입금",
|
||||
["class" => "btn btn-sm btn-info btn-circle", "style" => "color:white", "target" => "_self"]
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<?php endforeach ?>
|
||||
<td>
|
||||
<?php if ($entity->status == DEFAULTS['STATUS']) : ?>
|
||||
<?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
|
||||
<?= anchor(URLS['cancelCart'] . '/' . $entity->getPrimaryKey(), ICONS['DELETE'] . '주문취소', ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user