Browse Source

feat:商品设置所属小程序,小程序过滤展示商品

caoliqin 1 day ago
parent
commit
32e7a62164

+ 2 - 0
fs-service/src/main/java/com/fs/common/param/BaseQueryParam.java

@@ -18,5 +18,7 @@ public class BaseQueryParam extends BaseEntity implements Serializable {
     private Integer limit;
     @ApiModelProperty(value = "搜索字符串")
     private String keyword;
+    @ApiModelProperty(value = "当前的appid")
+    private String appId;
 
 }

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

@@ -339,4 +339,8 @@ public class FsStoreProductScrm extends BaseEntity
     @Excel(name = "国产或进口")
     private String domesticImported;
 
+    /** 所属小程序app_id,多个用逗号隔开 */
+    @Excel(name = "所属小程序app_id")
+    private String appIds;
+
 }

+ 6 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -3,6 +3,7 @@ package com.fs.hisStore.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.fs.common.param.BaseQueryParam;
 import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.FsStoreProductListSVO;
@@ -207,7 +208,10 @@ public interface FsStoreProductScrmMapper
             "        <foreach collection='maps.cateIds' item='cateId' open='(' separator=',' close=')'>\n" +
             "            #{cateId}\n" +
             "        </foreach>\n" +
-            "    </if>"+
+            "    </if>" +
+            "<if test = 'maps.appId != null and maps.appId != \" \" '> " +
+            " and ((FIND_IN_SET(#{maps.appId}, p.app_ids) > 0)) " +
+            "</if>"+
             "<if test = 'maps.defaultOrder != null and maps.defaultOrder==\"desc\"  '> " +
             "order by p.sort asc,product_id desc" +
             "</if>" +
@@ -269,7 +273,7 @@ public interface FsStoreProductScrmMapper
             "</if>" +
             "and  p.is_good=1 and p.is_display=1 order by p.sort desc limit #{count}")
     List<FsStoreProductListQueryVO> selectFsStoreProductGoodQuery(int count,@Param("config") MedicalMallConfig  config);
-    List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery(@Param("config") MedicalMallConfig  config);
+    List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery(@Param("config") MedicalMallConfig  config, @Param("param") BaseQueryParam param);
     List<FsStoreProductListQueryVO> selectFsStoreProductGoodListQuery(@Param("config") MedicalMallConfig  config);
     @Select({"<script> " +
             "select count(1) from fs_store_product_scrm  " +

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreProductAddEditParam.java

@@ -296,4 +296,7 @@ public class FsStoreProductAddEditParam implements Serializable
     @Excel(name = "国产或进口")
     private String domesticImported;
 
+    /** 所属小程序app_id,多个用逗号隔开 */
+    private String appIds;
+
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreProductQueryParam.java

@@ -40,4 +40,7 @@ public class FsStoreProductQueryParam extends BaseQueryParam implements Serializ
     private Integer isStores;
 
     List<Long> cateIds;
+
+    @ApiModelProperty(value = "当前的appid")
+    private String appId;
 }

+ 2 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.fs.common.core.domain.R;
+import com.fs.common.param.BaseQueryParam;
 import com.fs.his.domain.FsStoreProduct;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.domain.FsStoreProductRuleScrm;
@@ -102,7 +103,7 @@ public interface IFsStoreProductScrmService
 
     List<FsStoreProductListQueryVO> selectFsStoreProductGoodQuery(int count);
 
-    List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery();
+    List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery(BaseQueryParam param);
 
     List<FsStoreProductListQueryVO> selectFsStoreProductGoodListQuery();
 

+ 27 - 26
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -17,6 +17,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
+import com.fs.common.param.BaseQueryParam;
 import com.fs.common.utils.DateUtils;
 import com.fs.company.cache.ICompanyCacheService;
 import com.fs.config.cloud.CloudHostProper;
@@ -236,15 +237,15 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
         log.info("批量删除商品:{}", productIds);
         int result = fsStoreProductMapper.deleteFsStoreProductByIds(productIds);
-        
+
         // 清除缓存
         clearProductDetailCache(productIds);
-        
+
         // 异步处理商品删除联动逻辑
         if (result > 0) {
             handleProductDeleteAsync(productIds);
         }
-        
+
         return result;
     }
 
