From fe646416d8d46de7b896ddbf65a3ad0cd30b729b Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 15 七月 2020 16:05:56 +0800
Subject: [PATCH] 大淘客与好单库与主包剥离

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java |   59 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
index 5666f37..6010363 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -9,6 +9,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
@@ -20,7 +21,7 @@
 import com.yeshi.fanli.entity.bus.lable.QualityFactory;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
-import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
+import com.yeshi.goods.facade.entity.taobao.DaTaoKeDetailV2;
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
@@ -29,7 +30,6 @@
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
-import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
 import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
@@ -39,9 +39,6 @@
 
 @Service
 public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
-
-	@Resource
-	private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
 
 	@Resource
 	private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
@@ -146,9 +143,9 @@
 		return navList;
 	}
 
-	@Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
+	@Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize+'-'+#system")
 	@Override
-	public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
+	public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize, SystemEnum system) {
 		CommonContentResult result = null;
 		if (type == CommonContentTypeEnum._9k9) {
 			result = get9K9Content(cid, page, pageSize);
@@ -175,7 +172,7 @@
 		} else if (type == CommonContentTypeEnum.chaoPinReMai) {
 			result = getChaoPinReMaiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.chaoSheng) {
-			result = getCaoShengContent(cid, page, pageSize);
+			result = getCaoShengContent(cid, page, pageSize,system);
 		} else if (type == CommonContentTypeEnum.haoQuan) {
 			result = getHaoQuanContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.mianDan) {
@@ -205,35 +202,35 @@
 
 		DaTaoKeGoodsResult result = null;
 		if ("-1".equalsIgnoreCase(cid)) {
-			result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize,
+			result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
 					DaTaoKeApiUtil.SORT_DEFAULT);
+
 			if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
 				result = new DaTaoKeGoodsResult();
-				result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null,
-						new BigDecimal("10"),null, page, pageSize));
-				result.setTotalCount(
-						daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
+				result.setGoodsList(
+						daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), null, page, pageSize));
+				result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
 			}
 
 		} else if ("0".equalsIgnoreCase(cid)) {
-			result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize,
+			result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
 					DaTaoKeApiUtil.SORT_CREATETIME);
 			if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
 				result = new DaTaoKeGoodsResult();
-				result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null,
-						new BigDecimal("10"),"createTime", page, pageSize));
-				result.setTotalCount(
-						daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
+				result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), "createTime",
+						page, pageSize));
+				result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
 			}
 		} else {
 			List<Integer> cidList = new ArrayList<>();
 			cidList.add(Integer.parseInt(cid));
-			result = DaTaoKeApiUtil.search("", cidList, null, new BigDecimal("10"), page, pageSize,
+			result = DaTaoKeApiUtil.getGoodsList("", cidList, null, new BigDecimal("10"), null, page, pageSize,
 					DaTaoKeApiUtil.SORT_DEFAULT);
+
 			if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
 				result = new DaTaoKeGoodsResult();
 				result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(Integer.parseInt(cid),
-						new BigDecimal("10"),null, page, pageSize));
+						new BigDecimal("10"), null, page, pageSize));
 				result.setTotalCount(
 						daTaoKeGoodsDetailV2Service.countByMaxPrice(Integer.parseInt(cid), new BigDecimal("10")));
 			}
@@ -258,7 +255,7 @@
 	 * @param pageSize
 	 * @return
 	 */
-	private CommonContentResult getCaoShengContent(String cid, int page, int pageSize) {
+	private CommonContentResult getCaoShengContent(String cid, int page, int pageSize, SystemEnum system) {
 		pageSize = Constant.PAGE_SIZE;
 		Integer startAmount = null;
 		Integer endAmount = null;
@@ -282,7 +279,7 @@
 
 		double tkRate = 20.00;
 
-		BigDecimal proportion = hongBaoManageService.getFanLiRate();
+		BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
 		List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
 				proportion.toString(), startAmount, endAmount, tkRate);
 
@@ -390,7 +387,7 @@
 		List<Integer> cidList = new ArrayList<>();
 		cidList.add(4);// 灞呭鐢熸椿
 		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
+		result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
 		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		long count = 0;
 		if (result != null) {
@@ -415,7 +412,7 @@
 		List<Integer> cidList = new ArrayList<>();
 		cidList.add(6);// 缇庨
 		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
+		result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
 		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		long count = 0;
 		if (result != null) {
@@ -464,7 +461,9 @@
 		if ("1".equalsIgnoreCase(cid)) {// 澶ф窐瀹㈡暟鎹�
 			List<Integer> cidList = new ArrayList<>();
 			cidList.add(2);// 姣嶅┐
-			result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, DaTaoKeApiUtil.SORT_DEFAULT);
+			result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize,
+					DaTaoKeApiUtil.SORT_DEFAULT);
+
 			List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 			long count = 0;
 			if (result != null) {
@@ -512,7 +511,8 @@
 		List<Integer> cidList = new ArrayList<>();
 		cidList.add(1);// 濂宠
 		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
+		result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
+
 		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		long count = 0;
 		if (result != null) {
@@ -672,7 +672,7 @@
 		cidList.add(7);
 		cidList.add(13);
 		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
+		result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
 		DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("杩愬姩 鐢�", cidList, null, null, page, pageSize, sort);
 		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		long count = 0;
@@ -721,8 +721,9 @@
 			e.printStackTrace();
 		}
 		Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
-		for (TaoBaoGoodsBrief goods : listTaoKeGoods)
-			goodsMap.put(goods.getAuctionId(), goods);
+		if (listTaoKeGoods != null)
+			for (TaoBaoGoodsBrief goods : listTaoKeGoods)
+				goodsMap.put(goods.getAuctionId(), goods);
 		for (int i = 0; i < goodsList.size(); i++) {
 			if (goodsMap.get(goodsList.get(i).getAuctionId()) == null) {
 				goodsList.remove(i--);

--
Gitblit v1.8.0