|
|
@@ -1,17 +1,16 @@
|
|
|
package com.happy.action;
|
|
|
|
|
|
-import com.happy.Model.House;
|
|
|
-import com.happy.Model.weixin.PayResult;
|
|
|
-import com.happy.Model.weixin.WechatUnifiedOrder;
|
|
|
-import com.happy.Model.weixin.WeiXinUtil;
|
|
|
-import com.happy.Until.*;
|
|
|
-import com.happy.Until.Excel.toExcel;
|
|
|
-import com.happy.Until.weixin.JaxbUtil;
|
|
|
-import com.happy.Until.weixin.PayWxUtil;
|
|
|
-import com.happy.common.util.CommonResult;
|
|
|
-import com.happy.common.wx.WxUtil;
|
|
|
+import com.happy.Model.Hotel;
|
|
|
+import com.happy.Until.DateUtil;
|
|
|
+import com.happy.Until.Enum.B;
|
|
|
+import com.happy.Until.Func;
|
|
|
+import com.happy.Until.ResponseUtil;
|
|
|
+import com.happy.Until.ResultUtil;
|
|
|
+import com.happy.constant.ResultStatusCode;
|
|
|
+import com.happy.dto.IPage;
|
|
|
import com.happy.service.AppHomePageService;
|
|
|
import com.happy.service.BookService;
|
|
|
+import com.happy.service.HotelService;
|
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.struts2.ServletActionContext;
|
|
|
@@ -20,7 +19,6 @@ import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -35,18 +33,22 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
public BookService bookService;
|
|
|
@Resource
|
|
|
public AppHomePageService appHomePageService;
|
|
|
+ @Resource
|
|
|
+ public HotelService hotelService;
|
|
|
|
|
|
public int page; // 当前页
|
|
|
public int rows;// 每页显示的行数rows
|
|
|
|
|
|
public Integer id = new Integer(0);
|
|
|
public String status;
|
|
|
- private int hotelId = 0; //选择的当前酒店的id
|
|
|
+ public String hotelId; //选择的当前酒店的id
|
|
|
+ public String queryStartTime; // 查询开始时间
|
|
|
+ public String queryEndTime; // 查询结束时间
|
|
|
|
|
|
public String userCode; // 第一次进来获取用户的code
|
|
|
public String queryValue; // 首页查寻搜索关键词
|
|
|
- private Date startTimeQuery; // 查询订房开始时间
|
|
|
- private Date endTimeQuery; // 查询订房结束时间
|
|
|
+ public Date startTimeQuery; // 查询订房开始时间
|
|
|
+ public Date endTimeQuery; // 查询订房结束时间
|
|
|
|
|
|
public HttpServletRequest getRequest() {
|
|
|
return request;
|
|
|
@@ -113,7 +115,8 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
//getUserInfo();
|
|
|
|
|
|
// 获取民宿列表
|
|
|
- appHomePageService.getHotelList(queryValue,rows,page);
|
|
|
+ IPage iPage = appHomePageService.getHotelList(queryValue,rows,page);
|
|
|
+ ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(),iPage);
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
@@ -124,12 +127,48 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
*/
|
|
|
public String getHouseByHotelId()
|
|
|
{
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
// 如果未赋值,则直接跳出
|
|
|
- if (hotelId == 0 )
|
|
|
+ if (Func.checkNull(hotelId))
|
|
|
+ {
|
|
|
+ jsonObject.put(B.CODE, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
+ jsonObject.put(B.MESSAGE,ResultStatusCode.BAD_REQUEST.getMsg());
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());
|
|
|
return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用天去查"yyyy/MM/dd"
|
|
|
+// Date startDate = DateUtil.parseDate(queryStartTime,DateUtil.Time_Formatter_Day);
|
|
|
+// Date endDate = DateUtil.parseDate(queryStartTime,DateUtil.Time_Formatter_Day);
|
|
|
+ Hotel hotel = appHomePageService.getHotelAndHouseByHotelId(hotelId,queryStartTime, queryEndTime);
|
|
|
|
|
|
// 通过时间区间查询房间信息,并带好是否有房标识给前台
|
|
|
+ jsonObject.put(B.DATA,ResultUtil.ok(hotel));
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过酒店的id获取到酒店详细信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getHotelInfoByHotelId()
|
|
|
+ {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ // 如果未赋值,则直接跳出
|
|
|
+ if (Func.checkNull(hotelId))
|
|
|
+ {
|
|
|
+ jsonObject.put(B.CODE, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
+ jsonObject.put(B.MESSAGE,ResultStatusCode.BAD_REQUEST.getMsg());
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Hotel hotel = hotelService.getById(Func.parseInt(hotelId));
|
|
|
|
|
|
+ jsonObject.put(B.DATA,ResultUtil.ok(hotel));
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -151,11 +190,11 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
this.queryValue = queryValue;
|
|
|
}
|
|
|
|
|
|
- public int getHotelId() {
|
|
|
+ public String getHotelId() {
|
|
|
return hotelId;
|
|
|
}
|
|
|
|
|
|
- public void setHotelId(int hotelId) {
|
|
|
+ public void setHotelId(String hotelId) {
|
|
|
this.hotelId = hotelId;
|
|
|
}
|
|
|
|