From 9abab8ff78bb04ecdbaaf1962fa9c75b0aec933b Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 15 四月 2020 10:18:52 +0800
Subject: [PATCH] 测试修改
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java | 257 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 210 insertions(+), 47 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 daea8ce..4e138c4 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,11 +26,13 @@
import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
+import com.yeshi.fanli.entity.accept.AcceptData;
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;
import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -41,14 +43,17 @@
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
+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.RedisKeyEnum;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
@@ -91,6 +96,9 @@
@Resource
private UserGoodsStorageService userGoodsStorageService;
+ @Resource
+ private IntegralGetService integralGetService;
+
@Override
public int insert(UserShareGoodsRecord record) {
return userShareGoodsRecordMapper.insert(record);
@@ -120,10 +128,10 @@
public long countQueryByUid(Long uid, String source) {
return userShareGoodsRecordMapper.countQueryByUid(uid, source);
}
-
+
@Override
public List<UserShareGoodsGroup> listByRecordId(Long shareId) {
- return userShareGoodsGroupService.listByRecordId(shareId);
+ return userShareGoodsGroupService.listByRecordId(shareId);
}
@Override
@@ -204,12 +212,12 @@
}
}
}
-
+
String shareType = shareRecord.getShareType();
if (StringUtil.isNullOrEmpty(shareType)) {
shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
}
-
+
BigDecimal totalMoney = shareRecord.getTotalMoney();
if (totalMoney == null) {
shareRecord.setTotalMoney(new BigDecimal(0));
@@ -221,7 +229,7 @@
if (StringUtil.isNullOrEmpty(shareType)) {
shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
}
-
+
BigDecimal totalMoney = shareRecord.getTotalMoney();
if (totalMoney == null) {
shareRecord.setTotalMoney(new BigDecimal(0));
@@ -234,8 +242,7 @@
}
@Override
- public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType)
- throws UserShareGoodsRecordException {
+ public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType) throws UserShareGoodsRecordException {
if (goodsId == null) {
throw new UserShareGoodsRecordException(1, "鍒嗕韩鍟嗗搧涓嶈兘涓虹┖");
}
@@ -325,17 +332,15 @@
* @param userShareGoodsRecord
* @param listGoods
*/
- @Transactional
- public void multipleGoodsShareRecord(Long shareId, List<TaoBaoGoodsBrief> listGoods)
+ @Transactional(rollbackFor = Exception.class)
+ public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
throws UserShareGoodsRecordException {
// 鍒嗕韩璁板綍
Date date = new Date();
List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
- CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
- commonGoods.setState(taoBaoGoodsBrief.getState());
+ for (CommonGoods commonGoods : listGoods) {
try {
CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
@@ -370,7 +375,7 @@
* @param userShareGoodsRecord
* @param listGoods
*/
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord,
List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
@@ -421,9 +426,12 @@
/**
* 鐢熸垚鍒嗕韩鍥�
*
- * @param uid 鐢ㄦ埛id
- * @param shareId 鍒嗕韩璁板綍id
- * @param source 鏉ユ簮
+ * @param uid
+ * 鐢ㄦ埛id
+ * @param shareId
+ * 鍒嗕韩璁板綍id
+ * @param source
+ * 鏉ユ簮
* @param listGoods
* @return
* @throws UserShareGoodsRecordException
@@ -453,7 +461,7 @@
}
// 鑾峰彇鍒扮敤鎴风殑澶村儚
- UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
+ UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
if (user == null) {
throw new UserShareGoodsRecordException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
}
@@ -481,7 +489,8 @@
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;
}
@@ -517,7 +526,8 @@
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
- BigDecimal shareRate = hongBaoManageService.getShareRate(java.lang.System.currentTimeMillis());
+ BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
+ java.lang.System.currentTimeMillis());
for (UserShareGoodsGroup goodsGroup : list) {
CommonGoods commonGoods = goodsGroup.getCommonGoods();
@@ -602,7 +612,8 @@
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
- BigDecimal shareRate = hongBaoManageService.getShareRate(java.lang.System.currentTimeMillis());
+ BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
+ java.lang.System.currentTimeMillis());
for (UserShareGoodsGroup goodsGroup : list) {
CommonGoods commonGoods = goodsGroup.getCommonGoods();
@@ -656,7 +667,8 @@
}
@Override
- public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType) throws UserShareGoodsRecordException {
+ public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType, boolean isTaolijin)
+ throws UserShareGoodsRecordException {
if (auctionId == null || uid == null || uid <= 0) {
throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘");
}
@@ -665,10 +677,12 @@
recordDTO.setUid(uid);
recordDTO.setAuctionId(auctionId);
recordDTO.setGoodsType(goodsType);
+ recordDTO.setTaolijin(isTaolijin);
recordDTO.setSource(ShareSourceTypeEnum.goodsDetail);
// 鍒嗕韩id
- String key = StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#"+ goodsType);
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
+ StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType));
redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
recordDTO.setRedisKey(key);
@@ -676,8 +690,8 @@
}
@Override
- public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, List<Long> listStorageID)
- throws UserShareGoodsRecordException {
+ public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief,
+ List<Long> listStorageID) throws UserShareGoodsRecordException {
if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘");
}
@@ -690,23 +704,69 @@
record.setCreateTime(new Date());
userShareGoodsRecordMapper.insertSelective(record);
+ List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
+ for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
+ listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
+ }
+
Long id = record.getId();
// 鍒嗕韩閾炬帴
String shareUrl = getShareUrl(record);
// 鍒嗕韩浜岀淮鐮侀摼鎺�
- FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
+ FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
recordDTO.setUid(uid);
recordDTO.setShareId(id);
recordDTO.setShareUrl(shareUrl);
recordDTO.setListId(listStorageID);
- recordDTO.setListGoodsBrief(listGoodsBrief);
+ recordDTO.setListGoods(listCommonGoods);
recordDTO.setSharePictureUrl(uploadResult.getUrl());
recordDTO.setSource(ShareSourceTypeEnum.storage);
// 缂撳瓨鍒嗕韩鍟嗗搧淇℃伅
- String key = StringUtil.Md5(uid + "#GoodsStorage#" + id);
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
+ recordDTO.setRedisKey(key);
+
+ redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
+
+ return recordDTO;
+ }
+
+ @Override
+ public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID,
+ boolean needDrawPicture) throws UserShareGoodsRecordException {
+ if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) {
+ throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘");
+ }
+ // 鎻掑叆璁板綍
+ UserShareGoodsRecord record = new UserShareGoodsRecord();
+ record.setUid(uid);
+ record.setShareState(0); // 鍒濆鏈垎浜�
+ record.setSource(ShareSourceTypeEnum.storage);
+ record.setPicture(listGoods.get(0).getPicture()); // 鍙栦竴涓晢鍝佸浘鐗囦綔涓轰富鍥�
+ record.setCreateTime(new Date());
+ userShareGoodsRecordMapper.insertSelective(record);
+
+ Long id = record.getId();
+ // 鍒嗕韩閾炬帴
+ String shareUrl = getShareUrlV2(record);
+ // 鍒嗕韩浜岀淮鐮侀摼鎺�
+
+ ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
+ recordDTO.setUid(uid);
+ recordDTO.setShareId(id);
+ recordDTO.setShareUrl(shareUrl);
+ recordDTO.setListId(listStorageID);
+ recordDTO.setListGoods(listGoods);
+ if (needDrawPicture) {
+ FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods);
+ recordDTO.setSharePictureUrl(uploadResult.getUrl());
+ }
+ recordDTO.setSource(ShareSourceTypeEnum.storage);
+
+ // 缂撳瓨鍒嗕韩鍟嗗搧淇℃伅
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
recordDTO.setRedisKey(key);
redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -731,21 +791,26 @@
record.setCreateTime(new Date());
userShareGoodsRecordMapper.insertSelective(record);
+ List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
+ for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
+ listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
+ }
+
Long id = record.getId();
// 鍒嗕韩閾炬帴
String shareUrl = getShareUrl(record);
// 鍒嗕韩浜岀淮鐮侀摼鎺�
- FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
+ FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
recordDTO.setUid(uid);
recordDTO.setShareId(id);
- recordDTO.setListGoodsBrief(listGoodsBrief);
+ recordDTO.setListGoods(listCommonGoods);
recordDTO.setShareUrl(shareUrl);
recordDTO.setSharePictureUrl(uploadResult.getUrl());
recordDTO.setSource(ShareSourceTypeEnum.activity);
// 缂撳瓨鍒嗕韩鍟嗗搧淇℃伅
- String key = StringUtil.Md5(uid + "#Activity#" + id);
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Activity#" + id));
recordDTO.setRedisKey(key);
redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -769,6 +834,11 @@
record.setCreateTime(new Date());
userShareGoodsRecordMapper.insertSelective(record);
+ List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
+ for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
+ listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
+ }
+
Long id = record.getId();
// 鍒嗕韩閾炬帴
String shareUrl = getShareUrl(record);
@@ -777,11 +847,11 @@
recordDTO.setUid(uid);
recordDTO.setShareId(id);
recordDTO.setShareUrl(shareUrl);
- recordDTO.setListGoodsBrief(listGoodsBrief);
+ recordDTO.setListGoods(listCommonGoods);
recordDTO.setSource(ShareSourceTypeEnum.activity);
// 缂撳瓨鍒嗕韩鍟嗗搧淇℃伅
- String key = StringUtil.Md5(uid + "#Dynamic#" + id);
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Dynamic#" + id));
recordDTO.setRedisKey(key);
redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -790,12 +860,13 @@
}
@Override
- public void takeEffectShareRecord(String shareKey) throws UserShareGoodsRecordException {
+ public void takeEffectShareRecord(AcceptData acceptData, String shareKey) throws UserShareGoodsRecordException {
if (StringUtil.isNullOrEmpty(shareKey)) {
throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘");
}
ShareGoodsRecordDTO recordDTO = null;
- String value = redisManager.getCommonString(shareKey);
+ String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, shareKey);
+ String value = redisManager.getCommonString(redisKey);
if (!StringUtil.isNullOrEmpty(value)) {
recordDTO = JsonUtil.getSimpleGson().fromJson(value, ShareGoodsRecordDTO.class);
}
@@ -804,11 +875,14 @@
throw new UserShareGoodsRecordException(1, "鍒嗕韩淇℃伅涓嶅瓨鍦�");
}
+ Long uid = recordDTO.getUid();
+ boolean taolijin = recordDTO.isTaolijin();
+ boolean singleGoods = true;
Long shareId = recordDTO.getShareId();
ShareSourceTypeEnum source = recordDTO.getSource();
if (ShareSourceTypeEnum.goodsDetail.equals(source)) {
// 鍟嗗搧璇︽儏鍒嗕韩
- saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(),recordDTO.getGoodsType());
+ saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(), recordDTO.getGoodsType());
} else if (ShareSourceTypeEnum.activity.equals(source)) {
// 鍔ㄦ�佸垎浜�
UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
@@ -817,11 +891,17 @@
shareRecord.setUpdateTime(new Date());
updateByPrimaryKeySelective(shareRecord);
+ List<CommonGoods> listGoods = recordDTO.getListGoods();
+ if (listGoods != null && listGoods.size() > 1)
+ singleGoods = false;
+
// 淇濆瓨鍟嗗搧淇℃伅
- multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
+ multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
} else if (ShareSourceTypeEnum.storage.equals(source)) {
// 鍒嗕韩搴撳垎浜�
+ singleGoods = false;
+
UserShareGoodsRecord shareRecord = new UserShareGoodsRecord();
shareRecord.setId(shareId);
shareRecord.setShareState(1);
@@ -829,8 +909,8 @@
updateByPrimaryKeySelective(shareRecord);
// 淇濆瓨鍟嗗搧淇℃伅
- multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
-
+ multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
+
// 鏇存柊閫夊搧搴撳晢鍝佺姸鎬� 涓哄凡鍒嗕韩
List<Long> listId = recordDTO.getListId();
if (listId != null && listId.size() > 0) {
@@ -842,9 +922,19 @@
}
}
}
-
+
// 娓呯悊缂撳瓨
- redisManager.removeCommonString(shareKey);
+ redisManager.removeCommonString(redisKey);
+
+ if (singleGoods) {
+ if (taolijin) {
+ integralGetService.addShareTLJGoods(uid);
+ } else {
+ integralGetService.addShareSingleGoods(uid);
+ }
+ } else {
+ integralGetService.addShareMultipleGoods(uid);
+ }
}
/**
@@ -869,16 +959,39 @@
}
/**
+ * 鍒嗕韩閾炬帴
+ *
+ * @param shareRecord
+ * @return
+ */
+ public String getShareUrlV2(UserShareGoodsRecord shareRecord) {
+ Long uid = shareRecord.getUid();
+ Long shareId = shareRecord.getId();
+
+ String url = String.format("http://%s/share_mushGoods_1.6.0.html?uid=%s&shareId=%s", configService.getH5Host(),
+ AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "");
+
+ String shortLink = HttpUtil.getShortLink(url);
+ if (!StringUtil.isNullOrEmpty(shortLink)) {
+ url = shortLink;
+ }
+ return url;
+ }
+
+ /**
* 鐢熸垚鍒嗕韩鍥�
*
- * @param uid 鐢ㄦ埛id
- * @param shareId 鍒嗕韩璁板綍id
- * @param source 鏉ユ簮
+ * @param uid
+ * 鐢ㄦ埛id
+ * @param shareId
+ * 鍒嗕韩璁板綍id
+ * @param source
+ * 鏉ユ簮
* @param listGoods
* @return
* @throws UserShareGoodsRecordException
*/
- public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<TaoBaoGoodsBrief> listGoods)
+ public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<CommonGoods> listGoods)
throws UserShareGoodsRecordException {
InputStream erCodeInputStream = null;
@@ -890,7 +1003,7 @@
}
// 鑾峰彇鍒扮敤鎴风殑澶村儚
- UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
+ UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
if (user == null) {
throw new UserShareGoodsRecordException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
}
@@ -916,9 +1029,59 @@
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