|
|
@@ -592,9 +592,10 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
boolean hasUserBid = !CollectionUtils.isEmpty(userBids);
|
|
|
boolean hasWinBid = hasUserBid && userBids.stream().anyMatch(bid -> Objects.equals(bid.getStatus(), 1));
|
|
|
boolean hasDeposit = hasDepositQualification(lot, depositOrders);
|
|
|
+ String selfStatus = resolveSelfStatus(lot, hasDeposit, hasUserBid, hasWinBid);
|
|
|
|
|
|
- if (matchSelfScene(type, lot, hasDeposit, hasUserBid, hasWinBid)) {
|
|
|
- result.add(buildSelfLotVo(lot, userBids));
|
|
|
+ if (matchSelfScene(type, selfStatus)) {
|
|
|
+ result.add(buildSelfLotVo(lot, userBids, selfStatus));
|
|
|
}
|
|
|
}
|
|
|
sortSelfLots(type, result);
|
|
|
@@ -654,20 +655,36 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
&& Objects.equals(order.getAuctionId(), lot.getAuctionId()));
|
|
|
}
|
|
|
|
|
|
- private boolean matchSelfScene(String type, Lot lot, boolean hasDeposit, boolean hasUserBid, boolean hasWinBid) {
|
|
|
- if ("all".equals(type)) {
|
|
|
- return isWaitingLot(lot, hasDeposit) || isLiveLot(lot, hasDeposit, hasUserBid) || isLoseLot(lot, hasUserBid, hasWinBid);
|
|
|
+ private String resolveSelfStatus(Lot lot, boolean hasDeposit, boolean hasUserBid, boolean hasWinBid) {
|
|
|
+ if (isWaitingLot(lot, hasDeposit)) {
|
|
|
+ return "waiting";
|
|
|
}
|
|
|
- if ("waiting".equals(type)) {
|
|
|
- return isWaitingLot(lot, hasDeposit);
|
|
|
+ if (isLiveLot(lot, hasDeposit, hasUserBid)) {
|
|
|
+ return "live";
|
|
|
}
|
|
|
- if ("live".equals(type)) {
|
|
|
- return isLiveLot(lot, hasDeposit, hasUserBid);
|
|
|
+ if (isWinLot(lot, hasWinBid)) {
|
|
|
+ return "win";
|
|
|
+ }
|
|
|
+ if (isLoseLot(lot, hasUserBid, hasWinBid)) {
|
|
|
+ return "lose";
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean matchSelfScene(String type, String selfStatus) {
|
|
|
+ if (StringUtils.isEmpty(selfStatus)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ("all".equals(type)) {
|
|
|
+ return true;
|
|
|
}
|
|
|
if ("lose".equals(type) || "pass".equals(type) || "finish".equals(type)) {
|
|
|
- return isLoseLot(lot, hasUserBid, hasWinBid);
|
|
|
+ return "lose".equals(selfStatus);
|
|
|
}
|
|
|
- return false;
|
|
|
+ if ("win".equals(type)) {
|
|
|
+ return "win".equals(selfStatus);
|
|
|
+ }
|
|
|
+ return type.equals(selfStatus);
|
|
|
}
|
|
|
|
|
|
private boolean isWaitingLot(Lot lot, boolean hasDeposit) {
|
|
|
@@ -679,6 +696,10 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
&& (hasDeposit || hasUserBid);
|
|
|
}
|
|
|
|
|
|
+ private boolean isWinLot(Lot lot, boolean hasWinBid) {
|
|
|
+ return Constants.LOT_STATUS_SOLD.equals(lot.getStatus()) && hasWinBid;
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isLoseLot(Lot lot, boolean hasUserBid, boolean hasWinBid) {
|
|
|
if (!hasUserBid) {
|
|
|
return false;
|
|
|
@@ -689,11 +710,12 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
return Constants.LOT_STATUS_SOLD.equals(lot.getStatus()) && !hasWinBid;
|
|
|
}
|
|
|
|
|
|
- private LotVO buildSelfLotVo(Lot lot, List<Bid> userBids) {
|
|
|
+ private LotVO buildSelfLotVo(Lot lot, List<Bid> userBids, String selfStatus) {
|
|
|
LotVO lotVO = new LotVO();
|
|
|
BeanUtils.copyProperties(lot, lotVO);
|
|
|
lotVO.setBids(userBids);
|
|
|
lotVO.setCurrentPrice(Objects.nonNull(lot.getLastPrice()) ? lot.getLastPrice() : null);
|
|
|
+ lotVO.setSelfStatus(selfStatus);
|
|
|
return SensitiveDataUtils.handleViewDataSafe(lotVO);
|
|
|
}
|
|
|
|
|
|
@@ -706,20 +728,20 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
lots.sort(Comparator.comparing(Lot::getLastPriceTime, Comparator.nullsLast(Date::compareTo)).reversed());
|
|
|
return;
|
|
|
}
|
|
|
- if ("lose".equals(type) || "pass".equals(type) || "finish".equals(type)) {
|
|
|
+ if ("lose".equals(type) || "pass".equals(type) || "finish".equals(type) || "win".equals(type)) {
|
|
|
lots.sort(Comparator.comparing(Lot::getRealEndTime, Comparator.nullsLast(Date::compareTo)).reversed());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<LotVO> waiting = lots.stream().filter(lot -> Constants.LOT_STATUS_WAITING.equals(lot.getStatus()))
|
|
|
+ List<LotVO> waiting = lots.stream().filter(lot -> "waiting".equals(lot.getSelfStatus()))
|
|
|
.sorted(Comparator.comparing(Lot::getStartTime, Comparator.nullsLast(Date::compareTo)))
|
|
|
.collect(Collectors.toList());
|
|
|
List<LotVO> live = lots.stream()
|
|
|
- .filter(lot -> Constants.LOT_STATUS_STARTING.equals(lot.getStatus()) || Constants.LOT_STATUS_BIDDING.equals(lot.getStatus()))
|
|
|
+ .filter(lot -> "live".equals(lot.getSelfStatus()))
|
|
|
.sorted(Comparator.comparing(Lot::getLastPriceTime, Comparator.nullsLast(Date::compareTo)).reversed())
|
|
|
.collect(Collectors.toList());
|
|
|
List<LotVO> lose = lots.stream()
|
|
|
- .filter(lot -> Constants.LOT_STATUS_PASS.equals(lot.getStatus()) || Constants.LOT_STATUS_SOLD.equals(lot.getStatus()))
|
|
|
+ .filter(lot -> "lose".equals(lot.getSelfStatus()) || "win".equals(lot.getSelfStatus()))
|
|
|
.sorted(Comparator.comparing(Lot::getRealEndTime, Comparator.nullsLast(Date::compareTo)).reversed())
|
|
|
.collect(Collectors.toList());
|
|
|
lots.clear();
|