shoppingmallv2 init...
This commit is contained in:
parent
5a69e787cd
commit
00d0660b91
@ -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
|
||||
{
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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']);
|
||||
//주문정보 세션에 넣기
|
||||
|
||||
@ -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 [];
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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(
|
||||
"<BR>%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<BR>%s",
|
||||
lang("{$viewDatas['className']}.label.paymentday"),
|
||||
$paymentday,
|
||||
$price
|
||||
);
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'stock':
|
||||
case 'view_cnt':
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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" => "사용않함",
|
||||
],
|
||||
];
|
||||
|
||||
@ -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" => "판매중",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<?php $total_price = 0 ?>
|
||||
<?php $total_sale = 0 ?>
|
||||
<?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>
|
||||
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
|
||||
</td>
|
||||
@ -29,7 +29,7 @@
|
||||
<td><?= getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas) ?></td>
|
||||
<?php endforeach ?>
|
||||
<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"]) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<?= validation_show_error('quantity'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (in_array($viewDatas['category']->getPrimaryKey(), RENTAL_PRODUCT_CATEGORYS)) : ?>
|
||||
<?php if ($viewDatas['entity']->type == 'rental') : ?>
|
||||
<?php $paymentDayOptions = [DEFAULTS['EMPTY'] => "결제일 선택"];
|
||||
for ($i = 1; $i <= 28; $i++) {
|
||||
$paymentDayOptions[$i] = "매월 {$i}일";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user