Browse Source

修改有的优惠券到时间却未过期的问题

liu 2 years ago
parent
commit
16b3c72c0c
1 changed files with 7 additions and 2 deletions
  1. 7 2
      mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java

+ 7 - 2
mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java

@@ -157,10 +157,15 @@ public class HotelCouponImplDao implements HotelCouponDao {
 
 
     @Override
     @Override
     public int updateExpire() {
     public int updateExpire() {
-        //查询
+//        //查询
+//        String sql = "SELECT `id` from `hotel_coupon` WHERE 1=1 and (DATE_FORMAT(`effective_end_date`, '%Y-%m-%d') < CURDATE() AND `effective_lose_day` IS NULL  and `status` = 1)" +
+//                "    OR" +
+//                "    (DATE_FORMAT(DATE_ADD(`effective_end_date`, INTERVAL `effective_lose_day` + `effective_day` DAY),'%Y-%m-%d') < CURDATE()  and `status` = 1)";
+
+        //查询  当effective_lose_day或者effective_day为null时都找不到,所以不会将有效时间段的id找出来
         String sql = "SELECT `id` from `hotel_coupon` WHERE 1=1 and (DATE_FORMAT(`effective_end_date`, '%Y-%m-%d') < CURDATE() AND `effective_lose_day` IS NULL  and `status` = 1)" +
         String sql = "SELECT `id` from `hotel_coupon` WHERE 1=1 and (DATE_FORMAT(`effective_end_date`, '%Y-%m-%d') < CURDATE() AND `effective_lose_day` IS NULL  and `status` = 1)" +
                 "    OR" +
                 "    OR" +
-                "    (DATE_FORMAT(DATE_ADD(`effective_end_date`, INTERVAL `effective_lose_day` + `effective_day` DAY),'%Y-%m-%d') < CURDATE()  and `status` = 1)";
+                "    (DATE_FORMAT(DATE_ADD(`grant_end_date`, INTERVAL `effective_lose_day` + `effective_day` DAY),'%Y-%m-%d') < CURDATE()  and `status` = 1)";
         int num = 0;
         int num = 0;
         try {
         try {
             List<String> ids = namedParameterJdbcTemplate.queryForList(sql, EmptySqlParameterSource.INSTANCE, String.class);
             List<String> ids = namedParameterJdbcTemplate.queryForList(sql, EmptySqlParameterSource.INSTANCE, String.class);