From 09476adf2ae2bcc2f6685dafe4707938fd82bc78 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 25 七月 2019 12:19:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java |  114 +++++++++++++++++++++++---------------------------------
 1 files changed, 47 insertions(+), 67 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 d6ef71e..bb251d5 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
@@ -71,7 +71,6 @@
 import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
 import com.yeshi.fanli.util.factory.MonitorFactory;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
-import com.yeshi.fanli.util.jd.JDApiUtil;
 import com.yeshi.fanli.util.jd.JDUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
@@ -533,22 +532,15 @@
 	 * @param out
 	 */
 	public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
-
-		JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
-		if (jdGoods == null) {
-			jdGoods = JDApiUtil.getGoodsDetail(goodsId);
-		}
-
+		JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
 		if (jdGoods == null) {
 			out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐宸蹭笅鏋�"));
 			return;
 		}
 
-		// TODO
-		ShareInfoVO shareInfo = new ShareInfoVO();
-		String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
-				goodsId + "", Constant.SOURCE_TYPE_JD);
+		String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+				goodsId + "");
 
 		// 鍒哥煭杩炴帴
 		String shortLink = HttpUtil.getShortLink(url);
@@ -556,37 +548,31 @@
 			url = shortLink;
 		}
 
+		ShareInfoVO shareInfo = new ShareInfoVO();
 		shareInfo.setClickUrl(url);
 		shareInfo.setRule(configService.get("share_rule_link_jd"));
 		shareInfo.setPictUrl(jdGoods.getPicUrl());
 
 		String shareText = "";
-		String shopType = "浜笢浠�";
-
+		boolean hasCoupon = false;
 		// 鍒嗕韩妯℃澘
 		JDCouponInfo couponInfo = jdGoods.getCouponInfo();
-		if (couponInfo == null) {
-			String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
-			if (StringUtil.isNullOrEmpty(text)) {
-				text = configService.get("goods_share_text_nocoupon");
-			}
-			shareText = text.replace("{鏍囬}", jdGoods.getSkuName()).replace("{鍟嗗搧鍘熶环}",
-					MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "");
-		} else// 鏈夊埜
-		{
-			String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
-			if (StringUtil.isNullOrEmpty(text))
-				text = configService.get("goods_share_text_coupon");
-
-			shareText = text.replace("{鏍囬}", jdGoods.getSkuName())
-					.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "")
-					.replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "")
-					.replace("{浼樻儬鍒镐环}", JDUtil.getQuanPrice(jdGoods) + "");
+		ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
+		if (couponInfo == null) { // 鏃犲埜妯℃澘
+			if (textTemplate != null) 
+				shareText = textTemplate.getShareJDTextTemplate();
+			
+			if (StringUtil.isNullOrEmpty(shareText))
+				shareText = configService.get("goods_share_text_nocoupon_jd");
+		} else { // 鏈夊埜妯℃澘
+			hasCoupon = true;
+			if (textTemplate != null)
+				shareText = textTemplate.getShareJDTextTemplateCoupon();
+			
+			if (StringUtil.isNullOrEmpty(shareText))
+				shareText = configService.get("goods_share_text_coupon_jd");
 		}
-
-		shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-				.replace("{鏈堥攢閲弣", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{棰嗗埜鐭摼}", shortLink)
-				.replace("{娣樺彛浠", null);
+		shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, shortLink, hasCoupon);
 		shareInfo.setShareText(shareText);
 
 		String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
@@ -595,7 +581,6 @@
 		}
 		shareInfo.setDescText(descText);
 
-		//
 		String imgs = configService.get("goods_share_notify_imgs");
 		JSONArray array = JSONArray.fromObject(imgs);
 		int p = (int) (array.size() * Math.random());
@@ -658,55 +643,50 @@
 	 * @param out
 	 */
 	public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
-		PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
+		PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
 		if (goods == null) {
 			out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
 			return;
 		}
 
-		ShareInfoVO shareInfo = new ShareInfoVO();
-
-		// TODO
-		String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
-				goodsId + "", Constant.SOURCE_TYPE_PDD);
+		String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+				goodsId + "");
 
 		String shortLink = HttpUtil.getShortLink(url);
 		if (!StringUtil.isNullOrEmpty(shortLink)) {
 			url = shortLink;
 		}
-
+		
+		ShareInfoVO shareInfo = new ShareInfoVO();
 		shareInfo.setClickUrl(url);
 		shareInfo.setRule(configService.get("share_rule_link_pdd"));
 		shareInfo.setPictUrl(goods.getGoodsImageUrl());
 
-		String shareText = "";
-		String shopType = "鎷煎澶氫环";
-
-		// 鏃犲埜
+		String template = "";
+		boolean hasCoupon = false;
+		ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
 		if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
-			String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
-			if (StringUtil.isNullOrEmpty(text))
-				text = configService.get("goods_share_text_nocoupon");
-			shareText = text.replace("{鏍囬}", goods.getGoodsName()).replace("{鍟嗗搧鍘熶环}",
-					MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "");
-		} else// 鏈夊埜
-		{
-			String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
-			if (StringUtil.isNullOrEmpty(text))
-				text = configService.get("goods_share_text_coupon");
+			if (textTemplate != null)
+				template = textTemplate.getSharePDDTextTemplate();
 
-			shareText = text.replace("{鏍囬}", goods.getGoodsName())
-					.replace("{鍟嗗搧鍘熶环}",
-							MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
-					.replace("{浼樻儬鍒搁潰棰潁",
-							MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
-					.replace("{浼樻儬鍒镐环}", PinDuoDuoUtil.getQuanPrice(goods) + "");
+			if (StringUtil.isNullOrEmpty(template))
+				template = configService.get("goods_share_text_nocoupon_pdd");
+		} else {
+			hasCoupon = true;
+			if (textTemplate != null)
+				template = textTemplate.getSharePDDTextTemplateCoupon();
+			
+			if (StringUtil.isNullOrEmpty(template))
+				template = configService.get("goods_share_text_coupon_pdd");
 		}
 
-		shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-				.replace("{鏈堥攢閲弣", goods.getSalesTip()).replace("{棰嗗埜鐭摼}", shortLink)
-				.replace("{娣樺彛浠", null);
+		// 鍒涘缓鍙d护
+		String token = PinDuoDuoApiUtil.createGenerate(goodsId);
+				
+		// 鐢熸垚鍒嗕韩鍐呭
+		String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
+						hasCoupon, token);
 		shareInfo.setShareText(shareText);
 
 		String descText = shareText.replace(goods.getGoodsName(), "").trim();

--
Gitblit v1.8.0