Просмотр исходного кода

商城-商品/积分商品/商品分类 + appid

三七 2 дней назад
Родитель
Сommit
f862787582

+ 7 - 0
fs-service/src/main/java/com/fs/his/domain/FsIntegralGoods.java

@@ -1,6 +1,8 @@
 package com.fs.his.domain;
 
 import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
@@ -66,6 +68,11 @@ public class FsIntegralGoods extends BaseEntity
     @Excel(name = "产品编码")
     private String barCode;
 
+    private String appIds;
+
+    @TableField(exist = false)
+    private String appId;
+
     /**
      * 非数据库字段 仅用于订单信息存储购买数量
      */

+ 4 - 0
fs-service/src/main/java/com/fs/his/mapper/FsIntegralGoodsMapper.java

@@ -76,9 +76,13 @@ public interface FsIntegralGoodsMapper
             "            <if test=\"goodsType != null \"> and goods_type = #{goodsType}</if>\n" +
             "            <if test=\"status != null \"> and status = #{status}</if>\n" +
             "            <if test=\"integral != null \"> and integral = #{integral}</if>\n" +
+            "<if test = 'appId != null and appId != \" \" '> " +
+            " and ((FIND_IN_SET(#{appId}, app_ids) > 0)) " +
+            "</if>"+
             "        </where> order by sort,goods_id desc"+
             "</script>"})
     List<FsIntegralGoodsListVO> selectFsIntegralGoodsListVO(FsIntegralGoods fsIntegralGoods);
+
     @Select({"<script> " +
             "select g.goods_id,g.img_url,g.images,g.goods_name,g.ot_price,g.goods_type,g.integral,g.cash,g.sort  from fs_integral_goods g  " +
             "where g.status=1  " +

+ 34 - 3
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductCategoryScrm.java

@@ -1,10 +1,11 @@
 package com.fs.hisStore.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 
 /**
- * 商品分类对象 fs_store_product_category
+ * 商品分类对象 fs_store_product_category_scrm
  *
  * @author fs
  * @date 2022-03-15
@@ -32,6 +33,7 @@ public class FsStoreProductCategoryScrm extends BaseEntity
     @Excel(name = "图标")
     private String pic;
 
+
     /** 是否推荐 */
     @Excel(name = "是否推荐")
     private Integer isShow;
@@ -40,6 +42,28 @@ public class FsStoreProductCategoryScrm extends BaseEntity
     @Excel(name = "删除状态")
     private Integer isDel;
 
+    private String appIds;
+
+    /**
+    * 根据appId来区分分类时
+    */
+    @TableField(exist = false)
+    private String appId;
+
+    @Excel(name = "关联店铺id(没有关联则为默认店铺)")
+    private Long storeId;
+
+
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+
     public Long getStoreId() {
         return storeId;
     }
@@ -48,8 +72,15 @@ public class FsStoreProductCategoryScrm extends BaseEntity
         this.storeId = storeId;
     }
 
-    @Excel(name = "关联店铺id(没有关联则为默认店铺)")
-    private Long storeId;
+
+
+    public String getAppIds() {
+        return appIds;
+    }
+
+    public void setAppIds(String appIds) {
+        this.appIds = appIds;
+    }
 
     public void setCateId(Long cateId)
     {

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductScrm.java

@@ -343,6 +343,9 @@ public class FsStoreProductScrm extends BaseEntity
     @Excel(name = "所属小程序app_id")
     private String appIds;
 
+    @TableField(exist = false)
+    private String appId;
+
     /** 限购数量 */
     @Excel(name = "限购数量")
     private Integer purchaseLimit;

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsIntegralGoodsScrmMapper.java

@@ -80,6 +80,9 @@ public interface FsIntegralGoodsScrmMapper
             "<if test = 'maps.goodsType != null and maps.goodsType != 0     '> " +
             "and g.goods_type = #{maps.goodsType}  " +
             "</if>" +
+            "<if test = 'maps.appId != null and maps.appId != \" \" '> " +
+            " and ((FIND_IN_SET(#{maps.appId}, g.app_ids) > 0)) " +
+            "</if>"+
             " order by g.goods_id desc "+
             "</script>"})
     List<FsIntegralGoodsListUVO> selectFsIntegralGoodsListUVO(@Param("maps")FsIntegralGoodsListUParam param);

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductCategoryScrmMapper.java

