wangqifan hace 4 años
padre
commit
8b54c442ff

+ 1 - 1
src/main/java/com/izouma/nineth/domain/ShowCollection.java

@@ -36,7 +36,7 @@ public class ShowCollection extends BaseEntity {
 
     private String name;
 
-    private AssetStatus assetStatus;
+    private String status;
 
     private int sort;
 }

+ 24 - 0
src/main/java/com/izouma/nineth/service/ShowroomService.java

@@ -98,6 +98,7 @@ public class ShowroomService {
                 }
                 showCollection.setShowroomId(show.getId());
                 showCollection.setAssetId(collection.getAssetId());
+                showCollection.setStatus(getStatus(collection));
                 showCollectionRepo.save(showCollection);
             }
         });
@@ -225,6 +226,7 @@ public class ShowroomService {
                             coll.setShowroomId(recordRoom.getId());
                             // 可能没有
                             coll.setAssetId(collection.getAssetId());
+                            coll.setStatus(getStatus(collection));
 
                             showCollectionRepo.save(coll);
                         }
@@ -260,4 +262,26 @@ public class ShowroomService {
         showroomRepo.save(showroom);
         cacheService.clearShowroom();
     }
+
+    public String getStatus(Collection collection) {
+        boolean salable = collection.isSalable();
+        LocalDateTime startTime = collection.getStartTime();
+        LocalDateTime now = LocalDateTime.now();
+        if (startTime.isBefore(now)) {
+            return "仅展示";
+        }
+        if (!salable) {
+            return "仅展示";
+        }
+        if (collection.getSoldOut() > 1) {
+            return "已售罄";
+        }
+        if (collection.isNoSoldOut()) {
+            return "已售罄";
+        }
+        if (collection.getSoldOut() != 1 & collection.getStock() == 0) {
+            return "即将售罄";
+        }
+        return "寄售中";
+    }
 }