فهرست منبع

小程序端的展示

xw 1 روز پیش
والد
کامیت
649e216641

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

@@ -1,5 +1,6 @@
 package com.fs.hisStore.mapper;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -435,4 +436,8 @@ public interface FsStoreProductScrmMapper
     List<FsStoreProductListVO> liveList(@Param("maps") LiveGoods maps);
 
     List<FsStoreProductScrm> selectFsStoreProductByProductIds(@Param("productIds") List<Long> productIdsLong);
+
+    List<FsStoreProductListQueryVO> selectFsStoreProductNewQueryPage(Map<String, Object> params);
+
+    List<FsStoreProductListQueryVO> selectFsStoreProductHotQueryPage(Map<String, Object> params);
 }

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

@@ -157,4 +157,10 @@ public interface IFsStoreProductScrmService
     List<Long> selectTagIdsByProductId(Long productId);
 
     List<Long> selectUserEndCategoryIdsByProductId(Long productId);
+
+    /** 绿色有机分页(与 selectFsStoreProductNewQuery 条件一致,支持分页) */
+    List<FsStoreProductListQueryVO> selectFsStoreProductNewQueryPage(int pageNum, int pageSize, String appId, String keyword);
+
+    /** 上新推荐分页(与 selectFsStoreProductHotQuery 条件一致,支持分页) */
+    List<FsStoreProductListQueryVO> selectFsStoreProductHotQueryPage(int pageNum, int pageSize, String appId, String keyword);
 }

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

@@ -1765,4 +1765,24 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         }
         return fsStoreProductUserEndCategoryMapper.selectCategoryIdsByProductId(productId);
     }
+
+    @Override
+    public List<FsStoreProductListQueryVO> selectFsStoreProductNewQueryPage(int pageNum, int pageSize, String appId, String keyword) {
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("config", medicalMallConfig);
+        map.put("appId", appId);
+        map.put("keyword", keyword);
+        com.github.pagehelper.PageHelper.startPage(pageNum, pageSize);
+        return fsStoreProductMapper.selectFsStoreProductNewQueryPage(map);
+    }
+
+    @Override
+    public List<FsStoreProductListQueryVO> selectFsStoreProductHotQueryPage(int pageNum, int pageSize, String appId, String keyword) {
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("config", medicalMallConfig);
+        map.put("appId", appId);
+        map.put("keyword", keyword);
+        com.github.pagehelper.PageHelper.startPage(pageNum, pageSize);
+        return fsStoreProductMapper.selectFsStoreProductHotQueryPage(map);
+    }
 }

+ 8 - 7
fs-service/src/main/java/com/fs/live/mapper/LiveDataMapper.java

@@ -4,13 +4,7 @@ package com.fs.live.mapper;
 import com.fs.common.annotation.DataSource;
 import com.fs.common.enums.DataSourceType;
 import com.fs.live.domain.LiveData;
-import com.fs.live.vo.LiveDashBoardDataVo;
-import com.fs.live.vo.LiveDataDetailVo;
-import com.fs.live.vo.LiveDataListVo;
-import com.fs.live.vo.LiveDataStatisticsVo;
-import com.fs.live.vo.LiveUserDetailVo;
-import com.fs.live.vo.RecentLiveDataVo;
-import com.fs.live.vo.TrendDataVO;
+import com.fs.live.vo.*;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
@@ -176,4 +170,11 @@ public interface LiveDataMapper {
      */
     @DataSource(DataSourceType.SLAVE)
     List<LiveUserDetailVo> selectLiveUserDetailListBySql(@Param("liveId") Long liveId,@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
+
+    /**
+     * 查询正在直播的直播间(仅 liveId、liveType、封面、标题),用于首页推荐
+     * status=2 表示直播中
+     */
+    @DataSource(DataSourceType.SLAVE)
+    List<LiveAppSimpleVO> selectLivingLivesForApp();
 }

+ 2 - 0
fs-service/src/main/java/com/fs/live/service/ILiveDataService.java

@@ -169,4 +169,6 @@ public interface ILiveDataService {
     List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId, Long companyId, Long companyUserId);
 
     List<LiveDataListVo> exportLiveData(LiveDataParam param);
+
+    List<LiveAppSimpleVO> listLivingLivesForApp();
 }

+ 30 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

@@ -10,10 +10,7 @@ import com.fs.hisStore.mapper.FsUserScrmMapper;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.*;
 import com.fs.live.param.LiveDataParam;
