From 6de066700687dc54f680ef60a5285581d4fb44a1 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 22 Jun 2022 14:35:27 +0800 Subject: [PATCH] 20220528 --- src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java | 22 +++++++++++ src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java | 5 ++ src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html | 13 ++++-- src/main/java/cc/mrbird/febs/mall/controller/AdminMallGoodsController.java | 18 +++++++++ src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html | 14 +++++-- src/main/resources/templates/febs/views/modules/goods/goodsList.html | 28 ++++++++++++++ 6 files changed, 92 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminMallGoodsController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallGoodsController.java index 7a742cd..9dd068a 100644 --- a/src/main/java/cc/mrbird/febs/mall/controller/AdminMallGoodsController.java +++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallGoodsController.java @@ -99,6 +99,24 @@ } /** + * 商品-热卖 + */ + @GetMapping("goodsHot/{id}") + @ControllerEndpoint(operation = " 商品-热卖", exceptionMessage = "设置失败") + public FebsResponse goodsHot(@NotNull(message = "{required}") @PathVariable Long id) { + return adminMallGoodsService.goodsHot(id); + } + + /** + * 商品-取消热卖 + */ + @GetMapping("goodsNotHot/{id}") + @ControllerEndpoint(operation = " 商品-取消热卖", exceptionMessage = "设置失败") + public FebsResponse goodsNotHot(@NotNull(message = "{required}") @PathVariable Long id) { + return adminMallGoodsService.goodsNotHot(id); + } + + /** * 商品-上架 */ @GetMapping("upMallGoods/{id}") diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java b/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java index 28487c7..371035b 100644 --- a/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java +++ b/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java @@ -47,6 +47,11 @@ private Long categoryId; + /** + * 是否热卖 1:是 2:否 + */ + public static final Integer ISHOT_STATE_YES = 1; + public static final Integer ISHOT_STATE_NO = 2; private Integer isHot; /** diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java index 8389f94..14dcdcf 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java @@ -473,5 +473,27 @@ return mallGoodsMapper.getAllGoodsTree(); } + @Override + public FebsResponse goodsHot(Long id) { + MallGoods mallGoods = mallGoodsMapper.selectById(id); + if (ObjectUtil.isEmpty(mallGoods)) { + return new FebsResponse().fail().message("商品不存在,请刷新当前页面"); + } + mallGoods.setIsHot(MallGoods.ISHOT_STATE_YES); + mallGoodsMapper.updateById(mallGoods); + return new FebsResponse().success(); + } + + @Override + public FebsResponse goodsNotHot(Long id) { + MallGoods mallGoods = mallGoodsMapper.selectById(id); + if (ObjectUtil.isEmpty(mallGoods)) { + return new FebsResponse().fail().message("商品不存在,请刷新当前页面"); + } + mallGoods.setIsHot(MallGoods.ISHOT_STATE_NO); + mallGoodsMapper.updateById(mallGoods); + return new FebsResponse().success(); + } + } diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html index bcc7f0c..5208f25 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html @@ -28,16 +28,21 @@ </div> </div> </div> - <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品分类:</label> <div class="layui-input-block"> -<!-- <select name="categoryId" class="categary-addPeoduct" >--> -<!-- <option value="">请选择</option>--> -<!-- </select>--> <div id="goods-category"></div> </div> </div> + + <div class="layui-col-lg6"> + <label class="layui-form-label">是否主推:</label> + <div class="layui-input-block"> + <input type="radio" name="isHot" value="1" title="是" /> + <input type="radio" name="isHot" value="2" title="否" checked /> + </div> + </div> </div> <div class="layui-form-item"> diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsList.html b/src/main/resources/templates/febs/views/modules/goods/goodsList.html index c8de164..9a75209 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsList.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsList.html @@ -60,6 +60,13 @@ <input type="checkbox" value={{d.id}} lay-text="上架|下架" lay-skin="switch" lay-filter="upOrDownSwitch"> {{# } }} </script> +<script type="text/html" id="isHotSwitch"> + {{# if(d.isHot === 1) { }} + <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="isHotSwitch"> + {{# } else { }} + <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="isHotSwitch"> + {{# } }} +</script> <script type="text/html" id="isSkuFormat"> {{# if(d.isSku === 1) { }} <span>是</span> @@ -170,6 +177,18 @@ $query.click(); }); } + function goodsHot(id) { + febs.get(ctx + 'admin/goods/goodsHot/' + id, null, function () { + febs.alert.success('设置成功'); + $query.click(); + }); + } + function goodsNotHot(id) { + febs.get(ctx + 'admin/goods/goodsNotHot/' + id, null, function () { + febs.alert.success('设置成功'); + $query.click(); + }); + } // 查询按钮 $query.on('click', function () { @@ -211,6 +230,7 @@ }, minWidth: 150,align:'center'}, {field: 'categaryName', title: '分类', minWidth: 150,align:'left'}, {field: 'isSale', title: '是否上架', templet: '#upOrDownSwitch', minWidth: 130,align:'center'}, + {field: 'isHot', title: '是否主推', templet: '#isHotSwitch', minWidth: 130,align:'center'}, {templet:"#goodsTypeFormat", title: '商品类型', minWidth: 150,align:'left'}, {templet:"#isSkuFormat", title: '是否多规格', minWidth: 150,align:'left'}, {field: 'presentPrice', title: '现价', minWidth: 150,align:'left'}, @@ -243,6 +263,14 @@ } }) + form.on('switch(isHotSwitch)', function (data) { + if (data.elem.checked) { + goodsHot(data.value); + } else { + goodsNotHot(data.value); + } + }) + // 获取查询参数 function getQueryParams() { return { diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html index 10e16e6..d91bcd3 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html @@ -32,14 +32,19 @@ </div> </div> </div> - <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品分类:</label> <div class="layui-input-block"> -<!-- <select name="categoryId" class="categary-addPeoduct">--> -<!-- <option value="">请选择</option>--> -<!-- </select>--> <div id="goods-category"></div> + </div> + </div> + + <div class="layui-col-lg6"> + <label class="layui-form-label">是否主推:</label> + <div class="layui-input-block"> + <input type="radio" name="isHot" value="1" title="是" /> + <input type="radio" name="isHot" value="2" title="否" checked /> </div> </div> </div> @@ -636,6 +641,7 @@ "unit": goodsInfo.unit, "stock": goodsInfo.stock, "volume": goodsInfo.volume, + "isHot": goodsInfo.isHot, "goodsParameter": goodsInfo.goodsParameter, "goodsIntrodution": goodsInfo.goodsIntrodution, "isNormal": goodsInfo.isNormal, -- Gitblit v1.9.1