rentaiming
2024-05-30 9bcc40d213a44498c46dae5e678e592b918b40b0
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
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.controller.forepart.vo.MemberAuctionSalesroomVO;
import com.google.common.collect.Lists;
import com.ruoyi.auction.controller.management.dto.AuctionGoodsDTO;
import com.ruoyi.auction.controller.management.dto.AuctionGoodsQuery;
import com.ruoyi.auction.controller.management.vo.AuctionBidRecordVO;
import com.ruoyi.auction.controller.management.vo.AuctionGoodsVO;
import com.ruoyi.auction.domain.AuctionBidRecord;
import com.ruoyi.auction.domain.MemberAuctionCollection;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.*;
import com.ruoyi.auction.mapper.AuctionGoodsMapper;
import com.ruoyi.auction.service.IAuctionBidRecordService;
import com.ruoyi.auction.service.IAuctionGoodsService;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.enums.AuctionOrderTypeEnum;
import com.ruoyi.common.core.enums.AuctionStartStatusEnum;
import com.ruoyi.common.core.enums.BidStatusEnum;
import com.ruoyi.common.core.enums.BondStatusEnum;
import com.ruoyi.common.core.enums.OrderFromEnum;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.page.BeanUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.system.api.domain.AuctionGoods;
import com.ruoyi.system.api.domain.dto.*;
import com.ruoyi.system.api.domain.dto.AuctionGoodsListDTO;
import com.ruoyi.system.api.domain.dto.AuctionGoodsListPageDTO;
import com.ruoyi.system.api.domain.GoodsSku;
import com.ruoyi.system.api.domain.Member;
import com.ruoyi.system.api.domain.MemberAddress;
import com.ruoyi.system.api.domain.OrderAuctionBond;
import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO;
import com.ruoyi.system.api.domain.dto.OrderDTO;
import com.ruoyi.system.api.domain.dto.RefundDTO;
import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO;
import com.ruoyi.system.api.domain.vo.AuctionGoodsinfoVO;
import com.ruoyi.system.api.feignClient.GoodsSkuClient;
import com.ruoyi.system.api.feignClient.MemberClient;
import com.ruoyi.system.api.feignClient.OrderClient;
import io.seata.spring.annotation.GlobalTransactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
 
