|
|
@@ -512,7 +512,30 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
|
|
|
@Override
|
|
|
public List<LiveVO> selfLive(SelfVO selfVO) {
|
|
|
- Map<String, Live> cacheLive = CloneUtils.clone(cacheMap.viewAuction(selfVO.getAuctionId()));
|
|
|
+ UserInfo userInfo = UserUtils.getSimpleUserInfo();
|
|
|
+ if (userInfo == null) {
|
|
|
+ throw new ServiceException("璇峰厛鐧诲綍");
|
|
|
+ }
|
|
|
+ List<DepositOrder> depositOrders = selectPaidDepositOrders(userInfo.getId());
|
|
|
+ List<Bid> userBidList = bidMapper.selectBidList(Bid.builder()
|
|
|
+ .accountId(userInfo.getId().toString())
|
|
|
+ .build());
|
|
|
+ List<Lot> candidateLots = selectSelfCandidateLots(depositOrders, userBidList.stream()
|
|
|
+ .map(Bid::getLotId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+
|
|
|
+ Map<String, Live> cacheLive = new HashMap<>();
|
|
|
+ candidateLots.stream()
|
|
|
+ .map(Lot::getAuctionId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .forEach(auctionId -> {
|
|
|
+ Map<String, Live> auctionLive = CloneUtils.clone(cacheMap.viewAuction(auctionId));
|
|
|
+ if (!CollectionUtils.isEmpty(auctionLive)) {
|
|
|
+ cacheLive.putAll(auctionLive);
|
|
|
+ }
|
|
|
+ });
|
|
|
return cacheLive.values().stream()
|
|
|
.filter(live -> live.getAccountList().contains(UserUtils.getSimpleUserInfo().getId().toString()) &&
|
|
|
Constants.LOT_STATUS_BIDDING.equals(live.getLot().getStatus()))
|
|
|
@@ -539,12 +562,12 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
|
|
|
@Override
|
|
|
public List<LotVO> selfFinish(SelfVO selfVO) {
|
|
|
- return finishOrWin(selfVO, null);
|
|
|
+ return finishOrWin(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<LotVO> selfWin(SelfVO selfVO) {
|
|
|
- return finishOrWin(selfVO, 1);
|
|
|
+ return finishOrWin(1);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -554,19 +577,18 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
throw new ServiceException("请先登录");
|
|
|
}
|
|
|
String userId = userInfo.getId().toString();
|
|
|
- List<Lot> lotList = lotMapper.selectLotByAucId(selfVO.getAuctionId());
|
|
|
- List<DepositOrder> depositOrders = depositOrderMapper.selectList(new LambdaQueryWrapper<DepositOrder>()
|
|
|
- .eq(DepositOrder::getUserId, userInfo.getId())
|
|
|
- .eq(DepositOrder::getAuctionId, selfVO.getAuctionId())
|
|
|
- .in(DepositOrder::getStatus, 1));
|
|
|
-
|
|
|
+ List<DepositOrder> depositOrders = selectPaidDepositOrders(userInfo.getId());
|
|
|
+ List<Bid> userBidList = bidMapper.selectBidList(Bid.builder()
|
|
|
+ .accountId(userId)
|
|
|
+ .build());
|
|
|
+ Map<Long, List<Bid>> userBidMap = userBidList.stream()
|
|
|
+ .filter(bid -> Objects.nonNull(bid.getLotId()))
|
|
|
+ .collect(Collectors.groupingBy(Bid::getLotId));
|
|
|
+ List<Lot> lotList = selectSelfCandidateLots(depositOrders, userBidMap.keySet());
|
|
|
String type = StringUtils.isEmpty(selfVO.getType()) ? "all" : selfVO.getType();
|
|
|
List<LotVO> result = new ArrayList<>();
|
|
|
for (Lot lot : lotList) {
|
|
|
- List<Bid> userBids = bidMapper.selectBidList(Bid.builder()
|
|
|
- .lotId(lot.getId())
|
|
|
- .accountId(userId)
|
|
|
- .build());
|
|
|
+ List<Bid> userBids = userBidMap.getOrDefault(lot.getId(), Collections.emptyList());
|
|
|
boolean hasUserBid = !CollectionUtils.isEmpty(userBids);
|
|
|
boolean hasWinBid = hasUserBid && userBids.stream().anyMatch(bid -> Objects.equals(bid.getStatus(), 1));
|
|
|
boolean hasDeposit = hasDepositQualification(lot, depositOrders);
|
|
|
@@ -579,6 +601,47 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private List<DepositOrder> selectPaidDepositOrders(Integer userId) {
|
|
|
+ return depositOrderMapper.selectList(new LambdaQueryWrapper<DepositOrder>()
|
|
|
+ .eq(DepositOrder::getUserId, userId)
|
|
|
+ .eq(DepositOrder::getStatus, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Lot> selectSelfCandidateLots(List<DepositOrder> depositOrders, Collection<Long> bidLotIds) {
|
|
|
+ Map<Long, Lot> lotMap = new LinkedHashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(depositOrders)) {
|
|
|
+ depositOrders.stream()
|
|
|
+ .map(DepositOrder::getAuctionId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .forEach(auctionId -> addLots(lotMap, lotMapper.selectLotByAucId(auctionId)));
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> lotIds = new LinkedHashSet<>();
|
|
|
+ if (!CollectionUtils.isEmpty(bidLotIds)) {
|
|
|
+ lotIds.addAll(bidLotIds);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(depositOrders)) {
|
|
|
+ depositOrders.stream()
|
|
|
+ .map(DepositOrder::getLotId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .forEach(lotIds::add);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(lotIds)) {
|
|
|
+ addLots(lotMap, lotMapper.selectLotListByLotIds(new ArrayList<>(lotIds)));
|
|
|
+ }
|
|
|
+ return new ArrayList<>(lotMap.values());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addLots(Map<Long, Lot> lotMap, List<Lot> lots) {
|
|
|
+ if (CollectionUtils.isEmpty(lots)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lots.stream()
|
|
|
+ .filter(lot -> Objects.nonNull(lot.getId()))
|
|
|
+ .forEach(lot -> lotMap.put(lot.getId(), lot));
|
|
|
+ }
|
|
|
+
|
|
|
private boolean hasDepositQualification(Lot lot, List<DepositOrder> depositOrders) {
|
|
|
if (CollectionUtils.isEmpty(depositOrders)) {
|
|
|
return false;
|
|
|
@@ -665,10 +728,10 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
lots.addAll(lose);
|
|
|
}
|
|
|
|
|
|
- private List<LotVO> finishOrWin(SelfVO selfVO, Integer win) {
|
|
|
+ private List<LotVO> finishOrWin(Integer win) {
|
|
|
String account = UserUtils.getSimpleUserInfo().getId().toString();
|
|
|
List<LotVO> resultList = new ArrayList<>();
|
|
|
- List<Lot> lotList = lotMapper.selectLotByAucId(selfVO.getAuctionId());
|
|
|
+ List<Lot> lotList = lotMapper.selectLotFinishOrWin(win, account);
|
|
|
lotList.forEach(lot -> {
|
|
|
if (Constants.LOT_STATUS_PASS.equals(lot.getStatus()) || Constants.LOT_STATUS_SOLD.equals(lot.getStatus())) {
|
|
|
Bid condition = new Bid();
|