kaick пре 1 година
родитељ
комит
9aea7f4394

+ 6 - 7
src/main/java/com/caimei/www/controller/unlimited/ArticleController.java

@@ -65,7 +65,7 @@ public class ArticleController extends BaseController {
                 .setType("4").setAuthorId(id.toString()));
         List<Article> infoSelected = articleService.getArticleSelected(0, 5);
         List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(null,0, 3);
-        List<ProductList> productSellNumbers = productService.getProductSellNumbers();
+        List<ProductList> productSellNumbers = productService.getProductSellNumbers(null);
         List<BaseLink> data = articleService.getArticleLabels().getData();
         List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
         model.addAttribute("ads", Ads);
@@ -93,7 +93,7 @@ public class ArticleController extends BaseController {
         List<BaseLink> data = articleService.getArticleLabels().getData();
         List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
         List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(null,0, 3);
-        List<ProductList> productSellNumbers = productService.getProductSellNumbers();
+        List<ProductList> productSellNumbers = productService.getProductSellNumbers(null);
         model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
         model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3
         model.addAttribute("ads", Ads);
@@ -116,7 +116,7 @@ public class ArticleController extends BaseController {
         List<BaseLink> typeList = articleService.getArticleTypes();
         if (id == 1) {//精选文章
             List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(null,0, 3);
-            List<ProductList> productSellNumbers = productService.getProductSellNumbers();
+            List<ProductList> productSellNumbers = productService.getProductSellNumbers(null);
             model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
             model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3
         }
@@ -156,7 +156,7 @@ public class ArticleController extends BaseController {
         List<BaseLink> data = articleService.getArticleLabels().getData();
         List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
         List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(null,0, 3);
-        List<ProductList> productSellNumbers = productService.getProductSellNumbers();
+        List<ProductList> productSellNumbers = productService.getProductSellNumbers(null);
         model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
         model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3
         model.addAttribute("ads", Ads);
@@ -218,9 +218,8 @@ public class ArticleController extends BaseController {
         }
         String relatedLabels = articleService.relatedLabel(id);
         List<Article> infoSelected = articleService.getArticleSelected(0, 5);
-        Integer[] labelIds = article.getLabelIds();
-        List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(article.getLabelIds(), 0,3);
-        List<ProductList> productSellNumbers = productService.getProductSellNumbers();
+        List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(article.getRelatedLabelIds(), 0,3);
+        List<ProductList> productSellNumbers = productService.getProductSellNumbers(article.getRelatedLabelIds());
         model.addAttribute("infoSelected", infoSelected);//精选文章
         model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
         model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3

+ 2 - 2
src/main/java/com/caimei/www/mapper/ArticleDao.java

@@ -68,9 +68,9 @@ public interface ArticleDao {
      * @param
      * @return
      */
-    List<CmProductArchiveFile> findArchiveFileAddTime(@Param("productIds") List<String> productIds,@Param("pageNum") Integer pageNum,@Param("pageSize")  Integer pageSize);
+    List<CmProductArchiveFile> findArchiveFileAddTime(@Param("productIds") String[] productIds,@Param("pageNum") Integer pageNum,@Param("pageSize")  Integer pageSize);
 
-    List<String> findArchiveFileProductID(@Param("labelIds")Integer[] labelIds);
+    String[] findArchiveProductID(@Param("labelIds")String labelIds);
 
     /**
      * 获取文章广告

+ 2 - 1
src/main/java/com/caimei/www/mapper/ProductDao.java

@@ -9,6 +9,7 @@ import com.caimei.www.pojo.page.ProductDetail;
 import com.caimei.www.pojo.page.ProductList;
 import com.caimei.www.pojo.page.Sku;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -38,7 +39,7 @@ public interface ProductDao {
 
     List<ProductList> getAutoProductRecommends(Integer productId);
 
-    List<ProductList> getProductSellNumbers();
+    List<ProductList> getProductSellNumbers(@Param("productIds")String[] productIds);
 
     /**
      * 详情-相关参数

+ 4 - 0
src/main/java/com/caimei/www/pojo/page/Article.java

@@ -88,6 +88,10 @@ public class Article implements Serializable {
      * 关联标签库字符串
      */
     private String relatedLabels;
+    /**
+     * 关联标签库Id
+     */
+    private String relatedLabelIds;
 
     private static final long serialVersionUID = 1L;
 

+ 1 - 1
src/main/java/com/caimei/www/service/page/ArticleService.java

@@ -46,7 +46,7 @@ public interface ArticleService {
      * @param
      * @return
      */
-    List<CmProductArchiveFile> findArchiveFileAddTime(Integer[] labelIds,Integer pageNum,   Integer pageSize);
+    List<CmProductArchiveFile> findArchiveFileAddTime(String relatedLabelIds,Integer pageNum,   Integer pageSize);
     /**
      * 获取相关文章
      */

+ 1 - 1
src/main/java/com/caimei/www/service/page/ProductService.java

@@ -26,7 +26,7 @@ public interface ProductService {
      * @param
      * @return []
      */
-    List<ProductList> getProductSellNumbers();
+    List<ProductList> getProductSellNumbers(String relatedLabelIds);
     /**
      * 根据商品Id获取详情
      * @param productId

+ 4 - 7
src/main/java/com/caimei/www/service/page/impl/ArticleServiceImpl.java

@@ -22,6 +22,7 @@ import org.thymeleaf.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -121,13 +122,9 @@ public class ArticleServiceImpl implements ArticleService {
      *
      */
     @Override
-    public List<CmProductArchiveFile> findArchiveFileAddTime(Integer[] labelIds,Integer pageNum,  Integer pageSize) {
-        List<String> archiveFileProductID=null;
-        if(null!=labelIds){
-            archiveFileProductID = articleDao.findArchiveFileProductID(labelIds);
-        }
-
-        List<CmProductArchiveFile> selected = articleDao.findArchiveFileAddTime(archiveFileProductID,pageNum,pageSize);
+    public List<CmProductArchiveFile> findArchiveFileAddTime(String relatedLabelIds,Integer pageNum,  Integer pageSize) {
+        String[] archiveProductID=null!=relatedLabelIds?articleDao.findArchiveProductID(relatedLabelIds):null;
+        List<CmProductArchiveFile> selected = articleDao.findArchiveFileAddTime(archiveProductID,pageNum,pageSize);
         return selected;
     }
 

+ 6 - 2
src/main/java/com/caimei/www/service/page/impl/ProductServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.oss.common.utils.StringUtils;
 import com.aliyun.oss.internal.OSSUtils;
+import com.caimei.www.mapper.ArticleDao;
 import com.caimei.www.mapper.BaikeDao;
 import com.caimei.www.mapper.ProductDao;
 import com.caimei.www.pojo.JsonModel;
@@ -48,6 +49,8 @@ public class ProductServiceImpl implements ProductService {
     private ProductDao productDao;
     @Resource
     private BaikeDao baikeDao;
+    @Resource
+    private ArticleDao articleDao;
 
     /**
      * 根据商品Id获取详情
@@ -100,8 +103,9 @@ public class ProductServiceImpl implements ProductService {
     }
 
     @Override
-    public List<ProductList> getProductSellNumbers() {
-        List<ProductList> productSellNumbers = productDao.getProductSellNumbers();
+    public List<ProductList> getProductSellNumbers(String relatedLabelIds) {
+        String[] archiveProductID= null!=relatedLabelIds?articleDao.findArchiveProductID(relatedLabelIds):null;
+        List<ProductList> productSellNumbers = productDao.getProductSellNumbers(archiveProductID);
         if (null != productSellNumbers && productSellNumbers.size() > 0) {
             productSellNumbers.forEach(product -> {
                 // 设置 图片路径

+ 8 - 8
src/main/resources/mapper/ArticleMapper.xml

@@ -99,7 +99,7 @@
 		left join cm_product_archive  pa on cc.productArchiveId = pa.id
 		where cc.type = 3
 		<if test="productIds != null and productIds != ''">
-			pa.productId in
+			and pa.productId in
 			<foreach item="productID" collection="productIds" open="(" separator="," close=")">
 				#{productID}
 			</foreach>
@@ -109,16 +109,16 @@
 			limit #{pageNum},#{pageSize}
 		</if>
 	</select>
-	<select id="findArchiveFileProductID" resultType="string">
+	<select id="findArchiveProductID" resultType="string">
 		SELECT p.productID from  product p
 		left join cm_organize_product_info copi on copi.productId = p.productId
 		where
-		<foreach collection="labelIds" item="label" open="(" close=")" index="index" separator="OR">
-			p.labelIds like CONCAT(CONCAT('%', #{label}), '%')
+		copi.validFlag  = 2
+		and copi.organizeId= 0
+		and
+		<foreach item="labelId" collection="labelIds.split(',')" open="(" separator="OR" close=")">
+			p.labelIds like CONCAT('%', #{labelId}, '%')
 		</foreach>
-		and copi.validFlag  = 2
-		and copi.organizeId=0
-
 	</select>
     <select id="getArticleRelated" resultType="com.caimei.www.pojo.page.Article">
         select
@@ -206,7 +206,7 @@
 		  a.autoStatus AS autoStatus,
 		  a.recommendContent AS recommendContent,
 		  a.source AS source,
-		  a.labelIds,
+		  a.labelIds as relatedLabelIds,
 		  IFNULL((c.num + a.basePraise), 0) AS likes
 		FROM
 		  info AS a

+ 6 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -115,6 +115,12 @@
 		left join cm_organize_product_info copi on copi.productId = p.productId
 		where copi.validFlag  = 2
 		  and copi.organizeId = 0
+		<if test="productIds != null and productIds != ''">
+			and p.productId in
+			<foreach item="productID" collection="productIds" open="(" separator="," close=")">
+				#{productID}
+			</foreach>
+		</if>
 		order by sellNumber desc limit 0,3
 	</select>
     <select id="getPriceItemById" resultType="com.caimei.www.pojo.order.CartItem">