From e1a62ec62e7331d97af9302e90e1ce44af8235eb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 27 一月 2021 15:26:55 +0800
Subject: [PATCH] 拼多多授权绑定

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java |  167 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 148 insertions(+), 19 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
index 6fed2b6..e9264a2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
@@ -3,10 +3,13 @@
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -14,21 +17,23 @@
 import org.yeshi.utils.JsonUtil;
 
 import com.yeshi.fanli.dao.mybatis.brand.BrandClassShopMapper;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
 import com.yeshi.fanli.entity.brand.BrandClass;
 import com.yeshi.fanli.entity.brand.BrandClassShop;
 import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.taobao.SearchFilter;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
-import com.yeshi.fanli.entity.taobao.TaoBaoShop;
+import com.yeshi.common.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.exception.brand.BrandClassShopException;
 import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
 import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService;
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
 import com.yeshi.fanli.util.Constant;
@@ -58,6 +63,9 @@
 
 	@Resource
 	private HongBaoManageService hongBaoManageService;
+	
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
 	@Resource
 	private QualityGoodsService qualityGoodsService;
@@ -74,7 +82,7 @@
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public String saveShopInfo(Long cid, List<Long> list) throws BrandClassShopException {
 		if (list == null || list.size() == 0) {
 			throw new BrandClassShopException(1, "璇烽�夋嫨搴楅摵");
@@ -131,7 +139,7 @@
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top,
 			String key) throws BrandClassShopException {
 
@@ -257,8 +265,8 @@
 	}
 
 	@Override
-	@Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid")
-	public JSONObject listEffectiveCache(int page, Long cid) {
+	@Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid+'-'+#system")
+	public JSONObject listEffectiveCache(int page, Long cid,SystemEnum system) {
 		long countShop = 0;
 
 		if (cid != null && cid <= 0) {
@@ -268,7 +276,7 @@
 		List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
 		// 绗竴椤� 鏌ヨ鍏ㄩ儴鍒嗙被涓嬪簵閾�
 		if (page == 1 && cid != null) {
-			List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
+			List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
 			if (list == null) {
 				list = new ArrayList<BrandClassShop>();
 			} else if (list.size() > 0) {
@@ -311,7 +319,10 @@
 			count = taoBaoShopService.countBrandShopinfo(cid);
 		}
 
-		BigDecimal proportion = hongBaoManageService.getFanLiRate();
+		// 娣樺疂鍟嗗搧淇℃伅杩囨护
+		Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
+
+		BigDecimal proportion = hongBaoManageService.getFanLiRate(system);
 		for (TaoBaoShopVO taoBaoShopVO : listInfo) {
 
 			String shopLink = taoBaoShopVO.getShopLink();
@@ -332,7 +343,8 @@
 			List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>();
 			List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
 			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
-				listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null));
+				listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsMap.get(taoBaoGoodsBrief.getAuctionId()),
+						proportion.toString(), null));
 			}
 			taoBaoShopVO.setListGoods(listGoods);
 		}
@@ -342,9 +354,28 @@
 		return data;
 	}
 
+	/**
+	 * 鑾峰彇杩囨护鍟嗗搧
+	 * 
+	 * @param listInfo
+	 * @return
+	 */
+	private Map<Long, TaoBaoGoodsBrief> getFilterTaoBaoGoods(List<TaoBaoShopVO> listInfo) {
+		// 杩囨护鍟嗗搧
+		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+		for (TaoBaoShopVO taoBaoShopVO : listInfo) {
+			goodsList.addAll(taoBaoShopVO.getListGoodsBrief());
+		}
+		goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
+		Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
+		for (TaoBaoGoodsBrief goods : goodsList)
+			goodsMap.put(goods.getAuctionId(), goods);
+		return goodsMap;
+	}
+
 	@Override
