From 9bb4c9aeeb6165c08e6be165640f177f2c193627 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 22 May 2025 16:09:52 +0800
Subject: [PATCH] feat(mall): 添加微信小店功能

---
 src/main/java/cc/mrbird/febs/mall/vo/MallGoodsDetailsVo.java              |    8 +++
 src/main/resources/mapper/modules/MallGoodsMapper.xml                     |    4 ++
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java |   14 +++++++
 src/main/java/cc/mrbird/febs/mall/vo/MallGoodsListVo.java                 |    6 +++
 src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java                   |    5 ++
 src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html    |   46 +++++++++++++---------
 src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html |   23 ++++++++++-
 src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java             |    4 ++
 src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java                |    4 ++
 src/main/resources/templates/febs/views/modules/goods/goodsList.html      |    4 +
 10 files changed, 95 insertions(+), 23 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java b/src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java
index fdf6ed7..81a0352 100644
--- a/src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java
+++ b/src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java
@@ -10,6 +10,10 @@
 @ApiModel(value = "AddMallGoodsDto", description = "参数接收类")
 public class AddMallGoodsDto {
 
+    private String storeAppId;
+
+    private String storeGoodsId;
+
     private String goodsNo;
 
     private String goodsName;
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java b/src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java
index 3d8e80a..36f5e4b 100644
--- a/src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java
+++ b/src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java
@@ -11,6 +11,10 @@
 @ApiModel(value = "MallGoodsUpdateDto", description = "参数接收类")
 public class MallGoodsUpdateDto {
 
+    private String storeAppId;
+
+    private String storeGoodsId;
+
     private Long id;
 
     private String goodsNo;
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 6cb4c4c..ef7b6e2 100644
--- a/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java
+++ b/src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java
@@ -16,6 +16,11 @@
 @TableName("mall_goods")
 public class MallGoods extends BaseEntity {
 
+
+    private String storeAppId;
+
+    private String storeGoodsId;
+
     private String goodsNo;
 
     private String goodsName;
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 d2a5c45..eb2710c 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
@@ -73,6 +73,12 @@
             return new FebsResponse().fail().message("商品编号不能重复");
         }
         Integer carriageType = addMallGoodsDto.getCarriageType();
+        if (addMallGoodsDto.getIsNormal() == 3) {
+            String storeAppId = addMallGoodsDto.getStoreAppId();
+            if (ObjectUtil.isEmpty(storeAppId)) {
+                return new FebsResponse().fail().message("微信小店APP_ID不能为空");
+            }
+        }
         if (addMallGoodsDto.getGoodsType() == 1) {
             if (1 == carriageType) {
                 if (ObjectUtil.isEmpty(addMallGoodsDto.getCarriageAmount())
@@ -370,6 +376,14 @@
             }
         }
 
+
+        if (mallGoodsUpdateDto.getIsNormal() == 3) {
+            String storeAppId = mallGoodsUpdateDto.getStoreAppId();
+            if (ObjectUtil.isEmpty(storeAppId)) {
+                return new FebsResponse().fail().message("微信小店APP_ID不能为空");
+            }
+        }
+
         if (mallGoodsUpdateDto.getGoodsType() != 2) {
             Long categoryId = mallGoodsUpdateDto.getCategoryId();
             if (ObjectUtil.isEmpty(categoryId)) {
diff --git a/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsDetailsVo.java b/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsDetailsVo.java
index deb8872..3640115 100644
--- a/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsDetailsVo.java
+++ b/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsDetailsVo.java
@@ -18,6 +18,12 @@
     @ApiModelProperty(value = "id")
     private Long id;
 
+    @ApiModelProperty(value = "小店APP_ID")
+    private String storeAppId;
+
+    @ApiModelProperty(value = "小店商品ID")
+    private String storeGoodsId;
+
     @ApiModelProperty(value = "商品主图")
     private String thumb;
 
@@ -66,7 +72,7 @@
     @ApiModelProperty(value = "运费")
     private BigDecimal carriage;
 
-    @ApiModelProperty(value = "1-普通商品 2-套餐")
+    @ApiModelProperty(value = "1-普通商品 2-套餐 3-微信小店")
     private Integer isNormal;
 
     @ApiModelProperty(value = "轮播图")
diff --git a/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsListVo.java b/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsListVo.java
index f319ed2..83f83b4 100644
--- a/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsListVo.java
+++ b/src/main/java/cc/mrbird/febs/mall/vo/MallGoodsListVo.java
@@ -17,6 +17,12 @@
     @ApiModelProperty(value = "id")
     private Long id;
 
+    @ApiModelProperty(value = "小店APP_ID")
+    private String storeAppId;
+
+    @ApiModelProperty(value = "小店商品ID")
+    private String storeGoodsId;
+
     @ApiModelProperty(value = "规格ID")
     private Long skuId;
 
diff --git a/src/main/resources/mapper/modules/MallGoodsMapper.xml b/src/main/resources/mapper/modules/MallGoodsMapper.xml
index 8248c79..84b0c3f 100644
--- a/src/main/resources/mapper/modules/MallGoodsMapper.xml
+++ b/src/main/resources/mapper/modules/MallGoodsMapper.xml
@@ -5,6 +5,8 @@
     <resultMap id="MallGoodsMap" type="cc.mrbird.febs.mall.entity.MallGoods">
         <id property="id" column="id" />
         <result property="goodsNo" column="goods_no" />
+        <result property="storeAppId" column="store_app_id" />
+        <result property="storeGoodsId" column="store_goods_id" />
         <result property="goodsName" column="goods_name" />
         <result property="goodsIntrodution" column="goods_introdution" />
         <result property="unit" column="unit" />
@@ -342,6 +344,8 @@
         select
         a.id,
         a.goods_name,
+        a.store_app_id,
+        a.store_goods_id,
         a.goods_introdution goodsIntroduction,
         a.thumb,
         a.unit,
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 99d39ec..eaa4389 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
@@ -98,7 +98,7 @@
                                             <div class="layui-input-block">
                                                 <select name="isNormal" class="goods-type" lay-filter="goods-type-select">
                                                     <option value="1">普通商品区</option>
-<!--                                                    <option value="2">套餐区</option>-->
+                                                    <option value="3">微信小店</option>
                                                 </select>
                                             </div>
                                         </div>
@@ -110,15 +110,23 @@
 <!--                                            </div>-->
 <!--                                        </div>-->
 
-<!--                                        <div class="layui-form-item febs-hide tc-set">-->
-<!--                                            <label class="layui-form-label">积分折扣(%)</label>-->
-<!--                                            <div class="layui-input-block">-->
-<!--                                                <input type="text" name="staticProp" placeholder="请输入积分折扣" autocomplete="off" class="layui-input">-->
-<!--                                                <div class="layui-form-mid layui-word-aux">折扣积分=售价*积分折扣(%)*积分换算比例</div>-->
-<!--                                                <div class="layui-form-mid layui-word-aux">不允许使用积分设置成:0%</div>-->
-<!--                                                <div class="layui-form-mid layui-word-aux">全部使用积分设置成:大于等于100%</div>-->
-<!--                                            </div>-->
-<!--                                        </div>-->
+
+                                        <blockquote class="layui-elem-quote blue-border febs-hide tc-set">微信小店设置</blockquote>
+                                        <div class="layui-form-item febs-hide tc-set">
+                                            <div class="layui-col-lg6">
+                                                <label class="layui-form-label">APP_ID:</label>
+                                                <div class="layui-input-block">
+                                                    <input type="text" name="storeAppId" placeholder="请输入" autocomplete="off" class="layui-input">
+                                                </div>
+                                            </div>
+                                            <div class="layui-col-lg6">
+                                                <label class="layui-form-label">商品ID:</label>
+                                                <div class="layui-input-block">
+                                                    <input type="text" name="storeGoodsId" placeholder="请输入" autocomplete="off" class="layui-input">
+                                                    <div class="layui-form-mid layui-word-aux">不填写商品ID,则跳转到微信小店首页。</div>
+                                                </div>
+                                            </div>
+                                        </div>
                                     </div>
 
                                     <div class="layui-tab-item">
@@ -826,14 +834,14 @@
             return false;
         });
 
-        // form.on('select(goods-type-select)', function(data){
-        //     $('.tc-set').each(function() {
-        //         if (data.value == 2) {
-        //             $(this).show();
-        //         } else {
-        //             $(this).hide();
-        //         }
-        //     })
-        // });
+        form.on('select(goods-type-select)', function(data){
+            $('.tc-set').each(function() {
+                if (data.value == 3) {
+                    $(this).show();
+                } else {
+                    $(this).hide();
+                }
+            })
+        });
     });
 </script>
\ No newline at end of file
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 518d7a3..bab8894 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsList.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsList.html
@@ -82,8 +82,10 @@
 <script type="text/html" id="goodsTypeFormat">
     {{# if(d.isNormal == 1) { }}
         <span>普通商品</span>
+    {{# }else if(d.isNormal == 3) { }}
+        <span>微信小店</span>
     {{# } else { }}
-        <span>套餐</span>
+        <span>普通商品</span>
     {{# } }}
 </script>
 <style>
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 b8e6881..5094d99 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html
@@ -107,8 +107,25 @@
                                                 <select name="isNormal" class="goods-type"
                                                         lay-filter="goods-type-select">
                                                     <option value="1">普通商品区</option>
+                                                    <option value="3">微信小店</option>
 <!--                                                    <option value="2">套餐区</option>-->
                                                 </select>
+                                            </div>
+                                        </div>
+                                        <blockquote class="layui-elem-quote blue-border febs-hide tc-set">微信小店设置</blockquote>
+                                        <div class="layui-form-item febs-hide tc-set">
+                                            <div class="layui-col-lg6">
+                                                <label class="layui-form-label">APP_ID:</label>
+                                                <div class="layui-input-block">
+                                                    <input type="text" name="storeAppId" placeholder="请输入" autocomplete="off" class="layui-input">
+                                                </div>
+                                            </div>
+                                            <div class="layui-col-lg6">
+                                                <label class="layui-form-label">商品ID:</label>
+                                                <div class="layui-input-block">
+                                                    <input type="text" name="storeGoodsId" placeholder="请输入" autocomplete="off" class="layui-input">
+                                                    <div class="layui-form-mid layui-word-aux">不填写商品ID,则跳转到微信小店首页。</div>
+                                                </div>
                                             </div>
                                         </div>
 
@@ -849,6 +866,8 @@
             var thumbs = images.join(",");
             form.val("goods-update-form", {
                 "id": goodsInfo.id,
+                "storeAppId": goodsInfo.storeAppId,
+                "storeGoodsId": goodsInfo.storeGoodsId,
                 "goodsName": goodsInfo.goodsName,
                 "goodsNo": goodsInfo.goodsNo,
                 "unit": goodsInfo.unit,
@@ -886,7 +905,7 @@
 
             couponRule.setValue(goodsInfo.couponIds);
 
-            if (goodsInfo.isNormal == 2) {
+            if (goodsInfo.isNormal == 3) {
                 $(".tc-set").show();
             }
 
@@ -981,7 +1000,7 @@
 
         form.on('select(goods-type-select)', function (data) {
             $('.tc-set').each(function () {
-                if (data.value == 2) {
+                if (data.value == 3) {
                     $(this).show();
                 } else {
                     $(this).hide();

--
Gitblit v1.9.1