-import com.fs.live.service.ILiveDataService;
-import com.fs.live.service.ILiveUserFavoriteService;
-import com.fs.live.service.ILiveUserFollowService;
-import com.fs.live.service.ILiveUserLikeService;
+import com.fs.live.service.*;
 import com.fs.live.vo.*;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
@@ -92,6 +89,8 @@ public class LiveDataServiceImpl implements ILiveDataService {
     @Autowired
     private LiveOrderMapper liveOrderMapper;
 
+    @Autowired
+    private ILiveWatchUserService liveWatchUserService;
     /* 直播大屏展示 数据接口 */
     @Override
     public R dashboardData(Long liveId) {
@@ -222,6 +221,33 @@ public class LiveDataServiceImpl implements ILiveDataService {
         }
         return liveDataList;
     }
+
+    @Override
+    public List<LiveAppSimpleVO> listLivingLivesForApp() {
+        List<LiveAppSimpleVO> list = liveDataMapper.selectLivingLivesForApp();
+
+        if (list == null || list.isEmpty()) {
+            return list;
+        }
+        // 如果查询结果超过 3 条,进行截取
+        if (list.size() > 3) {
+            list = list.subList(0, 3);
+        }
+        for (LiveAppSimpleVO vo : list) {
+            if (vo.getLiveType() != null && vo.getLiveType() == 2 && vo.getLiveId() != null) {
+                try {
+                    Map<String, Integer> flagMap = liveWatchUserService.getLiveFlagWithCache(vo.getLiveId());
+                    if (flagMap != null && flagMap.containsKey("liveFlag")) {
+                        vo.setLiveFlag(flagMap.get("liveFlag"));
+                    }
+                } catch (Exception e) {
+                    log.warn("getLiveFlagWithCache fail liveId={}", vo.getLiveId(), e);
+                }
+            }
+        }
+        return list;
+    }
+
     /**
      * 查询直播数据
      *

+ 18 - 0
fs-service/src/main/java/com/fs/live/vo/LiveAppSimpleVO.java

@@ -0,0 +1,18 @@
+package com.fs.live.vo;
+
+import lombok.Data;
+
+/**
+ * 首页推荐-正在直播的直播间简要信息(liveId、liveType、封面、标题、liveFlag当liveType=2时从Redis取)
+ */
+@Data
+public class LiveAppSimpleVO {
+    private Long liveId;
+    private Integer liveType;
+    /** 直播间封面图片 */
+    private String liveImgUrl;
+    /** 直播间标题 */
+    private String liveName;
+    /** 当 liveType=2 时由 Redis 查询填充 */
+    private Integer liveFlag;
+}

+ 38 - 13
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -514,12 +514,12 @@
             inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1
         </if>
         where p.is_del=0 and p.is_show=1
-        <if test='config.isAudit == "1"'>
-            and p.is_audit = '1'
-        </if>
-        <if test='appId != null and appId = "" '>
-            and ((FIND_IN_SET(#{appId}, p.app_ids) > 0))
-        </if>
+<!--        <if test='config.isAudit == "1"'>-->
+<!--            and p.is_audit = '1'-->
+<!--        </if>-->
+<!--        <if test='appId != null and appId = "" '>-->
+<!--            and ((FIND_IN_SET(#{appId}, p.app_ids) > 0))-->
+<!--        </if>-->
         and p.is_new=1 and p.is_display=1 order by p.sort desc limit #{count}
     </select>
     <select id="selectFsStoreProductHotQuery" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
@@ -528,12 +528,12 @@
             inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1
         </if>
         where p.is_del=0 and p.is_show=1
-        <if test='config.isAudit == "1" '>
-            and p.is_audit = '1'
-        </if>
-        <if test='appId != null and appId = "" '>
-            and ((FIND_IN_SET(#{appId}, p.app_ids) > 0))
-        </if>
+<!--        <if test='config.isAudit == "1" '>-->
+<!--            and p.is_audit = '1'-->
+<!--        </if>-->
+<!--        <if test='appId != null and appId = "" '>-->
+<!--            and ((FIND_IN_SET(#{appId}, p.app_ids) > 0))-->
+<!--        </if>-->
         and  p.is_hot=1 and p.is_display=1 order by p.sort desc limit #{count}
     </select>
     <select id="selectFsStoreProductGoodListQuery" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
@@ -560,8 +560,33 @@
 
     <select id="getStoreProductInProductIdsForApp" resultType="com.fs.hisStore.domain.FsStoreProductScrm">
         <include refid="selectFsStoreProductVo"/>
-        where is_del = 0 and is_show = 1 and is_audit = 1
+        where is_del = 0 and is_show = 1
         and product_id IN
         <foreach collection="productIds" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
     </select>
+    <select id="selectFsStoreProductNewQueryPage" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
+        select p.* from fs_store_product_scrm p
+        <if test='config.isAudit == "1"'>
+            inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1
+        </if>
+        where p.is_del=0 and p.is_show=1
+        <if test='keyword != null and keyword != ""'>
+            and p.product_name like CONCAT('%', #{keyword}, '%')
+        </if>
+        and p.is_new=1 and p.is_display=1
+        order by CASE WHEN p.sort IS NULL OR p.sort = 0 THEN 1 ELSE 0 END ASC, CASE WHEN p.sort IS NULL OR p.sort = 0 THEN 0 ELSE p.sort END DESC, p.create_time DESC, p.product_id DESC
+    </select>
+
+    <select id="selectFsStoreProductHotQueryPage" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
+        select p.* from fs_store_product_scrm p
+        <if test='config.isAudit == "1" '>
+            inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1
+        </if>
+        where p.is_del=0 and p.is_show=1
+        <if test='keyword != null and keyword != ""'>
+            and p.product_name like CONCAT('%', #{keyword}, '%')
+        </if>
+        and  p.is_hot=1 and p.is_display=1
+        order by CASE WHEN p.sort IS NULL OR p.sort = 0 THEN 1 ELSE 0 END ASC, CASE WHEN p.sort IS NULL OR p.sort = 0 THEN 0 ELSE p.sort END DESC, p.create_time DESC, p.product_id DESC
+    </select>
 </mapper>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 118
fs-service/src/main/resources/mapper/hisStore/FsStoreProductUserEndCategoryMapper.xml


+ 8 - 0
fs-service/src/main/resources/mapper/live/LiveDataMapper.xml

@@ -565,4 +565,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY u.user_id, u.nick_name, u.nickname, order_info.orderCount, order_info.orderAmount, c.company_name, cu.user_name
         ORDER BY order_info.orderAmount DESC, liveWatchDuration DESC
     </select>
+
+    <!-- 首页推荐:正在直播的直播间,仅查 liveId、liveType、封面、标题 -->
+    <select id="selectLivingLivesForApp" resultType="com.fs.live.vo.LiveAppSimpleVO">
+        SELECT live_id AS liveId, live_type AS liveType, live_img_url AS liveImgUrl, live_name AS liveName
+        FROM live
+        WHERE status = 2 AND is_show = 1 AND (is_del = 0 OR is_del IS NULL) AND is_audit = 1
+        ORDER BY start_time DESC
+    </select>
 </mapper>

+ 86 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/IndexScrmController.java

@@ -15,6 +15,8 @@ import com.fs.hisStore.domain.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.*;
+import com.fs.live.service.ILiveDataService;
+import com.fs.live.vo.LiveAppSimpleVO;
 import com.fs.store.config.ConceptConfig;
 import com.fs.system.service.ISysConfigService;
 import com.github.pagehelper.PageHelper;
@@ -31,7 +33,10 @@ import org.springframework.web.servlet.ModelAndView;
 import springfox.documentation.annotations.Cacheable;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 
 @Api("首页接口")
@@ -63,6 +68,87 @@ public class IndexScrmController extends AppBaseController {
 	private ISysConfigService configService;
 	@Autowired
 	private IFsCoursePlaySourceConfigService coursePlaySourceConfigService;
+	@Autowired
+	private IFsStoreUserEndCategoryScrmService userEndCategoryScrmService;
+	@Autowired
+	private ILiveDataService liveDataService;
+
+	@ApiOperation("首页初始化")
+	@GetMapping("/home/init")
+	public R homeInit(@RequestParam(value = "storeId", required = false) Long storeId) {
+		Map<String, Object> data = new HashMap<>();
+		// 金刚区:前8条,排序 asc、创建时间 desc
+		List<FsStoreUserEndCategoryScrm> categoryTags = userEndCategoryScrmService.selectTop8ByPosition(storeId, 1);
+		// 瀑布流:前8条,排序 asc、创建时间 desc
+		List<FsStoreUserEndCategoryScrm> goodsNav = userEndCategoryScrmService.selectTop8ByPosition(storeId, 2);
+		data.put("channelList", Collections.emptyList());
+		data.put("categoryTags", categoryTags != null ? categoryTags : Collections.emptyList());
+		data.put("goodsNav", goodsNav != null ? goodsNav : Collections.emptyList());
+		return R.ok().put("data", data);
+	}
+
+
+	/**
+	 * 首页商品列表(支持用户端分类 id、区域 position、关键字 keyword)
+	 * id:用户端分类ID,为空时按 position 或查全部
+	 * position:1=金刚区 2=瀑布区,传入时查询该区域下全部产品(支持 keyword)
+	 * keyword:商品名称模糊搜索
+	 * 去重分页查商品ID → 查商品简表+标签 → 返回 productId、productName、image、price、otPrice、sales、tagList
+	 */
+	@ApiOperation("首页商品列表")
+	@GetMapping("/home/goods")
+	public R homeGoods(@RequestParam(value = "id", required = false) Long id,
+					   @RequestParam(value = "keyword", required = false) String keyword,
+					   @RequestParam(value = "storeId", required = false) Long storeId,
+					   @RequestParam(value = "position", required = false) Integer position,
+					   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+					   @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+		java.util.Map<String, Object> data = userEndCategoryScrmService.listProductsForApp(id, keyword, pageNum, pageSize, storeId, position);
+		return R.ok().put("data", data);
+	}
+
+
+	/**
+	 * 首页推荐区块(直播中、上新推荐等,可延迟加载)
+	 * live:正在直播的直播间(liveId、liveType、封面、标题;liveType=2 时 liveFlag 从 Redis 查)
+	 * green:商品“新品首发”开启的 2 条
+	 * hot:商品“是否热卖”开启的 2 条
+	 */
+	@ApiOperation("首页推荐区块")
+	@GetMapping("/home/recommend")
+	public R homeRecommend(HttpServletRequest request) {
+		String appId = request.getParameter("appId");
+		List<LiveAppSimpleVO> liveList = liveDataService.listLivingLivesForApp();
+		List<FsStoreProductListQueryVO> greenProduct = productService.selectFsStoreProductNewQuery(2, appId);
+		List<FsStoreProductListQueryVO> hotProduct = productService.selectFsStoreProductHotQuery(2, appId);
+		return R.ok()
+				.put("live", liveList != null ? liveList : Collections.emptyList())
+				.put("green", greenProduct != null ? greenProduct : Collections.emptyList())
+				.put("hot", hotProduct != null ? hotProduct : Collections.emptyList());
+	}
+
+	/**
+	 * 首页推荐「更多」分页:绿色有机(green) / 上新推荐(hot),逻辑同 homeRecommend 的 green、hot 查询,支持分页,默认第1页10条
+	 */
+	@ApiOperation("首页推荐更多分页")
+	@GetMapping("/home/goods/recommend")
+	public R homeGoodsRecommend(HttpServletRequest request,
+								@RequestParam(value = "type") String type,
+								@RequestParam(value = "keyword", required = false) String keyword,
+								@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+								@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+		String appId = request.getParameter("appId");
+		if (!"green".equalsIgnoreCase(type) && !"hot".equalsIgnoreCase(type)) {
+			return R.ok().put("data", new PageInfo<>(Collections.emptyList()));
+		}
+		List<FsStoreProductListQueryVO> list = "green".equalsIgnoreCase(type)
+				? productService.selectFsStoreProductNewQueryPage(pageNum, pageSize, appId, keyword)
+				: productService.selectFsStoreProductHotQueryPage(pageNum, pageSize, appId, keyword);
+		PageInfo<FsStoreProductListQueryVO> pageInfo = new PageInfo<>(list);
+		return R.ok().put("data", pageInfo);
+	}
+
+
 
 	@ApiOperation("获取首页数据")
 	@GetMapping("/getIndexData")

+ 2 - 2
fs-user-app/src/main/resources/application.yml

@@ -13,5 +13,5 @@ spring:
 #    active: druid-sxjz
 #    active: druid-qdtst
 #    active: druid-yzt
-#    active: druid-bjczwh-test
-    active: druid-hzjs-test
+    active: druid-bjczwh-test
+#    active: druid-hzjs-test

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است