From aa784ab65cc24caf45a4c38af7e5fdeb526eb393 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 14 五月 2019 14:49:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 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 5f23df9..3a17f20 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
@@ -26,6 +26,7 @@
 import com.google.gson.GsonBuilder;
 import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
 import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper;
+import com.yeshi.fanli.dto.share.ShareInfoDTO;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
@@ -230,6 +231,35 @@
 		singleGoodsShare(userShareGoodsRecord, goodsBrief);
 	}
 
+	
+	@Override
+	public Long saveSingleShareRecord(Long uid, Long auctionId) throws UserShareGoodsRecordException {
+
+		if (auctionId == null) {
+			throw new UserShareGoodsRecordException(1, "鍒嗕韩鍟嗗搧涓嶈兘涓虹┖");
+		}
+
+		if (uid == null) {
+			throw new UserShareGoodsRecordException(1, "鐢ㄦ埛ID涓嶈兘涓虹┖");
+		}
+
+		TaoBaoGoodsBrief goodsBrief = null;
+		try {
+			goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
+		} catch (TaobaoGoodsDownException e) {
+			throw new UserShareGoodsRecordException(1, "鍟嗗搧宸蹭笅鏋�");
+		}
+
+		UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
+		userShareGoodsRecord.setUid(uid);
+		userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
+		userShareGoodsRecord.setShareState(0);
+		// 鍗曚釜鍟嗗搧鍒嗕韩
+		singleGoodsShare(userShareGoodsRecord, goodsBrief);
+		
+		return userShareGoodsRecord.getId();
+	}
+	
 	@Override
 	public void save(Long uid, ShareSourceTypeEnum source, String title, TaoBaoGoodsBrief taoBaoGoodsBrief)
 			throws UserShareGoodsRecordException {
@@ -298,6 +328,59 @@
 
 		return map;
 	}
+	
+	
+	
+
+	/**
+	 * 淇濆瓨鍒嗕韩璁板綍
+	 * 
+	 * @param userShareGoodsRecord
+	 *            鍒嗕韩璁板綍锛� uid銆乸icture銆乻ource 涓哄繀杈撳叆
+	 * @throws UserShareGoodsRecordException
+	 */
+	@Override
+	public ShareInfoDTO saveShareRecord(Long uid, ShareSourceTypeEnum source, String title,
+			List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
+
+		if (listGoods == null || listGoods.size() == 0) {
+			throw new UserShareGoodsRecordException(1, "鍒嗕韩鍟嗗搧鏁伴噺涓嶈冻");
+		}
+
+		if (uid == null) {
+			throw new UserShareGoodsRecordException(1, "鐢ㄦ埛ID涓嶈兘涓虹┖");
+		}
+
+		if (source == null) {
+			throw new UserShareGoodsRecordException(1, "鍒嗕韩鏉ユ簮涓嶈兘涓虹┖");
+		}
+
+		UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
+		userShareGoodsRecord.setUid(uid);
+		userShareGoodsRecord.setSource(source);
+		userShareGoodsRecord.setTitle(title);
+		// 鍙栦竴涓晢鍝佸浘鐗囦綔涓轰富鍥�
+		userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
+
+		Date date = new Date();
+		userShareGoodsRecord.setShareState(0); // 鍒濆鏈垎浜�
+		userShareGoodsRecord.setCreateTime(date);
+		userShareGoodsRecord.setUpdateTime(date);
+		userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
+
+		Map<String, Object> map = new HashMap<String, Object>();
+		// 澶氫釜鍟嗗搧鍒嗕韩
+		FileUploadResult loadResult = multipleGoodsShare(userShareGoodsRecord, listGoods);
+	
+		ShareInfoDTO shareInfo = new ShareInfoDTO();
+		shareInfo.setMd5(loadResult.getMd5());
+		shareInfo.setCodeUrl(loadResult.getUrl());
+		shareInfo.setShareId(userShareGoodsRecord.getId());
+		shareInfo.setShareUrl(getShareUrl(userShareGoodsRecord));
+		
+		return shareInfo;
+	}
+
 
 	/**
 	 * 鍗曚釜鍟嗗搧鍒嗕韩鐢熸垚璁板綍
@@ -412,6 +495,22 @@
 		return shareImg;
 	}
 
+	public String  getShareUrl (UserShareGoodsRecord shareRecord) {
+		Long uid = shareRecord.getUid();
+		Long shareId = shareRecord.getId();
+		String source = shareRecord.getSource().name();
+
+		String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
+				configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "",
+				source + "");
+
+		String shortLink = HttpUtil.getShortLink(url);
+		if (!StringUtil.isNullOrEmpty(shortLink)) {
+			url = shortLink;
+		}
+		return url;
+	}
+	
 	/**
 	 * 鐢熸垚鍒嗕韩鍥�
 	 * 

--
Gitblit v1.8.0