xw 1 день тому
батько
коміт
a71cc9bb7e

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

@@ -113,4 +113,9 @@ public interface FsStoreProductCategoryScrmMapper
     List<OptionsVO> selectFsStoreProductPidList();
 
     List<Long> selectCateIdsByName(FsStoreProductCategoryScrm fsStoreProductCategoryScrm);
+
+    /**
+     * 「秒杀商品」一级分类及其子分类 ID(用于商品 cate_id 过滤)
+     */
+    List<Long> selectSeckillCategoryIdsForProduct(@Param("storeId") Long storeId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -90,6 +90,11 @@ public interface IFsStoreProductScrmService
 
     List<FsStoreProductListQueryVO> selectFsStoreProductListQuery(FsStoreProductQueryParam param);
 
+    /**
+     * 秒杀专区商品:分类为「秒杀商品」或其子分类,最多 10 条
+     */
+    List<FsStoreProductListQueryVO> selectFsStoreSeckillProductListQuery(Long storeId);
+
     FsStoreProductQueryVO selectFsStoreProductByIdQuery(Long productId,String storeId);
 
     void decProductStock(Long productId, Long productAttrValueId, Integer cartNum);

+ 15 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -11,6 +11,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.annotation.DataSource;
 import com.fs.common.constant.LiveKeysConstant;
@@ -1119,6 +1120,20 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         return fsStoreProductMapper.selectFsStoreProductListQuery(param);
     }
 
+    @Override
+    public List<FsStoreProductListQueryVO> selectFsStoreSeckillProductListQuery(Long storeId) {
+        List<Long> cateIds = fsStoreProductCategoryScrmMapper.selectSeckillCategoryIdsForProduct(storeId);
+        if (cateIds == null || cateIds.isEmpty()) {
+            return new ArrayList<>();
+        }
+        FsStoreProductQueryParam param = new FsStoreProductQueryParam();
+        param.setCateIds(cateIds);
+        param.setIsDisplay(1);
+        param.setStoreId(storeId);
+        PageHelper.startPage(1, 10);
+        return selectFsStoreProductListQuery(param);
+    }
+
     @Override
     public FsStoreProductQueryVO selectFsStoreProductByIdQuery(Long productId,String storeId) {
         return fsStoreProductMapper.selectFsStoreProductByIdQuery(productId,storeId,medicalMallConfig);

+ 20 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreProductCategoryScrmMapper.xml

@@ -45,6 +45,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     </select>
 
+    <!-- 秒杀:一级「秒杀商品」自身 + 其子分类 ID,与商品表 cate_id 关联 -->
+    <select id="selectSeckillCategoryIdsForProduct" resultType="java.lang.Long">
+        SELECT c.cate_id FROM fs_store_product_category_scrm c
+        WHERE c.is_del = 0 AND c.is_show = 1
+        AND (
+            (c.cate_name = '秒杀商品' AND c.pid = 0)
+            OR c.pid IN (
+                SELECT p.cate_id FROM fs_store_product_category_scrm p
+                WHERE p.cate_name = '秒杀商品' AND p.pid = 0 AND p.is_del = 0 AND p.is_show = 1
+                <if test="storeId != null">
+                    AND (p.store_id IS NULL OR p.store_id = #{storeId})
+                </if>
+            )
+        )
+        <if test="storeId != null">
+            AND (c.store_id IS NULL OR c.store_id = #{storeId})
+        </if>
+        ORDER BY c.sort ASC
+    </select>
+
     <insert id="insertFsStoreProductCategory" parameterType="FsStoreProductCategoryScrm" useGeneratedKeys="true" keyProperty="cateId">
         insert into fs_store_product_category_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">

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

@@ -83,6 +83,17 @@ public class ProductScrmController extends AppBaseController {
             return R.error("操作异常");
         }
     }
+    @ApiOperation("秒杀商品列表(分类为秒杀商品或其子分类,最多10个商品)")
+    @GetMapping("/getSeckillProducts")
+    public R getSeckillProducts(@RequestParam(name = "storeId", required = false) Long storeId) {
+        try {
+            List<FsStoreProductListQueryVO> list = productService.selectFsStoreSeckillProductListQuery(storeId);
+            return R.ok().put("data", list);
+        } catch (Exception e) {
+            return R.error("操作异常");
+        }
+    }
+
     @ApiOperation("获取分类")
     @GetMapping("/getProductCateByPid")
     public R getProductCateByPid(@RequestParam(value="pid") Long pid, @RequestParam(value="storeId",required = false) Long storeId,HttpServletRequest request){