mitao
2024-08-16 d7dc4db8d005a58f51d21d35147317762a16373f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package com.ruoyi.auction.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.auction.domain.AuctionBrowseRecord;
import com.ruoyi.auction.mapper.AuctionBondJlMapper;
import com.ruoyi.auction.mapper.AuctionBrowseRecordMapper;
import com.ruoyi.auction.mapper.AuctionGoodsMapper;
import com.ruoyi.auction.mapper.AuctionSalesroomMapper;
import com.ruoyi.auction.service.IAuctionBrowseRecordService;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.system.api.domain.AuctionBondJl;
import com.ruoyi.system.api.domain.AuctionGoods;
import com.ruoyi.system.api.domain.AuctionSalesroom;
import com.ruoyi.system.api.domain.GoodsSku;
import com.ruoyi.system.api.domain.dto.AuctionGoodsListDTO;
import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomDTO;
import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO;
import com.ruoyi.system.api.domain.vo.WdMemberAuctionSalesroomVO;
import com.ruoyi.system.api.feignClient.GoodsSkuClient;
import com.ruoyi.system.api.feignClient.OrderClient;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
 
/**
 * <p>
 * 会员商品浏览记录表 服务实现类
 * </p>
 *
 * @author mitao
 * @since 2024-05-30
 */
@Service
public class AuctionBrowseRecordServiceImpl extends ServiceImpl<AuctionBrowseRecordMapper, AuctionBrowseRecord> implements IAuctionBrowseRecordService {
 
 
 
    @Resource
    private AuctionSalesroomMapper auctionSalesroomMapper;
 
    @Resource
    private OrderClient orderClient;
 
    @Resource
    private GoodsSkuClient goodsSkuClient;
 
    @Resource
    private AuctionGoodsMapper auctionGoodsMapper;
 
