From dd6a31aae79b35ccf0e006704a4d9e1d950c57d6 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 23 五月 2020 09:55:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java |  137 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
index d264993..7088861 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -27,6 +27,7 @@
 import com.yeshi.fanli.dto.jd.JDPingouInfo;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
 import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
+import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
@@ -84,6 +85,8 @@
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
+import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
+import com.yeshi.fanli.util.vipshop.VipShopUtil;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo;
 import com.yeshi.fanli.vo.goods.ShareInfoVO;
@@ -247,6 +250,13 @@
 			createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
 			return;
 		}
+
+		// 鍞搧浼�
+		if (goodsType == Constant.SOURCE_TYPE_VIP) {
+			createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
+			return;
+		}
+
 	}
 
 	public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) {
@@ -1038,6 +1048,133 @@
 	}
 
 	/**
+	 * 鎷煎澶氬垎浜�
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param goodsId
+	 * @param source
+	 * @param out
+	 */
+	public void createVIPShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
+			PrintWriter out) {
+		VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + "");
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
+			return;
+		}
+
+		String jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid));
+
+		ShareInfoVO shareInfo = new ShareInfoVO();
+		shareInfo.setClickUrl(jumpLink);
+		shareInfo.setWxErCode(jumpLink);
+		shareInfo.setCommentTexts(new ArrayList<>());
+		shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkVIP.getKey()));
+		shareInfo.setPictUrl(goods.getGoodsThumbUrl());
+		if (needGoods) {
+			shareInfo
+					.setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods,
+							new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
+									hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
+									hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
+		}
+
+		String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid);
+		String shareText = shareGoodsTextTemplateService.createContentVIP(template, goods, jumpLink);
+		shareInfo.setShareText(shareText);
+
+		String descText = shareText.replace(goods.getGoodsName(), "").trim();
+		if (descText.startsWith("\\r\\n")) {
+			descText = descText.substring(0);
+		}
+		shareInfo.setDescText(descText);
+
+		//
+		String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(),
+				Integer.parseInt(acceptData.getVersion()));
+		JSONArray array = JSONArray.fromObject(imgs);
+
+		shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0));
+
+		// 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖
+		imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey());
+		array = JSONArray.fromObject(imgs);
+		shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0));
+
+		shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey()));
+
+		// 娣诲姞鍒嗕韩璁板綍
+		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		BigDecimal shareMoney = VipShopUtil.getGoodsFanLiMoney(goods, shareRate);
+		shareInfo.setShareMoney("楼" + shareMoney.toString());
+
+		try {
+			ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
+					Constant.SOURCE_TYPE_VIP, false);
+			shareInfo.setShareId(shareRecord.getRedisKey());
+		} catch (Exception e) {
+			try {
+				LogHelper.errorDetailInfo(e);
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+		}
+
+		String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+
+		String commentText = "";
+		String recommendText = "";
+		String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey());
+		recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getGoodsName());
+
+		recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", "");
+
+		String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey());
+		commentText = quickCommentText.replace("[鍘熶环]", goods.getMarketPrice());
+		commentText = commentText.replace("[閾炬帴]", jumpLink);
+
+		commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
+		commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
+		recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", "");
+
+		shareInfo.setRecommendText(deleteBlankLine(recommendText));
+		shareInfo.setCommentText(deleteBlankLine(commentText));
+
+		// 璁剧疆璇勮鏂囨湰閫夐」
+		shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
+				VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
+
+		out.print(JsonUtil.loadTrueResult(
+				JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
+
+		// 寮傛鎿嶄綔
+		com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
+			@Override
+			public void run() {
+				// 寮傛鎿嶄綔 娣诲姞鍒嗕韩璁板綍
+				UserShareGoodsHistory history = new UserShareGoodsHistory();
+				history.setUser(new UserInfo(uid));
+				history.setHongbao(shareMoney);
+				history.setCreateTime(new Date());
+				history.setGoodsType(Constant.SOURCE_TYPE_VIP);
+				history.setTkCode(null);
+				history.setLink(null);
+				history.setQuanLink(null);
+				history.setGoodsId(goodsId);
+				history.setPostPicture(goods.getGoodsThumbUrl());
+				history.setShareImg(jumpLink);
+				List<String> imgList = goods.getGoodsDetailPictures();
+				if (imgList == null) {
+					imgList = new ArrayList<>();
+				}
+				history.setPictures(JsonUtil.getGson().toJson(imgList));
+				shareGoodsService.addShareGoodsHistory(history);
+			}
+		});
+	}
+
+	/**
 	 * 棰勮鍒嗕韩妯℃澘
 	 * 
 	 * @param acceptData

--
Gitblit v1.8.0