From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 23 十一月 2019 18:30:01 +0800
Subject: [PATCH] 配置文件修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 100 insertions(+), 17 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 7d27c30..cef0740 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
@@ -3,13 +3,18 @@
 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 org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
+import org.yeshi.utils.JsonUtil;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 import com.yeshi.fanli.dto.common.CommonContentNav;
 import com.yeshi.fanli.dto.common.CommonContentResult;
 import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
@@ -17,18 +22,28 @@
 import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
 import com.yeshi.fanli.entity.bus.lable.QualityFactory;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
+import com.yeshi.fanli.entity.taobao.TaoBaoHongBaoInfo;
 import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
 import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
+import com.yeshi.fanli.exception.taobao.TaoKeApiException;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 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.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 @Service
 public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
@@ -47,6 +62,9 @@
 
 	@Resource
 	private QualityGoodsService qualityGoodsService;
+
+	@Resource
+	private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
 
 	private static List<CommonContentNav> getCommonNav() {
 		List<CommonContentNav> navList = new ArrayList<>();
@@ -126,6 +144,8 @@
 			navList = getCommonNav();
 		} else if (type == CommonContentTypeEnum.chaoPinReMai) {
 			navList = getCommonNav();
+		} else if (type == CommonContentTypeEnum.mianDan) {
+			navList = new ArrayList<>();
 		}
 
 		return navList;
@@ -134,36 +154,46 @@
 	@Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
 	@Override
 	public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
+		CommonContentResult result = null;
 		if (type == CommonContentTypeEnum._9k9) {
-			return get9K9Content(cid, page, pageSize);
+			result = get9K9Content(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.juJia) {
-			return getJuJiaShengHuoContent(cid, page, pageSize);
+			result = getJuJiaShengHuoContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.muYin) {
-			return getMuYinJingXuanContent(cid, page, pageSize);
+			result = getMuYinJingXuanContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.meiShi) {
-			return getYouXuanMeiShiContent(cid, page, pageSize);
+			result = getYouXuanMeiShiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.chuanYiDaPei) {
-			return getChuanYiDaPeiContent(cid, page, pageSize);
+			result = getChuanYiDaPeiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.meiZhuangGehu) {
-			return getMeiZhuangGeHuContent(cid, page, pageSize);
+			result = getMeiZhuangGeHuContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.jingPinXieBao) {
-			return getJingPinXieBaoContent(cid, page, pageSize);
+			result = getJingPinXieBaoContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.chaoNanReMai) {
-			return getChaoNanReMaiContent(cid, page, pageSize);
+			result = getChaoNanReMaiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.shuMaShouJi) {
-			return getShuMaShouJiContent(cid, page, pageSize);
+			result = getShuMaShouJiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.yunDongKuXie) {
-			return getYunDongKuXieContent(cid, page, pageSize);
+			result = getYunDongKuXieContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.qiCheHuWai) {
-			return getQiCheHuWaiContent(cid, page, pageSize);
+			result = getQiCheHuWaiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.chaoPinReMai) {
-			return getChaoPinReMaiContent(cid, page, pageSize);
+			result = getChaoPinReMaiContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.chaoSheng) {
-			return getCaoShengContent(cid, page, pageSize);
+			result = getCaoShengContent(cid, page, pageSize);
 		} else if (type == CommonContentTypeEnum.haoQuan) {
-			return getHaoQuanContent(cid, page, pageSize);
+			result = getHaoQuanContent(cid, page, pageSize);
+		} else if (type == CommonContentTypeEnum.mianDan) {
+			result = getMianDanContent(page, pageSize);
 		}
-		return null;
+
+		if (result != null) {// 鍟嗗搧淇℃伅杩囨护
+			List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService
+					.filterImportantTaoBaoGoods(result.getGoodsList());
+			result.setGoodsList(goodsList);
+		}
+
+		return result;
 	}
 
 	/**
@@ -466,7 +496,7 @@
 		List<Integer> cidList = new ArrayList<>();
 		cidList.add(1);// 濂宠
 		int sort = getCommonSort(cid);
-		result = DaTaoKeApiUtil.search("鍐呰。 濂�", cidList, null, null, page, pageSize, sort);
+		result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
 		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		long count = 0;
 		if (result != null) {
@@ -643,4 +673,57 @@
 		return new CommonContentResult(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<Long> listGid = new ArrayList<Long>();
+		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<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
+		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.getAfterUseCouplePrice(goods);
+			if (price.compareTo(new BigDecimal(10)) >= 0) {
+				goodsList.remove(i--);
+			}
+		}
+		result.setGoodsList(goodsList);
+		return result;
+	}
+
 }

--
Gitblit v1.8.0