From 1529cee74fe559806de1dbd616bc86e1e860dac5 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 03 一月 2020 15:08:35 +0800
Subject: [PATCH] 转链文本中的淘宝,京东链接

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
index a59e137..8517d29 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -50,6 +50,7 @@
 import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
 import com.yeshi.fanli.util.AESUtil;
 import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.ImageUtil;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
@@ -95,6 +96,7 @@
 
 	@Resource
 	private IntegralGetService integralGetService;
+	
 
 	@Override
 	public int insert(UserShareGoodsRecord record) {
@@ -329,7 +331,7 @@
 	 * @param userShareGoodsRecord
 	 * @param listGoods
 	 */
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
 			throws UserShareGoodsRecordException {
 		// 鍒嗕韩璁板綍
@@ -372,7 +374,7 @@
 	 * @param userShareGoodsRecord
 	 * @param listGoods
 	 */
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord,
 			List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
 
@@ -486,7 +488,7 @@
 		InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
 
 		FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
-				"sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
+				FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
 
 		return shareImg;
 	}
@@ -1021,9 +1023,60 @@
 
 		InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
 		FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
-				"sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
+				FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
 
 		return shareImg;
 	}
+	
+	@Override
+	public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException {
+		if (goods == null || uid == null) {
+			throw new UserShareGoodsRecordException(1, "鍙傛暟缂哄け");
+		}
 
+		UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
+		userShareGoodsRecord.setShareState(1);
+		userShareGoodsRecord.setUid(uid);
+		userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
+		CommonGoods resultCommonGoods = null;
+		try {
+			resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(goods);
+		} catch (CommonGoodsException e) {
+			throw new UserShareGoodsRecordException(1, "鍟嗗搧瀛樺叆澶辫触");
+		}
+
+		UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),uid);
+		if (singleGoods != null) {
+			// 鍗曚釜鍟嗗搧澶氭鍒嗕韩
+			userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
+			userShareGoodsRecord.setId(singleGoods.getRecordId());
+			userShareGoodsRecord.setUpdateTime(new Date());
+			userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
+
+			// 鏈�鏂板晢鍝�
+			singleGoods.setUpdateTime(new Date());
+			userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
+		} else {
+			// 鍗曚釜鍟嗗搧绗竴娆″垎浜�
+			Date date = new Date();
+			userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
+			userShareGoodsRecord.setCreateTime(date);
+			userShareGoodsRecord.setUpdateTime(date);
+			userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
+
+			singleGoods = new UserShareGoodsGroup();
+			singleGoods.setTotalOrder(0);
+			singleGoods.setTotalBrowse(0);
+			singleGoods.setTodayBrowse(0);
+			singleGoods.setTotalMoney(new BigDecimal(0));
+			singleGoods.setCreateTime(date);
+			singleGoods.setUpdateTime(date);
+			singleGoods.setCommonGoods(resultCommonGoods);
+			singleGoods.setRecordId(userShareGoodsRecord.getId());
+			userShareGoodsGroupService.insertSelective(singleGoods);
+		}
+	}
+	
+	
+	
 }

--
Gitblit v1.8.0