From f4a0f2acc63d7785eab108419a4e16f5f688cb95 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 18 一月 2020 12:06:27 +0800
Subject: [PATCH] 用户注册信息

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 1691 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 1,189 insertions(+), 502 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 2006852..40e69b7 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
@@ -11,6 +11,7 @@
 import javax.servlet.http.HttpServletRequest;
 
 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;
@@ -20,6 +21,7 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
 import com.yeshi.fanli.dto.jd.JDCouponInfo;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
 import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
@@ -30,11 +32,16 @@
 import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
 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.system.ConfigKeyEnum;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoLink;
-import com.yeshi.fanli.exception.ShareGoodsException;
+import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
+import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
+import com.yeshi.fanli.exception.share.ShareGoodsException;
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
@@ -45,24 +52,27 @@
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
 import com.yeshi.fanli.service.inter.monitor.MonitorService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
 import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
 import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
-import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
 import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
 import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
+import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
 import com.yeshi.fanli.util.AESUtil;
 import com.yeshi.fanli.util.Constant;
 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.VersionUtil;
+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;
 import com.yeshi.fanli.util.jd.JDApiUtil;
 import com.yeshi.fanli.util.jd.JDUtil;
@@ -72,10 +82,13 @@
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo;
+import com.yeshi.fanli.vo.goods.ShareInfoVO;
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
+@Controller
 @RequestMapping("api/v2/share")
 public class ShareControllerV2 {
 
@@ -113,6 +126,12 @@
 	private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
 
 	@Resource
+	private JDGoodsCacheUtil jdGoodsCacheUtil;
+
+	@Resource
+	private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
+
+	@Resource
 	private RedisManager redisManager;
 
 	@Resource
@@ -139,145 +158,58 @@
 	@Resource
 	private UserTaoLiJinRecordService userTaoLiJinRecordService;
 
+	private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
+			BigDecimal fanliMoney) {
+		List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>();
+		if (!StringUtil.isNullOrEmpty(token))
+			list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "娣樺彛浠�", token, true, false));
+		if (!StringUtil.isNullOrEmpty(link)) {
+			list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_LINK, "閾炬帴",link, true, false));
+		}
+		if (!StringUtil.isNullOrEmpty(inviteCode)) {
+			list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_INVITE_CODE, "閭�璇风爜", inviteCode, false,
+					true));
+		}
+
+		list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_DOWNLOAD_LINK, "涓嬭浇閾炬帴", "http://www.baidu.com", false,
+				true));
+
+		list.add(
+				new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_FANLI_MONEY, "杩斿埄閲戦", "楼 "+fanliMoney, false, true));
+
+		return list;
+	}
 
 	/**
-	 * 鑾峰彇鍒嗕韩璁板綍涓殑鍟嗗搧 鍒嗕韩淇℃伅
 	 * 
 	 * @param acceptData
-	 * @param recordId
-	 * @param out
-	 */
-	@RequestMapping(value = "getShareGoods", method = RequestMethod.POST)
-	public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
-
-		if (recordId == null) {
-			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
-			return;
-		}
-
-		try {
-			JSONArray array = new JSONArray();
-			JSONObject data = new JSONObject();
-
-			List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
-			if (list == null || list.size() == 0) {
-				data.put("title", "鍒嗕韩鍟嗗搧");
-				data.put("count", 0);
-				data.put("result_list", array);
-				out.print(JsonUtil.loadTrueResult(data));
-				return;
-			}
-
-			// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
-			List<TaoBaoGoodsBrief> listTaoKeGoods = null;
-			List<Long> listGid = new ArrayList<Long>();
-			for (UserShareGoodsGroup goodsGroup : list) {
-				CommonGoods commonGoods = goodsGroup.getCommonGoods();
-				if (commonGoods == null || commonGoods.getGoodsType() != Constant.SOURCE_TYPE_TAOBAO) {
-					continue;
-				}
-				listGid.add(commonGoods.getGoodsId());
-			}
-			
-			if (listGid.size() > 0) {
-				try {
-					listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
-				} catch (TaoKeApiException e) {
-					e.printStackTrace();
-				} catch (TaobaoGoodsDownException e) {
-					e.printStackTrace();
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-			}
-
-			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
-					.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
-			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-			BigDecimal shareRate = hongBaoManageService.getShareRate();
-
-			for (UserShareGoodsGroup goodsGroup : list) {
-				CommonGoods commonGoods = goodsGroup.getCommonGoods();
-				if (commonGoods == null) {
-					continue;
-				}
-
-				if (listTaoKeGoods != null && listTaoKeGoods.size() > 0
-						&& commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
-
-					int state = 1; // 榛樿鍋滃敭
-					Long goodsId = commonGoods.getGoodsId();
-					for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
-						Long auctionId = taoKeGoods.getAuctionId();
-						if (goodsId == auctionId || goodsId.equals(auctionId)) {
-							state = 0; // 鍦ㄥ敭
-							break;
-						}
-					}
-					commonGoods.setState(state);
-				}
-
-				// 浠婃棩娴忚璁板綍澶勭悊
-				Date date = new Date();
-				Date browseTime = goodsGroup.getBrowseTime();
-				if (!DateUtil.isSameDay(browseTime, date)) {
-					goodsGroup.setTodayBrowse(0); // 涓嶆槸鍚屼竴澶╂祻瑙堣褰曡缃�0
-				}
-
-				JSONObject dataObject = new JSONObject();
-				dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
-				dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
-				dataObject.put("totalOrder", goodsGroup.getTotalOrder());
-				dataObject.put("totalMoney", "楼" + goodsGroup.getTotalMoney());
-
-				GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate,
-						shareRate);
-				detailVO.setId(commonGoods.getId());
-				dataObject.put("goods", gson.toJson(detailVO));
-				array.add(dataObject);
-			}
-
-			String title = "";
-			UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId);
-			if (userShareGoodsRecord != null) {
-				title = userShareGoodsRecord.getTitle();
-			}
-
-			data.put("title", title);
-			data.put("count", list.size());
-			data.put("result_list", array);
-			out.print(JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触"));
-			e.printStackTrace();
-		}
-	}
-	
-	
-	
-	/**
-	 * 鍒涘缓鍒嗕韩
-	 * @param acceptData
 	 * @param uid
-	 * @param auctionId
+	 *            -鐢ㄦ埛ID
+	 * @param goodsId-鍟嗗搧ID
 	 * @param source
 	 * @param totalNum
 	 * @param goodsType
+	 * @param needGoods
+	 *            -鏄惁闇�瑕佸晢鍝佷俊鎭�
 	 * @param request
 	 * @param out
 	 */
 	@RequestMapping(value = "createShareInfo")
 	public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum,
