From cd4d7c2ff85d68aebec276073020224b5de56415 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 05 十一月 2019 10:29:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 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 3227405..780ec09 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
@@ -118,8 +118,11 @@
 			} else {
 				record.setIcon(resultObj.getIcon());
 			}
-			
-			record.setGoodsTotal(resultObj.getGoodsTotal());
+			if (state == 0){
+				record.setGoodsTotal(0);
+			} else {
+				record.setGoodsTotal(resultObj.getGoodsTotal());
+			}
 			record.setCreateTime(resultObj.getCreateTime());
 			record.setUpdateTime(new Date());
 			brandInfoMapper.updateByPrimaryKey(record);
@@ -255,8 +258,35 @@
 		
 		// 鍒犻櫎搴楅摵
 		brandShopCaheService.removeAgoByDate(date);
+		
+		long count = brandInfoMapper.countValidByCid(null);
+		if (count == 0)
+			return;
+
+		for (int page = 0; page < (count / 100) + 1; page++) {
+			updateTotalGoods(page * 100, 100);
+		}
 	}
 
+	/**
+	 * 鏇存柊鍟嗗搧鏁伴噺
+	 * @param start
+	 * @param count
+	 */
+	private void updateTotalGoods(long start, int count) {
+		List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
+		if (list == null || list.size() == 0)
+			return;
+		
+		for (BrandInfo brandInfo : list) {
+			long goodsTotal = brandGoodsCaheService.countByBrandId(brandInfo.getId());
+			
+			BrandInfo updateInfo = new BrandInfo();
+			updateInfo.setId(brandInfo.getId());
+			updateInfo.setGoodsTotal((int)goodsTotal);
+			brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
+		}
+	}
 	
 	
 	@Override

--
Gitblit v1.8.0