diff --git a/app/Controllers/Admin/OrderController.php b/app/Controllers/Admin/OrderController.php index 8c5572d..db449db 100644 --- a/app/Controllers/Admin/OrderController.php +++ b/app/Controllers/Admin/OrderController.php @@ -24,14 +24,14 @@ class OrderController extends AdminController { switch ($action) { case 'update': - return ['product_uid', "paymentday", "cost", "sale", "quantity", "status"]; + return ["type", 'product_uid', "paymentday", "cost", "sale", "quantity", "status"]; break; case "index": case "excel": - return ["user_uid", "name", "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"]; + return ["user_uid", "type", "name", "cost", "sale", "quantity", "price", "paymentday", "status", "updated_at", "created_at"]; break; case "view": - return ["user_uid", 'product_uid', "name", "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"]; + return ["user_uid", 'product_uid', "type", "name", "cost", "sale", "quantity", "type", "paymentday", "status", "updated_at", "created_at"]; break; default: return []; @@ -40,7 +40,7 @@ class OrderController extends AdminController } final public function getFieldFilters(): array { - return ["user_uid", 'product_uid', "status"]; + return ["user_uid", 'product_uid', "type", "status"]; } final public function getFieldBatchFilters(): array { diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 96065cf..6bbf7ef 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -24,11 +24,11 @@ class ProductController extends AdminController public function getFields(string $action = ""): array { - $fields = ["category_uid", 'name', "photo", "cost", "sale", "stock", "view_cnt", "status", "content",]; + $fields = ["category_uid", 'type', 'name', "photo", "cost", "sale", "stock", "view_cnt", "status", "content",]; switch ($action) { case "index": case "excel": - return ["category_uid", "user_uid", 'name', "cost", "sale", "price", "stock", "view_cnt", "status", "created_at"]; + return ["category_uid", "user_uid", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "status", "created_at"]; break; case "view": return [...$fields, "created_at"]; @@ -40,7 +40,7 @@ class ProductController extends AdminController } public function getFieldFilters(): array { - return ["category_uid", "user_uid", "status"]; + return ["category_uid", "user_uid", 'type', "status"]; } public function getFieldBatchFilters(): array { diff --git a/app/Controllers/Front/Order/CartController.php b/app/Controllers/Front/Order/CartController.php index cbf313d..36fe86d 100644 --- a/app/Controllers/Front/Order/CartController.php +++ b/app/Controllers/Front/Order/CartController.php @@ -77,7 +77,8 @@ class CartController extends OrderController } //결제방식이 월이용권이면 결제일 확인 $paymentDay = null; - if (in_array($product->category_uid, RENTAL_PRODUCT_CATEGORYS)) { + $type = $product->type; + if ($type == 'rental') { $paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다."); } //재고수 비교 @@ -92,7 +93,7 @@ class CartController extends OrderController //Transaction 시작 $this->_model->transStart(); //주문추가 - $entity = $this->_model->addCart($product, $this->_viewDatas['fieldDatas']['quantity'], $paymentDay); + $entity = $this->_model->addCart($product, $this->_viewDatas['fieldDatas']['quantity'], $type, $paymentDay); //상품재고감소 $product = $this->getProductModel()->addCart($product, $this->_viewDatas['fieldDatas']['quantity']); //주문정보 세션에 넣기 diff --git a/app/Controllers/Front/Order/OrderController.php b/app/Controllers/Front/Order/OrderController.php index ec1f9d6..e254470 100644 --- a/app/Controllers/Front/Order/OrderController.php +++ b/app/Controllers/Front/Order/OrderController.php @@ -37,10 +37,10 @@ class OrderController extends FrontController switch ($action) { case "index": case "excel": - return ['name', "cost", "sale", "quantity", "price"]; + return ["type", 'name', "cost", "sale", "quantity", "price", "status"]; break; case "view": - return ['name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"]; + return ["type", 'name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"]; break; default: return []; diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index f7765eb..071748c 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -21,11 +21,11 @@ class ProductController extends FrontController } public function getFields(string $action = ""): array { - $fields = ["photo", 'user_uid', 'name', "cost", "sale", "price", "stock", "view_cnt", "content",]; + $fields = ["photo", 'user_uid', 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "content",]; switch ($action) { case "index": case "excel": - return ["user_uid", "photo", 'name', "cost", "sale", "price", "stock", "view_cnt"]; + return ["user_uid", 'type', "photo", 'name', "cost", "sale", "price", "stock", "view_cnt"]; break; case "view": return [...$fields, "created_at"]; @@ -37,7 +37,7 @@ class ProductController extends FrontController } public function getFieldFilters(): array { - return ["user_uid"]; + return ["user_uid", 'type']; } public function getFieldBatchFilters(): array { diff --git a/app/Database/shoppingmall.sql b/app/Database/shoppingmall.sql index d7ce875..954456b 100644 --- a/app/Database/shoppingmall.sql +++ b/app/Database/shoppingmall.sql @@ -118,6 +118,7 @@ CREATE TABLE shoppingmall.tw_product ( uid varchar(36) NOT NULL, category_uid int(10) UNSIGNED NOT NULL COMMENT '상품분류', user_uid varchar(36) NULL COMMENT '생산자 정보', + type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성', name varchar(255) NOT NULL COMMENT '상품명', photo varchar(255) NULL COMMENT '이미지', cost int(10) UNSIGNED NOT NULL COMMENT '원가', @@ -145,8 +146,9 @@ CREATE TABLE shoppingmall.tw_order ( sale int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '할인가', price int(10) UNSIGNED NOT NULL COMMENT '결제액', quantity varchar(255) NOT NULL COMMENT '수량', + type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성', paymentday int(2) UNSIGNED NULL COMMENT '결제일', - status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 장바구니, unuse: 사용해지, rental:월이용권, onetime:판매,일회성', + status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 사용, unuse: 장바구니/사용않함', updated_at timestamp NULL DEFAULT NULL, created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, diff --git a/app/Helpers/Order_helper.php b/app/Helpers/Order_helper.php index 97e09e6..16d66e4 100644 --- a/app/Helpers/Order_helper.php +++ b/app/Helpers/Order_helper.php @@ -51,6 +51,7 @@ function getFieldForm_OrderHelper($field, $value, array $viewDatas, array $attri return form_input($field, $value, ['type' => 'number']); break; case "status": + case "type": $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); break; @@ -68,19 +69,20 @@ function getFieldView_OrderHelper($field, $entity, array $viewDatas) { $value = $entity->$field ?: DEFAULTS['EMPTY']; switch ($field) { + case 'type': + $paymentday = $value == 'rental' ? sprintf( + "
%s %s일", + lang("{$viewDatas['className']}.label.paymentday"), + $entity->paymentday + ) : ""; + return $viewDatas['fieldFormOptions'][$field][$value] . $paymentday; + break; case 'cost': case 'sale': return number_format(!$value ? 0 : $value) . "원"; break; case 'price': - $price = number_format(!$value ? 0 : $value) . "원"; - $paymentday = $entity->paymentday; - return sprintf( - "%s:%s
%s", - lang("{$viewDatas['className']}.label.paymentday"), - $paymentday, - $price - ); + return number_format(!$value ? 0 : $value) . "원"; break; case 'stock': case 'view_cnt': diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php index b0cf42b..791404f 100644 --- a/app/Helpers/Product_helper.php +++ b/app/Helpers/Product_helper.php @@ -52,6 +52,7 @@ function getFieldForm_ProductHelper($field, $value, array $viewDatas, array $att return form_input($field, $value, ['type' => 'number']); break; case "status": + case "type": $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); break; diff --git a/app/Language/ko/Order.php b/app/Language/ko/Order.php index 6326c2e..9c0af30 100644 --- a/app/Language/ko/Order.php +++ b/app/Language/ko/Order.php @@ -3,6 +3,7 @@ return [ 'title' => "주문 정보", 'label' => [ 'uid' => "주문번호", + 'type' => '형식', 'product_uid' => "상품정보", 'sess_id' => "세션ID", 'user_uid' => "사용자정보", @@ -17,13 +18,11 @@ return [ 'created_at' => "작성일" ], "TYPE" => [ - "use" => "월이용권", - "unuse" => "판매", + "rental" => "월이용권", + "onetime" => "판매/일회성", ], "STATUS" => [ - "use" => "장바구니", - "unuse" => "사용해지", - "rental" => "월이용권", - "onetime" => "일회성" + "use" => "사용", + "unuse" => "사용않함", ], ]; diff --git a/app/Language/ko/Product.php b/app/Language/ko/Product.php index dde3ea9..063ffb3 100644 --- a/app/Language/ko/Product.php +++ b/app/Language/ko/Product.php @@ -5,6 +5,7 @@ return [ 'uid' => "번호", 'category_uid' => "분류", 'user_uid' => "판매자", + 'type' => '형식', 'name' => "상품명", 'photo' => "이미지", 'cost' => "판매원가", @@ -18,8 +19,8 @@ return [ 'created_at' => "생성일" ], "TYPE" => [ - "use" => "월이용권", - "unuse" => "판매", + "rental" => "월이용권", + "onetime" => "일회성/판매", ], "STATUS" => [ "use" => "판매중", diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index d84a4b5..96c16a7 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -17,7 +17,7 @@ class OrderModel extends BaseModel $this->allowedFields = [ ...$this->allowedFields, 'product_uid', "user_uid", "name", "cost", "sale", "quantity", "price", - "paymentday", "status" + "type", "paymentday", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } @@ -43,6 +43,9 @@ class OrderModel extends BaseModel case 'paymentday': $rules[$field] = "if_exist|numeric"; break; + case 'type': + $rules[$field] = "required|string"; + break; default: $rules = parent::getFieldRule($field, $rules, $action); break; @@ -91,7 +94,7 @@ class OrderModel extends BaseModel } //장바구니에 넣기() - final public function addCart(ProductEntity $product, int $quantity, $paymentDay = null): OrderEntity + final public function addCart(ProductEntity $product, int $quantity, string $type, $paymentDay = null): OrderEntity { $formDatas = []; $formDatas['product_uid'] = $product->getPrimaryKey(); @@ -101,6 +104,7 @@ class OrderModel extends BaseModel $formDatas['sale'] = 0; $formDatas['quantity'] = $quantity; $formDatas['price'] = $formDatas['cost'] * $formDatas['quantity']; + $formDatas['type'] = $type; if (!is_null($paymentDay)) { $formDatas['paymentday'] = $paymentDay; } diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index 5296ce3..020ad2f 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -18,7 +18,7 @@ class ProductModel extends BaseModel $this->allowedFields = [ ...$this->allowedFields, "category_uid", "user_uid", - 'name', "photo", "cost", "price", "sale", + 'type', 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "content", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; @@ -40,6 +40,9 @@ class ProductModel extends BaseModel case $this->getTitleField(): $rules[$field] = "required|trim|string"; break; + case 'type': + $rules[$field] = "required|string"; + break; case 'photo': $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; diff --git a/app/Views/front/order/index.php b/app/Views/front/order/index.php index 4d071d8..90cc48f 100644 --- a/app/Views/front/order/index.php +++ b/app/Views/front/order/index.php @@ -21,7 +21,7 @@ - status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + status == DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> @@ -29,7 +29,7 @@ - status == DEFAULTS['STATUS']) : ?> + status != DEFAULTS['STATUS']) : ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> diff --git a/app/Views/front/product/view.php b/app/Views/front/product/view.php index b7201ee..ae54358 100644 --- a/app/Views/front/product/view.php +++ b/app/Views/front/product/view.php @@ -43,7 +43,7 @@ - getPrimaryKey(), RENTAL_PRODUCT_CATEGORYS)) : ?> + type == 'rental') : ?> "결제일 선택"]; for ($i = 1; $i <= 28; $i++) { $paymentDayOptions[$i] = "매월 {$i}일";