-			Integer goodsType, HttpServletRequest request, PrintWriter out) {
+			Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) {
 		if (uid == null || uid <= 0) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
 			return;
 		}
-		
-		if (goodsId == null || goodsId <= 0) {
-			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖"));
-			return;
+
+		if (needGoods == null)
+			needGoods = false;
+		try {
+			// 鏃ュ織璁板綍
+			String info = String.format("type=share&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, goodsId, source,
+					goodsType);
+			LogHelper.orderInfo(info);
+		} catch (Exception e) {
 		}
 
 		UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
@@ -286,148 +218,85 @@
 			return;
 		}
 
-		if (goodsType == null) {
-			goodsType = Constant.SOURCE_TYPE_TAOBAO;
+		if (goodsId == null || goodsId <= 0) {
+			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖"));
+			return;
 		}
-		
+
+		// 娣樺疂
+		if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+			createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out);
+			return;
+		}
+
+		// 浜笢
 		if (goodsType == Constant.SOURCE_TYPE_JD) {
-			// 浜笢 
-			createJDShare(acceptData, uid, goodsId, source, out);
-			return;
-		} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
-			// 鎷煎澶� 
-			createPDDShare(acceptData, uid, goodsId, source, out);
+			createJDShare(acceptData, uid, goodsId, source, needGoods, out);
 			return;
 		}
-		
+
+		// 鎷煎澶�
+		if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
+			return;
+		}
+	}
+
+	public static String getERCodeContent(String template, TaoBaoGoodsBrief goods, String token) {
+		return template.replace("[娣樺彛浠", token);
+	}
+
+	/**
+	 * 鍒涘缓娣樺疂鍒嗕韩淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param goodsId
+	 * @param totalNum
+	 * @param source
+	 * @param request
+	 * @param out
+	 */
+	public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
+			Boolean needGoods, HttpServletRequest request, PrintWriter out) {
+		if (needGoods == null)
+			needGoods = false;
 
 		UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
+		UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid);
+		String inviteCode = null;
+		if (userExtraInfo != null) {
+			if (!StringUtil.isNullOrEmpty(userExtraInfo.getInviteCodeVip())) {
+				inviteCode = userExtraInfo.getInviteCodeVip();
+			} else {
+				inviteCode = userExtraInfo.getInviteCode();
+			}
+		}
 		String relationId = null;
 		if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
 				&& extraInfo.getRelationValid() == true)
 			relationId = extraInfo.getRelationId();
