From 8ebf78f9d9a2663f53f09346abdd14c5964fdfeb Mon Sep 17 00:00:00 2001
From: yj <Administrator@192>
Date: 星期二, 03 三月 2020 19:11:00 +0800
Subject: [PATCH] 发圈修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
index 03f752c..7ca7425 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -20,6 +20,7 @@
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.yeshi.utils.DateUtil;
+import org.yeshi.utils.JsonUtil;
 import org.yeshi.utils.tencentcloud.COSManager;
 
 import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
@@ -49,6 +50,7 @@
 import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.RedisManager;
@@ -94,6 +96,9 @@
 	@Resource
 	private ShareGoodsService shareGoodsService;
 	
+	@Resource
+	private ConvertLinkManager convertLinkManager;
+	
 	
 
 	@Override
@@ -107,7 +112,7 @@
 		if (StringUtil.isNullOrEmpty(tilte)) {
 			throw new GoodsEvaluateException(1, "鎺ㄨ崘璇笉鑳戒负绌�");
 		}
-
+		
 		try {
 			ActivityUser activityUser = activityUserService.getActivityUserByNickName(record.getUser(), file);
 			if (activityUser == null)
@@ -417,7 +422,7 @@
 		if (addComment) {
 			String commentText = "";
 			if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
-				TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsId, null);
+				TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsId, "0");
 				String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey());
 				commentText = template.replace("[鍙d护]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
 			} else if (goodsType == Constant.SOURCE_TYPE_JD) {
@@ -443,6 +448,9 @@
 			} else {
 				commentText = commentText.replace("[鍒稿悗浠穄", goodsDetailVO.getCouponPrice().toString());
 			}
+			
+			commentText =commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
+
 			
 			CommentInfo commentInfo = new CommentInfo();
 			commentInfo.setId(UUID.randomUUID().toString().replace("-", ""));
@@ -731,7 +739,39 @@
 		if (StringUtil.isNullOrEmpty(pid)) {
 			throw new GoodsEvaluateException(1, "璇蜂繚瀛樼涓�閮ㄥ垎淇℃伅");
 		}
+		
+		if (StringUtil.isNullOrEmpty(commentInfo.getCoupon())) {
+			throw new GoodsEvaluateException(1, "鍒搁潰棰濅笉鑳戒负绌�");
+		}
+		
+		if (StringUtil.isNullOrEmpty(commentInfo.getTagDesc())) {
+			throw new GoodsEvaluateException(1, "鎻忚堪璇笉鑳戒负绌�");
+		}
+		
+		String tagUrl = commentInfo.getTagUrl();
+		String content = commentInfo.getContent();
+		if (StringUtil.isNullOrEmpty(tagUrl) && StringUtil.isNullOrEmpty(content) ) {
+			throw new GoodsEvaluateException(1, "璇勮璇拰閾炬帴涓嶈兘鍚屾椂涓虹┖");
+		}
 
+		String endTime = commentInfo.getEndTime();
+		if (!StringUtil.isNullOrEmpty(endTime)) {
+			try {
+				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+				sdf.parse(endTime);
+			} catch (Exception e) {
+				throw new GoodsEvaluateException(1, "璇峰~鍐欐纭殑鏃堕棿鏍煎紡锛�2020-03-05");
+			}
+		}
+		
+		if(!StringUtil.isNullOrEmpty(content)) {
+			try {
+				convertLinkManager.convertLinkFromText(content, 1L, true);
+			} catch (Exception e) {
+				throw new GoodsEvaluateException(1, "杞摼澶辫触");
+			}
+		}
+		
 		GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
 		if (resultObj == null)
 			throw new GoodsEvaluateException(1, "绗竴閮ㄥ垎淇℃伅缂哄け");
@@ -1277,7 +1317,15 @@
 				for (CommentInfo commentInfo: comments) {
 					String typeCoupon = commentInfo.getType();
 					if (StringUtil.isNullOrEmpty(typeCoupon)) {
-						commentInfo.setType(commentInfo.getTypeEnum().getDesc());
+						if (commentInfo.getTypeEnum() == null) {
+							commentInfo.setType("");
+						} else {
+							commentInfo.setType(commentInfo.getTypeEnum().getDesc());
+						}
+					} else if (typeCoupon.equals(CommentInfoEnum.goodsCoupon.name())) {
+						commentInfo.setType("鍟嗗搧浼樻儬鍒�");
+					} else if (typeCoupon.equals(CommentInfoEnum.currencyCoupon.name())) {
+						commentInfo.setType("閫氱敤浼樻儬鍒�");
 					}
 					
 					String coupon = commentInfo.getCoupon();
@@ -1470,7 +1518,7 @@
 					goodsEvaluate.setGoods(goodsVO);
 					
 					
-					TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(0L, goodsVO.getGoodsId(), null);
+					TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsVO.getGoodsId(), null);
 					String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey());
 					String commentText = template.replace("[鍙d护]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
 				
@@ -1481,6 +1529,8 @@
 					} else {
 						commentText = commentText.replace("[鍒稿悗浠穄", goodsVO.getCouponPrice().toString());
 					}
+					commentText =commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
+
 					
 					CommentInfo commentInfo = new CommentInfo();
 					commentInfo.setId(UUID.randomUUID().toString().replace("-", ""));

--
Gitblit v1.8.0