From 207dc8655711cddac2653e18b51e58a88dba2084 Mon Sep 17 00:00:00 2001
From: yj <Administrator@192>
Date: 星期五, 06 三月 2020 18:14:36 +0800
Subject: [PATCH] 发圈处理

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java |   97 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
index 308223d..ef88f21 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
@@ -1,26 +1,35 @@
 package com.yeshi.fanli.service.impl.taobao;
 
 import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
 import javax.annotation.Resource;
 
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.tencentcloud.COSManager;
 
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
+import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.db.MongoDBManager;
+import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
 import com.yeshi.fanli.util.taobao.TaoBaoShopUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 
 @Service
 public class TaoBaoShopServiceImpl implements TaoBaoShopService {
@@ -30,6 +39,9 @@
 
 	@Resource
 	private TaoBaoShopMapper taoBaoShopMapper;
+
+	@Resource
+	private HongBaoManageService hongBaoManageService;
 
 	@Override
 	public TaoBaoShopInfo getTaoBaoShopInfo(TaoBaoGoodsBrief goodsInfo) {
@@ -73,7 +85,7 @@
 	}
 
 	@Override
-	public void changeInfo(MultipartFile file, Long id, String shopName) {
+	public void changeInfo(MultipartFile file, Long id, String shopName, String key) {
 		TaoBaoShop taoBaoShop = taoBaoShopMapper.selectByPrimaryKey(id);
 		if (taoBaoShop == null) {
 			return;
@@ -105,6 +117,7 @@
 
 		updateShop.setId(id);
 		updateShop.setShopNameCustom(shopName);
+		updateShop.setKey(key);
 		taoBaoShopMapper.updateByPrimaryKeySelective(updateShop);
 	}
 
@@ -122,7 +135,7 @@
 		String type = contentType.substring(contentType.indexOf("/") + 1);
 
 		// 鏂囦欢璺緞
-		String filePath = "/img/TaoBaoShop/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+		String filePath = FilePathEnum.taoBaoShop.getPath()  + UUID.randomUUID().toString().replace("-", "") + "." + type;
 		// 鎵ц涓婁紶
 		String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
 
@@ -153,4 +166,84 @@
 		return shop;
 	}
 
+	@Override
+	@Cacheable(value = "brandCache", key = "'getShopByKey-'+#key")
+	public List<TaoBaoShopVO> getShopByKey(String key) {
+		List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
+		if (list == null || list.size() == 0) {
+			return null;
+		}
+
+		BigDecimal proportion = hongBaoManageService.getFanLiRate();
+		for (TaoBaoShopVO taoBaoShopVO : list) {
+
+			String shopLink = taoBaoShopVO.getShopLink();
+			if (StringUtil.isNullOrEmpty(shopLink)) {
+				taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId()));
+			}
+
+			String shopNameCustom = taoBaoShopVO.getShopNameCustom();
+			if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
+				taoBaoShopVO.setShopName(shopNameCustom);
+			}
+
+			String shopIconCustom = taoBaoShopVO.getShopIconCustom();
+			if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
+				taoBaoShopVO.setShopIcon(shopIconCustom);
+			}
+
+			List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>();
+			List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null));
+			}
+			taoBaoShopVO.setListGoods(listGoods);
+		}
+		return list;
+	}
+
+	@Override
+	@Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key+'-'+#platform+'-'+#version")
+	public List<TaoBaoShopVO> getShopByKeyV2(String key, String platform, String version) {
+		List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
+		if (list == null || list.size() == 0) {
+			return null;
+		}
+
+		ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(platform, version);
+
+		for (TaoBaoShopVO taoBaoShopVO : list) {
+
+			Integer userType = taoBaoShopVO.getUserType();
+			if (userType == null || userType == 0) {
+				taoBaoShopVO.setUserType(10);
+			} else {
+				taoBaoShopVO.setUserType(11);
+			}
+
+			String shopLink = taoBaoShopVO.getShopLink();
+			if (StringUtil.isNullOrEmpty(shopLink)) {
+				taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId()));
+			}
+
+			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();
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
+				listGoods.add(goodsDetailVO);
+			}
+			taoBaoShopVO.setListGoodsVO(listGoods);
+		}
+		return list;
+	}
 }

--
Gitblit v1.8.0