-		
-		if (source != null && "taolijin".equals(source)) {
+
+		if (StringUtil.isNullOrEmpty(relationId)) {
+			out.print(JsonUtil.loadFalseResult(3, "娣樺疂鏈巿鏉冿紝璇峰墠寰�\"鎴戠殑\"缁戝畾娣樺疂璐﹀彿"));
+			return;
+		}
+
+		// 娣樼ぜ閲戝垱寤哄垎浜�
+		if (source != null && "taolijin".equals(source)) {// 娣樼ぜ閲戝垎浜垱寤�
 			createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
 			return;
-		}
-		
-		try {
-			TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
-			
-			JSONObject data = new JSONObject();
-			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);
-			if (!StringUtil.isNullOrEmpty(shortLink)) {
-				url = shortLink;
-			}
-
-			data.put("clickUrl", url);
-			data.put("token", taoBaoLink.getTaoToken());
-			data.put("rule", configService.get("share_rule_link_tb"));
-			data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
-
-			String shareText = "";
-			// 鏃犲埜
-			String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
-
-			
-			if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
-				String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
-				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get("goods_share_text_nocoupon");
-				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
-						MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
-			} else// 鏈夊埜
-			{
-				String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
-				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get("goods_share_text_coupon");
-				
-				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
-						.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
-						.replace("{浼樻儬鍒搁潰棰潁",
-								MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
-						.replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
-			}
-			
-			shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
-					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken());
-			data.put("shareText", shareText);
-			String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
-			if (descText.startsWith("\\r\\n"))
-				descText = descText.substring(0);
-			data.put("descText", descText);
-			//
-			String imgs = configService.get("goods_share_notify_imgs");
-			JSONArray array = JSONArray.fromObject(imgs);
-			int p = (int) (array.size() * Math.random());
-			if (p < array.size())
-				data.put("notifyPicture", array.optString(p));
-			data.put("notifyDesc", configService.get("goods_share_notify"));
-
-			// 娣诲姞鍒嗕韩璁板綍
-			BigDecimal rate = hongBaoManageService.getShareRate();
-			BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
-
-			data.put("shareMoney", "楼" + shareMoney.toString());
-			try {
-				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_TAOBAO);
-				data.put("shareId", shareRecord.getRedisKey());
-			} catch (Exception e) {
-				try {
-					LogHelper.errorDetailInfo(e);
-				} catch (Exception e1) {
-					e1.printStackTrace();
-				}
-			}
-			out.print(JsonUtil.loadTrueResult(data));
-
-			final TaoBaoLink taobaoLink = taoBaoLink;
-			// 寮傛鎿嶄綔
-			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(UserShareGoodsHistory.TYPE_TAOBAO);
-					history.setTkCode(taobaoLink.getTaoToken());
-					history.setLink(taobaoLink.getClickUrl());
-					history.setQuanLink(taobaoLink.getCouponLink());
-					history.setGoodsId(taobaoLink.getGoods().getAuctionId());
-					history.setPostPicture(taobaoLink.getGoods().getPictUrl());
-
-					List<String> imgList = taobaoLink.getGoods().getImgList();
-					if (imgList == null) {
-						imgList = new ArrayList<>();
-					}
-					history.setPictures(JsonUtil.getGson().toJson(imgList));
-					shareGoodsService.addShareGoodsHistory(history);
-				}
-			});
+		} else {// 鏅�氬垎浜垱寤�
+			createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid,
+					needGoods, relationId, out);
 			return;
-		} catch (ShareGoodsException e) {
-			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:"+uid+"auctionId:"+goodsId, "");
-			// 鍒嗕韩鍑洪敊鎶ヨ
-			try {
-				monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
-			} catch (Exception e1) {
-			}
-			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
-			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
 		}
+
 	}
-	
-	
+
 	/**
 	 * 娣樼ぜ閲戝垱寤哄垎浜�
+	 * 
 	 * @param uid
 	 * @param auctionId
 	 * @param totalNum
@@ -435,112 +304,128 @@
 	 * @param request
 	 * @param out
 	 */
-	public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, PrintWriter out) {
+	public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
+			PrintWriter out) {
 		try {
-			TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
-			
-			TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
-			
+			TaoBaoGoodsBrief goods = null;
+			try {
+				goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
+			} catch (TaobaoGoodsDownException e2) {
+				e2.printStackTrace();
+			}
+
+			if (goods == null) {
+				out.print(JsonUtil.loadFalseResult("鍟嗗搧宸蹭笅鏋�"));
+				return;
+			}
+
+			if (goods.getTkRate() == null || goods.getTkRate().compareTo(new BigDecimal(0)) <= 0) {
+				// TaoKeApiUtil.specialConvertCoupon(auctionId, app);
+
+			}
+
 			// 璁$畻鎺ㄥ箍绾㈠寘
-			String warningRate = configTaoLiJinService.getValueByKey("warning_value");
+			String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
+			LogHelper.error("鎺ㄥ箍绾㈠寘姣斾緥:" + warningRate);
 			BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
-			
+			LogHelper.error("鎺ㄥ箍绾㈠寘:" + spreadMoney);
 			// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
 			if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
 				out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻"));
 				return;
 			}
-			
-			JSONObject data = new JSONObject();
-			data.put("spreadMoney", " 楼" + spreadMoney.toString());
-			
+
+			ShareInfoVO shareInfo = new ShareInfoVO();
+			shareInfo.setSpreadMoney(" 楼" + spreadMoney.toString());
+
 			String taoLiJinLink = null;
 			Long tljId = null;
 			try {
 				UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods);
 				tljId = record.getId();
 				taoLiJinLink = record.getSendUrl();
-				data.put("tljId", tljId);
-				data.put("surplusMoney", record.getSurplusMoney());
+				shareInfo.setTljId(tljId.toString());
+				shareInfo.setSurplusMoney(record.getSurplusMoney().toString());
 			} catch (UserTaoLiJinRecordException e) {
 				out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
 				return;
 			}
-			
+
 			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
 					Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
-					auctionId + "",AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
+					auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
 			String shortLink = HttpUtil.getShortLink(url);
 			if (!StringUtil.isNullOrEmpty(shortLink)) {
 				url = shortLink;
 			}