@@ -79,6 +79,9 @@ public interface FsStoreProductCategoryScrmMapper
             "<if test = 'maps.storeId != null    '> " +
             "and c.store_id =#{maps.storeId} " +
             "</if>" +
+            "<if test = 'maps.appId != null and maps.appId != \" \" '> " +
+            " and ((FIND_IN_SET(#{maps.appId}, c.app_ids) > 0)) " +
+            "</if>"+
             " order by c.sort asc "+
             "</script>"})
     List<FsStoreProductCategoryScrm> selectFsStoreProductCategoryListQuery(@Param("maps") FsStoreProductCategoryScrm param);

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -149,6 +149,9 @@ public interface FsStoreProductScrmMapper
             " <if test='maps.precautions != null and maps.precautions != \"\"'>" +
             "     AND p.precautions LIKE CONCAT('%', #{maps.precautions}, '%')" +
             " </if>"+
+            "<if test = 'maps.appId != null and maps.appId != \" \" '> " +
+            " and ((FIND_IN_SET(#{maps.appId}, p.app_ids) > 0)) " +
+            "</if>"+
             "<if test = 'maps.excludeProductIds != null '>" +
             "and p.product_id not in " +
             "<foreach collection='maps.excludeProductIds'  item='item' index='index'  open='(' separator=',' close=')'> " +

+ 1 - 0
fs-service/src/main/resources/application-config-druid-hsyy.yml

@@ -90,6 +90,7 @@ headerImg:
 ipad:
   ipadUrl: http://ipad.hshsyy.com
   aiApi: http://49.
+  wxIpadUrl:
   voiceApi:
   commonApi:
 wx_miniapp_temp:

+ 1 - 0
fs-service/src/main/resources/application-config-druid-mengniu.yml

@@ -95,6 +95,7 @@ headerImg:
 ipad:
   ipadUrl: http://ipad
   aiApi: http://49.
+  wxIpadUrl:
   voiceApi:
   commonApi:
 wx_miniapp_temp:

+ 5 - 1
fs-service/src/main/resources/mapper/his/FsIntegralGoodsMapper.xml

@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="descs"    column="descs"    />
         <result property="createTime"    column="create_time"    />
         <result property="barCode"    column="bar_code"    />
+        <result property="appIds"    column="app_ids"    />
     </resultMap>
 
     <sql id="selectFsIntegralGoodsVo">
-        select goods_id, img_url, images,bar_code, goods_name, ot_price, goods_type, status, integral, cash, sort, stock, descs, create_time from fs_integral_goods
+        select goods_id, img_url, images,bar_code, goods_name, ot_price, goods_type, status, integral, cash, sort, stock, descs, create_time,app_ids from fs_integral_goods
     </sql>
 
     <select id="selectFsIntegralGoodsList" parameterType="FsIntegralGoods" resultMap="FsIntegralGoodsResult">
@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">descs,</if>
             <if test="createTime != null">create_time,</if>
             <if test="barCode != null">bar_code,</if>
+            <if test="appIds != null">app_ids,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="goodsId != null">#{goodsId},</if>
@@ -75,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">#{descs},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="barCode != null">#{barCode},</if>
+            <if test="appIds != null">#{appIds},</if>
          </trim>
     </insert>
 
@@ -94,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">descs = #{descs},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="barCode != null">bar_code = #{barCode},</if>
+            <if test="appIds != null">app_ids = #{appIds},</if>
         </trim>
         where goods_id = #{goodsId}
     </update>

+ 6 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreProductCategoryScrmMapper.xml

