From 0bce3718e27947d7b2a97b29326a7bff6bc79228 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Mon, 23 Dec 2024 15:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=84=E5=94=AE=E5=A4=87?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/GoodsLogic.php | 2 +- app/shop/logic/goods/GoodsLogic.php | 6 ++- app/shop/view/goods/goods/add.html | 7 +-- app/shop/view/goods/goods/goods_base.html | 14 ++++-- ...53219_add_is_new_goods_fields_to_goods.php | 4 +- ...20_rename_is_new_goods_fields_to_goods.php | 34 ++++++++++++++ ...73712_add_presale_mask_fields_to_goods.php | 44 +++++++++++++++++++ 7 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 database/migrations/20241223073220_rename_is_new_goods_fields_to_goods.php create mode 100644 database/migrations/20241223073712_add_presale_mask_fields_to_goods.php diff --git a/app/api/logic/GoodsLogic.php b/app/api/logic/GoodsLogic.php index b7d1b7d7..d6805744 100755 --- a/app/api/logic/GoodsLogic.php +++ b/app/api/logic/GoodsLogic.php @@ -67,7 +67,7 @@ class GoodsLogic extends Logic } $goodsDetail = Goods::with(['goods_image', 'goods_item', 'shop']) - ->field('id,type,name,image,video,remark,goods_remark,content,purchase_price,issuing_price,wholesale_price,market_price,min_price,max_price,is_show_stock,stock,sales_actual,sales_virtual,clicks,clicks_virtual,shop_id,poster,subsidy_id,is_new_goods') + ->field('id,type,name,image,video,remark,goods_remark,content,purchase_price,issuing_price,wholesale_price,market_price,min_price,max_price,is_show_stock,stock,sales_actual,sales_virtual,clicks,clicks_virtual,shop_id,poster,subsidy_id,presale,presale_mask') ->where($onSaleWhere) ->where('id', $goodsId) ->findOrEmpty(); diff --git a/app/shop/logic/goods/GoodsLogic.php b/app/shop/logic/goods/GoodsLogic.php index af6f1aa0..6aac6ef4 100755 --- a/app/shop/logic/goods/GoodsLogic.php +++ b/app/shop/logic/goods/GoodsLogic.php @@ -417,7 +417,8 @@ class GoodsLogic extends Logic //更新主表 $data = [ 'name' => $post['name'], - 'is_new_goods' => isset($post['is_new_goods']) && $post['is_new_goods'] == 'on' ? 1 : 0, + 'presale' => isset($post['presale']) && $post['presale'] == 'on' ? 1 : 0, + 'presale_mask' => $post['presale_mask'], 'code' => $post['code'], 'shop_cate_id' => $post['shop_cate_id'], 'first_cate_id' => $post['first_cate_id'], @@ -956,7 +957,8 @@ class GoodsLogic extends Logic $data = [ 'type' => $post['type'], 'name' => trim($post['name']), - 'is_new_goods' => isset($post['is_new_goods']) && $post['is_new_goods'] == 'on' ? 1 : 0, + 'presale' => isset($post['presale']) && $post['presale'] == 'on' ? 1 : 0, + 'presale_mask' => $post['presale_mask'], 'code' => trim($post['code']) ? trim($post['code']) : create_goods_code($shop_id), 'shop_id' => $shop_id, 'shop_cate_id' => $post['shop_cate_id'], diff --git a/app/shop/view/goods/goods/add.html b/app/shop/view/goods/goods/add.html index 3092463f..f7b2e92c 100755 --- a/app/shop/view/goods/goods/add.html +++ b/app/shop/view/goods/goods/add.html @@ -843,7 +843,8 @@ var goods_info= {$info|raw|default=''}; // 商品类型 - $("input[name=is_new_goods]").prop("checked", goods_info['base']['is_new_goods'] == 1); + $("input[name=presale]").prop("checked", goods_info['base']['presale'] == 1); + $("input[name=presale_mask]").val(goods_info['base']['presale_mask']); $("input[name=type]").prop("disabled",true); $("input[name=type][value="+goods_info['base']['type']+"]").prop("checked",true); switchGoodsType(goods_info['base']['type']); @@ -853,8 +854,8 @@ $('textarea[name="delivery_content"]').val(goods_info['base']['delivery_content']); // 配送方式 renderDeliveryType(goods_info['base']['delivery_type'], goods_info['base']['type']); -$('textarea[name="goods_remark"]').val(goods_info['base']['goods_remark']); -$('input[name="work_remark"]').val(goods_info['base']['work_remark']); + $('textarea[name="goods_remark"]').val(goods_info['base']['goods_remark']); + $('input[name="work_remark"]').val(goods_info['base']['work_remark']); $('input[name="goods_id"]').val(goods_info['base']['id']); $('input[name="name"]').val(goods_info['base']['name']); $('input[name="code"]').val(goods_info['base']['code']); diff --git a/app/shop/view/goods/goods/goods_base.html b/app/shop/view/goods/goods/goods_base.html index 871c379f..d91c2651 100755 --- a/app/shop/view/goods/goods/goods_base.html +++ b/app/shop/view/goods/goods/goods_base.html @@ -25,11 +25,19 @@ - +
- +
- + +
+
+ + +
+ +
+
diff --git a/database/migrations/20241223053219_add_is_new_goods_fields_to_goods.php b/database/migrations/20241223053219_add_is_new_goods_fields_to_goods.php index 1afde62e..81ac29ea 100644 --- a/database/migrations/20241223053219_add_is_new_goods_fields_to_goods.php +++ b/database/migrations/20241223053219_add_is_new_goods_fields_to_goods.php @@ -37,8 +37,8 @@ class AddIsNewGoodsFieldsToGoods extends Migrator public function down() { // 回滚操作删除添加的字段 - $table = $this->table('goods_subsidy'); - $table->removeColumn('store_subsidy') + $table = $this->table('goods'); + $table->removeColumn('is_new_goods') ->update(); } } diff --git a/database/migrations/20241223073220_rename_is_new_goods_fields_to_goods.php b/database/migrations/20241223073220_rename_is_new_goods_fields_to_goods.php new file mode 100644 index 00000000..80f60c2c --- /dev/null +++ b/database/migrations/20241223073220_rename_is_new_goods_fields_to_goods.php @@ -0,0 +1,34 @@ +table('goods'); + $table->renameColumn('is_new_goods', 'presale')->update(); // 更新 + } +} diff --git a/database/migrations/20241223073712_add_presale_mask_fields_to_goods.php b/database/migrations/20241223073712_add_presale_mask_fields_to_goods.php new file mode 100644 index 00000000..70aab0cb --- /dev/null +++ b/database/migrations/20241223073712_add_presale_mask_fields_to_goods.php @@ -0,0 +1,44 @@ +table('goods'); + $table->addColumn('presale_mask', 'string', [ + 'limit' => 255, 'default' => '', 'null' => false, 'comment' => '预售备注' + ])->update(); // 更新表结构 + } + + public function down() + { + // 回滚操作删除添加的字段 + $table = $this->table('goods'); + $table->removeColumn('presale_mask') + ->update(); + } +}