-			data.put("clickUrl", url);
-			
-			
+			shareInfo.setClickUrl(url);
+
+			TaoBaoLink taoBaoLink = new TaoBaoLink();
+			taoBaoLink.setCouponLink(taoLiJinLink);
+			taoBaoLink.setClickUrl(taoLiJinLink);
+
 			// 鍒涘缓娣樺彛浠�
 			if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 閫氳繃绔嬪嵆鎺ㄥ箍鏂瑰紡鑾峰彇娣樺彛浠ゆ垚鍔�
 				String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
 				if (!StringUtil.isNullOrEmpty(quanToken)) {
 					taoBaoLink.setTaoToken(quanToken);
 				}
-			} else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) {
-				String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoBaoLink.getClickUrl());
-				if (!StringUtil.isNullOrEmpty(quanToken)) {
-					taoBaoLink.setTaoToken(quanToken);
-				}
 			}
-			data.put("token", taoBaoLink.getTaoToken());
-			data.put("rule", configService.get("share_rule_link_tb"));
-			data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
+			shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+			shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
+			shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500));
 
 			// 鏃犲埜
-			String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
+			String shopType = goods.getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
+					: TaoBaoConstant.SHARE_PRICE_TM;
 			String shareText = "";
-			
-			if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
+
+			if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
 				String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
 				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get("goods_share_text_nocoupon");
-				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
-						MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
+					text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+				shareText = text.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}",
+						MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
 			} else// 鏈夊埜
 			{
 				String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
 				if (StringUtil.isNullOrEmpty(text))
-					text = configTaoLiJinService.getValueByKey("goods_share_text");
-				
-				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
-						.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
-						.replace("{浼樻儬鍒搁潰棰潁",
-								MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
+					text = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
+
+				shareText = text.replace("{鏍囬}", goods.getTitle())
+						.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "")
+						.replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString())
 						.replace("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
-						.replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
+						.replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
 			}
-			
+
 			shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
-					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken());
-			data.put("shareText", shareText);
-			String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
+					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{棰嗗埜鐭摼}", shortLink)
+					.replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+			shareInfo.setShareText(shareText);
+
+			String descText = shareText.replace(goods.getTitle(), "").trim();
 			if (descText.startsWith("\\r\\n"))
 				descText = descText.substring(0);
-			data.put("descText", descText);
-			
-			String imgs = configService.get("goods_share_notify_imgs");
+
+			shareInfo.setDescText(descText);
+
+			String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
 			JSONArray array = JSONArray.fromObject(imgs);
 			int p = (int) (array.size() * Math.random());
-			if (p < array.size())
-				data.put("notifyPicture", array.optString(p));
-			data.put("notifyDesc", configService.get("goods_share_notify"));
+			if (p < array.size()) {
+				shareInfo.setNotifyPicture(array.optString(p));
+			}
+			shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
 
 			// 娣诲姞鍒嗕韩璁板綍
 			BigDecimal rate = hongBaoManageService.getShareRate();
-			BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
-
-			data.put("shareMoney", "楼" + shareMoney.toString());
+			BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
+			shareInfo.setShareMoney("楼" + shareMoney.toString());
 			try {
-				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
-				data.put("shareId", shareRecord.getRedisKey());
+				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
+						Constant.SOURCE_TYPE_TAOBAO, true);
+				shareInfo.setShareId(shareRecord.getRedisKey());
 			} catch (Exception e) {
 				try {
 					LogHelper.errorDetailInfo(e);
@@ -548,7 +433,169 @@
 					e1.printStackTrace();
 				}
 			}