@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="isDel"    column="is_del"    />
         <result property="storeId"    column="store_id"    />
+        <result property="appIds"    column="app_ids"    />
     </resultMap>
 
     <sql id="selectFsStoreProductCategoryVo">
-        select cate_id, pid, cate_name, sort, pic, is_show, create_time, update_time, is_del,store_id from fs_store_product_category_scrm
+        select cate_id, pid, cate_name, sort, pic, is_show, create_time, update_time, is_del,store_id,app_ids from fs_store_product_category_scrm
     </sql>
 
     <select id="selectFsStoreProductCategoryList" parameterType="FsStoreProductCategoryScrm" resultMap="FsStoreProductCategoryResult">
@@ -31,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isShow != null "> and is_show = #{isShow}</if>
             <if test="isDel != null "> and is_del = #{isDel}</if>
             <if test="storeId != null "> and store_id = #{storeId}</if>
+            <if test="appId != null  and appId != ''"> and ((FIND_IN_SET(#{appId}, app_ids) > 0)) </if>
         </where>
     </select>
 
@@ -57,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="isDel != null">is_del,</if>
             <if test="storeId != null">store_id,</if>
+            <if test="appIds != null">app_ids,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="pid != null">#{pid},</if>
@@ -68,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="isDel != null">#{isDel},</if>
             <if test="storeId != null">#{storeId},</if>
+            <if test="appIds != null">#{appIds},</if>
          </trim>
     </insert>
 
@@ -82,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="isDel != null">is_del = #{isDel},</if>
+            <if test="appIds != null">app_ids = #{appIds},</if>
         </trim>
         where cate_id = #{cateId}
     </update>

+ 41 - 40
fs-user-app/src/main/java/com/fs/app/controller/store/ProductScrmController.java

@@ -62,7 +62,7 @@ public class ProductScrmController extends AppBaseController {
 
     @Autowired
     private IFsStoreProductPurchaseLimitScrmService purchaseLimitService;
-    
+
     @Autowired
     private IFsStoreOrderItemScrmService orderItemService;
     /**
@@ -71,12 +71,13 @@ public class ProductScrmController extends AppBaseController {
      * @return     */
     @ApiOperation("获取分类")
     @GetMapping("/getProductCate")
-    public R getProductCate(@RequestParam(name = "storeId",required = false) Long storeId){
+    public R getProductCate(@RequestParam(name = "storeId",required = false) Long storeId,@RequestParam(name = "appId",required = false) String appId){
         try {
             FsStoreProductCategoryScrm param=new FsStoreProductCategoryScrm();
             param.setIsShow(1);
             param.setIsDel(0);
             param.setStoreId(storeId);
+            param.setAppId(appId);
             List<FsStoreProductCategoryScrm> list=categoryService.selectFsStoreProductCategoryListQuery(param);
             return R.ok().put("data",list);
         } catch (Exception e){
@@ -250,7 +251,7 @@ public class ProductScrmController extends AppBaseController {
     @Login
     @ApiOperation("检查商品限购")
     @GetMapping("/checkPurchaseLimit")
-    public R checkPurchaseLimit(@RequestParam(value="productId") Long productId, 
+    public R checkPurchaseLimit(@RequestParam(value="productId") Long productId,
                                 @RequestParam(value="num", required = false, defaultValue = "1") Integer num){
         try {
             // 查询商品信息
@@ -258,13 +259,13 @@ public class ProductScrmController extends AppBaseController {
             if(product == null){
                 return R.error("商品不存在");
             }
-            
+
             // 检查是否限购
             if(product.getPurchaseLimit() == null || product.getPurchaseLimit() <= 0){
                 // 商品不限购,直接返回成功
                 return R.ok();
             }
-            
+
             // 商品有限购,查询用户已购买数量
             String userId = getUserId();
             if(userId == null){
@@ -276,14 +277,14 @@ public class ProductScrmController extends AppBaseController {
             if (purchaseLimit != null) {
                 purchasedNum = purchaseLimit.getNum();
             }
-            
+
             // 计算剩余可购买数量
             int remainingPurchaseLimit = product.getPurchaseLimit() - purchasedNum;
             if (remainingPurchaseLimit < num) {
                 // 剩余可购买数量不足
                 return R.error("该商品限购" + product.getPurchaseLimit() + "件,您已购买" + purchasedNum + "件,本次购买" + num + "件,超出限购数量");
             }
-            
+
             // 剩余可购买数量充足
             return R.ok();
         } catch (Exception e){
@@ -376,29 +377,29 @@ public class ProductScrmController extends AppBaseController {
             if (userId == null) {
                 return R.error("用户未登录");
             }
-            
+
             if (param.getProducts() == null || param.getProducts().isEmpty()) {
                 return R.error("商品列表不能为空");
             }
-            
+
             Long userIdLong = Long.parseLong(userId);
             List<String> errorMessages = new ArrayList<>();
-            
+
             // 按productId分组,累加同一商品不同规格的数量
             Map<Long, Integer> productNumMap = new HashMap<>();
             Map<Long, String> productNameMap = new HashMap<>();
-            
+
             for (CartPurchaseLimitCheckParam.ProductItem item : param.getProducts()) {
                 Long productId = item.getProductId();
                 Integer num = item.getNum();
-                
+
                 if (productId == null || num == null || num <= 0) {
                     continue;
                 }
-                
+
                 // 累加同一商品的数量(不同规格算在一起)
                 productNumMap.put(productId, productNumMap.getOrDefault(productId, 0) + num);
-                
+
                 // 保存商品名称(用于错误提示)
                 if (!productNameMap.containsKey(productId)) {
                     FsStoreProductScrm product = productService.selectFsStoreProductById(productId);
@@ -407,24 +408,24 @@ public class ProductScrmController extends AppBaseController {
                     }
                 }
             }
-            
+
             // 遍历分组后的商品,检查限购
             for (Map.Entry<Long, Integer> entry : productNumMap.entrySet()) {
                 Long productId = entry.getKey();
                 Integer totalNum = entry.getValue(); // 同一商品所有规格的总数量
-                
+
                 // 查询商品信息
                 FsStoreProductScrm product = productService.selectFsStoreProductById(productId);
                 if (product == null) {
                     continue;
                 }
-                
+
                 // 检查是否限购
                 if (product.getPurchaseLimit() == null || product.getPurchaseLimit() <= 0) {
                     // 商品不限购,跳过
                     continue;
                 }
-                
+
                 // 商品有限购,查询用户已购买数量
                 FsStoreProductPurchaseLimitScrm purchaseLimit = purchaseLimitService.selectByProductIdAndUserId(
                         productId, userIdLong);
@@ -432,12 +433,12 @@ public class ProductScrmController extends AppBaseController {
                 if (purchaseLimit != null) {
                     purchasedNum = purchaseLimit.getNum();
                 }
-                
+
                 // 计算剩余可购买数量
                 int remainingPurchaseLimit = product.getPurchaseLimit() - purchasedNum;
                 if (remainingPurchaseLimit < totalNum) {
                     // 超过限购,添加错误信息
-                    String productName = productNameMap.getOrDefault(productId, 
+                    String productName = productNameMap.getOrDefault(productId,
                             product.getProductName() != null ? product.getProductName() : "商品ID:" + productId);
                     String errorMsg = String.format("商品【%s】限购%d件,您已购买%d件,本次购买%d件,超出限购数量",
                             productName,
@@ -447,13 +448,13 @@ public class ProductScrmController extends AppBaseController {
                     errorMessages.add(errorMsg);
                 }
             }
-            
+
             // 如果有错误信息,拼接并返回
             if (!errorMessages.isEmpty()) {
                 String errorMsg = String.join(";", errorMessages);
                 return R.error(errorMsg);
             }
-            
+
             // 所有商品都通过限购检查
             return R.ok();
         } catch (Exception e) {
@@ -470,39 +471,39 @@ public class ProductScrmController extends AppBaseController {
             if (userId == null) {
                 return R.error("用户未登录");
             }
-            
+
             if (orderCode == null || orderCode.trim().isEmpty()) {
                 return R.error("订单号不能为空");
             }
-            
+
             Long userIdLong = Long.parseLong(userId);
-            
+
             // 根据orderCode查询订单商品
             FsStoreOrderItemScrm queryParam = new FsStoreOrderItemScrm();
             queryParam.setOrderCode(orderCode);
             List<FsStoreOrderItemScrm> orderItems = orderItemService.selectFsStoreOrderItemList(queryParam);
-            
+
             if (orderItems == null || orderItems.isEmpty()) {
                 return R.error("订单不存在或订单中没有商品");
             }
-            
+
             List<String> errorMessages = new ArrayList<>();
-            
+
             // 按productId分组,累加同一商品不同规格的数量
             Map<Long, Integer> productNumMap = new HashMap<>();
             Map<Long, String> productNameMap = new HashMap<>();
-            
+
             for (FsStoreOrderItemScrm orderItem : orderItems) {
                 Long productId = orderItem.getProductId();
                 Integer num = orderItem.getNum();
-                
+
                 if (productId == null || num == null || num <= 0) {
                     continue;
                 }
-                
+
                 // 累加同一商品的数量(不同规格算在一起)
                 productNumMap.put(productId, productNumMap.getOrDefault(productId, 0) + num);
-                
+
                 // 保存商品名称(用于错误提示)
                 if (!productNameMap.containsKey(productId)) {
                     FsStoreProductScrm product = productService.selectFsStoreProductById(productId);
@@ -511,24 +512,24 @@ public class ProductScrmController extends AppBaseController {
                     }
                 }
             }
-            
+
             // 遍历分组后的商品,检查限购
             for (Map.Entry<Long, Integer> entry : productNumMap.entrySet()) {
                 Long productId = entry.getKey();
                 Integer totalNum = entry.getValue(); // 同一商品所有规格的总数量
-                
+
                 // 查询商品信息
                 FsStoreProductScrm product = productService.selectFsStoreProductById(productId);
                 if (product == null) {
                     continue;
                 }
-                
+
                 // 检查是否限购
                 if (product.getPurchaseLimit() == null || product.getPurchaseLimit() <= 0) {
                     // 商品不限购,跳过
                     continue;
                 }
-                
+
                 // 商品有限购,查询用户已购买数量
                 FsStoreProductPurchaseLimitScrm purchaseLimit = purchaseLimitService.selectByProductIdAndUserId(
                         productId, userIdLong);
@@ -536,12 +537,12 @@ public class ProductScrmController extends AppBaseController {
                 if (purchaseLimit != null) {
                     purchasedNum = purchaseLimit.getNum();
                 }
-                
+
                 // 计算剩余可购买数量(订单中的数量也要计算在内)
                 int remainingPurchaseLimit = product.getPurchaseLimit() - purchasedNum;
                 if (remainingPurchaseLimit < totalNum) {
                     // 超过限购,添加错误信息
-                    String productName = productNameMap.getOrDefault(productId, 
+                    String productName = productNameMap.getOrDefault(productId,
                             product.getProductName() != null ? product.getProductName() : "商品ID:" + productId);
                     String errorMsg = String.format("商品【%s】限购%d件,您已购买%d件,订单中购买%d件,超出限购数量",
                             productName,
@@ -551,13 +552,13 @@ public class ProductScrmController extends AppBaseController {
                     errorMessages.add(errorMsg);
                 }
             }
-            
+
             // 如果有错误信息,拼接并返回
             if (!errorMessages.isEmpty()) {
                 String errorMsg = String.join(";", errorMessages);
                 return R.error(errorMsg);
             }
-            
+
             // 所有商品都通过限购检查
             return R.ok();
         } catch (Exception e) {