From f4a0f2acc63d7785eab108419a4e16f5f688cb95 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 18 一月 2020 12:06:27 +0800 Subject: [PATCH] 用户注册信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java | 63 ++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 10 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 a4584e1..e0a57c7 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 @@ -62,7 +64,7 @@ @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,7 +116,7 @@ shareGoodsGroup.setTotalOrder(totalOrder + 1); // 鏇存柊棰勮鏀剁泭 - BigDecimal totalMoney = shareGoodsGroup.getTotalMoney(); + BigDecimal totalMoney = newestRecord.getTotalMoney(); if (totalMoney == null) { totalMoney = new BigDecimal(0); } @@ -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