Bläddra i källkod

藏品状态完善

chenzhengming 2 år sedan
förälder
incheckning
e5f230cb1a

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsMapper.java

@@ -67,4 +67,7 @@ public interface PostCollectionsMapper
      * @return 结果
      */
     public int selectPostCollectionsByName(PostCollectionsVo postCollectionsVo);
+
+    //批量修改藏品状态status
+    Long updatePostCollectionsStatus(Long systemId);
 }

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

@@ -73,6 +73,9 @@ public interface PostCollectionsSystemMapper
     // 查询该套系名 数量
     int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
 
+    //查询该套系状态status
+    String selectPostCollectionsSystemByStatus(Long systemId);
+
     //通过ids 查询套系
     List<PostCollectionsSystem> selectPostCollectionsSystemByIds(List<Long> ids);
 

+ 50 - 28
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsServiceImpl.java

@@ -2,8 +2,12 @@ package com.ruoyi.system.service.impl;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
+
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.PostCollectionsSystem;
 import com.ruoyi.system.domain.vo.PostCollectionsVo;
+import com.ruoyi.system.mapper.PostCollectionsSystemMapper;
 import com.ruoyi.system.service.IIssuerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -26,6 +30,8 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     private PostCollectionsMapper postCollectionsMapper;
     @Autowired
     private IIssuerService iIssuerService;
+    @Autowired
+    private PostCollectionsSystemMapper postCollectionsSystemMapper;
     /**
      * 查询藏品详细信息
      *
@@ -41,16 +47,22 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     /**
      * 查询藏品列表
      *
-     * @param id 藏品
+     * @param systemId 藏品
      * @return 藏品
      */
     @Override
-    public List<PostCollections> selectPostCollectionsList(Long id)
+    public List<PostCollections> selectPostCollectionsList(Long systemId)
     {
         PostCollections postCollections = new PostCollections();
-        //id是套系里的主键id
-        postCollections.setSystemId(id);
-        return postCollectionsMapper.selectPostCollectionsList(id);
+        String postCollectionsSystemStatus = postCollectionsSystemMapper.selectPostCollectionsSystemByStatus(systemId);
+        //判断藏品套系是否上架,如果没上架,令藏品status全部置为未上架
+        if (Objects.equals(postCollectionsSystemStatus, "0")){
+            //批量修改status
+            postCollectionsMapper.updatePostCollectionsStatus(systemId);
+        }
+        //systemId是套系里的主键id
+        postCollections.setSystemId(systemId);
+        return postCollectionsMapper.selectPostCollectionsList(systemId);
     }
 
     /**
@@ -65,30 +77,40 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
         Date nowDate = DateUtils.getNowDate();
         Date startTime =  postCollectionsVo.getStartTime();
         Date endTime =  postCollectionsVo.getEndTime();
-        //判空
-        if (null!=startTime && null!=endTime){
+        //获取此藏品套系status
+        Long systemId = postCollectionsVo.getSystemId();
+        String postCollectionsSystemStatus = postCollectionsSystemMapper.selectPostCollectionsSystemByStatus(systemId);
+        //判断藏品套系是否上架,如果没上架,令藏品也未上架
+        if (Objects.equals(postCollectionsSystemStatus, "0")){
+            postCollectionsVo.setStatus("4");//未上架
+        }
+        //如果套系已上架,判断以下时间线
+        else {
+            //判空
+            if (null!=startTime && null!=endTime){
 
-            /**
-             * 判断时间 (0预售 /1已售尽 /2正在售卖 /3已过期)
-             * 根据当前时间,对比售卖时间,
-             * 当前时间小于售卖时间,该套系藏品为预售,
-             * 当前时间大于售卖时间为已过期,
-             * 当前时间在售卖时间之间并且数量大于0为正在售卖
-             * 其余情况已售尽
-             */
-            if (nowDate.before(startTime)){
-                postCollectionsVo.setStatus("0");//预售
-            }
-            else if (nowDate.after(endTime)){
-                postCollectionsVo.setStatus("3");//已过期
-            }
-            else if (startTime.before(nowDate) &&
-                    endTime.after(nowDate) &&
-                    postCollectionsVo.getCollectionsNumber()>0){
-                postCollectionsVo.setStatus("2");//正在售卖
-            }
-            else if(postCollectionsVo.getCollectionsNumber()==0){
-                postCollectionsVo.setStatus("1");//售尽
+                /**
+                 * 判断时间 (0预售 /1已售尽 /2正在售卖 /3已过期)
+                 * 根据当前时间,对比售卖时间,
+                 * 当前时间小于售卖时间,该套系藏品为预售,
+                 * 当前时间大于售卖时间为已过期,
+                 * 当前时间在售卖时间之间并且数量大于0为正在售卖
+                 * 其余情况已售尽
+                 */
+                if (nowDate.before(startTime)){
+                    postCollectionsVo.setStatus("0");//预售
+                }
+                else if (nowDate.after(endTime)){
+                    postCollectionsVo.setStatus("3");//已过期
+                }
+                else if (startTime.before(nowDate) &&
+                        endTime.after(nowDate) &&
+                        postCollectionsVo.getCollectionsNumber()>0){
+                    postCollectionsVo.setStatus("2");//正在售卖
+                }
+                else if(postCollectionsVo.getCollectionsNumber()==0){
+                    postCollectionsVo.setStatus("1");//售尽
+                }
             }
         }
         postCollectionsVo.setCreateBy(getUsername());

+ 5 - 0
ruoyi-system/src/main/resources/mapper/system/PostCollectionsMapper.xml

@@ -117,4 +117,9 @@
     <select id="selectPostCollectionsByName" parameterType="PostCollectionsVo" resultType="int">
         select COUNT(name) FROM post_collections where name =  #{name} and del_flag = '0'
     </select>
+    <!--批量修改藏品状态status-->
+    <update id="updatePostCollectionsStatus"  parameterType="Long">
+        update post_collections set status = '4' where system_id=#{systemId} and del_flag = '0'
+    </update>
+
 </mapper>

+ 4 - 1
ruoyi-system/src/main/resources/mapper/system/PostCollectionsSystemMapper.xml

@@ -126,7 +126,10 @@
     <select id="selectPostCollectionsSystemByName" parameterType="PostCollectionsSystem" resultType="int">
         SELECT COUNT(name) FROM post_collections_system where name =  #{name} and del_flag = '0'
     </select>
-
+    <!--查询该套系状态status-->
+    <select id="selectPostCollectionsSystemByStatus" parameterType="Long" resultType="String">
+        select status from post_collections_system  where id = #{systemId}
+    </select>
     <!--通过ids 查询套系-->
     <select id="selectPostCollectionsSystemByIds" parameterType="String" resultMap="PostCollectionsSystemResult">
         <include refid="selectPostCollectionsSystemVo"/>