-	@Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid")
-	public JSONObject listEffectiveCacheV2(int page, Long cid) {
+	@Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid+'-'+#platform+'-'+#version+'-'+#system")
+	public JSONObject listEffectiveCacheV2(int page, Long cid,String platform,String version,SystemEnum system) {
 		long countShop = 0;
 
 		if (cid != null && cid <= 0) {
@@ -354,7 +385,7 @@
 		List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
 		// 绗竴椤� 鏌ヨ鍏ㄩ儴鍒嗙被涓嬪簵閾�
 		if (page == 1 && cid != null) {
-			List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
+			List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
 			if (list == null) {
 				list = new ArrayList<BrandClassShop>();
 			} else if (list.size() > 0) {
@@ -405,8 +436,11 @@
 			count = taoBaoShopService.countBrandShopinfo(cid);
 		}
 
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		ConfigParamsDTO paramsDTO = 	orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
+
+		// 娣樺疂鍟嗗搧淇℃伅杩囨护
+		Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
+
 		for (TaoBaoShopVO taoBaoShopVO : listInfo) {
 
 			Integer userType = taoBaoShopVO.getUserType();
@@ -433,11 +467,12 @@
 
 			List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>();
 			List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
+
 			// 鍟嗗搧娣诲姞鍒版洿鏂伴槦鍒�
 			taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
 			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
-				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate,
-						shareRate);
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory
+						.convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()),paramsDTO);
 				listGoods.add(goodsDetailVO);
 			}
 			taoBaoShopVO.setListGoodsVO(listGoods);
@@ -474,7 +509,7 @@
 				sf.setKey(shop.getShop().getShopName().replace("瀹樻柟鏃楄埌搴�", "").replace("鏃楄埌搴�", ""));
 				sf.setPage(1);
 				sf.setPageSize(100);
-				TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
+				TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf,null,null);
 				List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 				if (result != null && result.getTaoBaoGoodsBriefs() != null)
 					for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
@@ -494,4 +529,98 @@
 
 	}
 
+	
+	@Override
+	public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid,String platform,String version,SystemEnum system) {
+		if (cid != null && cid <= 0) {
+			cid = null;
+		}
+		
+		List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo(start, count, cid);
+		if (listInfo == null || listInfo.size() == 0)
+			return listInfo;
+		
+
+		ConfigParamsDTO paramsDTO = 
+				orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system);
+		// 娣樺疂鍟嗗搧淇℃伅杩囨护
+		Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
+
+		for (TaoBaoShopVO taoBaoShopVO : listInfo) {
+			String shopNameCustom = taoBaoShopVO.getShopNameCustom();
+			if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
+				taoBaoShopVO.setShopName(shopNameCustom);
+			}
+
+			String shopIconCustom = taoBaoShopVO.getShopIconCustom();
+			if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
+				taoBaoShopVO.setShopIcon(shopIconCustom);
+			}
+
+			List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>();
+			List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
+			// 鍟嗗搧娣诲姞鍒版洿鏂伴槦鍒�
+			taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory
+						.convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), paramsDTO);
+				listGoods.add(goodsDetailVO);
+			}
+			taoBaoShopVO.setListGoodsVO(listGoods);
+		}
+		return listInfo;
+	}
+
+	
+	@Override
+	public long countBrandShopinfo(Long cid) {
+		if (cid != null && cid <= 0) {
+			cid = null;
+		}
+		return taoBaoShopService.countBrandShopinfo(cid);
+	}
+	
+	
+	
+	@Override
+	public List<TaoBaoShop> listEffectiveClassShop(Long cid, SystemEnum system) {
+		if (cid == null)
+			return null;
+		
+		List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system);
+		if (list == null || list.size() == 0)
+			return null;
+
+	    List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
+		for (BrandClassShop brandClassShop : list) {
+			TaoBaoShop shop = brandClassShop.getShop();
+			if (shop != null) {
+				Integer userType = shop.getUserType();
+				if (userType == null || userType == 0) {
+					shop.setUserType(10);
+				} else {
+					shop.setUserType(11);
+				}
+
+				String shopLink = shop.getShopLink();
+				if (StringUtil.isNullOrEmpty(shopLink)) {
+					shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
+				}
+
+				String shopNameCustom = shop.getShopNameCustom();
+				if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
+					shop.setShopName(shopNameCustom);
+				}
+
+				String shopIconCustom = shop.getShopIconCustom();
+				if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
+					shop.setShopIcon(shopIconCustom);
+				}
+
+				listShop.add(shop);
+			}
+		}
+		return listShop;
+	}
+	
 }

--
Gitblit v1.8.0