licailing 3 роки тому
батько
коміт
b10c686eed

+ 2 - 0
src/main/java/com/izouma/nineth/repo/AuctionOrderRepo.java

@@ -29,5 +29,7 @@ public interface AuctionOrderRepo extends JpaRepository<AuctionOrder, Long>, Jpa
 
     AuctionOrder findFirstByAuctionRecordIdOrderByCreatedAt(Long recordId);
 
+    AuctionOrder findFirstByAuctionRecordIdOrderByIdDesc(Long recordId);
+
     AuctionOrder findFirstByAuctionIdAndPaymentTypeAndStatusNotIn(Long auctionId, AuctionPaymentType type, Collection<AuctionOrderStatus> status);
 }

+ 8 - 6
src/main/java/com/izouma/nineth/service/AuctionOrderService.java

@@ -260,11 +260,13 @@ public class AuctionOrderService {
             assetService.transfer(asset, order.getTotalPrice(), user, TransferReason.AUCTION, order.getId());
         }
 
-        //该出价记录表为竞得
-        AuctionRecord record = auctionRecordRepo.findById(order.getAuctionRecordId())
-                .orElseThrow(new BusinessException("无出价记录"));
-        record.setPurchased(true);
-        auctionRecordRepo.save(record);
+        //改出价记录表为竞得(一口价无出价表)
+        auctionRecordRepo.findById(order.getAuctionRecordId())
+                .ifPresent(record -> {
+                    record.setPurchased(true);
+                    auctionRecordRepo.save(record);
+                });
+
 
         //退保证金
         List<AuctionOrder> orders = auctionOrderRepo.findAllByAuctionIdAndPaymentTypeAndStatus(order.getAuctionId(),
@@ -405,7 +407,7 @@ public class AuctionOrderService {
                             .getId(), AuctionPaymentType.PURCHASE_PRICE, AuctionOrderStatus.NOT_PAID);
                     auctionOrders.forEach(this::cancel);
 
-                    auctionActivityService.changeStatus(act.getAssetId(), AuctionStatus.PASS);
+                    auctionActivityService.changeStatus(act.getId(), AuctionStatus.PASS);
                     log.info("拍卖定时任务流拍{}", act.getId());
 
                     //退其余保证金

+ 7 - 6
src/main/java/com/izouma/nineth/service/AuctionRecordService.java

@@ -116,14 +116,15 @@ public class AuctionRecordService {
             auctionRecordDTO.setDeposit(auctionActivity.getDeposit());
             auctionRecordDTO.setEndTime(auctionActivity.getEndTime());
             auctionRecordDTO.setAuctionType(auctionActivity.getAuctionType());
+            auctionRecordDTO.setAuctionStatus(auctionActivity.getStatus());
             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());
-                }
+//            if (auctionRecordDTO.getType().equals(AuctionRecordType.DEPOSIT) || auctionRecordDTO.isPurchased()) {
+            AuctionOrder auctionOrder = auctionOrderRepo.findFirstByAuctionRecordIdOrderByIdDesc(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);

+ 16 - 0
src/test/java/com/izouma/nineth/service/AuctionOrderServiceTest.java

@@ -0,0 +1,16 @@
+package com.izouma.nineth.service;
+
+
+import com.izouma.nineth.ApplicationTests;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class AuctionOrderServiceTest extends ApplicationTests {
+    @Autowired
+    private AuctionOrderService auctionOrderService;
+
+    @Test
+    public void test() {
+        auctionOrderService.passOverTimeAuction();
+    }
+}