From 9319c42fe02d041cee260ca0db8df67bcdf1ea0a Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 28 十月 2019 13:53:16 +0800
Subject: [PATCH] 免单券激活方式调整

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 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 134fb96..48c7fdb 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
@@ -10,6 +10,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.cache.annotation.Cacheable;
+import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.tencentcloud.COSManager;
@@ -68,6 +69,10 @@
 	@Resource
 	private BrandShopCaheService brandShopCaheService;
 
+	@Resource(name = "taskExecutor")
+	private TaskExecutor executor;
+	
+	
 	@Override
 	public void saveObject(MultipartFile file, BrandInfo record) throws BrandInfoException {
 		String name = record.getName();
@@ -117,6 +122,28 @@
 			record.setCreateTime(resultObj.getCreateTime());
 			record.setUpdateTime(new Date());
 			brandInfoMapper.updateByPrimaryKey(record);
+			
+			
+			if (state == 0){
+				executor.execute(new Runnable() {
+					@Override
+					public void run() {
+						brandGoodsCaheService.removeByBrandId(id);
+						brandShopCaheService.removeByBrandId(id);
+					}
+				});
+			}
+		}
+
+		if (state == 1) {
+			executor.execute(new Runnable() {
+				@Override
+				public void run() {
+					int goodsTotal = brandGoodsCaheService.addBrandGoods(record);
+					record.setGoodsTotal(goodsTotal);
+					brandInfoMapper.updateByPrimaryKeySelective(record);
+				}
+			});
 		}
 	}
 
@@ -144,6 +171,16 @@
 	
 	@Override
 	public int deleteBatchByPrimaryKey(List<Long> list) {
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				for (Long id: list) {
+					brandGoodsCaheService.removeByBrandId(id);
+					brandShopCaheService.removeByBrandId(id);
+				}
+			}
+		});
+		
 		return brandInfoMapper.deleteBatchByPrimaryKey(list);
 	}
 
@@ -209,6 +246,18 @@
 		return brandClassShopService.countBrandShopinfo(cid);
 	}
 
+	
+	@Override
+	public void removeAgoByDate(Date date) {
+		// 鍒犻櫎鍟嗗搧
+		brandGoodsCaheService.removeAgoByDate(date);
+		
+		// 鍒犻櫎搴楅摵
+		brandShopCaheService.removeAgoByDate(date);
+	}
+
+	
+	
 	@Override
 	public void addShopAndGoods(long start, int count) {
 		List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);

--
Gitblit v1.8.0