|
|
@@ -41,12 +41,11 @@ public class AuctionRecordService {
|
|
|
.findAll(JpaUtils.toSpecification(pageQuery, AuctionRecord.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
|
|
|
|
- public Page<AuctionRecordDTO> recordInfos(PageQuery pageQuery, Long userId) {
|
|
|
+ public Page<AuctionRecordDTO> recordInfos(PageQuery pageQuery) {
|
|
|
|
|
|
Page<AuctionRecord> records = auctionRecordRepo
|
|
|
.findAll(JpaUtils.toSpecification(pageQuery, AuctionRecord.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
|
|
|
-// Page<AuctionRecord> records = auctionRecordRepo.findAll((), JpaUtils.toPageRequest(pageQuery));
|
|
|
List<AuctionRecordDTO> auctionRecordDTOS = new ArrayList<>();
|
|
|
records.getContent().forEach(record -> {
|
|
|
AuctionActivity auctionActivity = auctionActivityRepo.findById(record.getAuctionId())
|
|
|
@@ -99,6 +98,42 @@ public class AuctionRecordService {
|
|
|
return new PageImpl<>(auctionRecordDTOS, records.getPageable(), records.getTotalElements());
|
|
|
}
|
|
|
|
|
|
+ public List<AuctionRecordDTO> userRecord(Long userId, AuctionType type) {
|
|
|
+ List<AuctionRecord> records = auctionRecordRepo.findByUserId(userId, type);
|
|
|
+ List<AuctionRecordDTO> auctionRecordDTOS = new ArrayList<>();
|
|
|
+ records.forEach(record -> {
|
|
|
+ AuctionActivity auctionActivity = auctionActivityRepo.findById(record.getAuctionId())
|
|
|
+ .orElse(null);
|
|
|
+ if (auctionActivity == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AuctionRecordDTO auctionRecordDTO = new AuctionRecordDTO();
|
|
|
+ BeanUtils.copyProperties(record, auctionRecordDTO);
|
|
|
+ auctionRecordDTO.setAuctionPic(auctionActivity.getPic());
|
|
|
+ auctionRecordDTO.setActPurchasedId((auctionActivity.getPurchaserId()));
|
|
|
+ auctionRecordDTO.setCreatedTime(record.getCreatedAt());
|
|
|
+ if (auctionRecordDTO.getType().equals(AuctionRecordType.DEPOSIT) || auctionRecordDTO.isPurchased()) {
|
|
|
+ AuctionOrder auctionOrder = auctionOrderRepo.findFirstByAuctionRecordIdOrderByCreatedAt(record.getId());
|
|
|
+ if (auctionOrder != null) {
|
|
|
+ auctionRecordDTO.setOrderId(auctionOrder.getId());
|
|
|
+ auctionRecordDTO.setOrderStatus(auctionOrder.getStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Set<AuctionOrderStatus> auctionOrderStatuses = new HashSet<>();
|
|
|
+ auctionOrderStatuses.add(AuctionOrderStatus.NOT_PAID);
|
|
|
+ auctionOrderStatuses.add(AuctionOrderStatus.CANCELLED);
|
|
|
+ AuctionOrder depositOrder = auctionOrderRepo.findFirstByAuctionIdAndPaymentTypeAndStatusNotIn(record
|
|
|
+ .getAuctionId(), AuctionPaymentType.DEPOSIT, auctionOrderStatuses);
|
|
|
+ if (depositOrder != null) {
|
|
|
+ auctionRecordDTO.setDepositStatus(depositOrder.getStatus());
|
|
|
+ } else {
|
|
|
+ auctionRecordDTO.setDepositStatus(AuctionOrderStatus.FINISH);
|
|
|
+ }
|
|
|
+ auctionRecordDTOS.add(auctionRecordDTO);
|
|
|
+ });
|
|
|
+ return auctionRecordDTOS;
|
|
|
+ }
|
|
|
+
|
|
|
public AuctionRecord create(Long userId, Long auctionId, BigDecimal amount) {
|
|
|
AuctionActivity auction = auctionActivityRepo.findById(auctionId)
|
|
|
.orElseThrow(new BusinessException("暂无"));
|