shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-17 13:38:55 +09:00
parent 5a69e787cd
commit 00d0660b91
14 changed files with 50 additions and 37 deletions

View File

@ -24,14 +24,14 @@ class OrderController extends AdminController
{ {
switch ($action) { switch ($action) {
case 'update': case 'update':
return ['product_uid', "paymentday", "cost", "sale", "quantity", "status"]; return ["type", 'product_uid', "paymentday", "cost", "sale", "quantity", "status"];
break; break;
case "index": case "index":
case "excel": 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; break;
case "view": 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; break;
default: default:
return []; return [];
@ -40,7 +40,7 @@ class OrderController extends AdminController
} }
final public function getFieldFilters(): array final public function getFieldFilters(): array
{ {
return ["user_uid", 'product_uid', "status"]; return ["user_uid", 'product_uid', "type", "status"];
} }
final public function getFieldBatchFilters(): array final public function getFieldBatchFilters(): array
{ {

View File

@ -24,11 +24,11 @@ class ProductController extends AdminController
public function getFields(string $action = ""): array 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) { switch ($action) {
case "index": case "index":
case "excel": 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; break;
case "view": case "view":
return [...$fields, "created_at"]; return [...$fields, "created_at"];
@ -40,7 +40,7 @@ class ProductController extends AdminController
} }
public function getFieldFilters(): array public function getFieldFilters(): array
{ {
return ["category_uid", "user_uid", "status"]; return ["category_uid", "user_uid", 'type', "status"];
} }
public function getFieldBatchFilters(): array public function getFieldBatchFilters(): array
{ {

View File

@ -77,7 +77,8 @@ class CartController extends OrderController
} }
//결제방식이 월이용권이면 결제일 확인 //결제방식이 월이용권이면 결제일 확인
$paymentDay = null; $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("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다."); $paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
} }
//재고수 비교 //재고수 비교
@ -92,7 +93,7 @@ class CartController extends OrderController
//Transaction 시작 //Transaction 시작
$this->_model->transStart(); $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']); $product = $this->getProductModel()->addCart($product, $this->_viewDatas['fieldDatas']['quantity']);
//주문정보 세션에 넣기 //주문정보 세션에 넣기

View File

@ -37,10 +37,10 @@ class OrderController extends FrontController
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return ['name', "cost", "sale", "quantity", "price"]; return ["type", 'name', "cost", "sale", "quantity", "price", "status"];
break; break;
case "view": 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; break;
default: default:
return []; return [];

View File

@ -21,11 +21,11 @@ class ProductController extends FrontController
} }
public function getFields(string $action = ""): array 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) { switch ($action) {
case "index": case "index":
case "excel": 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; break;
case "view": case "view":
return [...$fields, "created_at"]; return [...$fields, "created_at"];
@ -37,7 +37,7 @@ class ProductController extends FrontController
} }
public function getFieldFilters(): array public function getFieldFilters(): array
{ {
return ["user_uid"]; return ["user_uid", 'type'];
} }
public function getFieldBatchFilters(): array public function getFieldBatchFilters(): array
{ {

View File

@ -118,6 +118,7 @@ CREATE TABLE shoppingmall.tw_product (
uid varchar(36) NOT NULL, uid varchar(36) NOT NULL,
category_uid int(10) UNSIGNED NOT NULL COMMENT '상품분류', category_uid int(10) UNSIGNED NOT NULL COMMENT '상품분류',
user_uid varchar(36) NULL COMMENT '생산자 정보', user_uid varchar(36) NULL COMMENT '생산자 정보',
type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성',
name varchar(255) NOT NULL COMMENT '상품명', name varchar(255) NOT NULL COMMENT '상품명',
photo varchar(255) NULL COMMENT '이미지', photo varchar(255) NULL COMMENT '이미지',
cost int(10) UNSIGNED NOT 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 '할인가', sale int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '할인가',
price int(10) UNSIGNED NOT NULL COMMENT '결제액', price int(10) UNSIGNED NOT NULL COMMENT '결제액',
quantity varchar(255) 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 '결제일', 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, updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(), created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,

View File

@ -51,6 +51,7 @@ function getFieldForm_OrderHelper($field, $value, array $viewDatas, array $attri
return form_input($field, $value, ['type' => 'number']); return form_input($field, $value, ['type' => 'number']);
break; break;
case "status": case "status":
case "type":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
break; break;
@ -68,19 +69,20 @@ function getFieldView_OrderHelper($field, $entity, array $viewDatas)
{ {
$value = $entity->$field ?: DEFAULTS['EMPTY']; $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'type':
$paymentday = $value == 'rental' ? sprintf(
"<BR>%s %s일",
lang("{$viewDatas['className']}.label.paymentday"),
$entity->paymentday
) : "";
return $viewDatas['fieldFormOptions'][$field][$value] . $paymentday;
break;
case 'cost': case 'cost':
case 'sale': case 'sale':
return number_format(!$value ? 0 : $value) . ""; return number_format(!$value ? 0 : $value) . "";
break; break;
case 'price': case 'price':
$price = number_format(!$value ? 0 : $value) . ""; return number_format(!$value ? 0 : $value) . "";
$paymentday = $entity->paymentday;
return sprintf(
"%s:%s<BR>%s",
lang("{$viewDatas['className']}.label.paymentday"),
$paymentday,
$price
);
break; break;
case 'stock': case 'stock':
case 'view_cnt': case 'view_cnt':

View File

@ -52,6 +52,7 @@ function getFieldForm_ProductHelper($field, $value, array $viewDatas, array $att
return form_input($field, $value, ['type' => 'number']); return form_input($field, $value, ['type' => 'number']);
break; break;
case "status": case "status":
case "type":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
break; break;

View File

@ -3,6 +3,7 @@ return [
'title' => "주문 정보", 'title' => "주문 정보",
'label' => [ 'label' => [
'uid' => "주문번호", 'uid' => "주문번호",
'type' => '형식',
'product_uid' => "상품정보", 'product_uid' => "상품정보",
'sess_id' => "세션ID", 'sess_id' => "세션ID",
'user_uid' => "사용자정보", 'user_uid' => "사용자정보",
@ -17,13 +18,11 @@ return [
'created_at' => "작성일" 'created_at' => "작성일"
], ],
"TYPE" => [ "TYPE" => [
"use" => "월이용권", "rental" => "월이용권",
"unuse" => "판매", "onetime" => "판매/일회성",
], ],
"STATUS" => [ "STATUS" => [
"use" => "장바구니", "use" => "사용",
"unuse" => "사용해지", "unuse" => "사용않함",
"rental" => "월이용권",
"onetime" => "일회성"
], ],
]; ];

View File

@ -5,6 +5,7 @@ return [
'uid' => "번호", 'uid' => "번호",
'category_uid' => "분류", 'category_uid' => "분류",
'user_uid' => "판매자", 'user_uid' => "판매자",
'type' => '형식',
'name' => "상품명", 'name' => "상품명",
'photo' => "이미지", 'photo' => "이미지",
'cost' => "판매원가", 'cost' => "판매원가",
@ -18,8 +19,8 @@ return [
'created_at' => "생성일" 'created_at' => "생성일"
], ],
"TYPE" => [ "TYPE" => [
"use" => "월이용권", "rental" => "월이용권",
"unuse" => "판매", "onetime" => "일회성/판매",
], ],
"STATUS" => [ "STATUS" => [
"use" => "판매중", "use" => "판매중",

View File

@ -17,7 +17,7 @@ class OrderModel extends BaseModel
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, 'product_uid', "user_uid", ...$this->allowedFields, 'product_uid', "user_uid",
"name", "cost", "sale", "quantity", "price", "name", "cost", "sale", "quantity", "price",
"paymentday", "status" "type", "paymentday", "status"
]; ];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
@ -43,6 +43,9 @@ class OrderModel extends BaseModel
case 'paymentday': case 'paymentday':
$rules[$field] = "if_exist|numeric"; $rules[$field] = "if_exist|numeric";
break; break;
case 'type':
$rules[$field] = "required|string";
break;
default: default:
$rules = parent::getFieldRule($field, $rules, $action); $rules = parent::getFieldRule($field, $rules, $action);
break; 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 = [];
$formDatas['product_uid'] = $product->getPrimaryKey(); $formDatas['product_uid'] = $product->getPrimaryKey();
@ -101,6 +104,7 @@ class OrderModel extends BaseModel
$formDatas['sale'] = 0; $formDatas['sale'] = 0;
$formDatas['quantity'] = $quantity; $formDatas['quantity'] = $quantity;
$formDatas['price'] = $formDatas['cost'] * $formDatas['quantity']; $formDatas['price'] = $formDatas['cost'] * $formDatas['quantity'];
$formDatas['type'] = $type;
if (!is_null($paymentDay)) { if (!is_null($paymentDay)) {
$formDatas['paymentday'] = $paymentDay; $formDatas['paymentday'] = $paymentDay;
} }

View File

@ -18,7 +18,7 @@ class ProductModel extends BaseModel
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, ...$this->allowedFields,
"category_uid", "user_uid", "category_uid", "user_uid",
'name', "photo", "cost", "price", "sale", 'type', 'name', "photo", "cost", "price", "sale",
"stock", "view_cnt", "content", "status" "stock", "view_cnt", "content", "status"
]; ];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
@ -40,6 +40,9 @@ class ProductModel extends BaseModel
case $this->getTitleField(): case $this->getTitleField():
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
break; break;
case 'type':
$rules[$field] = "required|string";
break;
case 'photo': 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]"; $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; break;

View File

@ -21,7 +21,7 @@
<?php $total_price = 0 ?> <?php $total_price = 0 ?>
<?php $total_sale = 0 ?> <?php $total_sale = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?> <?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> <tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status == DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td nowrap> <td nowrap>
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?> <?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td> </td>
@ -29,7 +29,7 @@
<td><?= getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas) ?></td> <td><?= getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas) ?></td>
<?php endforeach ?> <?php endforeach ?>
<td> <td>
<?php if ($entity->status == DEFAULTS['STATUS']) : ?> <?php if ($entity->status != DEFAULTS['STATUS']) : ?>
<?= anchor(URLS['cancelCart'] . '/' . $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 ?> <?php endif ?>
</td> </td>

View File

@ -43,7 +43,7 @@
<?= validation_show_error('quantity'); ?> <?= validation_show_error('quantity'); ?>
</td> </td>
</tr> </tr>
<?php if (in_array($viewDatas['category']->getPrimaryKey(), RENTAL_PRODUCT_CATEGORYS)) : ?> <?php if ($viewDatas['entity']->type == 'rental') : ?>
<?php $paymentDayOptions = [DEFAULTS['EMPTY'] => "결제일 선택"]; <?php $paymentDayOptions = [DEFAULTS['EMPTY'] => "결제일 선택"];
for ($i = 1; $i <= 28; $i++) { for ($i = 1; $i <= 28; $i++) {
$paymentDayOptions[$i] = "매월 {$i}"; $paymentDayOptions[$i] = "매월 {$i}";