From de10879ac00f9c94dc02cada9a8a6117a8d81caf Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 19 七月 2019 15:40:01 +0800
Subject: [PATCH] 拼多多 京东分享模板兼容

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java |  547 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 526 insertions(+), 21 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 954ebb8..753465e 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
@@ -13,6 +13,7 @@
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.yeshi.utils.DateUtil;
 import org.yeshi.utils.HttpUtil;
 import org.yeshi.utils.JsonUtil;
@@ -31,10 +32,13 @@
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoLink;
+import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
 import com.yeshi.fanli.exception.ShareGoodsException;
+import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
@@ -61,6 +65,9 @@
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TaoBaoConstant;
+import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
+import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
 import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
 import com.yeshi.fanli.util.factory.MonitorFactory;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -113,6 +120,12 @@
 
 	@Resource
 	private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
+
+	@Resource
+	private JDGoodsCacheUtil jdGoodsCacheUtil;
+
+	@Resource
+	private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
 
 	@Resource
 	private RedisManager redisManager;
@@ -187,10 +200,10 @@
 			return;
 		}
 	}
-	
 
 	/**
 	 * 鍒涘缓娣樺疂鍒嗕韩淇℃伅
+	 * 
 	 * @param acceptData
 	 * @param uid
 	 * @param goodsId
@@ -212,7 +225,7 @@
 			out.print(JsonUtil.loadFalseResult(3, "娣樺疂鏈巿鏉冿紝璇峰墠寰�\"鎴戠殑\"缁戝畾娣樺疂璐﹀彿"));
 			return;
 		}
-		
+
 		// 娣樼ぜ閲戝垱寤哄垎浜�
 		if (source != null && "taolijin".equals(source)) {
 			createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
@@ -221,7 +234,7 @@
 
 		try {
 			ShareInfoVO shareInfo = new ShareInfoVO();
-			
+
 			TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
 
 			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
@@ -264,16 +277,15 @@
 			shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
 					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
 					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken());
-		
+
 			shareInfo.setShareText(shareText);
-			
+
 			String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
 			if (descText.startsWith("\\r\\n")) {
 				descText = descText.substring(0);
 			}
 			shareInfo.setDescText(descText);
-			
-			
+
 			// 鎻愮ず鍥炬枃鍐呭
 			String imgs = configService.get("goods_share_notify_imgs");
 			JSONArray array = JSONArray.fromObject(imgs);
@@ -287,7 +299,7 @@
 			BigDecimal rate = hongBaoManageService.getShareRate();
 			BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
 			shareInfo.setShareMoney("楼" + shareMoney.toString());
-			
+
 			// 鍒嗕韩id
 			try {
 				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
@@ -300,7 +312,7 @@
 					e1.printStackTrace();
 				}
 			}
-			
+
 			out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
 
 			final TaoBaoLink taobaoLink = taoBaoLink;
@@ -410,7 +422,7 @@
 			shareInfo.setToken(taoBaoLink.getTaoToken());
 			shareInfo.setRule(configService.get("share_single_goods_rule"));
 			shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
-			
+
 			// 鏃犲埜
 			String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
 			String shareText = "";
@@ -439,12 +451,11 @@
 					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
 					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken());
 			shareInfo.setShareText(shareText);
-			
-			
+
 			String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
 			if (descText.startsWith("\\r\\n"))
 				descText = descText.substring(0);
-			
+
 			shareInfo.setDescText(descText);
 
 			String imgs = configService.get("goods_share_notify_imgs");
@@ -548,7 +559,6 @@
 		shareInfo.setClickUrl(url);
 		shareInfo.setRule(configService.get("share_rule_link_jd"));
 		shareInfo.setPictUrl(jdGoods.getPicUrl());
-		
 
 		String shareText = "";
 		String shopType = "浜笢浠�";
@@ -584,7 +594,7 @@
 			descText = descText.substring(0);
 		}
 		shareInfo.setDescText(descText);
-		
+
 		//
 		String imgs = configService.get("goods_share_notify_imgs");
 		JSONArray array = JSONArray.fromObject(imgs);
@@ -593,7 +603,6 @@
 			shareInfo.setNotifyPicture(array.optString(p));
 		}
 		shareInfo.setNotifyDesc(configService.get("goods_share_notify_jd"));
-		
 
 		// 娣诲姞鍒嗕韩璁板綍
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
@@ -656,7 +665,7 @@
 		}
 
 		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),
@@ -699,13 +708,13 @@
 				.replace("{鏈堥攢閲弣", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{棰嗗埜鐭摼}", shortLink)
 				.replace("{娣樺彛浠", null);
 		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.get("goods_share_notify_imgs");
 		JSONArray array = JSONArray.fromObject(imgs);
@@ -714,13 +723,12 @@
 			shareInfo.setNotifyPicture(array.optString(p));
 		}
 		shareInfo.setNotifyDesc(configService.get("goods_share_notify_pdd"));
-		
 
 		// 娣诲姞鍒嗕韩璁板綍
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
 		BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
 		shareInfo.setShareMoney("楼" + shareMoney.toString());
-		
+
 		try {
 			ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
 					Constant.SOURCE_TYPE_JD);
@@ -765,6 +773,503 @@
 	}
 
 	/**
+	 * 棰勮鍒嗕韩妯℃澘
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param template
+	 * @param goodsId
+	 * @param hasCoupon
+	 * @param out
+	 */
+	@RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST)
+	public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, Long goodsId,
+			Long tljId, Boolean hasCoupon, PrintWriter out) {
+		if (uid == null) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (goodsId == null) {
+			out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧ID涓嶈兘涓虹┖"));
+			return;
+		}
+
+		if (goodsType == null || goodsType > 3 || goodsType < 1) {
+			out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			createTaoBaoViewText(goodsType, uid, template, goodsId, tljId, hasCoupon, out);
+			return;
+		}
+
+		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
+			return;
+		}
+
+		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
+			return;
+		}
+	}
+
+	/**
+	 * 鍒涘缓娣樺疂鍒嗕韩妯℃澘
+	 * 
+	 * @param uid
+	 * @param template
+	 * @param goodsType
+	 * @param goodsId
+	 * @param tljId
+	 * @param hasCoupon
+	 * @param out
+	 */
+	public void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId,
+			Boolean hasCoupon, PrintWriter out) {
+		TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId);
+		if (goods == null)
+			try {
+				goods = redisManager.getTaoBaoGoodsBrief(goodsId);
+			} catch (TaobaoGoodsDownException e) {
+				goods = null;
+			}
+
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(template)) {
+			template = getShareTemplate(goodsType, uid, hasCoupon, tljId);
+		}
+
+		// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
+		if (hasCoupon) {
+			// 鏈夊埜鍟嗗搧
+			if (tljId != null) {
+				try {
+					shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
+				} catch (ShareGoodsTextTemplateException e) {
+					out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+					return;
+				}
+			} else {
+				try {
+					shareGoodsTextTemplateService.isCouponTemplateRight(template);
+				} catch (ShareGoodsTextTemplateException e) {
+					out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+					return;
+				}
+			}
+		} else {
+			// 鏅�氬晢鍝�
+			try {
+				shareGoodsTextTemplateService.isCommonTemplateRight(template);
+			} catch (ShareGoodsTextTemplateException e) {
+				out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+				return;
+			}
+		}
+
+		String url = null;
+		if (tljId != null) {
+			UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId);
+			if (userTaoLiJinRecord == null) {
+				out.print(JsonUtil.loadFalseResult(5, "娣樼ぜ閲戦鍙栭摼鎺ヤ笉瀛樺湪"));
+				return;
+			}
+			url = userTaoLiJinRecord.getSendUrl();
+		} else {
+			url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+					Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+					goods.getAuctionId() + "");
+		}
+
+		String shortLink = HttpUtil.getShortLink(url);
+
+		// 鏌ヨ鏄惁鏈夊垎浜�
+		UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId());
+		String token = "";
+		if (userShareHistory != null) {
+			token = userShareHistory.getTkCode();
+		}
+
+		if (StringUtil.isNullOrEmpty(token)) {
+			TaoKeAppInfo app = new TaoKeAppInfo();
+			app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
+			app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
+			app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+			app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
+			TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
+			if (goodsLink != null)
+				token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
+						StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl()
+								: goodsLink.getCouponLink());
+		}
+		String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink,
+				hasCoupon, tljId);
+		JSONObject data = new JSONObject();
+		data.put("content", content);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鍒涘缓浜笢鍒嗕韩妯℃澘
+	 * 
+	 * @param uid
+	 * @param template
+	 * @param goodsType
+	 * @param goodsId
+	 * @param tljId
+	 * @param hasCoupon
+	 * @param out
+	 */
+	public void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
+			PrintWriter out) {
+		JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(template)) {
+			template = getShareTemplate(goodsType, uid, hasCoupon, null);
+		}
+
+		// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
+		if (hasCoupon) {
+			// 鏈夊埜鍟嗗搧
+			try {
+				shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
+			} catch (ShareGoodsTextTemplateException e) {
+				out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+				return;
+			}
+
+		} else {
+			// 鏅�氬晢鍝�
+			try {
+				shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
+			} catch (ShareGoodsTextTemplateException e) {
+				out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+				return;
+			}
+		}
+
+		String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+				goodsId + "");
+		String shortLink = HttpUtil.getShortLink(url);
+
+		String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
+				hasCoupon);
+		JSONObject data = new JSONObject();
+		data.put("content", content);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鍒涘缓浜笢鍒嗕韩妯℃澘
+	 * 
+	 * @param uid
+	 * @param template
+	 * @param goodsType
+	 * @param goodsId
+	 * @param tljId
+	 * @param hasCoupon
+	 * @param out
+	 */
+	public void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
+			PrintWriter out) {
+		PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(template)) {
+			template = getShareTemplate(goodsType, uid, hasCoupon, null);
+		}
+
+		// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
+		if (hasCoupon) {
+			// 鏈夊埜鍟嗗搧
+			try {
+				shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
+			} catch (ShareGoodsTextTemplateException e) {
+				out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+				return;
+			}
+
+		} else {
+			// 鏅�氬晢鍝�
+			try {
+				shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
+			} catch (ShareGoodsTextTemplateException e) {
+				out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+				return;
+			}
+		}
+
+		// 鍒涘缓h5杩炴帴
+		String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+				goodsId + "");
+		String shortLink = HttpUtil.getShortLink(url);
+
+		// 鍒涘缓鍙d护
+		String token = PinDuoDuoApiUtil.createGenerate(goodsId);
+
+		// 鐢熸垚鍒嗕韩鍐呭
+		String content = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
+				hasCoupon, token);
+
+		JSONObject data = new JSONObject();
+		data.put("content", content);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鑾峰彇鍒嗕韩妯℃澘
+	 * 
+	 * @param uid
+	 * @param hasCoupon
+	 * @param tljId
+	 * @return
+	 */
+	private String getShareTemplate(int goodsType, Long uid, boolean hasCoupon, Long tljId) {
+		String template = "";
+		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			if (hasCoupon) {
+				if (tljId != null) {
+					template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
+					if (StringUtil.isNullOrEmpty(template))
+						template = configTaoLiJinService.getValueByKey("goods_share_text");
+				} else {
+					template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
+					if (StringUtil.isNullOrEmpty(template))
+						template = configService.get("goods_share_text_coupon");
+				}
+
+			} else {
+				template = shareGoodsTextTemplateService.getCommonTemplate(uid);
+				if (StringUtil.isNullOrEmpty(template))
+					template = configService.get("goods_share_text_nocoupon");
+			}
+		} else if (goodsType == Constant.SOURCE_TYPE_JD) {
+			ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
+			if (hasCoupon) {
+				if (textTemplate != null) {
+					template = textTemplate.getShareJDTextTemplateCoupon();
+				}
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get("goods_share_text_coupon_jd");
+				}
+			} else {
+				if (textTemplate != null) {
+					template = textTemplate.getShareJDTextTemplate();
+				}
+
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get("goods_share_text_nocoupon_jd");
+				}
+			}
+		} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
+			if (hasCoupon) {
+				if (textTemplate != null) {
+					template = textTemplate.getSharePDDTextTemplateCoupon();
+				}
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get("goods_share_text_coupon_pdd");
+				}
+			} else {
+				if (textTemplate != null) {
+					template = textTemplate.getSharePDDTextTemplate();
+				}
+
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get("goods_share_text_nocoupon_pdd");
+				}
+			}
+		}
+		return template;
+	}
+
+	/**
+	 * 鑾峰彇鍒嗕韩妯℃澘
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param hasCoupon
+	 * @param out
+	 */
+	@RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST)
+	public void getShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
+			PrintWriter out) {
+		if (uid == null) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (hasCoupon == null) {
+			out.print(JsonUtil.loadFalseResult(1, "鏄惁鏈夊埜瀛楁涓虹┖"));
+			return;
+		}
+
+		JSONObject data = new JSONObject();
+		data.put("template", getShareTemplate(goodsType, uid, hasCoupon, tljId));
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鑾峰彇鍒嗕韩妯℃澘缂栬緫瑙勫垯
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
+	public void getShareTextTemplateRules(AcceptData acceptData, Integer goodsType, Long tljId, PrintWriter out) {
+		if (goodsType == null || goodsType > 3 || goodsType < 1) {
+			out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			if (tljId != null) {
+				out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules")));
+			} else {
+				out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
+			}
+		} else if (goodsType == Constant.SOURCE_TYPE_JD) {
+			out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_jd")));
+		} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_pdd")));
+		}
+	}
+
+	/**
+	 * 淇濆瓨妯℃澘
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param hasCoupon
+	 * @param template
+	 * @param out
+	 */
+	@RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST)
+	public void saveShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
+			String template, PrintWriter out) {
+		if (StringUtil.isNullOrEmpty(template)) {
+			out.print(JsonUtil.loadFalseResult(1, "鍒嗕韩妯℃澘涓虹┖"));
+			return;
+		}
+
+		if (goodsType == null || goodsType > 3 || goodsType < 1) {
+			out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		try {
+			if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+				// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
+				if (hasCoupon) {
+					// 鏈夊埜鍟嗗搧
+					if (tljId != null) {
+						shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
+						shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template);
+					} else {
+						shareGoodsTextTemplateService.isCouponTemplateRight(template);
+						shareGoodsTextTemplateService.saveCouponTemplate(uid, template);
+					}
+				} else {
+					// 鏅�氬晢鍝�
+					shareGoodsTextTemplateService.isCommonTemplateRight(template);
+					shareGoodsTextTemplateService.saveCommonTemplate(uid, template);
+				}
+			} else if (goodsType == Constant.SOURCE_TYPE_JD) {
+				if (hasCoupon) {
+					shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
+					shareGoodsTextTemplateService.saveCouponTemplateJD(uid, template);
+				} else {
+					shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
+					shareGoodsTextTemplateService.saveCommonTemplateJD(uid, template);
+					out.print(JsonUtil.loadTrueResult(""));
+				}
+			} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
+				if (hasCoupon) {
+					shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
+					shareGoodsTextTemplateService.saveCouponTemplatePDD(uid, template);
+				} else {
+					shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
+					shareGoodsTextTemplateService.saveCommonTemplatePDD(uid, template);
+					out.print(JsonUtil.loadTrueResult(""));
+				}
+			}
+		} catch (ShareGoodsTextTemplateException e) {
+			out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+			return;
+		}
+		out.print(JsonUtil.loadTrueResult(""));
+	}
+
+	/**
+	 * 杩樺師妯℃澘
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param hasCoupon  -鏄惁鏈夊埜
+	 * @param out
+	 */
+	@RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST)
+	public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon,
+			Integer goodsType, PrintWriter out) {
+		if (uid == null) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (goodsType == null || goodsType > 3 || goodsType < 1) {
+			out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		 if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			if (hasCoupon) {
+				if (tljId != null) {
+					shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
+				} else {
+					shareGoodsTextTemplateService.resetCouponTemplate(uid);
+				}
+			} else {
+				shareGoodsTextTemplateService.resetCommonTemplate(uid);
+			}
+		 } else  if (goodsType == Constant.SOURCE_TYPE_JD) {
+			 if (hasCoupon) {
+				shareGoodsTextTemplateService.resetCouponTemplateJD(uid);
+			} else {
+				shareGoodsTextTemplateService.resetCommonTemplateJD(uid);
+			}
+		 } else  if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			 if (hasCoupon) {
+				shareGoodsTextTemplateService.resetCouponTemplatePDD(uid);
+			} else {
+				shareGoodsTextTemplateService.resetCommonTemplatePDD(uid);
+			}
+		 }
+		 
+		 
+		if (goodsId != null) {
+			viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out);
+			return;
+		}
+		out.print(JsonUtil.loadTrueResult(""));
+	}
+
+	/**
 	 * 鑾峰彇鍒嗕韩璁板綍涓殑鍟嗗搧 鍒嗕韩淇℃伅
 	 * 
 	 * @param acceptData

--
Gitblit v1.8.0