From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 19 五月 2020 17:13:23 +0800
Subject: [PATCH] 饿了么绘图,添加口碑

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java |   63 ++++++++++++++++++++++++-------
 1 files changed, 48 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 3083fec..28bc515 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
@@ -33,9 +33,11 @@
 import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
 import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
 import com.yeshi.fanli.vo.brand.BrandInfoVO;
@@ -50,6 +52,9 @@
 
 	@Resource
 	private HongBaoManageService hongBaoManageService;
+	
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
 	@Resource
 	private QualityGoodsService qualityGoodsService;
@@ -201,20 +206,42 @@
 	 * @throws Exception
 	 */
 	public String uploadPicture(MultipartFile file) throws Exception {
-
 		// 鏂囦欢瑙f瀽
 		InputStream inputStream = file.getInputStream();
 		String contentType = file.getContentType();
 		String type = contentType.substring(contentType.indexOf("/") + 1);
 
 		// 鏂囦欢璺緞
-		String filePath = "/img/brand/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+		String filePath = FilePathEnum.brand.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
 		// 鎵ц涓婁紶
-		String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
-
-		return fileLink;
+		return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
 	}
 
+	
+	@Override
+	public void switchState(Long id) throws BrandInfoException {
+		if (id == null) {
+			throw new BrandInfoException(1, "璇蜂紶閫掓纭弬鏁�");
+		}
+		BrandInfo resultObj = brandInfoMapper.selectByPrimaryKey(id);
+		if (resultObj == null) {
+			throw new BrandInfoException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+		}
+		
+		Integer state = resultObj.getState();
+		if (state == null || state == 0) {
+			state = 1;
+		} else {
+			state = 0;
+		}
+		
+		BrandInfo updateObj = new BrandInfo();
+		updateObj.setId(id);
+		updateObj.setState(state);
+		brandInfoMapper.updateByPrimaryKeySelective(updateObj);
+	}
+	
+	
 	@Override
 	public int deleteBatchByPrimaryKey(List<Long> list) {
 		executor.execute(new Runnable() {
@@ -370,12 +397,15 @@
 	@Override
 	public void addShopAndGoods(long start, int count) {
 		List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
+		addShopAndGoods(list);
+	}
+
+	@Override
+	public void addShopAndGoods(List<BrandInfo> list) {
 		if (list == null || list.size() == 0)
 			return;
 
-		long startTime = java.lang.System.currentTimeMillis();
-		LogHelper.test(start + "鍝佺墝鏇存柊service---addShopAndGoods" + startTime);
-
+		// long startTime = java.lang.System.currentTimeMillis();
 		for (BrandInfo brandInfo : list) {
 			try {
 				String name = brandInfo.getName();
@@ -396,9 +426,7 @@
 				LogHelper.errorDetailInfo(e);
 			}
 		}
-
-		long endTime = java.lang.System.currentTimeMillis();
-		LogHelper.test(start + "鍝佺墝鏇存柊service---addShopAndGoods" + endTime + ",鏈鎬昏�楁椂:" + (endTime - startTime) / 1000);
+		// long endTime = java.lang.System.currentTimeMillis();
 	}
 
 	@Override
@@ -426,7 +454,7 @@
 		if (list == null || list.size() == 0)
 			return null;
 
-		ConfigParamsDTO configParamsDTO = hongBaoManageService.getShowComputeRate(platform, version);
+		ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
 
 		List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
 		for (int i = 0; i < list.size(); i++) {
@@ -469,7 +497,7 @@
 
 	@Override
 	@Cacheable(value = "brandCache", key = "'listByAlikeName-'+#key+'-'+#platform+'-'+#version")
-	public BrandInfoVO listByAlikeName(String key,String platform,String version) {
+	public BrandInfoVO listByAlikeName(String key, String platform, String version) {
 		if (StringUtil.isNullOrEmpty(key))
 			return null;
 
@@ -477,8 +505,7 @@
 		if (list == null || list.size() == 0)
 			return null;
 
-
-		ConfigParamsDTO configParamsDTO =  hongBaoManageService.getShowComputeRate(platform, version);
+		ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version);
 
 		BrandInfoVO brand = list.get(0);
 		List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId(1, 3, brand.getId());
@@ -512,4 +539,10 @@
 		brand.setListGoods(listGoodsVO);
 		return brand;
 	}
+
+	@Override
+	public List<BrandInfo> listValidOrderByUpdateTime(int page, int pageSize) {
+		return brandInfoMapper.listValidAll((page - 1) * pageSize, pageSize);
+	}
+
 }

--
Gitblit v1.8.0