Browse Source

新增套系更改(自动type)

zyf12 2 years ago
parent
commit
1e494bf466

+ 38 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsSystemServiceImpl.java

@@ -1,13 +1,20 @@
 package com.ruoyi.system.service.impl;
 
+import java.sql.Time;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.vo.CollectionsVo;
+import org.apache.commons.lang3.builder.ToStringExclude;
+import org.apache.ibatis.type.LocalDateTimeTypeHandler;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.PostCollectionsSystemMapper;
 import com.ruoyi.system.domain.PostCollectionsSystem;
@@ -101,6 +108,37 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
         //补充字段
         postCollectionsSystem.setUpdateBy(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
+        /*SimpleDateFormat formatter= new SimpleDateFormat("YYYY_MM_DD_HH_MM_SS");
+        Date localDate = new Date(System.currentTimeMillis());
+        Date startDate=postCollectionsSystem.getStartTime();
+        Date endDate=postCollectionsSystem.getEndTime();
+        if(localDate.after(startDate)){
+            postCollectionsSystem.setType(Long.valueOf(1));
+        }else if(startDate.after(localDate)&&endDate.after(localDate)){
+            postCollectionsSystem.setType(Long.valueOf(0));
+        }else {
+            postCollectionsSystem.setType(Long.valueOf(2));
+        }*/
+        /**
+         * 判断时间 (在售0/预售1/已过期2)
+         * 根据当前时间,对比套系时间,当前小于套系时间,该套系藏品为“以过期”,
+         * 当前时间大于套系时间为“预售”
+         */
+        Date nowDate = DateUtils.getNowDate();
+        Date startTime = postCollectionsSystem.getStartTime();
+        Date endTime = postCollectionsSystem.getEndTime();
+        //当前时间早于套系时间 ->预售
+        if (null!=startTime && null!=endTime){
+            if (nowDate.before(startTime)){
+                postCollectionsSystem.setType((long) 1);
+            }
+            else if (nowDate.after(endTime)){
+                postCollectionsSystem.setType((long) 2);
+            }
+            else {
+                postCollectionsSystem.setType((long) 0);
+            }
+        }
         return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
     }