@@ -258,7 +259,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     public void handleProductDeleteAsync(Long[] productIds) {
         try {
             log.info("开始异步处理商品删除联动,商品IDs: {}", Arrays.toString(productIds));
-            
+
             // 查询所有未直播(1)、直播中(2)和直播回放(4)的直播间
             // 使用 LiveMapper 查询状态为1,2,4的直播间(包括所有类型)
             List<Live> allLiveList = liveMapper.liveListAll();
@@ -283,19 +284,19 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                 }
             }
-            
+
             if (targetLiveList.isEmpty()) {
                 log.info("没有找到需要处理的直播间");
                 return;
             }
-            
+
             log.info("找到 {} 个需要处理的直播间", targetLiveList.size());
-            
+
             // 遍历每个被删除的商品
             for (Long productId : productIds) {
                 processProductDeleteForLives(productId, targetLiveList);
             }
-            
+
             log.info("商品删除联动处理完成");
         } catch (Exception e) {
             log.error("异步处理商品删除联动失败", e);
@@ -315,19 +316,19 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 if (liveId == null) {
                     continue;
                 }
-                
+
                 // 1. 删除直播商品
                 deleteLiveGoodsByProductId(productId, liveId);
-                
+
                 // 2. 删除直播定时任务(直播上下架、直播卡片)
                 deleteLiveAutoTasksByProductId(productId, liveId);
-                
+
                 // 3. 删除直播抽奖(产品关联被删除的商品)
                 deleteLiveLotteryProductConfByProductId(productId, liveId);
-                
+
                 // 4. 删除直播定时任务(抽奖,里面关联了这个商品的)
                 deleteLiveAutoTasksByLotteryProductId(productId, liveId);
-                
+
             } catch (Exception e) {
                 log.error("处理直播间 {} 的商品 {} 删除联动失败", live.getLiveId(), productId, e);
             }
@@ -346,7 +347,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryGoods.setProductId(productId);
             queryGoods.setLiveId(liveId);
             List<LiveGoods> goodsList = liveGoodsService.selectLiveGoodsList(queryGoods);
