diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 695b125..52e74cb 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -122,14 +122,11 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
});
$routes->group('order', static function ($routes) {
$routes->get('', 'OrderController::index');
+ $routes->post('insert/(:uuid)', 'OrderController::insert/$1');
$routes->get('view/(:uuid)', 'OrderController::view/$1');
$routes->post('batchjob', 'OrderController::batchjob`');
$routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']);
});
- $routes->group('ecommerce', static function ($routes) {
- $routes->get('', 'EcommerceController::index');
- $routes->post('addcart', 'EcommerceController::addCart');
- });
});
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
$routes->get('/', 'Home::index');
diff --git a/app/Config/Services.php b/app/Config/Services.php
index 8de73ea..df7c8ad 100644
--- a/app/Config/Services.php
+++ b/app/Config/Services.php
@@ -29,12 +29,4 @@ class Services extends BaseService
* return new \CodeIgniter\Example();
* }
*/
-
- public static function ecommerce($getShared = true)
- {
- if ($getShared) {
- return static::getSharedInstance('ecommerce');
- }
- return new \App\Service\EcommerceService();
- }
}
diff --git a/app/Config/Services_Shoppingmall.php b/app/Config/Services_Shoppingmall.php
deleted file mode 100644
index 260277c..0000000
--- a/app/Config/Services_Shoppingmall.php
+++ /dev/null
@@ -1,88 +0,0 @@
-_service = service('ecommerce');
- parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_service->getClassName());
- }
-
- protected function addCart_process()
- {
- //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);
- }
- }
- //장바구니에 담기
- public function addCart()
- {
- $msg = "";
- try {
- $this->_viewDatas['fields'] = $this->_service->getFields(__FUNCTION__);
- $this->_viewDatas['fieldRules'] = $this->_service->getFieldRules($this->_viewDatas['fields'], __FUNCTION__);
- //Transaction 시작
- $this->_service->transStart();
- $this->addCart_process();
- $this->_service->addCart($this->_viewDatas['fieldDatas']);
- //Transaction Commit
- $this->_service->transCommit();
- $msg = sprintf(
- "%s에서 해당 상품 %s개를 장바구니에 담았습니다.",
- $this->_viewDatas['title'],
- $this->_viewDatas['fieldDatas']['quantity']
- );
- return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
- } catch (\Exception $e) {
- //Transaction Rollback
- $this->_service->transRollback();
- log_message("error", $e->getMessage());
- log_message("error", var_export($this->_viewDatas['fieldDatas'], true));
- $msg = sprintf(
- "%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s",
- $this->_viewDatas['title'],
- $e->getMessage()
- );
- return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
- } finally {
- $this->_session->setFlashdata("return_message", $msg);
- }
- }
-}
diff --git a/app/Controllers/Admin/OrderController.php b/app/Controllers/Admin/OrderController.php
index b328ac7..3470b1f 100644
--- a/app/Controllers/Admin/OrderController.php
+++ b/app/Controllers/Admin/OrderController.php
@@ -16,4 +16,39 @@ class OrderController extends AdminController
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
}
+
+ //장바구니에 담기
+ public function insert()
+ {
+ $msg = "";
+ try {
+ $this->_viewDatas['fields'] = $this->_model->getFields(__FUNCTION__);
+ $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], __FUNCTION__);
+ //Transaction 시작
+ $this->_model->transStart();
+ $this->insert_process();
+ $this->_model->addCart($this->_viewDatas['fieldDatas']);
+ //Transaction Commit
+ $this->_model->transCommit();
+ $msg = sprintf(
+ "%s에서 해당 상품 %s개를 장바구니에 담았습니다.",
+ $this->_viewDatas['title'],
+ $this->_viewDatas['fieldDatas']['quantity']
+ );
+ return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
+ } catch (\Exception $e) {
+ //Transaction Rollback
+ $this->_model->transRollback();
+ log_message("error", $e->getMessage());
+ log_message("error", var_export($this->_viewDatas['fieldDatas'], true));
+ $msg = sprintf(
+ "%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s",
+ $this->_viewDatas['title'],
+ $e->getMessage()
+ );
+ return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
+ } finally {
+ $this->_session->setFlashdata("return_message", $msg);
+ }
+ }
}
diff --git a/app/Service/EcommerceService.php b/app/Service/EcommerceService.php
deleted file mode 100644
index a79e53c..0000000
--- a/app/Service/EcommerceService.php
+++ /dev/null
@@ -1,53 +0,0 @@
-_productModel = new ProductModel();
- $this->_orderModel = new OrderModel();
- }
-
- //Form Fields
- public function getFields(string $action): array
- {
- return ["product_uid", "quantity", "price", "status"];
- }
- //Field별 Form Rule용
- public function getFieldRules(array $fields, string $action): array
- {
- $rules = array();
- foreach ($fields as $field) {
- switch ($field) {
- case "product_uid":
- $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
- break;
- case "sess_id":
- $rules[$field] = "required|string";
- break;
- case 'quantity':
- case 'price':
- $rules[$field] = "required|numeric";
- break;
- default:
- break;
- }
- }
- return $rules;
- }
-
- //장바구니에 담기
- public function addCart(array $fieldDatas)
- {
- $product = $this->_productModel->getEntity($fieldDatas['product_uid']);
- $this->_productModel->addCart($product, $fieldDatas['quantity'], $fieldDatas['price']);
- $this->_orderModel->addCart($product, $fieldDatas['quantity'], $fieldDatas['price']);
- }
-}
diff --git a/app/Views/admin/ecommerce/index.php b/app/Views/admin/ecommerce/index.php
deleted file mode 100644
index 28fce26..0000000
--- a/app/Views/admin/ecommerce/index.php
+++ /dev/null
@@ -1,46 +0,0 @@
-= $this->extend('layouts/admin') ?>
-= $this->section('content') ?>
-
-
- = form_open(current_url(), array("method" => "get")) ?>
-
- 조건검색:- = getFieldFilter_OrderHelper($field, $$field, $fieldFormOptions) ?>
- = $this->include('templates/admin/index_head'); ?>
-
- = form_close(); ?>
-
- = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
-
-
- | 번호 |
- = getFieldIndex_Column_OrderHelper($field, $order_field, $order_value) ?> |
- 작업 |
-
-
-
- getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
- |
- = form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = $total_count - (($page - 1) * $per_page + $i) ?>
- |
-
- = getFieldIndex_Row_OrderHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
-
-
- = $entity->getStatus() == DEFAULTS['STATUS'] ? anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) : "" ?>
- |
-
-
-
-
-
-
- - = form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
- - = getFieldFilter_OrderHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
- - = form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
-
- = $pagination ?>
-
- = form_close(); ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/ecommerce/view.php b/app/Views/admin/ecommerce/view.php
deleted file mode 100644
index d64b8be..0000000
--- a/app/Views/admin/ecommerce/view.php
+++ /dev/null
@@ -1,34 +0,0 @@
-= $this->extend('layouts/admin') ?>
-= $this->section('content') ?>
-= $this->include('templates/admin/header'); ?>
-
-
- | 제품명 |
- = $product->getTitle() ?> |
-
-
- | 판매가 |
- = number_format($product->getPrice()) ?> |
-
-
- | 할인가 |
- = number_format($product->getSale()) ?>원 |
-
-
- | 판매금액 |
- = number_format($product->getPrice() - $product->getSale()) ?>원 |
-
-
- | 구매수량 |
- = $order->getQuantity() ?>개 |
-
-
- | 구매금액 |
- = number_format($order->getPrice()) ?>원 |
-
-
- | = html_entity_decode($product->getContent()) ?> |
-
-
-= $this->include('templates/admin/footer'); ?>
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/product/orderform.php b/app/Views/admin/product/orderform.php
index ae26bdd..98b2386 100644
--- a/app/Views/admin/product/orderform.php
+++ b/app/Views/admin/product/orderform.php
@@ -1,4 +1,4 @@
-= form_open("admin/ecommerce/addcart", ['method' => 'post']) ?>
+= form_open("admin/order/insert", ['method' => 'post']) ?>
= form_hidden("product_uid", $entity->getPrimaryKey()) ?>
= form_hidden("price", $entity->getPrice() - $entity->getSale()) ?>
구매 수량 : = getFieldForm_ProductHelper('quantity', 1, $fieldFormOptions) ?>