From 505d8e50a24a22cda05d04da8485ccc87fe8761e Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 15 八月 2019 16:02:25 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java |   68 +++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java
index 0a902d2..fb03d95 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java
@@ -1,6 +1,8 @@
 package com.yeshi.fanli.service.impl.goods;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.cache.annotation.Cacheable;
@@ -8,6 +10,7 @@
 
 import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
 import com.yeshi.fanli.dto.jd.JDSearchResult;
+import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
@@ -17,7 +20,6 @@
 public class JDCommonTemplateContentServiceImpl implements JDCommonTemplateContentService {
 
 	private Map<String, Long> countMap = new HashMap<String, Long>();
-	
 
 	@Cacheable(value = "jdCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
 	@Override
@@ -36,33 +38,49 @@
 		return null;
 	}
 
-	
 	private JDSearchResult get9K9Content(String cid, int page, int pageSize) {
-		int[] arrayId = {10, 17};
-		return getJingFenGoods(page, pageSize, "9k9-", arrayId);
+		int[] arrayId = { 10, 17 };
+		JDSearchResult result = getJingFenGoods(page, pageSize, "9k9-", arrayId);
+
+		return filterGoods(result);
 	}
-	
+
+	private JDSearchResult filterGoods(JDSearchResult result) {
+		List<Long> skuIds = new ArrayList<>();
+		if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
+			for (JDGoods goods : result.getGoodsList()) {
+				skuIds.add(goods.getSkuId());
+			}
+			List<JDGoods> goodsList = JDApiUtil.listGoodsDetail(skuIds);
+			result.setGoodsList(goodsList);
+		}
+		return result;
+	}
+
 	private JDSearchResult getJDPeiSongContent(String cid, int page, int pageSize) {
-		int[] arrayId = {15, 18};
-		return getJingFenGoods(page, pageSize, "peisong-", arrayId);
+		int[] arrayId = { 15, 18 };
+		JDSearchResult result = getJingFenGoods(page, pageSize, "peisong-", arrayId);
+		return filterGoods(result);
 	}
-	
+
 	private JDSearchResult getJiaDianContent(String cid, int page, int pageSize) {
-		int[] arrayId = {5, 2};
-		return getJingFenGoods(page, pageSize, "jiadian-", arrayId);
+		int[] arrayId = { 5, 2 };
+		JDSearchResult result = getJingFenGoods(page, pageSize, "jiadian-", arrayId);
+		return filterGoods(result);
 	}
-	
+
 	private JDSearchResult getBaiHuoContent(String cid, int page, int pageSize) {
-		int[] arrayId = {6, 3};
-		return getJingFenGoods(page, pageSize, "baihuo-", arrayId);
+		int[] arrayId = { 6, 3 };
+		JDSearchResult result = getJingFenGoods(page, pageSize, "baihuo-", arrayId);
+		return filterGoods(result);
 	}
-	
+
 	private JDSearchResult getJuJiaContent(String cid, int page, int pageSize) {
-		int[] arrayId = {7, 4};
-		return getJingFenGoods(page, pageSize, "jujia-", arrayId);
+		int[] arrayId = { 7, 4 };
+		JDSearchResult result = getJingFenGoods(page, pageSize, "jujia-", arrayId);
+		return filterGoods(result);
 	}
-	
-	
+
 	/**
 	 * 9蹇�9鍖呴偖
 	 * 
@@ -81,21 +99,21 @@
 			if (count != null) {
 				addCount += count;
 			}
-			
+
 			if (count != null && totalCount > addCount) {
-				pageTemp = (int)(addCount / Constant.PAGE_SIZE);
+				pageTemp = (int) (addCount / Constant.PAGE_SIZE);
 				continue; // 褰撳墠鍒嗙被鍟嗗搧涓嶈冻
 			} else {
-				page = page - pageTemp; 
+				page = page - pageTemp;
 				categoryId = arrayId[i];
 				break;
 			}
 		}
-		
+
 		if (categoryId == null) {
 			return null;
 		}
-		
+
 		JDSearchResult result = JDApiUtil.getJingFenGoods(page, categoryId);
 		long count = 0;
 		if (result != null) {
@@ -104,8 +122,8 @@
 				count = pageEntity.getTotalCount();
 			}
 		}
-		
-		long mcount = (count/Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
+
+		long mcount = (count / Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
 		if (mcount == 0) {
 			mcount = 20;
 		}

--
Gitblit v1.8.0