From 652de4214ebe5efcf3abd30e68c83cb38beb2a23 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期一, 22 六月 2020 16:44:09 +0800
Subject: [PATCH] 云发单-发圈调整

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   66 +++++++++++++++------------------
 1 files changed, 30 insertions(+), 36 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 f135d5e..18cec44 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
@@ -45,12 +45,14 @@
 import com.yeshi.fanli.entity.dynamic.SimpleGoods;
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.system.ConfigKeyEnum;
+import com.yeshi.fanli.entity.taobao.PidUser;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoLink;
 import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
 import com.yeshi.fanli.exception.dynamic.ActivityUserException;
 import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
 import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
+import com.yeshi.fanli.exception.share.ShareGoodsException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.activity.ActivityUserService;
@@ -2009,6 +2011,7 @@
 			commentInfo.setContent(comment);
 			commentInfo.setType("");
 		} else {
+			goodsBrief.setCouponLink(null);
 			String token = shareGoodsService.createTaoBaoToken(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief);
 			String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey());
 			String commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(token));
@@ -2063,34 +2066,19 @@
 		goodsEvaluateDao.save(goodsEvaluate);
 	}
 
+
 	
 	@Override
-	public void addGoodsEvaluate2(String goodsId, List<String> imgs, ActivityUser user, String title, String comment) throws GoodsEvaluateException {
-		if (goodsId == null || user == null || StringUtil.isNullOrEmpty(title)) {
+	public void addGoodsEvaluate2(TaoBaoGoodsBrief goodsBrief, List<String> imgs, ActivityUser user, String title, String comment) throws GoodsEvaluateException {
+		if (goodsBrief == null || user == null || StringUtil.isNullOrEmpty(title)) {
 			throw new GoodsEvaluateException(1, "鐩稿叧鍙傛暟涓嶈兘涓虹┖");
 		}
-
 		Date limitDate = DateUtil.reduceDay(new Date(), 7);
 		
-		List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExistLimitTime(Constant.SOURCE_TYPE_TAOBAO, goodsId, limitDate);
+		Long goodsId = goodsBrief.getAuctionId();
+		List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExistLimitTime(Constant.SOURCE_TYPE_TAOBAO, goodsId + "", limitDate);
 		if (evaluateList != null && evaluateList.size() > 0)
 			throw new GoodsEvaluateException(1, "璇ュ晢鍝佸凡瀛樺湪");
-
-		TaoBaoGoodsBrief goodsBrief = null;
-		try {
-			goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
-		} catch (TaobaoGoodsDownException e) {
-			throw new GoodsEvaluateException(1, "鍟嗗搧宸蹭笅鏋�");
-		}
-
-		if (goodsBrief == null) {
-			throw new GoodsEvaluateException(1, "鏈壘鍒板晢鍝佷俊鎭�");
-		}
-
-		BigDecimal couponAmount = goodsBrief.getCouponAmount();
-		if (couponAmount == null || couponAmount.compareTo(new BigDecimal(0)) < 1) {
-			throw new GoodsEvaluateException(1, "璇ュ晢鍝佹棤鍒�");
-		}
 
 		if (imgs == null) {
 			imgs = new ArrayList<>();
@@ -2137,27 +2125,33 @@
 			i++;
 		}
 
+		
+		// 鐢熸垚鍙d护
+		String token = null;
+		try {
+			TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1");
+			token = taoBaoLink.getTaoToken();
+		} catch (ShareGoodsException e) {
+			e.printStackTrace();
+			throw new GoodsEvaluateException(1, "杞摼澶辫触");
+		}
+		 
+		 
+		String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey());
+		String commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(token));
+		if (!goodsVO.isHasCoupon()) {
+			commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
+			commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
+			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.setNeedSpin(true);
 		commentInfo.setId(UUID.randomUUID().toString().replace("-", ""));
 		commentInfo.setTypeEnum(CommentInfoEnum.goodsCoupon);
-		if (!StringUtil.isNullOrEmpty(comment)) {
-			commentInfo.setContent(comment);
-			commentInfo.setType("");
-		} else {
-			String token = shareGoodsService.createTaoBaoToken(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief);
-			String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey());
-			String commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(token));
-			if (!goodsVO.isHasCoupon()) {
-				commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
-				commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
-				commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n",
-						"\r\n");
-			}
-			commentInfo.setContent(commentText);
-			commentInfo.setType(CommentInfoEnum.goodsCoupon.getDesc());
-		}
+		commentInfo.setContent(commentText);
+		commentInfo.setType(CommentInfoEnum.goodsCoupon.getDesc());
 
 		List<CommentInfo> commentsNew = new ArrayList<>();
 		commentsNew.add(commentInfo);

--
Gitblit v1.8.0