Administrator
2018-12-10 0908b7a4f3508b7c2691c063672bd151bde53bfb
浏览记录修改
1个文件已修改
37 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
@@ -100,38 +100,44 @@
    
    /**
     * 更新浏览记录数据
     * @param uid
     * @param auctionId
     * @param shareId 分享id
     * @param count 浏览次数
     */
    @Override
    public void updateBrowseRecord (Long uid, Long auctionId, int count) throws UserShareGoodsRecordException{
        if (uid == null) {
            throw new UserShareGoodsRecordException(1, "用户ID不能为空");
    public void updateBrowseRecord (Long shareId, int count) throws UserShareGoodsRecordException{
        if (shareId == null) {
            throw new UserShareGoodsRecordException(1, "分享id为空");
        }
        
        if (auctionId == null) {
            throw new UserShareGoodsRecordException(1, "商品ID不能为空");
        List<UserShareGoodsGroup> list = listByRecordId(shareId);
        if (list == null || list.size() == 0) {
            throw new UserShareGoodsRecordException(1, "分享商品已不存在");
        }
        
        UserShareGoodsGroup newestRecord = getNewestRecord(uid, auctionId);
        List<UserShareGoodsGroup> listUpdate = new ArrayList<UserShareGoodsGroup>();
        
        if (newestRecord != null) {
        for (UserShareGoodsGroup group: list) {
            // 注意: 修改记录数据、但不可修改更新设置
            UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(newestRecord.getId());
            UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
            
            shareGoodsGroup.setTotalBrowse(newestRecord.getTotalBrowse() + count);
            shareGoodsGroup.setTotalBrowse(group.getTotalBrowse() + count);
            
            Date browseTime = newestRecord.getBrowseTime();
            Date browseTime = group.getBrowseTime();
            if (DateUtil.isSameDay(browseTime, new Date())) {
                shareGoodsGroup.setTodayBrowse(newestRecord.getTodayBrowse() + count);
                shareGoodsGroup.setTodayBrowse(group.getTodayBrowse() + count);
            } else {
                shareGoodsGroup.setTodayBrowse(count);
                shareGoodsGroup.setBrowseTime(new Date());
            }
            
            updateByPrimaryKeySelective(shareGoodsGroup);
            listUpdate.add(shareGoodsGroup);
        }
        userShareGoodsGroupMapper.updateBatchSelective(listUpdate);
    }
    
    /**
     * 更新订单记录数据
@@ -239,8 +245,7 @@
                    commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
                }
                String json = gson
                        .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate, null));
                String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null));
                dataObject.put("groupId", userShareGoodsGroup.getId());
                dataObject.put("goods", json);