From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java | 1336 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 844 insertions(+), 492 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 c2edc1b..f5b6810 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
@@ -1,492 +1,844 @@
-package com.yeshi.fanli.service.impl.goods;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-
-import com.yeshi.fanli.dto.common.CommonContentNav;
-import com.yeshi.fanli.dto.common.CommonContentResult;
-import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
-import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult;
-import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
-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.fanli.service.inter.goods.CommonTemplateContentService;
-import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
-import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
-import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
-import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
-import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
-import com.yeshi.fanli.util.taobao.TaoBaoUtil;
-
-@Service
-public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
-
-	@Resource
-	private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
-
-	@Resource
-	private TaobaoMeterialService taobaoMeterialService;
-
-	@Resource
-	private TaoKeGoodsService taoKeGoodsService;
-
-	private static List<CommonContentNav> getCommonNav() {
-		List<CommonContentNav> navList = new ArrayList<>();
-		navList.add(new CommonContentNav("1", "缁煎悎"));
-		navList.add(new CommonContentNav("2", "鏈�鏂�"));
-		navList.add(new CommonContentNav("3", "鐑崠"));
-		navList.add(new CommonContentNav("4", "閿�閲�"));
-		navList.add(new CommonContentNav("5", "杩斿埄姣�"));
-		return navList;
-	}
-
-	private static int getCommonSort(String cid) {
-		int sort = DaTaoKeApiUtil.SORT_DEFAULT;
-		if ("1".equalsIgnoreCase(cid))
-			sort = DaTaoKeApiUtil.SORT_DEFAULT;
-		else if ("2".equalsIgnoreCase(cid))
-			sort = DaTaoKeApiUtil.SORT_CREATETIME;
-		else if ("3".equalsIgnoreCase(cid))
-			sort = DaTaoKeApiUtil.SORT_COUPON_NUM;
-		else if ("4".equalsIgnoreCase(cid))
-			sort = DaTaoKeApiUtil.SORT_SALES;
-		else if ("5".equalsIgnoreCase(cid))
-			sort = DaTaoKeApiUtil.SORT_COMMISSION;
-
-		return sort;
-	}
-
-	@Override
-	public List<CommonContentNav> getNavList(CommonContentTypeEnum type) {
-		List<CommonContentNav> navList = new ArrayList<>();
-		if (type == CommonContentTypeEnum._9k9) {
-			navList.add(new CommonContentNav("-1", "缁煎悎"));
-			navList.add(new CommonContentNav("0", "鏈�鏂�"));
-			for (GoodsClass gc : DaTaoKeUtil.goodsClasses) {
-				navList.add(new CommonContentNav(gc.getId() + "", gc.getName()));
-			}
-		} else if (type == CommonContentTypeEnum.chaoSheng) {
-			navList.add(new CommonContentNav("1", "5%~10%杩斿埄"));
-			navList.add(new CommonContentNav("2", "10%~20%杩斿埄"));
-			navList.add(new CommonContentNav("3", "20%~30%杩斿埄"));
-			navList.add(new CommonContentNav("4", "30%~40%杩斿埄"));
-			navList.add(new CommonContentNav("5", "40%浠ヤ笂杩斿埄"));
-		} else if (type == CommonContentTypeEnum.haoQuan) {
-			navList.add(new CommonContentNav("1", "5~10鍏冨埜"));
-			navList.add(new CommonContentNav("2", "10~30鍏冨埜"));
-			navList.add(new CommonContentNav("3", "30~50鍏冨埜"));
-			navList.add(new CommonContentNav("4", "50鍏冧互涓婂埜"));
-		} else if (type == CommonContentTypeEnum.juJia) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.meiShi) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.muYin) {
-			navList.add(new CommonContentNav("1", "绮鹃��"));
-			navList.add(new CommonContentNav("澶囧瓡", "澶囧瓡"));
-			navList.add(new CommonContentNav("0鑷�6涓湀", "0~6鏈�"));
-			navList.add(new CommonContentNav("7鑷�12涓湀", "7~12鏈�"));
-			navList.add(new CommonContentNav("1鑷�3宀�", "1~3宀�"));
-			navList.add(new CommonContentNav("4鑷�6宀�", "4~6宀�"));
-			navList.add(new CommonContentNav("7鑷�12宀�", "7~12宀�"));
-		} else if (type == CommonContentTypeEnum.reMai) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.chuanYiDaPei) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.meiZhuangGehu) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.jingPinXieBao) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.chaoNanReMai) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.shuMaShouJi) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.yunDongKuXie) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.qiCheHuWai) {
-			navList = getCommonNav();
-		} else if (type == CommonContentTypeEnum.chaoPinReMai) {
-			navList = getCommonNav();
-		}
-
-		return navList;
-	}
-
-	@Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
-	@Override
-	public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
-		if (type == CommonContentTypeEnum._9k9) {
-			return get9K9Content(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.juJia) {
-			return getJuJiaShengHuoContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.muYin) {
-			return getMuYinJingXuanContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.meiShi) {
-			return getYouXuanMeiShiContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.chuanYiDaPei) {
-			return getChuanYiDaPeiContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.meiZhuangGehu) {
-			return getMeiZhuangGeHuContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.jingPinXieBao) {
-			return getJingPinXieBaoContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.chaoNanReMai) {
-			return getChaoNanReMaiContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.shuMaShouJi) {
-			return getShuMaShouJiContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.yunDongKuXie) {
-			return getYunDongKuXieContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.qiCheHuWai) {
-			return getQiCheHuWaiContent(cid, page, pageSize);
-		} else if (type == CommonContentTypeEnum.chaoPinReMai) {
-			return getChaoPinReMaiContent(cid, page, pageSize);
-		}
-		return null;
-	}
-
-	private CommonContentResult get9K9Content(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		if ("-1".equalsIgnoreCase(cid)) {
-			result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize,
-					DaTaoKeApiUtil.SORT_DEFAULT);
-
-		} else if ("0".equalsIgnoreCase(cid)) {
-			result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize,
-					DaTaoKeApiUtil.SORT_CREATETIME);
-		} else {
-			List<Integer> cidList = new ArrayList<>();
-			cidList.add(Integer.parseInt(cid));
-			result = DaTaoKeApiUtil.search("", cidList, null, new BigDecimal("10"), page, pageSize,
-					DaTaoKeApiUtil.SORT_DEFAULT);
-		}
-
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 灞呭鐢熸椿
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		List<Integer> cidList = new ArrayList<>();
-		cidList.add(4);// 灞呭鐢熸椿
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 浼橀�夌編椋�
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		List<Integer> cidList = new ArrayList<>();
-		cidList.add(6);// 缇庨
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 娼搧鐑崠
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("娼�", null, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 鑾峰彇姣嶅┐绮鹃��
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		if ("1".equalsIgnoreCase(cid)) {// 澶ф窐瀹㈡暟鎹�
-			List<Integer> cidList = new ArrayList<>();
-			cidList.add(2);// 姣嶅┐
-			result = DaTaoKeApiUtil.search("", null, null, null, page, pageSize, DaTaoKeApiUtil.SORT_DEFAULT);
-			List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-			long count = 0;
-			if (result != null) {
-				count = result.getTotalCount();
-				if (result.getGoodsList() != null)
-					for (DaTaoKeDetailV2 detail : result.getGoodsList())
-						goodsList.add(TaoBaoUtil.convert(detail));
-			}
-			return new CommonContentResult(goodsList, count);
-
-		} else {//
-			List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("姣嶅┐_" + cid,
-					"姣嶅┐涓婚");
-
-			if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
-				return null;
-			}
-
-			TaobaoMeterial meterial = taobaoMeterials.get(0);
-			Integer materialId = meterial.getMaterialId();
-			if (materialId != null) {
-				List<TaoBaoGoodsBrief> listBrands = new ArrayList<>();
-				try {
-					listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-				return new CommonContentResult(listBrands, 1000);
-			}
-			return new CommonContentResult(new ArrayList<>(), 0);
-		}
-
-	}
-
-	/**
-	 * 绌胯。鎼厤
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getChuanYiDaPeiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		List<Integer> cidList = new ArrayList<>();
-		cidList.add(1);// 濂宠
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("鍐呰。 濂�", cidList, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 缇庡涓姢
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getMeiZhuangGeHuContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		List<Integer> cidList = new ArrayList<>();
-		cidList.add(3);// 缇庡
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("娲楁姢", cidList, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 绮惧搧闉嬪寘
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-
-	private CommonContentResult getJingPinXieBaoContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("闉� 濂�", null, null, null, page, pageSize, sort);
-		DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("鍖� 濂�", null, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount() + result1.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-			if (result1.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result1.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		Collections.shuffle(goodsList);
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 娼敺鐑崠
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getChaoNanReMaiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("娼� 鐢�", null, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		Collections.shuffle(goodsList);
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 鏁扮爜鎵嬫満
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getShuMaShouJiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("鐢�", null, null, null, page, pageSize, sort);
-		DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("鎵嬫満", null, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount() + result1.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-			if (result1.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result1.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		Collections.shuffle(goodsList);
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 杩愬姩閰烽瀷
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getYunDongKuXieContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("闉� 鐢�", null, null, null, page, pageSize, sort);
-		DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("杩愬姩 鐢�", null, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount() + result1.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-			if (result1.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result1.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		Collections.shuffle(goodsList);
-		return new CommonContentResult(goodsList, count);
-	}
-
-	/**
-	 * 姹借溅鎴峰
-	 * 
-	 * @param cid
-	 * @param page
-	 * @param pageSize
-	 * @return
-	 */
-	private CommonContentResult getQiCheHuWaiContent(String cid, int page, int pageSize) {
-		DaTaoKeGoodsResult result = null;
-		List<Integer> cidList = new ArrayList<>();
-		cidList.add(7);
-		cidList.add(13);
-		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("", null, null, null, page, pageSize, sort);
-		DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("杩愬姩 鐢�", cidList, null, null, page, pageSize, sort);
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-		long count = 0;
-		if (result != null) {
-			count = result.getTotalCount() + result1.getTotalCount();
-			if (result.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-			if (result1.getGoodsList() != null)
-				for (DaTaoKeDetailV2 detail : result1.getGoodsList())
-					goodsList.add(TaoBaoUtil.convert(detail));
-		}
-		Collections.shuffle(goodsList);
-		return new CommonContentResult(goodsList, count);
-	}
-
-}
+package com.yeshi.fanli.service.impl.goods;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.SystemFunction;
+import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.util.SystemInfoUtil;
+import com.yeshi.fanli.util.factory.CommonGoodsFactory;
+import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuJDGoodsInfo;
+import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuListResult;
+import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuPDDGoodsInfo;
+import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail;
+import com.yeshi.goods.facade.utils.taobao.HaoDanKuApiUtil;
+import com.yeshi.goods.facade.utils.taobao.HaoDankuUtil;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import com.yeshi.fanli.dto.common.CommonContentNav;
+import com.yeshi.fanli.dto.common.CommonContentResult;
+import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
+import com.yeshi.goods.facade.dto.taobao.dataoke.DaTaoKeGoodsResult;
+import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
+import com.yeshi.fanli.entity.bus.lable.QualityFactory;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
+import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2;
+import com.yeshi.fanli.exception.taobao.TaoKeApiException;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
+import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
+import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
+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.goods.facade.service.DaTaoKeGoodsDetailV2Service;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil;
+import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+@Service
+public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
+
+    @Resource
+    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
+
+    @Resource
+    private TaobaoMeterialService taobaoMeterialService;
+
+    @Resource
+    private TaoKeGoodsService taoKeGoodsService;
+
+    @Resource
+    private HongBaoManageService hongBaoManageService;
+
+    @Resource
+    private QualityGoodsService qualityGoodsService;
+
+    @Resource
+    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
+
+    private static List<CommonContentNav> getCommonNav(SystemEnum system) {
+        List<CommonContentNav> navList = new ArrayList<>();
+        navList.add(new CommonContentNav("1", "缁煎悎"));
+        navList.add(new CommonContentNav("2", "鏈�鏂�"));
+        navList.add(new CommonContentNav("3", "鐑崠"));
+        navList.add(new CommonContentNav("4", "閿�閲�"));
+        if (SystemInfoUtil.hasFunctions(system, SystemFunction.fanli))
+            navList.add(new CommonContentNav("5", "杩斿埄姣�"));
+        return navList;
+    }
+
+    private static int getCommonSort(String cid) {
+        int sort = DaTaoKeApiUtil.SORT_DEFAULT;
+        if ("1".equalsIgnoreCase(cid))
+            sort = DaTaoKeApiUtil.SORT_DEFAULT;
+        else if ("2".equalsIgnoreCase(cid))
+            sort = DaTaoKeApiUtil.SORT_CREATETIME;
+        else if ("3".equalsIgnoreCase(cid))
+            sort = DaTaoKeApiUtil.SORT_COUPON_NUM;
+        else if ("4".equalsIgnoreCase(cid))
+            sort = DaTaoKeApiUtil.SORT_SALES;
+        else if ("5".equalsIgnoreCase(cid))
+            sort = DaTaoKeApiUtil.SORT_COMMISSION;
+
+        return sort;
+    }
+
+    @Override
+    public List<CommonContentNav> getNavList(CommonContentTypeEnum type, SystemEnum system) {
+        List<CommonContentNav> navList = new ArrayList<>();
+        if (type == CommonContentTypeEnum._9k9) {
+            navList.add(new CommonContentNav("-1", "缁煎悎"));
+            navList.add(new CommonContentNav("0", "鏈�鏂�"));
+            for (GoodsClass gc : DaTaoKeUtil.goodsClasses) {
+                navList.add(new CommonContentNav(gc.getId() + "", gc.getName()));
+            }
+        } else if (type == CommonContentTypeEnum.chaoSheng) {
+            navList.add(new CommonContentNav("1", "1-5鍏冭繑鍒�"));
+            navList.add(new CommonContentNav("2", "5-10鍏冭繑鍒� "));
+            navList.add(new CommonContentNav("3", "10-15鍏冭繑鍒�"));
+            navList.add(new CommonContentNav("4", "15-20鍏冭繑鍒�"));
+            navList.add(new CommonContentNav("5", "20鍏冧互涓婅繑鍒�"));
+        } else if (type == CommonContentTypeEnum.haoQuan) {
+            navList.add(new CommonContentNav("1", "1-5鍏冨埜"));
+            navList.add(new CommonContentNav("2", "5-10鍏冨埜"));
+            navList.add(new CommonContentNav("3", "10-20鍏冨埜"));
+            navList.add(new CommonContentNav("4", "20-30鍏冨埜"));
+            navList.add(new CommonContentNav("5", "30-50鍏冨埜"));
+            navList.add(new CommonContentNav("6", "50鍏冧互涓婂埜"));
+        } else if (type == CommonContentTypeEnum.juJia) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.meiShi) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.muYin) {
+            navList.add(new CommonContentNav("1", "绮鹃��"));
+            navList.add(new CommonContentNav("澶囧瓡", "澶囧瓡"));
+            navList.add(new CommonContentNav("0鑷�6涓湀", "0~6鏈�"));
+            navList.add(new CommonContentNav("7鑷�12涓湀", "7~12鏈�"));
+            navList.add(new CommonContentNav("1鑷�3宀�", "1~3宀�"));
+            navList.add(new CommonContentNav("4鑷�6宀�", "4~6宀�"));
+            navList.add(new CommonContentNav("7鑷�12宀�", "7~12宀�"));
+        } else if (type == CommonContentTypeEnum.reMai) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
+            navList = getCommonNav(system);
+        } else if (type == CommonContentTypeEnum.mianDan) {
+            navList = new ArrayList<>();
+        } else if (type == CommonContentTypeEnum.pddHotGoodsRank) {
+            //濂藉崟搴撴暟鎹�
+            navList.add(new CommonContentNav("0", "鍏ㄩ儴"));
+            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
+                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
+            }
+        } else if (type == CommonContentTypeEnum.jdHotGoodsRank) {
+            //濂藉崟搴撴暟鎹�
+            navList.add(new CommonContentNav("0", "鍏ㄩ儴"));
+            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
+                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
+            }
+        } else if (type == CommonContentTypeEnum.tbHotGoodsRank) {
+            //濂藉崟搴撴暟鎹�
+            navList.add(new CommonContentNav("0", "鍏ㄩ儴"));
+            for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) {
+                navList.add(new CommonContentNav(category.getId() + "", category.getName()));
+            }
+        }
+
+        return navList;
+    }
+
+    @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize+'-'+#system")
+    @Override
+    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);
+        } else if (type == CommonContentTypeEnum.juJia) {
+            result = getJuJiaShengHuoContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.muYin) {
+            result = getMuYinJingXuanContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.meiShi) {
+            result = getYouXuanMeiShiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
+            result = getChuanYiDaPeiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
+            result = getMeiZhuangGeHuContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.jingPinXieBao) {
+            result = getJingPinXieBaoContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.chaoNanReMai) {
+            result = getChaoNanReMaiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.shuMaShouJi) {
+            result = getShuMaShouJiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.yunDongKuXie) {
+            result = getYunDongKuXieContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
+            result = getQiCheHuWaiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
+            result = getChaoPinReMaiContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.chaoSheng) {
+            result = getCaoShengContent(cid, page, pageSize, system);
+        } else if (type == CommonContentTypeEnum.haoQuan) {
+            result = getHaoQuanContent(cid, page, pageSize);
+        } else if (type == CommonContentTypeEnum.mianDan) {
+            result = getMianDanContent(page, pageSize);
+        } else if (type == CommonContentTypeEnum.pddHotGoodsRank) {
+            result = getPDDHotGoodsRankContent(cid, page);
+        } else if (type == CommonContentTypeEnum.jdHotGoodsRank) {
+            result = getJDHotGoodsRankContent(cid, page);
+        } else if (type == CommonContentTypeEnum.tbHotGoodsRank) {
+            result = getTBHotGoodsRankContent(cid, page);
+        }
+
+        if (result != null) {// 鍟嗗搧淇℃伅杩囨护
+            List<CommonGoods> goodsList = taoBaoGoodsUpdateService
+                    .filterImportantTaoBaoGoodsWithCommonGoods(result.getGoodsList());
+            result.setGoodsList(goodsList);
+        }
+
+        return result;
+    }
+
+    /**
+     * 9蹇�9鍖呴偖
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult get9K9Content(String cid, int page, int pageSize) {
+        if (pageSize == 20)
+            pageSize = 50;
+
+        DaTaoKeGoodsResult result = null;
+        if ("-1".equalsIgnoreCase(cid)) {
+            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")));
+            }
+
+        } else if ("0".equalsIgnoreCase(cid)) {
+            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")));
+            }
+        } else {
+            List<Integer> cidList = new ArrayList<>();
+            cidList.add(Integer.parseInt(cid));
+            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));
+                result.setTotalCount(
+                        daTaoKeGoodsDetailV2Service.countByMaxPrice(Integer.parseInt(cid), new BigDecimal("10")));
+            }
+        }
+
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 瓒呯骇鐪侀挶
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getCaoShengContent(String cid, int page, int pageSize, SystemEnum system) {
+        pageSize = Constant.PAGE_SIZE;
+        Integer startAmount = null;
+        Integer endAmount = null;
+
+        if (cid.equalsIgnoreCase(1 + "")) {
+            startAmount = 1;
+            endAmount = 5;
+        } else if (cid.equalsIgnoreCase(2 + "")) {
+            startAmount = 5;
+            endAmount = 10;
+        } else if (cid.equalsIgnoreCase(3 + "")) {
+            startAmount = 10;
+            endAmount = 15;
+        } else if (cid.equalsIgnoreCase(4 + "")) {
+            startAmount = 15;
+            endAmount = 20;
+        } else if (cid.equalsIgnoreCase(5 + "")) {
+            startAmount = 20;
+            endAmount = 10000;
+        }
+
+        double tkRate = 20.00;
+
+        BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
+        List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
+                proportion.toString(), startAmount, endAmount, tkRate);
+
+        long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
+                tkRate);
+
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        // 閬嶅巻鍒楄〃鏁版嵁
+        if (listQuery != null)
+            for (QualityFactory quality : listQuery) {
+                TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
+                if (taoBaoGoodsBrief == null) {
+                    continue;
+                }
+
+                int biz30day = taoBaoGoodsBrief.getBiz30day();
+                if (biz30day >= 10000) {
+                    double sales = biz30day;
+                    String salesCountMidea = String.format("%.1f", sales / 10000);
+                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+                } else {
+                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
+                }
+                goodsList.add(taoBaoGoodsBrief);
+            }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 楂橀濂藉埜
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getHaoQuanContent(String cid, int page, int pageSize) {
+        pageSize = Constant.PAGE_SIZE;
+
+        Integer startAmount = null;
+        Integer endAmount = null;
+
+        if (cid.equalsIgnoreCase(1 + "")) {
+            startAmount = 1;
+            endAmount = 5;
+        } else if (cid.equalsIgnoreCase(2 + "")) {
+            startAmount = 5;
+            endAmount = 10;
+        } else if (cid.equalsIgnoreCase(3 + "")) {
+            startAmount = 10;
+            endAmount = 20;
+        } else if (cid.equalsIgnoreCase(4 + "")) {
+            startAmount = 20;
+            endAmount = 30;
+        } else if (cid.equalsIgnoreCase(5 + "")) {
+            startAmount = 30;
+            endAmount = 50;
+        } else if (cid.equalsIgnoreCase(6 + "")) {
+            startAmount = 50;
+            endAmount = 10000;
+        }
+
+        Integer startPropor = 20;
+
+        List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
+                startAmount, endAmount, startPropor);
+
+        long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
+
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+
+        // 閬嶅巻鍒楄〃鏁版嵁
+
+        for (QualityFactory selectionGoods : listQuery) {
+
+            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+
+            if (taoBaoGoodsBrief == null) {
+                continue;
+            }
+
+            int biz30day = taoBaoGoodsBrief.getBiz30day();
+            if (biz30day >= 10000) {
+                double sales = biz30day;
+                String salesCountMidea = String.format("%.1f", sales / 10000);
+                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+            } else {
+                taoBaoGoodsBrief.setSalesCount(biz30day + "");
+            }
+            goodsList.add(taoBaoGoodsBrief);
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 灞呭鐢熸椿
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        List<Integer> cidList = new ArrayList<>();
+        cidList.add(4);// 灞呭鐢熸椿
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 浼橀�夌編椋�
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        List<Integer> cidList = new ArrayList<>();
+        cidList.add(6);// 缇庨
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 娼搧鐑崠
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("娼�", null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 鑾峰彇姣嶅┐绮鹃��
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        if ("1".equalsIgnoreCase(cid)) {// 澶ф窐瀹㈡暟鎹�
+            List<Integer> cidList = new ArrayList<>();
+            cidList.add(2);// 姣嶅┐
+            result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize,
+                    DaTaoKeApiUtil.SORT_DEFAULT);
+
+            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+            long count = 0;
+            if (result != null) {
+                count = result.getTotalCount();
+                if (result.getGoodsList() != null)
+                    for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                        goodsList.add(TaoBaoUtil.convert(detail));
+            }
+            return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+
+        } else {//
+            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("姣嶅┐_" + cid,
+                    "姣嶅┐涓婚");
+
+            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+                return null;
+            }
+
+            TaobaoMeterial meterial = taobaoMeterials.get(0);
+            Integer materialId = meterial.getMaterialId();
+            if (materialId != null) {
+                List<TaoBaoGoodsBrief> listBrands = new ArrayList<>();
+                try {
+                    listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(listBrands), 1000);
+            }
+            return new CommonContentResult(new ArrayList<>(), 0);
+        }
+
+    }
+
+    /**
+     * 绌胯。鎼厤
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getChuanYiDaPeiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        List<Integer> cidList = new ArrayList<>();
+        cidList.add(1);// 濂宠
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
+
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 缇庡涓姢
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getMeiZhuangGeHuContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        List<Integer> cidList = new ArrayList<>();
+        cidList.add(3);// 缇庡
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("娲楁姢", cidList, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 绮惧搧闉嬪寘
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+
+    private CommonContentResult getJingPinXieBaoContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("闉� 濂�", null, null, null, page, pageSize, sort);
+        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("鍖� 濂�", null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount() + result1.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+            if (result1.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        Collections.shuffle(goodsList);
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 娼敺鐑崠
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getChaoNanReMaiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("娼� 鐢�", null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        Collections.shuffle(goodsList);
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 鏁扮爜鎵嬫満
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getShuMaShouJiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("鐢�", null, null, null, page, pageSize, sort);
+        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("鎵嬫満", null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount() + result1.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+            if (result1.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        Collections.shuffle(goodsList);
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 杩愬姩閰烽瀷
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getYunDongKuXieContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        int sort = getCommonSort(cid);
+        result = DaTaoKeApiUtil.search("闉� 鐢�", null, null, null, page, pageSize, sort);
+        DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("杩愬姩 鐢�", null, null, null, page, pageSize, sort);
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        long count = 0;
+        if (result != null) {
+            count = result.getTotalCount() + result1.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+            if (result1.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        Collections.shuffle(goodsList);
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 姹借溅鎴峰
+     *
+     * @param cid
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    private CommonContentResult getQiCheHuWaiContent(String cid, int page, int pageSize) {
+        DaTaoKeGoodsResult result = null;
+        List<Integer> cidList = new ArrayList<>();
+        cidList.add(7);
+        cidList.add(13);
+        int sort = getCommonSort(cid);
+        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;
+        if (result != null) {
+            count = result.getTotalCount() + result1.getTotalCount();
+            if (result.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+            if (result1.getGoodsList() != null)
+                for (DaTaoKeDetailV2 detail : result1.getGoodsList())
+                    goodsList.add(TaoBaoUtil.convert(detail));
+        }
+        Collections.shuffle(goodsList);
+        return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count);
+    }
+
+    /**
+     * 鑾峰彇鍏嶅崟鍟嗗搧
+     *
+     * @return
+     */
+    private CommonContentResult getMianDanContent(int page, int pageSize) {
+        CommonContentResult result = new CommonContentResult();
+        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+        long count = qualityGoodsService.countFreeGoods();
+        result.setCount(count);
+        List<String> listGid = new ArrayList<>();
+        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+        for (QualityFactory qualityFactory : listQuery) {
+            TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
+            if (taoBaoGoodsBrief == null) {
+                continue;
+            }
+            listGid.add(taoBaoGoodsBrief.getAuctionId());
+            goodsList.add(taoBaoGoodsBrief);
+        }
+        // 鍘绘帀宸茬粡涓嶅湪鍞殑鍟嗗搧
+        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+        try {
+            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+        } catch (TaoKeApiException e) {
+            e.printStackTrace();
+        } catch (TaobaoGoodsDownException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Map<String, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
+        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--);
+            }
+        }
+        // 杩囨护鍩烘湰鍟嗗搧淇℃伅
+        goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
+
+        for (int i = 0; i < goodsList.size(); i++) {
+            TaoBaoGoodsBrief goods = goodsList.get(i);
+            BigDecimal price = TaoBaoUtil.getCouponPrice(goods);
+            if (price.compareTo(new BigDecimal(10)) >= 0) {
+                goodsList.remove(i--);
+            }
+        }
+        result.setGoodsList(CommonGoodsFactory.createTaoBaoList(goodsList));
+        return result;
+    }
+
+
+    /**
+     * 鎷煎澶氱儹閿�
+     *
+     * @return
+     */
+    private CommonContentResult getPDDHotGoodsRankContent(String cid, int page) {
+        cid = cid == null ? 0 + "" : cid;
+        CommonContentResult result = new CommonContentResult();
+        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getPDDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+        result.setCount(1000);
+        List<CommonGoods> goodsList = new ArrayList<>();
+        if (pddResult != null) {
+            List<HaoDanKuPDDGoodsInfo> list = pddResult.getResultList();
+            for (HaoDanKuPDDGoodsInfo goodsInfo : list) {
+                goodsList.add(CommonGoodsFactory.create(goodsInfo));
+            }
+        }
+        result.setGoodsList(goodsList);
+        return result;
+    }
+
+    /**
+     * 浜笢鐑攢
+     *
+     * @return
+     */
+    private CommonContentResult getJDHotGoodsRankContent(String cid, int page) {
+        CommonContentResult result = new CommonContentResult();
+        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getJDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+        result.setCount(1000);
+        List<CommonGoods> goodsList = new ArrayList<>();
+        if (pddResult != null) {
+            List<HaoDanKuJDGoodsInfo> list = pddResult.getResultList();
+            for (HaoDanKuJDGoodsInfo goodsInfo : list) {
+                goodsList.add(CommonGoodsFactory.create(goodsInfo));
+            }
+        }
+        result.setGoodsList(goodsList);
+        return result;
+    }
+
+
+    /**
+     * 娣樺疂鐑攢
+     *
+     * @return
+     */
+    private CommonContentResult getTBHotGoodsRankContent(String cid, int page) {
+        CommonContentResult result = new CommonContentResult();
+        HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getTBHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+        result.setCount(1000);
+        List<CommonGoods> goodsList = new ArrayList<>();
+        if (pddResult != null) {
+            List<HDKGoodsDetail> list = pddResult.getResultList();
+            for (HDKGoodsDetail goodsInfo : list) {
+                goodsList.add(CommonGoodsFactory.create(goodsInfo));
+            }
+        }
+        result.setGoodsList(goodsList);
+        return result;
+    }
+
+}

--
Gitblit v1.8.0