diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index dc38b57..2d66e0f 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -175,7 +175,7 @@ define('URLS', [
'Order' => '/front/order',
'addCart' => '/front/order/addCart',
'cancelCart' => '/front/order/cancelCart',
- 'Billing' => '/front/billing',
+ 'Billing' => '/front/billing/insert',
'cardPayment' => '/front/billing/payment/card',
'depositPayment' => '/front/billing/payment/deposit',
]);
diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php
index bc41848..8cb70a6 100644
--- a/app/Controllers/BaseController.php
+++ b/app/Controllers/BaseController.php
@@ -585,7 +585,7 @@ abstract class BaseController extends Controller
$this->_viewDatas['pagination'] = $this->index_getPagination();
//모델 처리
$this->_viewDatas['entitys'] = $this->index_getEntitys();
- // echo $this->_model->getLastQuery();
+ echo $this->_model->getLastQuery();
// exit;
// log_message("debug", __METHOD__ . "에서 findAll 호출:" . $this->_model->getLastQuery());
//setting return_url to session flashdata
diff --git a/app/Controllers/Front/Order/CartController.php b/app/Controllers/Front/Order/CartController.php
index 4ea4d01..cbf313d 100644
--- a/app/Controllers/Front/Order/CartController.php
+++ b/app/Controllers/Front/Order/CartController.php
@@ -2,8 +2,6 @@
namespace App\Controllers\Front\Order;
-use App\Entities\OrderEntity;
-use App\Entities\ProductEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
@@ -69,6 +67,19 @@ class CartController extends OrderController
$this->insert_validate();
//상품정보가져오기
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]);
+ //상품갯수확인
+ if (!$this->_viewDatas['fieldDatas']['quantity']) {
+ throw new \Exception("상품갯수가 지정되지 않았습니다.");
+ }
+ //구매금액확인
+ if (!$this->_viewDatas['fieldDatas']['price']) {
+ throw new \Exception("구매금액이 지정되지 않았습니다.");
+ }
+ //결제방식이 월이용권이면 결제일 확인
+ $paymentDay = null;
+ if (in_array($product->category_uid, RENTAL_PRODUCT_CATEGORYS)) {
+ $paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
+ }
//재고수 비교
if ($product->stock < $this->_viewDatas['fieldDatas']['quantity']) {
throw new \Exception("구매수량이 너무 많습니다.\n구매수량:{$this->_viewDatas['fieldDatas']['quantity']}개, 남은 재고수량:{$product->stock}개");
@@ -78,20 +89,15 @@ class CartController extends OrderController
if ($price != $this->_viewDatas['fieldDatas']['price']) {
throw new \Exception("실 상품금액{$price} 와 구매금액{$this->_viewDatas['fieldDatas']['price']}이 서로 다릅니다.");
}
- //결제방식이 월이용권이면 결제일 확인
- $paymentDay = null;
- if (in_array($product->category_uid, RENTAL_PRODUCT_CATEGORYS)) {
- $paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
- }
//Transaction 시작
$this->_model->transStart();
//주문추가
- $order = $this->_model->addCart($product, $this->_viewDatas['fieldDatas']['quantity'], $paymentDay);
+ $entity = $this->_model->addCart($product, $this->_viewDatas['fieldDatas']['quantity'], $paymentDay);
//상품재고감소
- $entity = $this->getProductModel()->addCart($product, $this->_viewDatas['fieldDatas']['quantity']);
+ $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, $order->getPrimaryKey()]);
+ $this->_session->set(SESSION_NAMES['CART'], [...$order_uids, $entity->getPrimaryKey()]);
//Transaction Commit
$this->_model->transComplete();
$msg = sprintf(
@@ -125,15 +131,15 @@ class CartController extends OrderController
$msg = "";
try {
//주문정보 가져오기
- $entity = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $uid]);
+ $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
//상품정보 가져오기
- $entity = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->product_uid]);
+ $product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->product_uid]);
//Transaction 시작
- $this->getProductModel()->transStart();
+ $this->_model->transStart();
//주문취소
- $entity = $this->getProductModel()->modify($entity, ['status' => 'unuse']);
+ $entity = $this->delete_process($entity);
//상품반환
- $entity = $this->getProductModel()->cancelCart($entity, $entity->quantity);
+ $product = $this->getProductModel()->cancelCart($product, $entity->quantity);
//주문정보 세션에서 빼기
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
$temps = array();
@@ -144,12 +150,12 @@ class CartController extends OrderController
}
$this->_session->set(SESSION_NAMES['CART'], $temps);
//Transaction Commit
- $this->getProductModel()->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->getProductModel()->transRollback();
+ $this->_model->transRollback();
$msg = sprintf(
"%s에서 다음 오류로 인해 주문취소를 실패하였습니다.\n%s",
$this->_viewDatas['title'],
diff --git a/app/Controllers/Front/Order/OrderController.php b/app/Controllers/Front/Order/OrderController.php
index 5a8b356..ec1f9d6 100644
--- a/app/Controllers/Front/Order/OrderController.php
+++ b/app/Controllers/Front/Order/OrderController.php
@@ -37,7 +37,7 @@ class OrderController extends FrontController
switch ($action) {
case "index":
case "excel":
- return ['name', "cost", "sale", "quantity", "price", "status", "created_at"];
+ return ['name', "cost", "sale", "quantity", "price"];
break;
case "view":
return ['name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
diff --git a/app/Helpers/Order_helper.php b/app/Helpers/Order_helper.php
index f71bb31..97e09e6 100644
--- a/app/Helpers/Order_helper.php
+++ b/app/Helpers/Order_helper.php
@@ -141,17 +141,6 @@ function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): strin
);
return sprintf("%s
%s", $uid, $title);
break;
- case 'status':
- //장바구니인경우
- if ($value == DEFAULTS['STATUS']) {
- return anchor(
- URLS['Billing'] . '/' . $entity->getPrimaryKey(),
- CLASS_ICONS['BILLING'] . '결제하기',
- ["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"]
- );
- } else {
- return getFieldView_OrderHelper($field, $entity, $viewDatas);
- }
default:
return getFieldView_OrderHelper($field, $entity, $viewDatas);
break;
diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php
index 79339a0..d84a4b5 100644
--- a/app/Models/OrderModel.php
+++ b/app/Models/OrderModel.php
@@ -11,7 +11,6 @@ class OrderModel extends BaseModel
protected $table = "tw_order";
protected $useAutoIncrement = false;
protected $returnType = OrderEntity::class;
- protected $useSoftDeletes = true;
public function __construct()
{
parent::__construct('Order');
@@ -92,19 +91,21 @@ class OrderModel extends BaseModel
}
//장바구니에 넣기()
- final public function addCart(ProductEntity $entity, int $quantity, $paymentDay = null): OrderEntity
+ final public function addCart(ProductEntity $product, int $quantity, $paymentDay = null): OrderEntity
{
$formDatas = [];
- $formDatas['product_uid'] = $entity->getPrimaryKey();
+ $formDatas['product_uid'] = $product->getPrimaryKey();
//상품명을 복사해서 구매한 상품명에 넣기
- $formDatas[$this->getTitleField()] = $entity->getTitle();
- $formDatas['cost'] = $entity->price;
+ $formDatas[$this->getTitleField()] = $product->getTitle();
+ $formDatas['cost'] = $product->price;
$formDatas['sale'] = 0;
$formDatas['quantity'] = $quantity;
$formDatas['price'] = $formDatas['cost'] * $formDatas['quantity'];
if (!is_null($paymentDay)) {
$formDatas['paymentday'] = $paymentDay;
}
+ // echo var_export($formDatas, true);
+ // exit;
return $this->create($formDatas);
}
//장바구니에 빼기
diff --git a/app/Views/front/order/card/update.php b/app/Views/front/billing/card/update.php
similarity index 100%
rename from app/Views/front/order/card/update.php
rename to app/Views/front/billing/card/update.php
diff --git a/app/Views/front/order/deposit/billing.php b/app/Views/front/billing/deposit/billing.php
similarity index 100%
rename from app/Views/front/order/deposit/billing.php
rename to app/Views/front/billing/deposit/billing.php
diff --git a/app/Views/front/order/deposit/update.php b/app/Views/front/billing/deposit/update.php
similarity index 100%
rename from app/Views/front/order/deposit/update.php
rename to app/Views/front/billing/deposit/update.php
diff --git a/app/Views/front/order/index.php b/app/Views/front/order/index.php
index af73dfd..9f89e02 100644
--- a/app/Views/front/order/index.php
+++ b/app/Views/front/order/index.php
@@ -1,40 +1,73 @@
= $this->extend('layouts/front') ?>
= $this->section('content') ?>
+
= html_entity_decode($viewDatas['category']->head) ?>
-
- = $this->include('templates/front/index_head') ?>
+
+
+
+
= $this->include('templates/front/index_head') ?>
+
+
+
+ | # |
+ = getFieldIndex_Column_OrderHelper($field, $viewDatas) ?>
+ @ |
+
+
+
+
+
+
+
+ status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
+ |
+ = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
+ |
+
+ = getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas) ?> |
+
+
+ status == DEFAULTS['STATUS']) : ?>
+ = anchor(URLS['cancelCart'] . '/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
+
+ |
+
+ price ?>
+ sale ?>
+
+
+
+
+
+
+ = form_open_multipart(URLS['Billing'], $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
+
+
결제정보
+
+ 상품수
+ = count($viewDatas['entitys']) ?>개
+
+
+ 상품금액
+ = number_format($total_price) ?>원
+
+
+ 할인금액
+ = number_format($total_sale) ?>원
+
+
+ 총결제금액
+ = number_format($total_price - $total_sale) ?>원
+
+
= form_submit('', '결제하기', array("class" => "btn btn-outline btn-primary")); ?>
+
+ = form_close(); ?>
+
+
+
= $viewDatas['pagination'] ?>
+
= html_entity_decode($viewDatas['category']->tail) ?>
-
-
-
- | # |
- = getFieldIndex_Column_OrderHelper($field, $viewDatas) ?>
- @ |
-
-
-
-
-
- status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
- |
- = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
- |
-
- = getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas) ?> |
-
-
- status == DEFAULTS['STATUS']) : ?>
- = anchor(URLS['cancelCart'] . '/' . $entity->getPrimaryKey(), ICONS['DELETE'] . '주문취소', ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
-
- |
-
-
-
-
-
-
= $viewDatas['pagination'] ?>
-
= html_entity_decode($viewDatas['category']->tail) ?>
= $this->endSection() ?>
\ No newline at end of file
diff --git a/public/css/front/order.css b/public/css/front/order.css
new file mode 100644
index 0000000..beb5f26
--- /dev/null
+++ b/public/css/front/order.css
@@ -0,0 +1,48 @@
+/* ------------------------------------------------------------
+* Name : admin.css
+* Desc : Admin StyleSheet
+* Created : 2016/9/11 Tri-aBility by Junheum,Choi
+* Updated :
+------------------------------------------------------------ */
+div#order {
+ position:relative;
+}
+div#order div.orderbox {
+ position:fixed;
+ width:200px;
+ height:220px;
+ padding:10px;
+ border:1px solid gray;
+}
+div#order div.orderbox div.title{
+ font-size:18px;
+ font-weight: 500;
+ padding-bottom:10px;
+ border-bottom:2px solid gray;
+}
+
+div#order div.orderbox div.item{
+ padding-bottom:5px;
+}
+div#order div.orderbox div.item span.label{
+ color: gray;
+}
+div#order div.orderbox div.item span.value{
+ float:right;
+}
+div#order div.orderbox div.total{
+ padding-top:10px;
+ border-top:2px solid gray;
+}
+div#order div.orderbox div.total span.label{
+ color: gray;
+}
+div#order div.orderbox div.total span.value{
+ float:right;
+ font-size:18px;
+ font-weight: 800;
+}
+div#order div.orderbox div.submit{
+ text-align:center;
+ padding-top:25px;
+}
\ No newline at end of file