lt14 il y a 7 ans
Parent
commit
b5350b41c6

+ 13 - 0
sql/cinema.sql

@@ -357,3 +357,16 @@ UNLOCK TABLES;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
 -- Dump completed on 2019-04-24 21:20:52
+
+-- 定时任务
+show variables like '%sche%';
+set global event_scheduler =1;
+CREATE PROCEDURE cancel ()
+  update ticket SET  state =2 WHERE minute(timediff(now(),time))>15 and state=0;
+create event if not exists e_cancel
+  on schedule every 30 second
+  on completion preserve
+do call cancel();
+
+alter event e_cancel ON
+COMPLETION PRESERVE ENABLE;

+ 0 - 4
src/main/java/com/example/cinema/blImpl/sales/TicketServiceImpl.java

@@ -7,17 +7,13 @@ import com.example.cinema.data.promotion.ActivityMapper;
 import com.example.cinema.data.promotion.CouponMapper;
 import com.example.cinema.data.promotion.VIPCardMapper;
 import com.example.cinema.data.sales.TicketMapper;
-import com.example.cinema.po.Coupon;
 import com.example.cinema.po.Ticket;
-import com.example.cinema.po.VIPCard;
 import com.example.cinema.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * Created by liying on 2019/4/16.

+ 13 - 0
src/main/java/com/example/cinema/po/Ticket.java

@@ -3,6 +3,8 @@ package com.example.cinema.po;
 import com.example.cinema.vo.TicketVO;
 import com.example.cinema.vo.TicketWithScheduleVO;
 
+import java.sql.Timestamp;
+
 /**
  * Created by liying on 2019/4/16.
  */
@@ -35,6 +37,16 @@ public class Ticket {
      */
     private int state;
 
+    private Timestamp time;
+
+    public Timestamp getTime() {
+        return time;
+    }
+
+    public void setTime(Timestamp time) {
+        this.time = time;
+    }
+
     public Ticket() {
     }
 
@@ -61,6 +73,7 @@ public class Ticket {
                 stateString = "未完成";
         }
         vo.setState(stateString);
+        vo.setTime(time);
         return vo;
 
     }

+ 12 - 0
src/main/java/com/example/cinema/vo/TicketVO.java

@@ -1,5 +1,7 @@
 package com.example.cinema.vo;
 
+import java.sql.Timestamp;
+
 /**
  * Created by liying on 2019/4/16.
  */
@@ -31,6 +33,16 @@ public class TicketVO {
      */
     private String state;
 
+    private Timestamp time;
+
+    public Timestamp getTime() {
+        return time;
+    }
+
+    public void setTime(Timestamp time) {
+        this.time = time;
+    }
+
     public TicketVO() {
     }
 

+ 14 - 0
src/main/java/com/example/cinema/vo/TicketWithScheduleVO.java

@@ -1,5 +1,7 @@
 package com.example.cinema.vo;
 
+import java.sql.Timestamp;
+
 /**
  * Created by liying on 2019/4/16.
  */
@@ -31,9 +33,21 @@ public class TicketWithScheduleVO {
      */
     private String state;
 
+    private Timestamp time;
+
+
+
     public TicketWithScheduleVO() {
     }
 
+    public Timestamp getTime() {
+        return time;
+    }
+
+    public void setTime(Timestamp time) {
+        this.time = time;
+    }
+
     public int getId() {
         return id;
     }

+ 1 - 0
src/main/resources/dataImpl/sales/TicketMapper.xml

@@ -49,6 +49,7 @@
         <result column="column_index" property="columnIndex"></result>
         <result column="row_index" property="rowIndex"></result>
         <result column="state" property="state"></result>
+        <result column="time" property="time"></result>
     </resultMap>
 
 </mapper>

+ 1 - 0
src/main/resources/static/js/userMovieBuy.js

@@ -170,6 +170,7 @@ function orderConfirmClick() {
         '/vip/' + sessionStorage.getItem('id') + '/get',
         function (res) {
             isVIP = res.success;
+            useVIP = res.success;
             if (isVIP) {
                 $('#member-balance').html("<div><b>会员卡余额:</b>" + res.content.balance.toFixed(2) + "元</div>");
             } else {

+ 1 - 0
src/main/resources/templates/userMember.html

@@ -35,6 +35,7 @@
             <span class="gray-text" style="vertical-align: middle">用户A&nbsp;<span class="caret"></span></span>
         </button>
         <ul class="dropdown-menu">
+            <li><a href="/user/buy">电影票</a></li>
             <li><a href="#">卡包</a></li>
             <li id="logout"><a href="#">登出</a></li>
         </ul>