Browse Source

预约流程代码优化

ouyang 3 years ago
parent
commit
84384c7624
1 changed files with 5 additions and 8 deletions
  1. 5 8
      src/main/java/com/izouma/nineth/service/SubscribeService.java

+ 5 - 8
src/main/java/com/izouma/nineth/service/SubscribeService.java

@@ -24,16 +24,13 @@ public class SubscribeService {
 
     public void create(Subscribe record) {
         Collection collection = collectionRepo.findById(record.getCollectionId()).orElseThrow(new BusinessException("查无此藏品"));
-        if (ObjectUtil.isEmpty(collection.getStartTime())){
-            throw new BusinessException("此藏品没有预约开始时间");
-        }
-        if (!collection.getStartTime().isBefore(LocalDateTime.now())){
+//        if (ObjectUtil.isEmpty(collection.getStartTime()) && ObjectUtil.isEmpty(collection.getEndTime())) {
+//            throw new BusinessException("此藏品没有开启预约");
+//        }
+        if (!collection.getStartTime().isBefore(LocalDateTime.now())) {
             throw new BusinessException("还未到预约时间");
         }
-        if (ObjectUtil.isEmpty(collection.getEndTime())){
-            throw new BusinessException("此藏品没有预约结束时间");
-        }
-        if (!collection.getEndTime().isBefore(LocalDateTime.now())){
+        if (!collection.getEndTime().isBefore(LocalDateTime.now())) {
             throw new BusinessException("已超过预约时间");
         }
         subscribeRepo.save(record);