Эх сурвалжийг харах

藏品列表显示完善,查询藏品详情,新增藏品...

chenzhengming 2 жил өмнө
parent
commit
951235ef17

+ 31 - 16
ruoyi-system/src/main/java/com/ruoyi/system/domain/PostCollections.java

@@ -7,6 +7,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+
+import java.math.BigDecimal;
+
 /**
  * 藏品对象 post_collections
  *
@@ -33,15 +36,18 @@ public class PostCollections extends BaseEntity
     private String name;
 
     /** 售卖开始时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "售卖开始时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "售卖开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
 
     /** 售卖结束时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "售卖结束时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "售卖结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date endTime;
 
+    @Excel(name = "价格")
+    private BigDecimal price;
+
     /** 0 未上架 1 已上架 */
     @Excel(name = "0 未上架 1 已上架")
     private String status;
@@ -60,11 +66,11 @@ public class PostCollections extends BaseEntity
 
     /** 创建者 */
     @Excel(name = "创建者")
-    private String createUser;
+    private String createBy;
 
     /** 更新者 */
     @Excel(name = "更新者")
-    private String updateUser;
+    private String updateBy;
 
     /** 0 不删除 1 删除 */
     private String delFlag;
@@ -128,6 +134,14 @@ public class PostCollections extends BaseEntity
         this.status = status;
     }
 
