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/TaoBaoGoodsBriefServiceImpl.java |   62 ++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java
index c29b0a2..311edb1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java
@@ -1,11 +1,13 @@
 package com.yeshi.fanli.service.impl.goods;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
 
-import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper;
@@ -14,10 +16,10 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
 import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
-import com.yeshi.fanli.exception.ShareGoodsException;
+import com.yeshi.fanli.exception.share.ShareGoodsException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.user.TBPidService;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
@@ -49,36 +51,28 @@
 		BigDecimal rate = hongBaoManageService.getShareRate();
 		return TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
 	}
-	
-	
+
 	@Override
 	public void deleteByPrimaryKey(Long id) {
 		taoBaoGoodsBriefMapper.deleteByPrimaryKey(id);
 	}
-	
+
 	@Override
 	public void deleteBatchByGoodsId(List<Long> list) {
 		taoBaoGoodsBriefMapper.deleteBatchByGoodsId(list);
 	}
 
-	
 	@Override
 	public List<TaoBaoGoodsBrief> queryByAuctionId(Long auctionId) {
 		return taoBaoGoodsBriefMapper.queryByAuctionId(auctionId);
 	}
-	
-	
+
 	@Override
 	public List<Long> listExistById(List<Long> list) {
 		if (list != null && list.size() > 0)
 			return taoBaoGoodsBriefMapper.listExistById(list);
 		else
 			return null;
-	}
-
-	@Override
-	public int insertSelective(TaoBaoGoodsBrief taoBaoGoodsBrief) {
-		return taoBaoGoodsBriefMapper.insertSelective(taoBaoGoodsBrief);
 	}
 
 	@Override
@@ -200,16 +194,48 @@
 
 		return taoBaoGoodsBrief;
 	}
-	
-	
+
 	@Override
 	public List<TaoBaoGoodsBrief> listByShopId(long start, int count, Long shopId) {
 		return taoBaoGoodsBriefMapper.listByShopId(start, count, shopId);
 	}
-	
+
 	@Override
 	public long countByShopId(Long shopId) {
 		return taoBaoGoodsBriefMapper.countByShopId(shopId);
 	}
-	
+
+	@Override
+	public List<TaoBaoGoodsBrief> filterOffLineGoods(List<TaoBaoGoodsBrief> goodsList) {
+		int page = goodsList.size() % 40 == 0 ? goodsList.size() / 40 -1 : goodsList.size() / 40;
+		List<TaoBaoGoodsBrief> flist = new ArrayList<>();
+		for (int i = 0; i <= page; i++) {
+			List<TaoBaoGoodsBrief> list = goodsList.subList(i * 40,
+					i * 40 + 40 > goodsList.size() ?goodsList.size(): i * 40 + 40 );
+			String ids = "";
+			for (TaoBaoGoodsBrief goods : list) {
+				ids += goods.getAuctionId() + ",";
+			}
+			ids = ids.endsWith(",") ? ids.substring(0, ids.length() - 1) : ids;
+			Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
+			try {
+				List<TaoBaoGoodsBrief> finalList = TaoKeApiUtil.getBatchGoodsInfos(ids);
+				if (finalList != null)
+					for (TaoBaoGoodsBrief ggods : finalList)
+						goodsMap.put(ggods.getAuctionId(), ggods);
+
+				for (int j = 0; j < list.size(); j++) {
+					if (goodsMap.get(list.get(j).getAuctionId()) == null) {
+						list.remove(j);
+						j--;
+					}
+				}
+			} catch (TaobaoGoodsDownException e) {
+				e.printStackTrace();
+			}
+			flist.addAll(list);
+		}
+		return flist;
+	}
+
 }

--
Gitblit v1.8.0