-            
+
             if (!goodsList.isEmpty()) {
                 Long[] goodsIds = goodsList.stream()
                         .map(LiveGoods::getGoodsId)
@@ -370,9 +371,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             LiveAutoTask queryTask = new LiveAutoTask();
             queryTask.setLiveId(liveId);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
-            
+
             List<Long> taskIdsToDelete = new ArrayList<>();
-            
+
             for (LiveAutoTask task : taskList) {
                 // 任务类型:1-定时推送卡片商品 6-自动上下架
                 if (task.getTaskType() != null && (task.getTaskType() == 1L || task.getTaskType() == 6L)) {
@@ -396,7 +397,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                 }
             }
-            
+
             if (!taskIdsToDelete.isEmpty()) {
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
@@ -419,7 +420,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryConf.setProductId(productId);
             queryConf.setLiveId(liveId);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
-            
+
             if (!confList.isEmpty()) {
                 Long[] ids = confList.stream()
                         .map(LiveLotteryProductConf::getId)
@@ -445,23 +446,23 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryConf.setProductId(productId);
             queryConf.setLiveId(liveId);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
-            
+
             if (confList.isEmpty()) {
                 return;
             }
-            
+
             // 获取所有相关的抽奖ID
             Set<Long> lotteryIds = confList.stream()
                     .map(LiveLotteryProductConf::getLotteryId)
                     .collect(Collectors.toSet());
-            
+
             // 查询该直播间的所有定时任务
             LiveAutoTask queryTask = new LiveAutoTask();
             queryTask.setLiveId(liveId);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
-            
+
             List<Long> taskIdsToDelete = new ArrayList<>();
-            
+
             for (LiveAutoTask task : taskList) {
                 // 任务类型:4-抽奖
                 if (task.getTaskType() != null && task.getTaskType() == 4L) {
@@ -475,7 +476,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                 }
             }
-            
+
             if (!taskIdsToDelete.isEmpty()) {
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
@@ -1078,8 +1079,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     }
 
     @Override
-    public List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery() {
-        return fsStoreProductMapper.selectFsStoreProductTuiListQuery(medicalMallConfig);
+    public List<FsStoreProductListQueryVO> selectFsStoreProductTuiListQuery(BaseQueryParam param) {
+        return fsStoreProductMapper.selectFsStoreProductTuiListQuery(medicalMallConfig, param);
     }
 
     @Override

+ 9 - 2
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -75,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="netContent"    column="net_content"    />
         <result property="shelfLife"    column="shelf_life"    />
         <result property="domesticImported"    column="domestic_imported"    />
+        <result property="appIds"    column="app_ids"    />
     </resultMap>
 
     <sql id="selectFsStoreProductVo">
@@ -86,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                is_display,tui_cate_id,company_ids,is_drug,drug_image,drug_reg_cert_no,common_name,dosage_form,
                unit_price,batch_number,mah,mah_address,manufacturer,manufacturer_address,indications,dosage,
                adverse_reactions,contraindications,precautions,is_audit,store_id,return_address,brand,food_production_license_code,
-               origin_place,net_content,shelf_life,domestic_imported
+               origin_place,net_content,shelf_life,domestic_imported,app_ids
                from fs_store_product_scrm
     </sql>
 
@@ -99,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                p.is_display,p.tui_cate_id,p.company_ids,p.is_drug,p.drug_image,p.drug_reg_cert_no,p.common_name,p.dosage_form,
                p.unit_price,p.batch_number,p.mah,p.mah_address,p.manufacturer,p.manufacturer_address,p.indications,p.dosage,
                p.adverse_reactions,p.contraindications,p.precautions,p.is_audit,p.store_id,p.return_address,p.brand,p.food_production_license_code,
-               p.origin_place,p.net_content,p.shelf_life,p.domestic_imported
+               p.origin_place,p.net_content,p.shelf_life,p.domestic_imported,app_ids
         from fs_store_product_scrm p
     </sql>
 
@@ -276,6 +277,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="netContent != null and netContent != ''">net_content,</if>
             <if test="shelfLife != null">shelf_life,</if>
             <if test="domesticImported != null and domesticImported != ''">domestic_imported,</if>
+            <if test="appIds != null and appIds != ''">app_ids, </if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="image != null and image != ''">#{image},</if>
@@ -347,6 +349,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="netContent != null and netContent != ''">#{netContent},</if>
             <if test="shelfLife != null">#{shelfLife},</if>
             <if test="domesticImported != null and domesticImported != ''">#{domesticImported},</if>
+            <if test="appIds != null and appIds != ''">#{appIds}, </if>
          </trim>
     </insert>
 
@@ -422,6 +425,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="netContent != null">net_content = #{netContent},</if>
             <if test="shelfLife != null">shelf_life = #{shelfLife},</if>
             <if test="domesticImported != null">domestic_imported = #{domesticImported},</if>
+            <if test="appIds != null and appIds != ''">app_ids = #{appIds}, </if>
         </trim>
         where product_id = #{productId}
     </update>
@@ -482,6 +486,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test='config.isAudit == "1" '>
         and fsp.is_audit = '1'
         </if>
+        <if test = 'param.appId != null and param.appId != ""'>
+        and ((FIND_IN_SET(#{param.appId}, fsp.app_ids) > 0))
+        </if>
         and fsp.is_best=1 and fsp.is_display=1 order by fsp.sort desc,fsp.product_id desc
     </select>
     <select id="bulkCopyFsStoreProductByIds" resultMap="FsStoreProductResult">

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

@@ -260,7 +260,7 @@ public class ProductScrmController extends AppBaseController {
     @GetMapping("/getTuiProducts")
     public R getTuiProducts(BaseQueryParam param, HttpServletRequest request){
         PageHelper.startPage(param.getPage(), param.getPageSize());
-        List<FsStoreProductListQueryVO> list=productService.selectFsStoreProductTuiListQuery();
+        List<FsStoreProductListQueryVO> list=productService.selectFsStoreProductTuiListQuery(param);
         PageInfo<FsStoreProductListQueryVO> listPageInfo=new PageInfo<>(list);
         return R.ok().put("data",listPageInfo);
     }