From 89cc8f054c27f70fcfe16f14554a8a12e0c19e23 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 18 十二月 2019 09:22:31 +0800
Subject: [PATCH] 邀请统计

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java |   87 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
index 25f724f..5689cdb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -27,6 +27,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.exception.brand.BrandInfoException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
 import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
 import com.yeshi.fanli.service.inter.brand.BrandInfoService;
@@ -363,7 +364,7 @@
 			} else {
 				updateInfo.setShopTotal(listshop.size());
 			}
-			
+			updateInfo.setWeight(Math.random() * 1000);
 			brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
 		}
 	}
@@ -376,19 +377,25 @@
 			return;
 
 		for (BrandInfo brandInfo : list) {
-			String name = brandInfo.getName();
-			String searchKey = brandInfo.getSearchKey();
-			if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
-				continue;
-
-			// 娣诲姞鍟嗗搧
-			BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(brandInfo);
-
-			brandInfo.setGoodsTotal(numInfo.getGoodsTotal());
-			brandInfo.setShopTotal(numInfo.getShopTotal());
-			brandInfo.setUpdateTime(new Date());
-			brandInfo.setWeight(Math.random() * 1000);
-			brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
+			try {
+				String name = brandInfo.getName();
+				String searchKey = brandInfo.getSearchKey();
+				if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
+					continue;
+				// 娣诲姞鍟嗗搧
+				BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(brandInfo);
+				
+				BrandInfo updateInfo = new BrandInfo(); 
+				updateInfo.setId(brandInfo.getId());
+				updateInfo.setWeight(Math.random() * 1000);
+				updateInfo.setGoodsTotal(numInfo.getGoodsTotal());
+				updateInfo.setShopTotal(numInfo.getShopTotal());
+				updateInfo.setUpdateTime(new Date());
+				brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
+			} catch (Exception e) {
+				LogHelper.errorDetailInfo(e);
+			}
+			
 		}
 	}
 
@@ -419,7 +426,7 @@
 
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+		ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
 		List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
 		for (int i = 0; i < list.size(); i++) {
 			BrandInfoVO brand = list.get(i);
@@ -458,4 +465,54 @@
 		}
 		return listInfo;
 	}
+	
+	
+	
+	
+	@Override
+	@Cacheable(value = "brandCache", key = "'listByAlikeName-'+#key")
+	public BrandInfoVO listByAlikeName(String key) {
+		if (StringUtil.isNullOrEmpty(key))
+			return null;
+			
+		List<BrandInfoVO> list = brandInfoMapper.listByAlikeName(key);
+		if (list == null || list.size() == 0)
+			return null;
+
+		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
+		
+		BrandInfoVO brand = list.get(0);
+		List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId(1, 3, brand.getId());
+		if (listGoods == null || listGoods.size() < 3)
+			return null;
+
+		List<GoodsDetailVO> listGoodsVO = new ArrayList<GoodsDetailVO>();
+		for (BrandGoodsCahe brandGoods : listGoods) {
+			JDGoods goodsJD = brandGoods.getGoodsJD();
+			if (goodsJD != null) {
+				listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, configParamsDTO));
+				continue;
+			}
+
+			TaoBaoGoodsBrief goodsTB = brandGoods.getGoodsTB();
+			if (goodsTB != null) {
+				listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, configParamsDTO));
+				continue;
+			}
+
+			PDDGoodsDetail goodsPDD = brandGoods.getGoodsPDD();
+			if (goodsPDD != null) {
+				listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, configParamsDTO));
+				continue;
+			}
+		}
+
+		if (listGoodsVO.size() < 3) 
+			return null;
+		
+		brand.setListGoods(listGoodsVO);
+		return brand;
+	}
 }

--
Gitblit v1.8.0