+    public BigDecimal getPrice() {
+        return price;
+    }
+
+    public void setPrice(BigDecimal price) {
+        this.price = price;
+    }
+
     public String getStatus()
     {
         return status;
@@ -159,23 +173,23 @@ public class PostCollections extends BaseEntity
     {
         return image;
     }
-    public void setCreateUser(String createUser)
+    public void setcreateBy(String createBy)
     {
-        this.createUser = createUser;
+        this.createBy = createBy;
     }
 
-    public String getCreateUser()
+    public String getcreateBy()
     {
-        return createUser;
+        return createBy;
     }
-    public void setUpdateUser(String updateUser)
+    public void setUpdateBy(String updateBy)
     {
-        this.updateUser = updateUser;
+        this.updateBy = updateBy;
     }
 
-    public String getUpdateUser()
+    public String getUpdateBy()
     {
-        return updateUser;
+        return updateBy;
     }
     public void setDelFlag(String delFlag)
     {
@@ -196,14 +210,15 @@ public class PostCollections extends BaseEntity
                 .append("name", getName())
                 .append("startTime", getStartTime())
                 .append("endTime", getEndTime())
+                .append("price" , getPrice())
                 .append("status", getStatus())
                 .append("collectionsNumber", getCollectionsNumber())
                 .append("collectionsStory", getCollectionsStory())
                 .append("image", getImage())
                 .append("createTime", getCreateTime())
                 .append("updateTime", getUpdateTime())
-                .append("createUser", getCreateUser())
-                .append("updateUser", getUpdateUser())
+                .append("createBy", getcreateBy())
+                .append("updateBy", getUpdateBy())
                 .append("delFlag", getDelFlag())
                 .toString();
     }

+ 14 - 14
ruoyi-system/src/main/java/com/ruoyi/system/domain/PostCollectionsSystem.java

@@ -30,12 +30,12 @@ public class PostCollectionsSystem extends BaseEntity
 
     /** 开始展示时间 */
     @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "开始展示时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "开始展示时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
 
     /** 结束展示时间 */
     @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "结束展示时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "结束展示时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date endTime;
 
 
@@ -53,11 +53,11 @@ public class PostCollectionsSystem extends BaseEntity
 
     /** 创建者 */
     @Excel(name = "创建者")
-    private String createUser;
+    private String createBy;
 
     /** 更新者 */
     @Excel(name = "更新者")
-    private String updateUser;
+    private String updateBy;
 
     /** 删除标志 (0不删除 1删除) */
     private String delFlag;
@@ -135,23 +135,23 @@ public class PostCollectionsSystem extends BaseEntity
     {
         return giftExchange;
     }
-    public void setCreateUser(String createUser)
+    public void setCreateBy(String createBy)
     {
-        this.createUser = createUser;
+        this.createBy = createBy;
     }
 
-    public String getCreateUser()
+    public String getCreateBy()
     {
-        return createUser;
+        return createBy;
     }
-    public void setUpdateUser(String updateUser)
+    public void setUpdateBy(String updateBy)
     {
-        this.updateUser = updateUser;
+        this.updateBy = updateBy;
     }
 
-    public String getUpdateUser()
+    public String getUpdateBy()
     {
-        return updateUser;
+        return updateBy;
     }
     public void setDelFlag(String delFlag)
     {
@@ -176,8 +176,8 @@ public class PostCollectionsSystem extends BaseEntity
                 .append("image", getImage())
                 .append("giftExchange", getGiftExchange())
                 .append("updateTime", getUpdateTime())
-                .append("createUser", getCreateUser())
-                .append("updateUser", getUpdateUser())
+                .append("createBy", getCreateBy())
+                .append("updateBy", getUpdateBy())
                 .append("delFlag", getDelFlag())
                 .toString();
     }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/PostCollectionsVo.java

@@ -6,7 +6,7 @@ import com.ruoyi.system.domain.PostCollections;
  * 发行商名字
  */
 public class PostCollectionsVo extends PostCollections {
-  private String IssuerName;
+    private String IssuerName;
 
     public String getIssuerName() {
         return IssuerName;

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

@@ -19,7 +19,7 @@ public interface PostCollectionsMapper
      * @param id 藏品主键
      * @return 藏品
      */
-    public PostCollections selectPostCollectionsById(Long id);
+    public PostCollectionsVo selectPostCollectionsById(Long id);
 
     /**
      * 查询藏品列表

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/IPostCollectionsService.java

@@ -19,7 +19,7 @@ public interface IPostCollectionsService
      * @param id 藏品主键
      * @return 藏品
      */
-    public PostCollections selectPostCollectionsById(Long id);
+    public PostCollectionsVo selectPostCollectionsById(Long id);
 
     /**
      * 查询藏品列表

+ 45 - 10
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.vo.PostCollectionsVo;
@@ -10,6 +11,8 @@ import com.ruoyi.system.mapper.PostCollectionsMapper;
 import com.ruoyi.system.domain.PostCollections;
 import com.ruoyi.system.service.IPostCollectionsService;
 
+import static com.ruoyi.common.utils.SecurityUtils.getUsername;
+
 /**
  * 藏品Service业务层处理
  *
@@ -23,15 +26,14 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     private PostCollectionsMapper postCollectionsMapper;
     @Autowired
     private IIssuerService iIssuerService;
-
     /**
-     * 查询藏品
+     * 查询藏品详细信息
      *
      * @param id 藏品主键
      * @return 藏品
      */
     @Override
-    public PostCollections selectPostCollectionsById(Long id)
+    public PostCollectionsVo selectPostCollectionsById(Long id)
     {
         return postCollectionsMapper.selectPostCollectionsById(id);
     }
@@ -45,12 +47,9 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     @Override
     public List<PostCollections> selectPostCollectionsList(Long id)
     {
-        //这个id是套系里的主键id
         PostCollections postCollections = new PostCollections();
+        //id是套系里的主键id
         postCollections.setSystemId(id);
-        //查询藏品列表时将套系id赋给postCollectionsVo
-        PostCollectionsVo postCollectionsVo = new PostCollectionsVo();
-        postCollectionsVo.setSystemId(id);
         return postCollectionsMapper.selectPostCollectionsList(id);
     }
 
@@ -63,8 +62,43 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     @Override
     public int insertPostCollections(PostCollectionsVo postCollectionsVo)
     {
-        postCollectionsVo.setCreateTime(DateUtils.getNowDate());
-        postCollectionsVo.setIssuerId(iIssuerService.selectIssuerByIdForIssuerName(postCollectionsVo.getIssuerName()));//传入发行商id
+        Date nowDate = DateUtils.getNowDate();
+        Date startTime =  postCollectionsVo.getStartTime();
+        Date endTime =  postCollectionsVo.getEndTime();
+        //判空
+        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");//售尽
+            }
+        }
+        postCollectionsVo.setCreateBy(getUsername());
+        postCollectionsVo.setUpdateBy(getUsername());
+        postCollectionsVo.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
+        postCollectionsVo.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
+        //通过发行方的名字查询id存进数据库
+        postCollectionsVo.setSystemId(postCollectionsVo.getSystemId());
+        postCollectionsVo.setIssuerId(iIssuerService.selectIssuerByIdForIssuerName(postCollectionsVo.getIssuerName()));
+
         return postCollectionsMapper.insertPostCollections(postCollectionsVo);
     }
 
@@ -77,7 +111,8 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     @Override
     public int updatePostCollections(PostCollections postCollections)
     {
-        postCollections.setUpdateTime(DateUtils.getNowDate());
+        postCollections.setUpdateBy(getUsername());
+        postCollections.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsMapper.updatePostCollections(postCollections);
     }
 

+ 13 - 12
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsSystemServiceImpl.java

@@ -70,20 +70,21 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
         Date startTime = postCollectionsSystem.getStartTime();
         Date endTime = postCollectionsSystem.getEndTime();
         //当前时间早于套系时间 ->预售
-        if (nowDate.before(startTime)){
-            postCollectionsSystem.setType((long) 1);
-        }
-        else if (nowDate.after(endTime)){
-            postCollectionsSystem.setType((long) 2);
-        }
-        else {
-            postCollectionsSystem.setType((long) 0);
+        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);
+            }
         }
