Browse Source

百科详情-相关推荐列表

Aslee 2 năm trước cách đây
mục cha
commit
7e45644424

+ 5 - 0
src/main/java/com/caimei/www/mapper/BaikeDao.java

@@ -43,4 +43,9 @@ public interface BaikeDao {
     BaikeType getBaikeType(Integer typeId);
 
     List<BaikeProductFile> findVideoList(Integer productId);
+
+    List<BaikeProduct> getManualRecommendList(Integer productId);
+
+    List<BaikeProduct> getAutoRecommendList(@Param("shopId") Integer shopId, @Param("typeId") Integer typeId, @Param("productId") Integer productId);
+
 }

+ 23 - 0
src/main/java/com/caimei/www/pojo/baike/BaikeProduct.java

@@ -20,6 +20,11 @@ public class BaikeProduct implements Serializable {
 
     private Integer productId;
 
+    /**
+     * 商品类型:1产品,2仪器
+     */
+    private Integer commodityType;
+
     /**
      * 产品/仪器图片
      */
@@ -30,6 +35,11 @@ public class BaikeProduct implements Serializable {
      */
     private String name;
 
+    /**
+     * 发布来源:1采美,2供应商
+     */
+    private Integer publishSource;
+
     /**
      * 供应商id
      */
@@ -123,6 +133,10 @@ public class BaikeProduct implements Serializable {
      * 是否置顶标识:0否,1是
      */
     private Integer topFlag;
+    /**
+     * 分类id
+     */
+    private Integer typeId;
     /**
      * 分类名称
      */
@@ -133,6 +147,11 @@ public class BaikeProduct implements Serializable {
      */
     private Integer pv;
 
+    /**
+     * 推荐类型:1手动推荐,2自动推荐
+     */
+    private Integer recommendType;
+
     /**
      * 参数列表
      */
@@ -153,4 +172,8 @@ public class BaikeProduct implements Serializable {
      * 视频列表
      */
     private List<BaikeProductFile> videoList;
+    /**
+     * 相关推荐商品列表
+     */
+    private List<BaikeProduct> recommendList;
 }

+ 14 - 0
src/main/java/com/caimei/www/service/page/impl/ProductServiceImpl.java

@@ -292,6 +292,20 @@ public class ProductServiceImpl implements ProductService {
             if (StringUtils.isNullOrEmpty(baikeProduct.getShopLogo())) {
                 baikeProduct.setShopLogo("/img/default/suppliver.jpg");
             }
+            // 相关推荐数据
+            List<BaikeProduct> recommendList;
+            if (1 == baikeProduct.getRecommendType()) {
+                // 手动推荐
+                recommendList = baikeDao.getManualRecommendList(productId);
+            } else {
+                recommendList = baikeDao.getAutoRecommendList(baikeProduct.getShopId(), baikeProduct.getTypeId(), baikeProduct.getProductId());
+            }
+            recommendList.forEach(recommendProduct->{
+                // 问题列表
+                List<BaikeProductQuestion> queList = baikeDao.findQuestionList(recommendProduct.getProductId());
+                recommendProduct.setQuestionList(queList);
+            });
+            baikeProduct.setRecommendList(recommendList);
         }
         return baikeProduct;
     }

+ 27 - 1
src/main/resources/mapper/BaikeMapper.xml

@@ -5,9 +5,10 @@
 		update cm_baike_product set actualPv = actualPv + 1 where id = #{id}
 	</update>
 	<select id="getBaikeProductDetail" resultType="com.caimei.www.pojo.baike.BaikeProduct">
-		select a.id              AS "id",
+		select a.id              AS "productId",
 			   a.commodityType   AS "commodityType",
 			   a.name            AS "name",
+		       a.publishSource,
 		       a.shopId			 AS "shopId",
 		       s.name			 AS "shopName",
 		       s.logo			 AS "shopLogo",
@@ -35,6 +36,7 @@
 			   a.topPosition     AS "topPosition",
 			   a.status          AS "status",
 			   a.addTime         AS "addTime",
+			   a.recommendType,
 			   cbt.name          as "typeName"
 		from cm_baike_product a
 				 left join cm_baike_type cbt on a.typeId = cbt.id
@@ -62,4 +64,28 @@
 		from cm_baike_product_file
 		where productId = #{productId}
 	</select>
+	<select id="getManualRecommendList" resultType="com.caimei.www.pojo.baike.BaikeProduct">
+		select p.id as productId, p.commodityType, p.image, p.name, p.discription, p.publishTime, (p.basePv + p.actualPv) as pv
+		from cm_baike_product_recommend cbpr
+				 left join cm_baike_product p on cbpr.recommendProductId = p.id
+		where productId = #{productId}
+		  and p.delFlag = 0
+		order by -cbpr.sort desc
+	</select>
+	<select id="getAutoRecommendList" resultType="com.caimei.www.pojo.baike.BaikeProduct">
+		select p.id as recommendProductId, p.name as recommendProductName
+		from cm_baike_product p
+		where typeId = #{typeId}
+		<if test="shopId != null">
+			and shopId = #{shopId}
+		</if>
+		<if test="productId != null">
+			and id != #{productId}
+		</if>
+		and p.delFlag = 0
+		and p.status = 1
+		and p.onlineStatus = 2
+		order by p.addTime desc
+		limit 15
+	</select>
 </mapper>