From eda623f37c3260f4b4657e34a8a39798c72432b1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期日, 28 六月 2020 15:49:14 +0800
Subject: [PATCH] 搜索接口增加小黄条返回
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java | 69 ++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
index 59831dc..0dcfedb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
@@ -10,12 +10,14 @@
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper;
+import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
-import com.yeshi.fanli.entity.bus.user.HongBao;
+import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
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.UserShareGoodsGroupService;
+import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@Service
@@ -56,13 +58,13 @@
}
@Override
- public List<UserShareGoodsGroup> listByRecordId(Long recordId) {
- return userShareGoodsGroupMapper.listByRecordId(recordId);
+ public List<UserShareGoodsGroup> listByRecordId(Long recordId, boolean notBackSuVip) {
+ return userShareGoodsGroupMapper.listByRecordId(recordId, notBackSuVip);
}
@Override
public UserShareGoodsGroup getSingleGoods(Long cid, Long uid) {
- return userShareGoodsGroupMapper.getSingleGoods(cid, uid);
+ return userShareGoodsGroupMapper.getSingleGoods(ShareSourceTypeEnum.goodsDetail,cid, uid );
}
@Override
@@ -71,8 +73,8 @@
}
@Override
- public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId) {
- return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId);
+ public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId, Integer goodsType) {
+ return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId, goodsType);
}
@@ -82,7 +84,7 @@
* @param auctionId
*/
@Override
- public void updateOrderRecord (HongBao hongBao) throws UserShareGoodsRecordException{
+ public void updateOrderRecord (HongBao hongBao, int goodsType) throws UserShareGoodsRecordException{
if (hongBao == null) {
throw new UserShareGoodsRecordException(1, "hongBao涓嶈兘涓虹┖");
@@ -101,7 +103,7 @@
throw new UserShareGoodsRecordException(1, "鍟嗗搧ID涓嶈兘涓虹┖");
}
- UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId());
+ UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId(), goodsType);
if (newestRecord != null) {
// 鏇存柊璁㈠崟鏁伴噺
@@ -114,11 +116,11 @@
shareGoodsGroup.setTotalOrder(totalOrder + 1);
// 鏇存柊棰勮鏀剁泭
- BigDecimal totalMoney = shareGoodsGroup.getTotalMoney();
+ BigDecimal totalMoney = newestRecord.getTotalMoney();
if (totalMoney == null) {
totalMoney = new BigDecimal(0);
}
- BigDecimal resultMoney = MoneyBigDecimalUtil.mul(totalMoney, hongBao.getMoney());
+ BigDecimal resultMoney = MoneyBigDecimalUtil.add(totalMoney, hongBao.getMoney());
shareGoodsGroup.setTotalMoney(resultMoney);
updateByPrimaryKeySelective(shareGoodsGroup);
@@ -143,12 +145,16 @@
throw new UserShareGoodsRecordException(1, "鍟嗗搧Id涓嶈兘涓虹┖");
}
- UserShareGoodsGroup group = getNewestRecord(uid, auctionId);
+ UserShareGoodsGroup group = getNewestRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
if (group != null) {
UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
// 绱娴忚
- shareGoodsGroup.setTotalBrowse(group.getTotalBrowse() + count);
+ Integer totalBrowse = group.getTotalBrowse();
+ if (totalBrowse == null) {
+ totalBrowse = 0;
+ }
+ shareGoodsGroup.setTotalBrowse(totalBrowse + count);
// 浠婃棩娴忚
Date date = new Date();
@@ -159,6 +165,43 @@
shareGoodsGroup.setTodayBrowse(count);
}
shareGoodsGroup.setBrowseTime(date);
+
+ userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup);
+ }
+ }
+
+
+
+ @Override
+ public void updateBrowseNum(Long uid, Long id, int goodsType) throws UserShareGoodsRecordException{
+
+ if (uid == null) {
+ throw new UserShareGoodsRecordException(1, "鐢ㄦ埛ID涓嶈兘涓虹┖");
+ }
+
+ if (id == null) {
+ throw new UserShareGoodsRecordException(1, "鍟嗗搧Id涓嶈兘涓虹┖");
+ }
+
+ UserShareGoodsGroup group = getNewestRecord(uid, id, goodsType);
+ if (group != null) {
+ UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
+ // 绱娴忚
+ Integer totalBrowse = group.getTotalBrowse();
+ if (totalBrowse == null) {
+ totalBrowse = 0;
+ }
+ shareGoodsGroup.setTotalBrowse(totalBrowse + 1);
+
+ // 浠婃棩娴忚
+ Date date = new Date();
+ Date browseTime = group.getBrowseTime();
+ if (DateUtil.isSameDay(browseTime, date)) {
+ shareGoodsGroup.setTodayBrowse(group.getTodayBrowse() + 1);
+ } else {
+ shareGoodsGroup.setTodayBrowse(1);
+ }
+ shareGoodsGroup.setBrowseTime(date);
userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup);
}
}
--
Gitblit v1.8.0