-			out.print(JsonUtil.loadTrueResult(data));
+			out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
+
+			final TaoBaoLink taobaoLink = taoBaoLink;
+			final TaoBaoGoodsBrief finalGoods = goods;
+			// 寮傛鎿嶄綔
+			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(UserShareGoodsHistory.TYPE_TAOBAO);
+					history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
+					history.setLink(taobaoLink.getClickUrl());
+					history.setQuanLink(taobaoLink.getCouponLink());
+					history.setGoodsId(finalGoods.getAuctionId());
+					history.setPostPicture(finalGoods.getPictUrl());
+					history.setShareImg(taobaoLink.getClickUrl());
+					List<String> imgList = finalGoods.getImgList();
+					if (imgList == null) {
+						imgList = new ArrayList<>();
+					}
+					history.setPictures(JsonUtil.getGson().toJson(imgList));
+					shareGoodsService.addShareGoodsHistory(history);
+				}
+			});
+			return;
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, "");
+			out.print(JsonUtil.loadFalseResult("鍒涘缓鍒嗕韩鍑洪敊"));
+			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+		}
+	}
+
+	public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid,
+			boolean needGoods, String relationId, PrintWriter out) {
+		try {
+			ShareInfoVO shareInfo = new ShareInfoVO();
+
+			TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
+
+			if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
+				ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(platform, version);
+				GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
+				shareInfo.setGoodsInfo(goodsInfo);
+			}
+
+			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);
+			if (!StringUtil.isNullOrEmpty(shortLink)) {
+				url = shortLink;
+			}
+
+			shareInfo.setClickUrl(url);
+			shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+			shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
+			shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
+
+			String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
+			List<String> commentTexts = new ArrayList<>();
+			if (!StringUtil.isNullOrEmpty(commentTextStr)) {
+				JSONArray array = JSONArray.fromObject(commentTextStr);
+				for (int i = 0; i < array.size(); i++) {
+					if (StringUtil.isNullOrEmpty(inviteCode)) {
+						if (array.optString(i).contains("[閭�璇风爜]")) {
+							continue;
+						}
+					}
+					if (StringUtil.isNullOrEmpty(inviteCode))
+						commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+								.replace("[娣樺彛浠", shareInfo.getToken()));
+					else
+						commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+								.replace("[閭�璇风爜]", inviteCode).replace("[娣樺彛浠", shareInfo.getToken()));
+				}
+			}
+			shareInfo.setCommentTexts(commentTexts);
+
+			String shareText = "";
+			// 鏃犲埜
+			String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
+					: TaoBaoConstant.SHARE_PRICE_TM;
+
+			if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
+				String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
+				if (StringUtil.isNullOrEmpty(text))
+					text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
+						MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
+			} else// 鏈夊埜
+			{
+				String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
+				if (StringUtil.isNullOrEmpty(text))
+					text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
+
+				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
+						.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
+						.replace("{浼樻儬鍒搁潰棰潁",
+								MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
+						.replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
+			}
+
+			shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
+					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
+					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(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);
+			// 娴嬭瘯
+			// 2.0.2涔嬪墠
+			if (!VersionUtil.greaterThan_2_0_2(platform, version))
+				shareInfo.setClickUrl(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()),
+						taoBaoLink.getGoods(), shareInfo.getToken()));
+
+			shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()),
+					taoBaoLink.getGoods(), shareInfo.getToken()));
+
+			// 鎻愮ず鍥炬枃鍐呭
+			String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+			JSONArray array = JSONArray.fromObject(imgs);
+			int p = (int) (array.size() * Math.random());
+			if (p < array.size()) {
+				shareInfo.setNotifyPicture(array.optString(p));
+			}
+			shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+
+			// 鍒嗕韩閲戦
+			BigDecimal rate = hongBaoManageService.getShareRate();
+			BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
+			shareInfo.setShareMoney("楼" + shareMoney.toString());
+
+			// 鍒嗕韩id
+			try {
+				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
+						Constant.SOURCE_TYPE_TAOBAO, false);
+				shareInfo.setShareId(shareRecord.getRedisKey());
+			} catch (Exception e) {
+				try {
+					LogHelper.errorDetailInfo(e);
+				} catch (Exception e1) {
+					e1.printStackTrace();
+				}
+			}
+
+			// 璁剧疆璇勮鏂囨湰閫夐」
+			shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getToken(), null, inviteCode,
+					TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate())));
+
+			shareInfo.setCommentText(shareInfo.getShareText());
+			shareInfo.setRecommendText(shareInfo.getDescText());
+
+			out.print(JsonUtil.loadTrueResult(
+					JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
 
 			final TaoBaoLink taobaoLink = taoBaoLink;
 			// 寮傛鎿嶄綔
@@ -561,12 +608,11 @@
 					history.setHongbao(shareMoney);
 					history.setCreateTime(new Date());
 					history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
-					history.setTkCode(taobaoLink.getTaoToken());
+					history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
 					history.setLink(taobaoLink.getClickUrl());
 					history.setQuanLink(taobaoLink.getCouponLink());
 					history.setGoodsId(taobaoLink.getGoods().getAuctionId());
 					history.setPostPicture(taobaoLink.getGoods().getPictUrl());
-
 					List<String> imgList = taobaoLink.getGoods().getImgList();
 					if (imgList == null) {
 						imgList = new ArrayList<>();
@@ -577,21 +623,15 @@
 			});
 			return;
 		} catch (ShareGoodsException e) {
-			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:"+uid+"auctionId:"+auctionId, "");
-			// 鍒嗕韩鍑洪敊鎶ヨ
-			try {
-				monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
-			} catch (Exception e1) {
-			}
+			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + " goodsId:" + goodsId, "");
 			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
-			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
 		}
 	}