-
         //补充字段
-        postCollectionsSystem.setCreateUser(getUsername());
+        postCollectionsSystem.setCreateBy(getUsername());
         postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
-        postCollectionsSystem.setUpdateUser(getUsername());
+        postCollectionsSystem.setUpdateBy(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.insertPostCollectionsSystem(postCollectionsSystem);
     }
@@ -98,7 +99,7 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     public int updatePostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
     {
         //补充字段
-        postCollectionsSystem.setUpdateUser(getUsername());
+        postCollectionsSystem.setUpdateBy(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
     }

+ 1 - 3
ruoyi-system/src/main/resources/mapper/system/IssuerMapper.xml

@@ -35,9 +35,7 @@
         <include refid="selectIssuerVo"/>
         where id = #{id}
     </select>
-    <!--
-      通过发行方的名字查询ID
-    -->
+    <!--通过发行方的名字查询ID-->
     <select id="selectIssuerByIdForIssuerName" resultType="Long">
         SELECT id FROM issuer WHERE Issuer_name = #{Issuer_name}
     </select>

+ 21 - 14
ruoyi-system/src/main/resources/mapper/system/PostCollectionsMapper.xml

@@ -11,32 +11,36 @@
         <result property="name"    column="name"    />
         <result property="startTime"    column="start_time"    />
         <result property="endTime"    column="end_time"    />
+        <result property="price"    column="price"    />
         <result property="status"    column="status"    />
         <result property="collectionsNumber"    column="collections_number"    />
         <result property="collectionsStory"    column="collections_story"    />
         <result property="image"    column="image"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
-        <result property="createUser"    column="create_user"    />
-        <result property="updateUser"    column="update_user"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
         <result property="delFlag"    column="del_flag"    />
     </resultMap>
 
     <sql id="selectPostCollectionsVo">
-        select id, system_id, issuer_id, name, start_time, end_time, status, collections_number, collections_story, image, create_time, update_time, create_user, update_user, del_flag from post_collections
+        select id, system_id, issuer_id, name, start_time, end_time,price, status, collections_number, collections_story, image, create_time, update_time, create_by, update_by, del_flag from post_collections
     </sql>
 
     <select id="selectPostCollectionsList" parameterType="PostCollections" resultMap="PostCollectionsResult">
         <include refid="selectPostCollectionsVo"/>
         <where>
-            <if test="systemId != null "> and system_id = #{id}</if>
+            <if test="systemId != null "> and system_id = #{id}</if><!--条件套系id等于前端传过来的id-->
             and del_flag = '0'
         </where>
     </select>
-
-    <select id="selectPostCollectionsById" parameterType="Long" resultMap="PostCollectionsResult">
-        <include refid="selectPostCollectionsVo"/>
-        where id = #{id} and del_flag = '0'
+    <!--查询藏品详细信息,查发行方名称字段-->
+    <select id="selectPostCollectionsById" parameterType="Long" resultType="PostCollectionsVo">
+        select  c.image , c.name , c.price , c.start_time, c.end_time ,c.collections_number,c.collections_story , i.Issuer_name issuerName
+        from post_collections c
+        left join issuer i
+        on c.issuer_id = i.id
+        where c.id = #{id} and c.del_flag = '0'
     </select>
 
     <insert id="insertPostCollections" parameterType="PostCollections" useGeneratedKeys="true" keyProperty="id">
@@ -47,14 +51,15 @@
             <if test="name != null">name,</if>
             <if test="startTime != null">start_time,</if>
             <if test="endTime != null">end_time,</if>
+            <if test="price != null">price,</if>
             <if test="status != null">status,</if>
             <if test="collectionsNumber != null">collections_number,</if>
             <if test="collectionsStory != null">collections_story,</if>
             <if test="image != null">image,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
-            <if test="createUser != null">create_user,</if>
-            <if test="updateUser != null">update_user,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
             <if test="delFlag != null">del_flag,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -63,14 +68,15 @@
             <if test="name != null">#{name},</if>
             <if test="startTime != null">#{startTime},</if>
             <if test="endTime != null">#{endTime},</if>
+            <if test="price != null">#{price},</if>
             <if test="status != null">#{status},</if>
             <if test="collectionsNumber != null">#{collectionsNumber},</if>
             <if test="collectionsStory != null">#{collectionsStory},</if>
             <if test="image != null">#{image},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
-            <if test="createUser != null">#{createUser},</if>
-            <if test="updateUser != null">#{updateUser},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
             <if test="delFlag != null">#{delFlag},</if>
         </trim>
     </insert>
@@ -83,14 +89,15 @@
             <if test="name != null">name = #{name},</if>
             <if test="startTime != null">start_time = #{startTime},</if>
             <if test="endTime != null">end_time = #{endTime},</if>
+            <if test="price != null">#{price},</if>
             <if test="status != null">status = #{status},</if>
             <if test="collectionsNumber != null">collections_number = #{collectionsNumber},</if>
             <if test="collectionsStory != null">collections_story = #{collectionsStory},</if>
             <if test="image != null">image = #{image},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
-            <if test="createUser != null">create_user = #{createUser},</if>
-            <if test="updateUser != null">update_user = #{updateUser},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
         </trim>
         where id = #{id}

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

@@ -15,13 +15,13 @@
         <result property="image"    column="image"    />
         <result property="giftExchange"    column="gift_exchange"    />
         <result property="updateTime"    column="update_time"    />
-        <result property="createUser"    column="create_user"    />
-        <result property="updateUser"    column="update_user"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
         <result property="delFlag"    column="del_flag"    />
     </resultMap>
 
     <sql id="selectPostCollectionsSystemVo">
-        select id, type, name, create_time, start_time, end_time, status, image, gift_exchange, update_time, create_user, update_user, del_flag from post_collections_system
+        select id, type, name, create_time, start_time, end_time, status, image, gift_exchange, update_time, create_by, update_by, del_flag from post_collections_system
     </sql>
 
     <select id="selectPostCollectionsSystemList" parameterType="PostCollectionsSystem" resultMap="PostCollectionsSystemResult">
@@ -34,8 +34,8 @@
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null  and image != ''"> and image = #{image}</if>
             <if test="giftExchange != null "> and gift_exchange = #{giftExchange}</if>
-            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
-            <if test="updateUser != null  and updateUser != ''"> and update_user = #{updateUser}</if>
+            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
+            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
         and del_flag = '0'
         </where>
     </select>
@@ -57,8 +57,8 @@
             <if test="image != null">image,</if>
             <if test="giftExchange != null">gift_exchange,</if>
             <if test="updateTime != null">update_time,</if>
-            <if test="createUser != null">create_user,</if>
-            <if test="updateUser != null">update_user,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
             <if test="delFlag != null">del_flag,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -71,8 +71,8 @@
             <if test="image != null">#{image},</if>
             <if test="giftExchange != null">#{giftExchange},</if>
             <if test="updateTime != null">#{updateTime},</if>
-            <if test="createUser != null">#{createUser},</if>
-            <if test="updateUser != null">#{updateUser},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
             <if test="delFlag != null">#{delFlag},</if>
         </trim>
     </insert>
@@ -89,8 +89,8 @@
             <if test="image != null">image = #{image},</if>
             <if test="giftExchange != null">gift_exchange = #{giftExchange},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
-            <if test="createUser != null">create_user = #{createUser},</if>
-            <if test="updateUser != null">update_user = #{updateUser},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
         </trim>
         where id = #{id}
@@ -132,8 +132,8 @@
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null  and image != ''"> and image = #{image}</if>
             <if test="giftExchange != null "> and gift_exchange = #{giftExchange}</if>
-            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
-            <if test="updateUser != null  and updateUser != ''"> and update_user = #{updateUser}</if>
+            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
+            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
             and del_flag = '0'
         </where>
     </select>