From b6c37e4bc38db88a360d0f2c6099183f9bb75bdc Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 22 四月 2019 14:31:59 +0800
Subject: [PATCH] 券推送插入

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
index 30f95ce..833b06c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
@@ -6,10 +6,10 @@
 import java.util.UUID;
 
 import javax.annotation.Resource;
-import javax.transaction.Transactional;
 
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.tencentcloud.COSManager;
 
@@ -96,6 +96,12 @@
 			COSManager.getInstance().deleteFile(picture);
 		}
 
+		/* 鍒犻櫎缃戠粶鍥剧墖 */
+		String pictureSecond = goodsSubClass.getPictureSecond();
+		if (!StringUtil.isNullOrEmpty(pictureSecond)) {
+			COSManager.getInstance().deleteFile(pictureSecond);
+		}
+		
 		/* 鍒犻櫎鎵�鏈夊叧鑱斿瓙绫� */
 		List<GoodsSubClass> subList = goodsSubClassMapper.queryByPid(recordId, null);
 		if (subList != null && subList.size() > 0) {
@@ -116,7 +122,7 @@
 	
 	
 	@Override
-	public void saveObject(MultipartFile file, GoodsSubClass record, Integer type, Long pid) throws GoodsSubClassException, Exception{
+	public void saveObject(MultipartFile file, MultipartFile file2, GoodsSubClass record, Integer type, Long pid) throws GoodsSubClassException, Exception{
 		
 		String name = record.getName();
 		if (name == null || name.trim().length() == 0) {
@@ -129,11 +135,18 @@
 			picture = uploadPicture(file);
 		}
 		
+		// 鍥剧墖涓婁紶
+		String pictureSecond = null;
+		if (file2 != null) {
+			pictureSecond = uploadPicture(file2);
+		}
+				
+		
 		String params = record.getSearchParam();
 		if (params== null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
 			record.setSearchJson(null);
-		} else {
-			record.setSearchJson(params);
+		} else if (!StringUtil.isJson(params)) {
+			throw new GoodsSubClassException(1, "绛涢�夋潯浠堕潪JSON鏍煎紡");
 		}
 		
 		Long id = record.getId();
@@ -168,6 +181,7 @@
 			
 			record.setLevel(type);
 			record.setPicture(picture);
+			record.setPictureSecond(pictureSecond);
 			record.setState(0);
 			record.setAndroidClick(0L);
 			record.setIosClick(0L);
@@ -197,6 +211,16 @@
 				record.setPicture(resultObj.getPicture());
 			}
 			
+			
+			if (pictureSecond != null && pictureSecond.trim().length() > 0) {
+				// 鍒犻櫎鑰佸浘
+				removePicture(resultObj.getPictureSecond());
+				// 瀛樺偍鏂板浘
+				record.setPictureSecond(pictureSecond);
+			} else {
+				record.setPictureSecond(resultObj.getPictureSecond());
+			}
+			
 			record.setLevel(resultObj.getLevel());
 			record.setRootClass(resultObj.getRootClass());
 			record.setWeight(resultObj.getWeight());

--
Gitblit v1.8.0