From cd637932a970e7935b17d41568fe89c92775bccc Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 06 十二月 2019 17:18:27 +0800
Subject: [PATCH] 双12活动添加,邀请码发布修改,爬单新规则添加

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java |   69 +++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 22 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 11967ac..34364e4 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;
@@ -95,29 +96,49 @@
 			state = 0;
 			record.setState(state);
 		}
-		// 鍥剧墖涓婁紶
+		
+	
 		String picture = null;
 		if (file != null) {
-			try {
+			try { // 鍥剧墖涓婁紶
 				picture = uploadPicture(file);
 			} catch (Exception e) {
 				throw new BrandInfoException(1, "鍥剧墖涓婁紶澶辫触");
 			}
 		}
-
+		
+		String searchKey = record.getSearchKey();
+		if (!StringUtil.isNullOrEmpty(searchKey)) {
+			if (StringUtil.isNullOrEmpty(record.getSearchKeyJD()))
+				record.setSearchKeyJD(searchKey);
+			
+			if (StringUtil.isNullOrEmpty(record.getSearchKeyPDD()))
+				record.setSearchKeyPDD(searchKey);
+		}
+		
+		String shopKey = record.getShopKey();
+		if (!StringUtil.isNullOrEmpty(shopKey)) {
+			if (StringUtil.isNullOrEmpty(record.getShopKeyJD()))
+				record.setShopKeyJD(shopKey);
+			
+			if (StringUtil.isNullOrEmpty(record.getShopKeyPDD()))
+				record.setShopKeyPDD(shopKey);
+		}
 		record.setName(name.trim());
+		record.setUpdateTime(new Date());
+		
 		Long id = record.getId();
 		if (id == null) {
-			record.setCreateTime(new Date());
+			record.setIcon(picture);
+			record.setWeight(500.00);
 			record.setGoodsTotal(0);
 			record.setShopTotal(0);
-			record.setUpdateTime(new Date());
+			record.setCreateTime(new Date());
 			brandInfoMapper.insert(record);
 			
 			BrandInfo resultObj = new BrandInfo();
 			resultObj.setId(record.getId());
 			resultObj.setOrder(Integer.valueOf(record.getId().toString()));
-			resultObj.setWeight(500.00);
 			brandInfoMapper.updateByPrimaryKeySelective(resultObj);
 		} else {
 			BrandInfo resultObj = brandInfoMapper.selectByPrimaryKey(id);
@@ -142,11 +163,9 @@
 				record.setGoodsTotal(resultObj.getGoodsTotal());
 				record.setShopTotal(resultObj.getShopTotal());
 			}
-			
 			record.setOrder(resultObj.getOrder());
 			record.setWeight(resultObj.getWeight());
 			record.setCreateTime(resultObj.getCreateTime());
-			record.setUpdateTime(new Date());
 			brandInfoMapper.updateByPrimaryKey(record);
 			
 			if (state == 0){
@@ -345,7 +364,7 @@
 			} else {
 				updateInfo.setShopTotal(listshop.size());
 			}
-			
+			updateInfo.setWeight(Math.random() * 1000);
 			brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
 		}
 	}
@@ -358,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);
+			}
+			
 		}
 	}
 

--
Gitblit v1.8.0