Browse Source

套系藏品上下架1.2.2

sjx 2 years ago
parent
commit
ce0452298c

+ 5 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.vo.CollectionsVo;
 import com.ruoyi.system.service.IPostCollectionsService;
+import com.ruoyi.system.utils.CollectionStatusJudgment;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -157,17 +158,19 @@ public class PostCollectionsSystemController extends BaseController
     @ApiOperation("更改套系状态(上架 /下架)")
     @PostMapping("/status/{status}")
     public AjaxResult changeStatus(@RequestParam("ids")List<Long> ids, @PathVariable String status){
-       List<PostCollectionsSystem> postCollectionsSystemList = postCollectionsSystemService.listByIds(ids);
+        List<PostCollectionsSystem> postCollectionsSystemList = postCollectionsSystemService.listByIds(ids);
 
         postCollectionsSystemList = postCollectionsSystemList.stream().map(
                 (item) ->{
                     item.setStatus(status);
                     //更改藏品的状态
-                    postCollectionsService.selectPostCollectionsList(item.getId());
+                    CollectionStatusJudgment.JudgmentStatus(item.getId());
                     return item;
                 }
         ).collect(Collectors.toList());
 
        return toAjax(postCollectionsSystemService.updateBatchById(postCollectionsSystemList));
     }
+
+
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsSystemMapper.java

@@ -78,6 +78,6 @@ public interface PostCollectionsSystemMapper
 
     //通过ids 查询套系
     List<PostCollectionsSystem> selectPostCollectionsSystemByIds(List<Long> ids);
-
+    //通过id批量修改
     int updateBatchById(List<PostCollectionsSystem> postCollectionsSystemList);
 }

+ 0 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsServiceImpl.java

@@ -56,10 +56,6 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     public List<PostCollections> selectPostCollectionsList(Long systemId)
     {
         PostCollections postCollections = new PostCollections();
-        //套系未上架
-
-        CollectionStatusJudgment.JudgmentStatus(systemId);
-
         //systemId是套系里的主键id
         postCollections.setSystemId(systemId);
         return postCollectionsMapper.selectPostCollectionsList(postCollections.getSystemId());

+ 21 - 19
ruoyi-system/src/main/java/com/ruoyi/system/utils/CollectionStatusJudgment.java

@@ -24,28 +24,30 @@ public class CollectionStatusJudgment {
     public void setPostCollectionsSystemMapper(PostCollectionsSystemMapper postCollectionsSystemMapper) {
         CollectionStatusJudgment.postCollectionsSystemMapper = postCollectionsSystemMapper;
     }
+
     @Autowired
     public void setPostCollectionsMapper(PostCollectionsMapper postCollectionsMapper) {
         CollectionStatusJudgment.postCollectionsMapper = postCollectionsMapper;
     }
+
     /**
      * 如果已经上架,判断藏品状态时间
      *
      * @param postCollectionsVo
      * @return 结果
      */
-    public static void JudgmentTime(PostCollectionsVo postCollectionsVo){
+    public static void JudgmentTime(PostCollectionsVo postCollectionsVo) {
 
         Date nowDate = DateUtils.getNowDate();
-        Date startTime =  postCollectionsVo.getStartTime();
-        Date endTime =  postCollectionsVo.getEndTime();
+        Date startTime = postCollectionsVo.getStartTime();
+        Date endTime = postCollectionsVo.getEndTime();
         //获取此藏品套系status
         Long systemId = postCollectionsVo.getSystemId();
 
         String postCollectionsSystemStatus = postCollectionsSystemMapper.selectPostCollectionsSystemByStatus(systemId);
-        if (Objects.equals(postCollectionsSystemStatus, "1")){
+        if (Objects.equals(postCollectionsSystemStatus, "1")) {
             //判空
-            if (null!=startTime && null!=endTime){
+            if (null != startTime && null != endTime) {
 
                 /**
                  * 判断时间 (0预售 /1已售尽 /2正在售卖 /3已过期)
@@ -55,44 +57,44 @@ public class CollectionStatusJudgment {
                  * 当前时间在售卖时间之间并且数量大于0为正在售卖
                  * 其余情况已售尽
                  */
-                if (nowDate.before(startTime)){
+                if (nowDate.before(startTime)) {
                     postCollectionsVo.setStatus("0");//预售
-                }
-                else if (nowDate.after(endTime)){
+                } else if (nowDate.after(endTime)) {
                     postCollectionsVo.setStatus("3");//已过期
-                }
-                else if (startTime.before(nowDate) &&
+                } else if (startTime.before(nowDate) &&
                         endTime.after(nowDate) &&
-                        postCollectionsVo.getCollectionsNumber()>0){
+                        postCollectionsVo.getCollectionsNumber() > 0) {
                     postCollectionsVo.setStatus("2");//正在售卖
-                }
-                else if(postCollectionsVo.getCollectionsNumber()==0){
+                } else if (postCollectionsVo.getCollectionsNumber() == 0) {
                     postCollectionsVo.setStatus("1");//售尽
                 }
             }
         }
 
     }
+
     /**
      * 如果未上架,令藏品状态为未上架
      *
      * @param systemId
      * @return 结果
      */
-    public static void JudgmentStatus(Long systemId){
+    public static void JudgmentStatus(Long systemId) {
         PostCollections postCollections = new PostCollections();
         String postCollectionsSystemStatus = postCollectionsSystemMapper.selectPostCollectionsSystemByStatus(systemId);
         //判断藏品套系是否上架,如果没上架,令藏品status全部置为未上架
-        if (null!=postCollectionsSystemStatus){
-            if (Objects.equals(postCollectionsSystemStatus, "0")){
+        if (null != postCollectionsSystemStatus) {
+            if (Objects.equals(postCollectionsSystemStatus, "0")) {
                 postCollections.setUpdateBy(getUsername());
-                postCollections.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
+                postCollections.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getTime()));
                 postCollections.setSystemId(systemId);
                 //批量修改status,动态查询藏品列表
                 postCollectionsMapper.updatePostCollectionsStatus(postCollections);
+            } else {
+                //上架
             }
-        }
 
         }
 
-    }
+    }
+}