-	
-	
-	
+
 	/**
 	 * 浜笢鍒涘缓鍒嗕韩
+	 * 
 	 * @param acceptData
 	 * @param uid
 	 * @param goodsId
@@ -600,201 +640,85 @@
 	 * @param request
 	 * @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);
-			}
-			
-			if (jdGoods == null) {
-				out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐宸蹭笅鏋�"));
-				return;
-			}
-			
-
-			JSONObject data = new JSONObject();
-			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 shortLink = HttpUtil.getShortLink(url);
-			if (!StringUtil.isNullOrEmpty(shortLink)) {
-				url = shortLink;
-			}
-
-			data.put("clickUrl", url);
-			data.put("rule", configService.get("share_rule_link_jd"));
-			data.put("pictUrl", jdGoods.getPicUrl());
-
-			String shareText = "";
-			
-			String shopType = "浜笢浠�";
-
-			// 鍒嗕韩妯℃澘
-			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) + "" );
-			}
-			
-			shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-					.replace("{鏈堥攢閲弣", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days()))
-					.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", null);
-			data.put("shareText", shareText);
-			
-			
-			String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
-			if (descText.startsWith("\\r\\n"))
-				descText = descText.substring(0);
-			data.put("descText", descText);
-			//
-			String imgs = configService.get("goods_share_notify_imgs");
-			JSONArray array = JSONArray.fromObject(imgs);
-			int p = (int) (array.size() * Math.random());
-			if (p < array.size())
-				data.put("notifyPicture", array.optString(p));
-			data.put("notifyDesc", configService.get("goods_share_notify_jd"));
-
-			// 娣诲姞鍒嗕韩璁板綍
-			BigDecimal shareRate = hongBaoManageService.getShareRate();
-			BigDecimal shareMoney =JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
-
-			data.put("shareMoney", "楼" + shareMoney.toString());
-			try {
-				ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_JD);
-				data.put("shareId", shareRecord.getRedisKey());
-			} catch (Exception e) {
-				try {
-					LogHelper.errorDetailInfo(e);
-				} catch (Exception e1) {
-					e1.printStackTrace();
-				}
-			}
-			out.print(JsonUtil.loadTrueResult(data));
-
-			// 寮傛鎿嶄綔
-			final JDGoods goods = jdGoods;
-			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_JD);
-					history.setTkCode(null);
-					history.setLink(null);
-					history.setQuanLink(null);
-					history.setGoodsId(goodsId);
-					history.setPostPicture(goods.getPicUrl());
-
-					List<String> imgList = goods.getImageList();
-					if (imgList == null) {
-						imgList = new ArrayList<>();
-					}
-					history.setPictures(JsonUtil.getGson().toJson(imgList));
-					shareGoodsService.addShareGoodsHistory(history);
-				}
-			});
-	}
-	
-	
-	/**
-	 * 鎷煎澶氬垎浜�
-	 * @param acceptData
-	 * @param uid
-	 * @param goodsId
-	 * @param source
-	 * @param out
-	 */
-	public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
-		
-		PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
-		if (goods == null) {
+	public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
+			PrintWriter out) {
+		JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
+		if (jdGoods == null) {
 			out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
 			return;
 		}
 
-		JSONObject data = new JSONObject();
-		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 shortLink = HttpUtil.getShortLink(url);
-		if (!StringUtil.isNullOrEmpty(shortLink)) {
-			url = shortLink;
-		}
+		// String url = String.format("http://%s%s?uid=%s&id=%s",
+		// configService.getH5Host(),
+		// Constant.systemCommonConfig.getShareGoodsPagePathJD(),
+		// AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+		// goodsId + "");
 
-		data.put("clickUrl", url);
-		// 甯姪涓績-浠嬬粛
-		data.put("rule", configService.get("share_rule_link_pdd"));
-		data.put("pictUrl", goods.getGoodsImageUrl());
+		String couponUrl = null;
+		JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
+		if (couponInfo != null) {
+			couponUrl = couponInfo.getLink();
+		}
+		String materialId = "https://item.jd.com/" + goodsId + ".html";
+		String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
+				uid + "");
+
+		ShareInfoVO shareInfo = new ShareInfoVO();
+		shareInfo.setClickUrl(jumpLink);
+		shareInfo.setWxErCode(jumpLink);
+		shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkJD.getKey()));
+		shareInfo.setPictUrl(jdGoods.getPicUrl());
+		shareInfo.setCommentTexts(new ArrayList<>());
+
+		if (needGoods)
+			shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods,
+					hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion())));
 
 		String shareText = "";
-		
-		String shopType = "鎷煎澶氫环";
+		boolean hasCoupon = false;
 
-		// 鏃犲埜
-		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");
-			
-			shareText = text.replace("{鏍囬}", goods.getGoodsName())
-					.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
-					.replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
-					.replace("{浼樻儬鍒镐环}", PinDuoDuoUtil.getQuanPrice(goods) + "" );
+		// 鍒嗕韩妯℃澘
+		ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
+		if (couponInfo == null) { // 鏃犲埜妯℃澘
+			if (textTemplate != null)
+				shareText = textTemplate.getShareJDTextTemplate();
+
+			if (StringUtil.isNullOrEmpty(shareText))
+				shareText = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey());
+		} else { // 鏈夊埜妯℃澘
+			hasCoupon = true;
+			if (textTemplate != null)
+				shareText = textTemplate.getShareJDTextTemplateCoupon();
+
+			if (StringUtil.isNullOrEmpty(shareText))
+				shareText = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey());
 		}
-		
-		shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
-				.replace("{鏈堥攢閲弣", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity()))
-				.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", null);
-		data.put("shareText", shareText);
-		String descText = shareText.replace(goods.getGoodsName(), "").trim();
-		if (descText.startsWith("\\r\\n"))
+		shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink,
+				hasCoupon);
+		shareInfo.setShareText(shareText);
+
+		String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
+		if (descText.startsWith("\\r\\n")) {
 			descText = descText.substring(0);
-		data.put("descText", descText);
-		//
-		String imgs = configService.get("goods_share_notify_imgs");
+		}
+		shareInfo.setDescText(descText);
+
+		String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
 		JSONArray array = JSONArray.fromObject(imgs);
 		int p = (int) (array.size() * Math.random());
