夏文涛 2 years ago
parent
commit
3a8833b4e1

+ 1 - 1
mhotel/src/com/happy/action/AppMePageAction.java

@@ -129,7 +129,7 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
             querySql.append(" and create_userid = '").append(userId).append("' ");
         }
 
-        IPage<Booking> iPage = bookService.queryPage(querySql.toString(), page, rows);
+        IPage<Booking> iPage = bookService.queryPage(querySql.toString(), page, rows, "create_time");
         List<Booking> bookList = iPage.getPageList();
         if (bookList != null) {
             for (Booking book : bookList) {

+ 2 - 2
mhotel/src/com/happy/action/IDCAction.java

@@ -124,7 +124,7 @@ public class IDCAction extends ActionSupport implements ServletRequestAware {
 //        }
         resultJson.put("message", "查询成功");
         resultJson.put("code", 200);
-        resultJson.put("data", list);
+        resultJson.put("data", list == null ? new ArrayList<>() : list);
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
     }
@@ -154,7 +154,7 @@ public class IDCAction extends ActionSupport implements ServletRequestAware {
 //        }
         resultJson.put("message", "查询成功");
         resultJson.put("code", 200);
-        resultJson.put("data", list);
+        resultJson.put("data", list == null ? new ArrayList<>() : list);
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
     }

+ 2 - 2
mhotel/src/com/happy/action/bookAction.java

@@ -347,7 +347,7 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
             s1.append(" and DATE_FORMAT(pay_time,'%Y-%m-%d') >= '").append(payStartTime).append("'")
                     .append(" and DATE_FORMAT(pay_time,'%Y-%m-%d') <= '").append(payEndTime).append("'");
         }
-        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows);
+        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows,"create_time");
         //获取订单汇总信息
         BookTypeEto bookTypeEto = bookService.getBookStatusSum(s1.toString());
         bookTypeEto.setSumAccount(new BigDecimal(bookTypeEto.getSumAccount()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
@@ -472,7 +472,7 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
         if(maxTotalPrice!=null){
             s1.append(" and house_total_price <= '").append(maxTotalPrice).append("'");
         }
-        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows);
+        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows, "check_out_time");
         //获取订单汇总信息
         BookTypeEto bookTypeEto = bookService.getBookStatusSum(s1.toString());
         bookTypeEto.setBookIPage(bookIPage);

+ 2 - 2
mhotel/src/com/happy/dao/BookDao.java

@@ -7,7 +7,7 @@ import com.happy.dto.BookTypeEto;
 import java.util.List;
 
 public interface BookDao {
-    
+
     /**
      * 描述:新增
      * @param book
@@ -43,7 +43,7 @@ public interface BookDao {
      * @param rows
      * @return
      */
-    List<Booking> queryPage(String sqlx, int page, int rows);
+    List<Booking> queryPage(String sqlx, int page, int rows, String orderDesc);
 
 
     /**

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

@@ -217,11 +217,11 @@ public class BookImplDao implements BookDao {
     }
 
     @Override
-    public List<Booking> queryPage(String sqlx, int page, int rows) {
+    public List<Booking> queryPage(String sqlx, int page, int rows, String orderDesc) {
         SqlUtil.filterKeyword(sqlx);
 
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = "SELECT a.*,b.name hotel_township_name,c.hstatus hstatus,c.status hotelStatus FROM (select "+selectCol+" from booking) a left join hotel_dict b on a.hotel_township = b.id left join hotel c on a.hotel_id = c.id WHERE 1=1 "+sqlx+" ORDER BY check_out_time DESC limit :start,:rows ";
+        String sql = "SELECT a.*,b.name hotel_township_name,c.hstatus hstatus,c.status hotelStatus FROM (select "+selectCol+" from booking) a left join hotel_dict b on a.hotel_township = b.id left join hotel c on a.hotel_id = c.id WHERE 1=1 "+sqlx+" ORDER BY " +orderDesc+ " DESC limit :start,:rows ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("start", start);
         sps.addValue("rows", rows);

+ 1 - 1
mhotel/src/com/happy/service/BookService.java

@@ -44,7 +44,7 @@ public interface BookService {
      * @param rows
      * @return
      */
-    IPage<Booking> queryPage(String sqlx, int page, int rows);
+    IPage<Booking> queryPage(String sqlx, int page, int rows, String orderDesc);
 
     /**
      * 描述:查询列表

+ 2 - 2
mhotel/src/com/happy/service/impl/BookImplService.java

@@ -75,9 +75,9 @@ public class BookImplService implements BookService {
     }
 
     @Override
-    public IPage<Booking> queryPage(String sqlx, int page, int rows) {
+    public IPage<Booking> queryPage(String sqlx, int page, int rows, String orderDesc) {
         IPage<Booking> iPage = new IPage();
-        List<Booking> bookList = bookDao.queryPage(sqlx,page,rows);
+        List<Booking> bookList = bookDao.queryPage(sqlx,page,rows,orderDesc);
         int total = bookDao.queryTotal(sqlx);
         iPage.setPageList(bookList);
         iPage.setPage(page);