/**
 * <p>
 * 拍卖商品表 服务实现类
 * </p>
 *
 * @author mitao
 * @since 2024-05-16
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AuctionGoodsServiceImpl extends ServiceImpl<AuctionGoodsMapper, AuctionGoods> implements IAuctionGoodsService {
 
    private final GoodsSkuClient goodsSkuClient;
    private final MemberClient memberClient;
    private final OrderClient orderClient;
    private final IAuctionBidRecordService auctionBidRecordService;
 
    @Resource
    private MemberAuctionCollectionServiceImpl memberAuctionCollectionServiceImpl;
 
    @Resource
    private IAuctionGoodsService auctionGoodsService;
 
    @Resource
    private AuctionGoodsMapper auctionGoodsMapper;
 
    /**
     * 获取拍卖商品列表的分页数据
     *
     * @param query 拍卖商品查询对象
     * @return PageDTO<AuctionGoodsVO>
     */
    @Override
    public PageDTO<AuctionGoodsVO> getAuctionGoodsPage(AuctionGoodsQuery query) {
        Set<Long> goodsSkuIdList = null;
        if (StringUtils.isNotEmpty(query.getGoodsSkuName())) {
            List<GoodsSku> goodsSku = goodsSkuClient.getGoodsByName(query.getGoodsSkuName(),
                            SecurityConstants.INNER)
                    .getData();
            goodsSkuIdList = goodsSku.stream().map(GoodsSku::getId)
                    .collect(Collectors.toSet());
        }
        Page<AuctionGoods> page = this.lambdaQuery()
                .select(AuctionGoods::getId, AuctionGoods::getGoodsSkuId,
                        AuctionGoods::getListingStatus, AuctionGoods::getStartStatus,
                        AuctionGoods::getStartTime, AuctionGoods::getEndTime,
                        AuctionGoods::getAuctionStock, AuctionGoods::getMinimumMarkupAmount).in(
                        StringUtils.isNotEmpty(goodsSkuIdList), AuctionGoods::getGoodsSkuId,
                        goodsSkuIdList).eq(StringUtils.isNotNull(query.getAuthentication()),
                        AuctionGoods::getAuthentication, query.getAuthentication())
                .eq(StringUtils.isNotNull(query.getListingStatus()), AuctionGoods::getListingStatus,
                        query.getListingStatus())
                .eq(StringUtils.isNotNull(query.getStartStatus()), AuctionGoods::getStartStatus,
                        query.getStartStatus())
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        return PageDTO.of(page, AuctionGoodsVO.class);
    }
 
    @Override
    @Transactional
    @GlobalTransactional(rollbackFor = Exception.class)
    public void saveAuctionGoods(AuctionGoodsDTO dto) {
        Long id = dto.getId();
        Long goodsSkuId = dto.getGoodsSkuId();
        AuctionGoods auctionGoods = BeanUtils.copyBean(dto, AuctionGoods.class);
        // 添加
        if (StringUtils.isNull(id)) {
            if (StringUtils.isNull(goodsSkuId)) {
                throw new ServiceException("商品id不能为空");
            }
            GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(goodsSkuId, SecurityConstants.INNER)
                    .getData();
            if (StringUtils.isNull(goodsSku)) {
                throw new ServiceException("商品不存在");
            }
            if (goodsSku.getStock() < dto.getAuctionStock()) {
                throw new ServiceException("商品库存不足");
            }
            this.save(auctionGoods);
            // 扣减商品库存
            GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
            goodsStockUpdDTO.setGoodsSkuId(goodsSkuId);
            goodsStockUpdDTO.setAuctionStock(dto.getAuctionStock() * -1);
            goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                    SecurityConstants.INNER);
        } else {
            // 编辑
            AuctionGoods auctionGoodsOrg = this.getById(id);
            if (StringUtils.isNull(auctionGoodsOrg)) {
                throw new ServiceException("拍卖商品不存在");
            }
            if (auctionGoodsOrg.getStartStatus().equals(AuctionStartStatusEnum.IN_AUCTION)) {
                throw new ServiceException("商品正在拍卖中不能编辑");
            }
            if (auctionGoodsOrg.getStartStatus().equals(AuctionStartStatusEnum.ENDED)) {
                throw new ServiceException("商品拍卖已结束不能编辑");
            }
            GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(goodsSkuId, SecurityConstants.INNER)
                    .getData();
            if (StringUtils.isNull(goodsSku)) {
                throw new ServiceException("商品不存在");
            }
            if (goodsSku.getStock() + auctionGoodsOrg.getAuctionStock() < dto.getAuctionStock()) {
                throw new ServiceException("商品库存不足");
            }
            auctionGoodsOrg.setStartingPrice(dto.getStartingPrice());
            auctionGoodsOrg.setMinimumMarkupAmount(dto.getMinimumMarkupAmount());
            auctionGoodsOrg.setStartTime(dto.getStartTime());
            auctionGoodsOrg.setEndTime(dto.getEndTime());
            auctionGoodsOrg.setAuctionStock(dto.getAuctionStock());
            auctionGoodsOrg.setBond(dto.getBond());
            auctionGoodsOrg.setAuthentication(dto.getAuthentication());
            auctionGoodsOrg.setDescription(dto.getDescription());
            auctionGoodsOrg.setShareTitle(dto.getShareTitle());
            auctionGoodsOrg.setSharePic(dto.getSharePic());
            this.updateById(auctionGoodsOrg);
            // 更新商品库存
            GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
            goodsStockUpdDTO.setGoodsSkuId(goodsSkuId);
            goodsStockUpdDTO.setAuctionStock(
                    auctionGoodsOrg.getAuctionStock() - dto.getAuctionStock());
            goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                    SecurityConstants.INNER);
        }
    }
 
    /**
     * 查看拍卖商品详情
     *
     * @param id 拍卖商品id
     * @return AuctionGoodsVO
     */
    @Override
    public AuctionGoodsVO getAuctionGoodsById(Long id) {
        AuctionGoods auctionGoods = this.getById(id);
        if (StringUtils.isNull(auctionGoods)) {
            throw new ServiceException("拍卖商品不存在");
        }
        AuctionGoodsVO auctionGoodsVO = BeanUtils.copyBean(auctionGoods, AuctionGoodsVO.class);
        if (!auctionGoods.getStartStatus().equals(AuctionStartStatusEnum.IN_PREVIEW)) {
            List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery()
                    .eq(AuctionBidRecord::getTargetId, auctionGoodsVO.getId())
                    .eq(AuctionBidRecord::getAuctionType, AuctionOrderTypeEnum.REGULAR_ITEMS)
                    .orderByDesc(AuctionBidRecord::getLastBidAmount).list();
            if (StringUtils.isNotEmpty(list)) {
                Set<Long> collect = list.stream().map(AuctionBidRecord::getMemberId)
                        .collect(Collectors.toSet());
                List<Member> memberList = memberClient.
                        getMemberListByIds(collect, SecurityConstants.INNER).getData();
                Map<Long, String> memberMap = memberList.stream()
                        .collect(Collectors.toMap(Member::getId, Member::getNickname));
                List<AuctionBidRecordVO> auctionBidRecordVOS = BeanUtils.copyList(list,
                        AuctionBidRecordVO.class);
                for (AuctionBidRecordVO vo : auctionBidRecordVOS) {
                    String memberName = memberMap.get(vo.getMemberId());
                    vo.setMemberName(StringUtils.isNotEmpty(memberName) ? memberName : "");
                }
                auctionGoodsVO.setRecordList(auctionBidRecordVOS);
            }
        }
        return auctionGoodsVO;
    }
 
    /**
     * 立即结束
     *
     * @param id 拍卖商品id
     */
    @Override
    @GlobalTransactional(rollbackFor = Exception.class)
    @Transactional
    public void stopAuctionGoods(Long id) {
        AuctionGoods auctionGoods = this.lambdaQuery().eq(AuctionGoods::getId, id)
                .eq(AuctionGoods::getStartStatus, AuctionStartStatusEnum.IN_AUCTION).one();
        if (StringUtils.isNull(auctionGoods)) {
            throw new ServiceException("拍卖商品不存在");
        }
        if (auctionGoods.getStartStatus().equals(AuctionStartStatusEnum.IN_AUCTION)) {
            // 查询出价记录
            List<AuctionBidRecord> auctionBidRecords = auctionBidRecordService.getBidRecordByGoodsId(
                    id);
            Long memberId = null;
            if (StringUtils.isNotEmpty(auctionBidRecords)) {
                // 中标
                AuctionBidRecord auctionBidRecord = auctionBidRecords.get(0);
                auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                auctionBidRecordService.updateById(auctionBidRecord);
                memberId = auctionBidRecord.getMemberId();
                // 创建待支付订单
                OrderDTO orderDTO = new OrderDTO();
                orderDTO.setAuctionType(AuctionOrderTypeEnum.REGULAR_ITEMS);
                orderDTO.setGoodsQuantity(auctionGoods.getAuctionStock());
                orderDTO.setGoodsSkuId(auctionGoods.getGoodsSkuId());
                orderDTO.setBound(auctionGoods.getBond());
                orderDTO.setMemberId(auctionBidRecord.getMemberId());
                orderDTO.setTotalAmount(auctionBidRecord.getLastBidAmount());
                orderDTO.setOrderFrom(OrderFromEnum.AUCTION_ORDERS);
                orderDTO.setOrderTime(LocalDateTime.now());
                MemberAddress data = memberClient.getMemberAddressOne(
                        auctionBidRecord.getMemberId(), SecurityConstants.INNER).getData();
                if (StringUtils.isNotNull(data)) {
                    orderDTO.setReceiverName(data.getRecipientName());
                    orderDTO.setReceiverCity(data.getReceiverCity());
                    orderDTO.setReceiverDetailAddress(data.getDetailedAddress());
                    orderDTO.setReceiverphone(data.getRecipientPhone());
                }
                orderClient.saveOrderOne(orderDTO, SecurityConstants.INNER);
            } else {
                // 没有人出价,退回拍卖商品库存
                GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                goodsStockUpdDTO.setGoodsSkuId(auctionGoods.getGoodsSkuId());
                goodsStockUpdDTO.setAuctionStock(auctionGoods.getAuctionStock());
                goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                        SecurityConstants.INNER);
            }
            // 结束拍卖
            this.lambdaUpdate().set(AuctionGoods::getStartStatus, AuctionStartStatusEnum.ENDED)
                    .eq(AuctionGoods::getId, id).update();
            // 查询已支付保证金记录
            List<OrderAuctionBond> auctionBondList = orderClient.getOrderAuctionBondList(id,
                    AuctionOrderTypeEnum.REGULAR_ITEMS,
                    BondStatusEnum.PAID,
                    SecurityConstants.INNER).getData();
            if (StringUtils.isNotEmpty(auctionBondList)) {
                List<RefundDTO> refundDTOList = new ArrayList<>();
                for (OrderAuctionBond orderAuctionBond : auctionBondList) {
                    // 已中标需在订单完成后退保证金
                    if (orderAuctionBond.getMemberId().equals(memberId)) {
                        continue;
                    }
                    RefundDTO refundDTO = new RefundDTO();
                    refundDTO.setOrderNo(orderAuctionBond.getOrderNo());
                    refundDTO.setAmount(orderAuctionBond.getBond());
                }
                // 远程调用订单服务进行退款
                Map<String, Object> data = orderClient.refund(refundDTOList,
                        SecurityConstants.INNER).getData();
                // 处理退款返回结果
                List<String> successfulOrders = new ArrayList<>();
                List<String> failedOrders = new ArrayList<>();
 
                data.forEach((key, value) -> {
                    if ((boolean) value) {
                        successfulOrders.add(key);
                    } else {
                        failedOrders.add(key);
                    }
                });
                log.info("订单号:{},退款失败", failedOrders);
                // 退款成功的订单修改状态
                List<Long> ids = auctionBondList.stream().map(bond -> {
                    if (successfulOrders.contains(bond.getOrderNo())) {
                        return bond.getId();
                    }
                    return null;
                }).filter(Objects::nonNull).collect(Collectors.toList());
                // 远程调用订单服务修改订单状态
                orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.PAID);
            }
        }
    }
 
    @Override
    public PageDTO<AuctionGoodsListVO> getAuctionGoodsList(AuctionGoodsListDTO auctionGoodsListDTO) {
        Set<Long> goodsSkuIdList = null;
        if (StringUtils.isNotEmpty(auctionGoodsListDTO.getGoodsSkuName())) {
            List<GoodsSku> goodsSku = goodsSkuClient.getGoodsByName(auctionGoodsListDTO.getGoodsSkuName(),
                            SecurityConstants.INNER)
                    .getData();
            goodsSkuIdList = goodsSku.stream().map(GoodsSku::getId)
                    .collect(Collectors.toSet());
        }
        AuctionGoodsListPageDTO auctionGoodsListPageDTO=new AuctionGoodsListPageDTO();
        auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList);
 
        Page<AuctionGoodsListVO> page = new Page<>();
        page.setSize(auctionGoodsListDTO.getPageSize());
        page.setCurrent(auctionGoodsListDTO.getPageCurr());
        List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList(page, auctionGoodsListPageDTO);
        List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>();
        for (AuctionGoods auctionGoods:auctionGoodsPgeList){
            AuctionGoodsListVO auctionGoodsVO=new AuctionGoodsListVO();
            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());
            auctionGoodsVOS.add(auctionGoodsVO);
 
        }
        page.setRecords(auctionGoodsVOS);
        return PageDTO.of(page);
    }
 
    @Override
    public AuctionGoodsinfoVO getAuctionGoodsInfo(AuctionGoodsListDTO auctionGoodsListDTO) {
        AuctionGoods byId = auctionGoodsService.getById(auctionGoodsListDTO.getGoodsSkuId());
        GoodsSku goodsSkuOne = goodsSkuClient.getGoodsSkuOne(byId.getGoodsSkuId(), SecurityConstants.INNER).getData();
        AuctionGoodsinfoVO auctionGoodsinfoVO=new AuctionGoodsinfoVO();
        auctionGoodsinfoVO.setGoodsSkuId(byId.getGoodsSkuId());
        auctionGoodsinfoVO.setGoodsSkuName(goodsSkuOne.getSkuName());
        auctionGoodsinfoVO.setStartingPrice(byId.getStartingPrice());
        auctionGoodsinfoVO.setSalesroomStock(byId.getAuctionStock());
        auctionGoodsinfoVO.setStartStatus(byId.getStartStatus());
        auctionGoodsinfoVO.setStartTime(byId.getStartTime());
        auctionGoodsinfoVO.setEndTime(byId.getEndTime());
        auctionGoodsinfoVO.setUnit(goodsSkuOne.getUnit());
        auctionGoodsinfoVO.setDescription(goodsSkuOne.getDescription());
        auctionGoodsinfoVO.setYears(goodsSkuOne.getYears());
        GoodsBrand data = goodsSkuClient.getBrandOne(goodsSkuOne.getBrandId(), SecurityConstants.INNER).getData();
        GoodsCategory data1 = goodsSkuClient.getCategoryOne(goodsSkuOne.getCategoryId(), SecurityConstants.INNER).getData();
        GoodsSeries data2 = goodsSkuClient.getSeriesOne(goodsSkuOne.getSeriesId(), SecurityConstants.INNER).getData();
        GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(goodsSkuOne.getFlavorTypeId(), SecurityConstants.INNER).getData();
        auctionGoodsinfoVO.setBrand(data.getBrandName());
        auctionGoodsinfoVO.setCategory(data1.getCategoryName());
        auctionGoodsinfoVO.setSeries(data2.getSeriesName());
        auctionGoodsinfoVO.setFlavorType(data3.getFlavorTypeName());
        auctionGoodsinfoVO.setCoverPic(goodsSkuOne.getCoverPic());
        auctionGoodsinfoVO.setAlbum(goodsSkuOne.getAlbum());
        auctionGoodsinfoVO.setAuthentication(byId.getAuthentication());
        auctionGoodsinfoVO.setMinimumMarkupAmount(byId.getMinimumMarkupAmount());
        auctionGoodsinfoVO.setSpec(goodsSkuOne.getSpec());
        auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit());
        auctionGoodsinfoVO.setShareTitle(goodsSkuOne.getShareTitle());
        auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit());
        LambdaQueryWrapper<AuctionBidRecord> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(AuctionBidRecord::getMemberId,auctionGoodsListDTO.getMemberId());
        wrapper1.eq(AuctionBidRecord::getAuctionType,1);
        wrapper1.eq(AuctionBidRecord::getTargetId,byId.getId());
        wrapper1.eq(AuctionBidRecord::getDelFlag,0);
        AuctionBidRecord list1 = auctionBidRecordService.getOne(wrapper1);
        if (list1!=null){
            auctionGoodsinfoVO.setIsBond(2);
            auctionGoodsinfoVO.setPresentBid(list1.getLastBidAmount());
            if (list1.getStatus().getCode()==2){
                auctionGoodsinfoVO.setIsStatus(2);
            }else{
                auctionGoodsinfoVO.setIsStatus(1);
            }
        }else{
            auctionGoodsinfoVO.setIsBond(1);
            auctionGoodsinfoVO.setIsStatus(1);
        }
        LambdaQueryWrapper<MemberAuctionCollection> wrapper2= Wrappers.lambdaQuery();
        wrapper2.eq(MemberAuctionCollection::getMemberId,auctionGoodsListDTO.getMemberId());
        wrapper2.eq(MemberAuctionCollection::getTargetId,byId.getId());
        wrapper2.eq(MemberAuctionCollection::getDelFlag,0);
        MemberAuctionCollection one = memberAuctionCollectionServiceImpl.getOne(wrapper2);
        if (one!=null){
            auctionGoodsinfoVO.setIsCollection(2);
        }else {
            auctionGoodsinfoVO.setIsCollection(1);
        }
        List<OrderAuctionBond> datas = orderClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData();
        if (datas.size()>0){
            auctionGoodsinfoVO.setIsApply(2);
        }else{
            auctionGoodsinfoVO.setIsApply(1);
        }
        return auctionGoodsinfoVO;
    }
 
    @Override
    public PageDTO<AuctionGoodsListVO> getWdAuctionSalesList(AuctionGoodsListDTO auctionGoodsListDTO) {
        MemberAuctionSalesroomDTO memberAuctionSalesroomDTO =new MemberAuctionSalesroomDTO();
        memberAuctionSalesroomDTO.setMemberId(auctionGoodsListDTO.getMemberId());
        List<OrderAuctionBond> data = orderClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData();
        Set<Long> goodsSkuIdList = null;
        goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId)
                .collect(Collectors.toSet());
 
        AuctionGoodsListPageDTO auctionGoodsListPageDTO=new AuctionGoodsListPageDTO();
        auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList);
 
        Page<AuctionGoodsListVO> page = new Page<>();
        page.setSize(auctionGoodsListDTO.getPageSize());
        page.setCurrent(auctionGoodsListDTO.getPageCurr());
        List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList(page, auctionGoodsListPageDTO);
        List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>();
        for (AuctionGoods auctionGoods:auctionGoodsPgeList){
            AuctionGoodsListVO auctionGoodsVO=new AuctionGoodsListVO();
            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());
 
            LambdaQueryWrapper<AuctionBidRecord> wrapper1= Wrappers.lambdaQuery();
            wrapper1.eq(AuctionBidRecord::getMemberId,auctionGoodsListDTO.getMemberId());
            wrapper1.eq(AuctionBidRecord::getAuctionType,1);
            wrapper1.eq(AuctionBidRecord::getTargetId,auctionGoods.getId());
            wrapper1.eq(AuctionBidRecord::getDelFlag,0);
            AuctionBidRecord list1 = auctionBidRecordService.getOne(wrapper1);
            if (list1!=null){
                if (list1.getStatus().getCode()==2){
                    auctionGoodsVO.setIsStatus(2);
                }else{
                    auctionGoodsVO.setIsStatus(1);
                }
            }else{
                auctionGoodsVO.setIsStatus(1);
            }
 
            auctionGoodsVOS.add(auctionGoodsVO);
 
        }
        page.setRecords(auctionGoodsVOS);
        return PageDTO.of(page);
    }
}