From 52bc8ff0de3c7538d1401423c1cba9615c0c2082 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 18 六月 2020 17:22:24 +0800
Subject: [PATCH] 发圈商品来源修改 + 云发单规则调整

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |  136 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 136 insertions(+), 0 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 f532b96..f135d5e 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
@@ -1957,6 +1957,7 @@
 
 		// 鐧藉簳鍥�
 		List<String> imgs = new ArrayList<>();
+		
 		imgs.addAll(goodsBrief.getImgList());
 
 		// 鍟嗗搧VO
@@ -2062,6 +2063,141 @@
 		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)) {
+			throw new GoodsEvaluateException(1, "鐩稿叧鍙傛暟涓嶈兘涓虹┖");
+		}
+
+		Date limitDate = DateUtil.reduceDay(new Date(), 7);
+		
+		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<>();
+		}
+		if (imgs.size() == 0) {
+			imgs.addAll(goodsBrief.getImgList());
+		}
+
+		// 鍟嗗搧VO
+		ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
+		paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+		GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
+
+		// 鍟嗗搧鍥剧墖淇℃伅
+		int i = 0;
+		List<ImgInfo> imgList = new ArrayList<ImgInfo>();
+		 
+		for (String img : imgs) {
+			ImgInfo imgInfo = new ImgInfo();
+			imgInfo.setH(1);
+			imgInfo.setW(1);
+			imgInfo.setLarge(false);
+			imgInfo.setUrl(img);
+			imgInfo.setUrlHD(img);
+			if (i != 0) {
+				imgInfo.setType(ImgEnum.img);
+			} else {
+				imgInfo.setType(ImgEnum.goods);
+				SimpleGoods simpleGoods = new SimpleGoods();
+				simpleGoods.setGoodsId(goodsVO.getGoodsId());
+				simpleGoods.setGoodsType(goodsVO.getGoodsType());
+				simpleGoods.setState(goodsVO.getState());
+				CouponInfoVO couponInfo = goodsVO.getCouponInfo();
+				if (couponInfo == null) {
+					simpleGoods.setPrice(goodsVO.getZkPrice());
+				} else {
+					simpleGoods.setPrice(goodsVO.getCouponPrice());
+					simpleGoods.setAmount(couponInfo.getAmount());
+				}
+				imgInfo.setGoods(simpleGoods);
+				imgInfo.setGoodsVO(goodsVO);
+			}
+			imgList.add(imgInfo);
+			i++;
+		}
+
+		// 璇勮鍐呭
+		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());
+		}
+
+		List<CommentInfo> commentsNew = new ArrayList<>();
+		commentsNew.add(commentInfo);
+
+		// 涓�琛屾樉绀哄灏戜釜鍥剧墖
+		int lineNum = 0;
+		if (imgList.size() > 0) {
+			if (imgList.size() == 1) {
+				lineNum = 1;
+			} else if (imgList.size() == 3) {
+				lineNum = 3;
+			} else if (imgList.size() == 2 || imgList.size() == 4) {
+				lineNum = 2;
+			} else {
+				lineNum = 3;
+			}
+		}
+
+		GoodsEvaluate goodsEvaluate = new GoodsEvaluate();
+		goodsEvaluate.setId(UUID.randomUUID().toString().replace("-", ""));
+		goodsEvaluate.setUser(user);
+		goodsEvaluate.setTitle(getDescNew(title));
+		goodsEvaluate.setState(1);
+		goodsEvaluate.setDynamicType(1);
+		goodsEvaluate.setType(EvaluateEnum.single);
+		goodsEvaluate.setShareNum((int) (Math.random() * 5000) + 1000);
+		goodsEvaluate.setShareNumReal(0);
+		goodsEvaluate.setWeight(0.0);
+		goodsEvaluate.setStartTime(new Date());
+		goodsEvaluate.setEndTime(DateUtil.plusDayDate(3, new Date()));
+		goodsEvaluate.setPublishTime(new Date());
+		goodsEvaluate.setCreateTime(new Date());
+		goodsEvaluate.setUpdateTime(new Date());
+		goodsEvaluate.setGoods(goodsVO);
+		goodsEvaluate.setLineNum(lineNum);
+		goodsEvaluate.setImgList(imgList);
+		goodsEvaluate.setComments(commentsNew);
+		goodsEvaluateDao.save(goodsEvaluate);
+	}
+	
 	@Override
 	public void addGoodsEvaluateByDaTaoKe() {
 		List<Long> listId = null;

--
Gitblit v1.8.0