Kaynağa Gözat

添加广告优惠券页面展示

liu 2 yıl önce
ebeveyn
işleme
036a5d45bd

+ 27 - 0
mhotel/src/com/happy/action/hotelCoupomAction.java

@@ -236,6 +236,33 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
     }
     }
 
 
     /**
     /**
+     * 广告——优惠券分页
+     */
+    public String advertisingCouponPage(){
+        JSONObject resultJson = new JSONObject();
+        StringBuilder s1 = new StringBuilder("");
+
+        if (name != null){
+            s1.append(" and name like '%").append(name).append("%' ");
+        }
+
+        IPage<HotelCoupon> hotelCouponIPage = hotelCoupomService.advertisingCouponPage(s1.toString(),page,rows);
+
+        if(hotelCouponIPage!=null && !"".equals(hotelCouponIPage)){
+            resultJson.put("message", "查询分页成功");
+            resultJson.put("code", 200);
+            resultJson.put("data", hotelCouponIPage);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }else{
+            resultJson.put("message", "查询分页失败");
+            resultJson.put("code", 500);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }
+
+        return null;
+    }
+
+    /**
      * 描述:定时任务修改优惠卷状态
      * 描述:定时任务修改优惠卷状态
      */
      */
     public void setCoupomStatus(){
     public void setCoupomStatus(){

+ 4 - 0
mhotel/src/com/happy/dao/HotelCouponDao.java

@@ -86,4 +86,8 @@ public interface HotelCouponDao {
     int updatReversedNumber(HotelCoupon hotelCoupon);
     int updatReversedNumber(HotelCoupon hotelCoupon);
 
 
     List<CouponModel> getCoupon(String strs);
     List<CouponModel> getCoupon(String strs);
+
+    List<HotelCoupon> advertisingCouponPage(String sqlx, Integer page, Integer rows);
+
+    int advertisingCouponPageTotal(String sqlx);
 }
 }

+ 25 - 0
mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java

@@ -307,6 +307,31 @@ public class HotelCouponImplDao implements HotelCouponDao {
     }
     }
 
 
     @Override
     @Override
+    public List<HotelCoupon> advertisingCouponPage(String sqlx, Integer page, Integer rows) {
+        SqlUtil.filterKeyword(sqlx);
+        int start = (page - 1) * rows;// 每页的起始下标
+        String sql = "select " +
+                "id,hotelIds,name,type,rebate_price,deduction_price,max_deduction,grant_number,limit_number,grant_start_date,grant_end_date," +
+                "meet_price,effective_start_date,effective_end_date,effective_type,effective_day,effective_lose_day,create_id,create_date,modify_date,status,remainder_number,reversed_number" +
+                " from hotel_coupon where  status = 1 and DATE_FORMAT( grant_end_date, '%Y-%m-%d' ) >= CURDATE( )" + sqlx + " ORDER BY create_date DESC limit :start , :rows ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("start", start);
+        sps.addValue("rows", rows);
+        List<HotelCoupon> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(HotelCoupon.class));
+        if (list != null && list.size() > 0) return list;
+        return null;
+    }
+
+    @Override
+    public int advertisingCouponPageTotal(String sqlx) {
+        SqlUtil.filterKeyword(sqlx);
+        String sql = "SELECT count(*) FROM `hotel_coupon` where  status = 1 and DATE_FORMAT( grant_end_date, '%Y-%m-%d' ) >= CURDATE( ) " + sqlx;
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        return namedParameterJdbcTemplate.queryForInt(sql, sps);
+    }
+
+    @Override
     public int updateRemainderNumber(String complaintId, String modifyDate) {
     public int updateRemainderNumber(String complaintId, String modifyDate) {
         String sql = "UPDATE `hotel_coupon`  SET remainder_number=remainder_number-1 ,modify_date=:modifyDate WHERE id=:complaintId ";
         String sql = "UPDATE `hotel_coupon`  SET remainder_number=remainder_number-1 ,modify_date=:modifyDate WHERE id=:complaintId ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();

+ 2 - 0
mhotel/src/com/happy/service/HotelCoupomService.java

@@ -95,4 +95,6 @@ public interface HotelCoupomService {
     int updatReversedNumber(HotelCoupon hotelCoupon);
     int updatReversedNumber(HotelCoupon hotelCoupon);
 
 
     List<CouponModel> getCoupon(String strs);
     List<CouponModel> getCoupon(String strs);
+
+    IPage<HotelCoupon> advertisingCouponPage(String toString, Integer page, Integer rows);
 }
 }

+ 34 - 0
mhotel/src/com/happy/service/impl/HotelCoupomImplService.java

@@ -288,4 +288,38 @@ public class HotelCoupomImplService implements HotelCoupomService {
         return hotelCouponDao.getCoupon(strs);
         return hotelCouponDao.getCoupon(strs);
     }
     }
 
 
+    @Override
+    public IPage<HotelCoupon> advertisingCouponPage(String sqlx, Integer page, Integer rows) {
+
+        IPage<HotelCoupon> iPage = new IPage();
+        List<HotelCoupon> hotelCouponList = hotelCouponDao.advertisingCouponPage(sqlx,page,rows);
+
+        if (hotelCouponList!=null && hotelCouponList.size()>0) {
+
+            hotelCouponList.forEach(hotelCoupon -> {
+                String hotelIds = hotelCoupon.getHotelIds();
+                String sql = " and id in ( " + hotelIds + " )";
+                List<Hotel> hotels = hotelDao.queryList(sql);
+                if (hotels != null) {
+                    StringBuilder stringBuilder = new StringBuilder();
+                    hotels.forEach(hotel -> {
+                        stringBuilder.append(hotel.getHname()).append(",");
+                    });
+                    String hotelNames = stringBuilder.deleteCharAt(stringBuilder.length() - 1).toString();
+                    hotelCoupon.setHotelNames(hotelNames);
+                }
+            });
+        }
+        int total = hotelCouponDao.advertisingCouponPageTotal(sqlx);
+        iPage.setPageList(hotelCouponList);
+        iPage.setPage(page);
+        iPage.setTotalPage( (int)Math.ceil((double)total/rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        return iPage;
+
+
+
+    }
+
 }
 }