From 9a24f2802a3d6fe3e82c05e52f2880d65ad04dcf Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 29 四月 2019 08:59:47 +0800
Subject: [PATCH] Merge branch 'div_develop' into master_develop

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
index 10768b0..31945a2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -5,6 +5,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.yeshi.utils.HttpUtil;
 
 import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
@@ -62,9 +63,25 @@
 		return null;
 	}
 
+	@Transactional
 	@Override
 	public void saveCouponTemplate(Long uid, String template) throws ShareGoodsTextTemplateException {
 		isCouponTemplateRight(template);
+		ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
+		if (old != null) {
+			ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
+			update.setId(old.getId());
+			update.setShareCouponTextTemplate(template);
+			update.setUpdateTime(new Date());
+			shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
+		} else {
+			ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
+			textTemplate.setCreateTime(new Date());
+			textTemplate.setShareCouponTextTemplate(template);
+			textTemplate.setUid(uid);
+			shareGoodsTextTemplateMapper.insertSelective(textTemplate);
+		}
+
 	}
 
 	@Override
@@ -98,25 +115,15 @@
 	}
 
 	@Override
-	public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, boolean hasCoupon) {
-		String 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);
-		if (!hasCoupon) {
-			String token = goods.getCouponLinkTaoToken();
-			if (StringUtil.isNullOrEmpty(token))
-				token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getAuctionUrl());
+	public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, String token,
+			String shortLink, boolean hasCoupon) {
 
+		if (!hasCoupon) {
 			return template.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}", goods.getZkPrice().toString())
 					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{鐭摼}", shortLink)
 					.replace("{娣樺彛浠", "").replace("{搴楅摵绫诲瀷}", goods.getUserType() == 1 ? "澶╃尗浠�"
 							: "娣樺疂浠�");
 		} else {
-			String token = goods.getCouponLinkTaoToken();
-			if (StringUtil.isNullOrEmpty(token))
-				token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getCouponLink());
-
 			return template.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}", goods.getZkPrice().toString())
 					.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{棰嗗埜鐭摼}", shortLink)
 					.replace("{娣樺彛浠", token).replace("{浼樻儬鍒搁潰棰潁", goods.getCouponAmount().toString())

--
Gitblit v1.8.0