-		if (p < array.size())
-			data.put("notifyPicture", array.optString(p));
-		
-		data.put("notifyDesc", configService.get("goods_share_notify_pdd"));
+		if (p < array.size()) {
+			shareInfo.setNotifyPicture(array.optString(p));
+		}
+		shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyJD.getKey()));
 
 		// 娣诲姞鍒嗕韩璁板綍
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		BigDecimal shareMoney =PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
-
-		data.put("shareMoney", "楼" + shareMoney.toString());
+		BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
+		shareInfo.setShareMoney("楼" + shareMoney.toString());
 		try {
-			ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_JD);
-			data.put("shareId", shareRecord.getRedisKey());
+			ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
+					Constant.SOURCE_TYPE_JD, false);
+			shareInfo.setShareId(shareRecord.getRedisKey());
 		} catch (Exception e) {
 			try {
 				LogHelper.errorDetailInfo(e);
@@ -802,9 +726,21 @@
 				e1.printStackTrace();
 			}
 		}
-		out.print(JsonUtil.loadTrueResult(data));
+
+		String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+
+		// 璁剧疆璇勮鏂囨湰閫夐」
+		shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
+				JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate())));
+		
+		shareInfo.setCommentText(shareInfo.getShareText());
+		shareInfo.setRecommendText(shareInfo.getDescText());
+
+		out.print(JsonUtil.loadTrueResult(
+				JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
 
 		// 寮傛鎿嶄綔
+		final JDGoods goods = jdGoods;
 		com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
 			@Override
 			public void run() {
@@ -818,8 +754,144 @@
 				history.setLink(null);
 				history.setQuanLink(null);
 				history.setGoodsId(goodsId);
+				history.setPostPicture(goods.getPicUrl());
+				history.setShareImg(jumpLink);
+
+				List<String> imgList = goods.getImageList();
+				if (imgList == null) {
+					imgList = new ArrayList<>();
+				}
+				history.setPictures(JsonUtil.getGson().toJson(imgList));
+				shareGoodsService.addShareGoodsHistory(history);
+			}
+		});
+	}
+
+	/**
+	 * 鎷煎澶氬垎浜�
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param goodsId
+	 * @param source
+	 * @param out
+	 */
+	public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
+			PrintWriter out) {
+		PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
+			return;
+		}
+
+		// String url = String.format("http://%s%s?uid=%s&id=%s",
+		// configService.getH5Host(),
+		// Constant.systemCommonConfig.getShareGoodsPagePathPDD(),
+		// AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+		// goodsId + "");
+
+		String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
+
+		ShareInfoVO shareInfo = new ShareInfoVO();
+		shareInfo.setClickUrl(jumpLink);
+		shareInfo.setWxErCode(jumpLink);
+		shareInfo.setCommentTexts(new ArrayList<>());
+		shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkPDD.getKey()));
+		shareInfo.setPictUrl(goods.getGoodsImageUrl());
+		if (needGoods) {
+			shareInfo
+					.setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods,
+							new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
+									hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
+									hongBaoManageService.getVIPFanLiRate())));
+		}
+
+		String template = "";
+		boolean hasCoupon = false;
+		ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
+		if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
+			if (textTemplate != null)
+				template = textTemplate.getSharePDDTextTemplate();
+
+			if (StringUtil.isNullOrEmpty(template))
+				template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey());
+		} else {
+			hasCoupon = true;
+			if (textTemplate != null)
+				template = textTemplate.getSharePDDTextTemplateCoupon();
+
+			if (StringUtil.isNullOrEmpty(template))
+				template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey());
+		}
+
+		// 鍒涘缓鍙d护
+		String token = PinDuoDuoApiUtil.createGenerate(goodsId);
+
+		// 鐢熸垚鍒嗕韩鍐呭
+		String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
+				hasCoupon, token);
+		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(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+		JSONArray array = JSONArray.fromObject(imgs);
+		int p = (int) (array.size() * Math.random());
+		if (p < array.size()) {
+			shareInfo.setNotifyPicture(array.optString(p));
+		}
+		shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey()));
+
+		// 娣诲姞鍒嗕韩璁板綍
+		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
+		shareInfo.setShareMoney("楼" + shareMoney.toString());
+
+		try {
+			ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
+					Constant.SOURCE_TYPE_PDD, false);
+			shareInfo.setShareId(shareRecord.getRedisKey());
+		} catch (Exception e) {
+			try {
+				LogHelper.errorDetailInfo(e);
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+		}
+
+		String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+
+		// 璁剧疆璇勮鏂囨湰閫夐」
+		shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
+				PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate())));
+		
+		shareInfo.setCommentText(shareInfo.getShareText());
+		shareInfo.setRecommendText(shareInfo.getDescText());
+
+		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_PDD);
+				history.setTkCode(null);
+				history.setLink(null);
+				history.setQuanLink(null);
+				history.setGoodsId(goodsId);
 				history.setPostPicture(goods.getGoodsImageUrl());