    @Resource
    private AuctionBondJlMapper auctionBondJlMapper;
 
 
    @Override
    public PageDTO<AuctionGoodsListVO> getWdAuctionBrowseRecordList(AuctionGoodsListDTO auctionGoodsListDTO) {
 
        Page<AuctionBrowseRecord> page = new Page<>();
        page.setSize(auctionGoodsListDTO.getPageSize());
        page.setCurrent(auctionGoodsListDTO.getPageCurr());
 
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime newTime7 = now.minusDays(7);
        LambdaQueryWrapper<AuctionBrowseRecord> wrapper3= Wrappers.lambdaQuery();
        wrapper3.eq(AuctionBrowseRecord::getDelFlag,0);
        wrapper3.eq(AuctionBrowseRecord::getBrowseType,1);
        wrapper3.eq(AuctionBrowseRecord::getMemberId,auctionGoodsListDTO.getMemberId());
        wrapper3.ge(AuctionBrowseRecord::getCreateTime, newTime7)
                .le(AuctionBrowseRecord::getCreateTime, now);
        if (StringUtils.isNotEmpty(auctionGoodsListDTO.getGoodsSkuName())) {
            wrapper3.like(AuctionBrowseRecord::getSkuName,auctionGoodsListDTO.getGoodsSkuName());
        }
 
      /*  Set<Long> goodsSkuIdList = null;
        if (auctionGoodsListDTO.getStartStatus()!=null&&auctionGoodsListDTO.getStartStatus()!=4){
            LambdaQueryWrapper<AuctionGoods> wrapper=Wrappers.lambdaQuery();
            wrapper.eq(AuctionGoods::getStartStatus,auctionGoodsListDTO.getStartStatus());
            wrapper.eq(AuctionGoods::getDelFlag,0);
            List<AuctionGoods> auctionSalesrooms = auctionGoodsMapper.selectList(wrapper);
            goodsSkuIdList = auctionSalesrooms.stream().map(AuctionGoods::getId)
                    .collect(Collectors.toSet());
        }
 
 
        if (auctionGoodsListDTO.getStartStatus()!=4) {
            if (goodsSkuIdList != null) {
                wrapper3.in(AuctionBrowseRecord::getTargetId,goodsSkuIdList);
            } else {
                goodsSkuIdList = new HashSet<>();
                goodsSkuIdList.add(0L);
                wrapper3.in(AuctionBrowseRecord::getTargetId,goodsSkuIdList);
            }
        }*/
 
        wrapper3.orderByDesc(AuctionBrowseRecord::getCreateTime);
        Page<AuctionBrowseRecord> page1 = this.page(page, wrapper3);
        PageDTO<AuctionGoodsListVO> articleCommentsVOPageDTO = PageDTO.of(page1, AuctionGoodsListVO.class);
        List<AuctionGoodsListVO> auctionGoodsPgeList = articleCommentsVOPageDTO.getList();
        List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>();
        for (AuctionGoodsListVO auctionGoodsVO:auctionGoodsPgeList){
            AuctionGoods   auctionGoods =auctionGoodsMapper.selectById(auctionGoodsVO.getTargetId());
            auctionGoodsVO.setAuctionStock(auctionGoods.getAuctionStock());
            auctionGoodsVO.setGoodsSkuId(auctionGoods.getId());
            auctionGoodsVO.setEndTime(auctionGoods.getEndTime());
            auctionGoodsVO.setStartTime(auctionGoods.getStartTime());
            auctionGoodsVO.setStartingPrice(auctionGoods.getStartingPrice());
            auctionGoodsVO.setStartStatus(auctionGoods.getStartStatus());
            GoodsSku goodsSkuOne = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), SecurityConstants.INNER).getData();
            auctionGoodsVO.setUnit(goodsSkuOne.getUnit());
            auctionGoodsVO.setSpec(goodsSkuOne.getSpec());
            auctionGoodsVO.setSpecUnit(goodsSkuOne.getSpecUnit());
            auctionGoodsVO.setGoodsSkuName(goodsSkuOne.getSkuName());
            auctionGoodsVO.setCoverPic(goodsSkuOne.getCoverPic());
            auctionGoodsVO.setYears(String.valueOf(goodsSkuOne.getYears().getYear()));
            auctionGoodsVO.setDescription(goodsSkuOne.getDescription());
            auctionGoodsVO.setDetail(goodsSkuOne.getDetail());
            auctionGoodsVOS.add(auctionGoodsVO);
        }
        return articleCommentsVOPageDTO;
    }
 
    @Override
    public PageDTO<WdMemberAuctionSalesroomVO> getWdAuctionSalesroomBrowseRecordList(MemberAuctionSalesroomDTO MemberAuctionSalesroomDTO) {
 
      /*  Set<Long> goodsSkuIdList = null;
        if (MemberAuctionSalesroomDTO.getStatus()!=4){
            LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
            wrapper.eq(AuctionSalesroom::getStatus,MemberAuctionSalesroomDTO.getStatus());
            wrapper.eq(AuctionSalesroom::getDelFlag,0);
            List<AuctionSalesroom> auctionSalesrooms = auctionSalesroomMapper.selectList(wrapper);
            goodsSkuIdList = auctionSalesrooms.stream().map(AuctionSalesroom::getId)
                            .collect(Collectors.toSet());
        }*/
 
 
 
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime newTime7 = now.minusDays(7);
        Page<AuctionBrowseRecord> page = new Page<>();
        page.setSize(MemberAuctionSalesroomDTO.getPageSize());
        page.setCurrent(MemberAuctionSalesroomDTO.getPageCurr());
        LambdaQueryWrapper<AuctionBrowseRecord> wrapper3= Wrappers.lambdaQuery();
        wrapper3.eq(AuctionBrowseRecord::getDelFlag,0);
        wrapper3.eq(AuctionBrowseRecord::getMemberId,MemberAuctionSalesroomDTO.getMemberId());
        wrapper3.eq(AuctionBrowseRecord::getBrowseType,2);
        wrapper3.ge(AuctionBrowseRecord::getCreateTime, newTime7)
                .le(AuctionBrowseRecord::getCreateTime, now);
 
     /*   if (MemberAuctionSalesroomDTO.getStatus()!=4) {
            if (goodsSkuIdList != null) {
                wrapper3.in(AuctionBrowseRecord::getTargetId,goodsSkuIdList);
            } else {
                goodsSkuIdList = new HashSet<>();
                goodsSkuIdList.add(0L);
                wrapper3.in(AuctionBrowseRecord::getTargetId,goodsSkuIdList);
            }
        }*/
 
 
        wrapper3.orderByDesc(AuctionBrowseRecord::getCreateTime);
        if (MemberAuctionSalesroomDTO.getSalesroomName()!=null){
            wrapper3.like(AuctionBrowseRecord::getSkuName,MemberAuctionSalesroomDTO.getSalesroomName());
        }
 
        Page<AuctionBrowseRecord> page1 = this.page(page, wrapper3);
        PageDTO<WdMemberAuctionSalesroomVO> articleCommentsVOPageDTO = PageDTO.of(page1, WdMemberAuctionSalesroomVO.class);
        List<WdMemberAuctionSalesroomVO> list1 = articleCommentsVOPageDTO.getList();
 
        for (WdMemberAuctionSalesroomVO auctionSalesroom1:list1){
            AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById(auctionSalesroom1.getTargetId());
            auctionSalesroom1.setSalesroomName(auctionSalesroom.getSalesroomName());
            auctionSalesroom1.setDescription(auctionSalesroom.getDescription());
            auctionSalesroom1.setStatus(auctionSalesroom.getStatus().getCode());
            auctionSalesroom1.setSalesroomId(auctionSalesroom.getId());
            auctionSalesroom1.setId(auctionSalesroom.getId());
            auctionSalesroom1.setCoverPic(auctionSalesroom.getCoverPic());
            MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1=new MemberAuctionSalesroomDTO();
            memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getId());
            memberAuctionSalesroomDTO1.setMemberId(MemberAuctionSalesroomDTO.getMemberId());
            LambdaQueryWrapper<AuctionBondJl> wrapper=Wrappers.lambdaQuery();
            wrapper.eq(AuctionBondJl::getAuctionSalesroomId,auctionSalesroom.getId());
            wrapper.eq(AuctionBondJl::getMemberId,MemberAuctionSalesroomDTO.getMemberId());
            wrapper.eq(AuctionBondJl::getIsState,0);
            AuctionBondJl auctionBondJl = auctionBondJlMapper.selectOne(wrapper);
            if (auctionBondJl!=null){
                auctionSalesroom1.setIsBond(2);
            }else{
                auctionSalesroom1.setIsBond(1);
            }
 
            MemberAuctionSalesroomDTO memberAuctionSalesroomDTO2=new MemberAuctionSalesroomDTO();
            memberAuctionSalesroomDTO2.setAuctionSalesroomId(auctionSalesroom.getId());
 
            LambdaQueryWrapper<AuctionBondJl> wrapper1=Wrappers.lambdaQuery();
            wrapper1.eq(AuctionBondJl::getAuctionSalesroomId,auctionSalesroom.getId());
            wrapper1.eq(AuctionBondJl::getBondType,2);
            wrapper1.eq(AuctionBondJl::getIsState,0);
            java.util.List<AuctionBondJl> auctionBondJls = auctionBondJlMapper.selectList(wrapper1);
 
            auctionSalesroom1.setBondNum(auctionBondJls.size());
            auctionSalesroom1.setBond(auctionSalesroom.getBond());
        }
        return articleCommentsVOPageDTO;
    }
}