-				
+				history.setShareImg(jumpLink);
 				List<String> imgList = null;
 				String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
 				if (goodsGalleryUrls != null) {
@@ -832,7 +904,622 @@
 				shareGoodsService.addShareGoodsHistory(history);
 			}
 		});
-}
-	
+	}
+
+	/**
+	 * 棰勮鍒嗕韩妯℃澘
+	 * 
+	 * @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_JD) {
+			createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
+			return;
+		}
+
+		if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			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 couponUrl = null;
+		JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
+		if (couponInfo != null) {
+			couponUrl = couponInfo.getLink();
+		}
+		String materialId = "https://item.jd.com/" + goodsId + ".html";
+		String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
+				uid + "");
+
+		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);
+
+		String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
+
+		// 鍒涘缓鍙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", new Date());
+				} else {
+					template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
+					if (StringUtil.isNullOrEmpty(template))
+						template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
+				}
+
+			} else {
+				template = shareGoodsTextTemplateService.getCommonTemplate(uid);
+				if (StringUtil.isNullOrEmpty(template))
+					template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+			}
+		} 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(ConfigKeyEnum.goodsShareTextCouponJD.getKey());
+				}
+			} else {
+				if (textTemplate != null) {
+					template = textTemplate.getShareJDTextTemplate();
+				}
+
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey());
+				}
+			}
+		} 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(ConfigKeyEnum.goodsShareTextCouponPDD.getKey());
+				}
+			} else {
+				if (textTemplate != null) {
+					template = textTemplate.getSharePDDTextTemplate();
+				}
+
+				if (StringUtil.isNullOrEmpty(template)) {
+					template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey());
+				}
+			}
+		}
+		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", new Date())));
+			} else {
+				out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
+			}
+		} else if (goodsType == Constant.SOURCE_TYPE_JD) {
+			out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey())));
+		} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey())));
+		}
+	}
+
+	/**
+	 * 淇濆瓨妯℃澘
+	 * 
+	 * @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
+	 * @param recordId
+	 * @param out
+	 */
+	@RequestMapping(value = "getShareGoods")
+	public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
+
+		if (recordId == null) {
+			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
+			return;
+		}
+
+		JSONArray array = new JSONArray();
+		JSONObject data = new JSONObject();
+
+		List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
+		if (list == null || list.size() == 0) {
+			data.put("title", "鍒嗕韩鍟嗗搧");
+			data.put("count", 0);
+			data.put("result_list", array);
+			out.print(JsonUtil.loadTrueResult(data));
+			return;
+		}
+
+		// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+		List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+		List<Long> listGid = new ArrayList<Long>();
+		for (UserShareGoodsGroup goodsGroup : list) {
+			CommonGoods commonGoods = goodsGroup.getCommonGoods();
+			Integer goodsType = commonGoods.getGoodsType();
+			if (commonGoods == null || goodsType == null || goodsType != Constant.SOURCE_TYPE_TAOBAO) {
+				continue;
+			}
+			listGid.add(commonGoods.getGoodsId());
+		}
+
+		if (listGid.size() > 0) {
+			try {
+				listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+			} catch (TaoKeApiException e) {
+				e.printStackTrace();
+			} catch (TaobaoGoodsDownException e) {
+				e.printStackTrace();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+
+		ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
+				acceptData.getVersion());
+
+		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+		for (UserShareGoodsGroup goodsGroup : list) {
+			CommonGoods commonGoods = goodsGroup.getCommonGoods();
+			if (commonGoods == null) {
+				continue;
+			}
+
+			// 楠岃瘉娣樺疂鍟嗗搧鏄惁鍦ㄥ敭
+			Integer goodsType = commonGoods.getGoodsType();
+			if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null
+					&& goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+				int state = 1; // 榛樿鍋滃敭
+				Long goodsId = commonGoods.getGoodsId();
+				for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+					Long auctionId = taoKeGoods.getAuctionId();
+					if (goodsId == auctionId || goodsId.equals(auctionId)) {
+						state = 0; // 鍦ㄥ敭
+						break;
+					}
+				}
+				commonGoods.setState(state);
+			}
+
+			// 浠婃棩娴忚璁板綍澶勭悊
+			Date date = new Date();
+			Date browseTime = goodsGroup.getBrowseTime();
+			if (!DateUtil.isSameDay(browseTime, date)) {
+				goodsGroup.setTodayBrowse(0); // 涓嶆槸鍚屼竴澶╂祻瑙堣褰曡缃�0
+			}
+
+			JSONObject dataObject = new JSONObject();
+			dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
+			dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
+			dataObject.put("totalOrder", goodsGroup.getTotalOrder());
+			dataObject.put("totalMoney", "楼" + goodsGroup.getTotalMoney());
+
+			GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
+			detailVO.setId(commonGoods.getId());
+			dataObject.put("goods", gson.toJson(detailVO));
+			array.add(dataObject);
+		}
+
+		String title = "";
+		UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId);
+		if (userShareGoodsRecord != null) {
+			title = userShareGoodsRecord.getTitle();
+		}
+
+		data.put("title", title);
+		data.put("count", list.size());
+		data.put("result_list", array);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
 
 }

--
Gitblit v1.8.0