Browse Source

收藏/住过

xieli 2 years ago
parent
commit
4192f92c95

+ 22 - 0
mhotel/src/com/happy/Model/Hotel.java

@@ -1,6 +1,9 @@
 package com.happy.Model;
 package com.happy.Model;
 
 
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @Description  
  * @Description  
@@ -161,6 +164,9 @@ public class Hotel {
 	 */
 	 */
 	private List<FileInfo> hotelFileInfoList;
 	private List<FileInfo> hotelFileInfoList;
 
 
+	private String collect_hotel;
+	private boolean is_collect_hotel;
+
 	public Integer getId() {
 	public Integer getId() {
 		return id;
 		return id;
 	}
 	}
@@ -420,4 +426,20 @@ public class Hotel {
 	public void setRoom_number_calc(String room_number_calc) {
 	public void setRoom_number_calc(String room_number_calc) {
 		this.room_number_calc = room_number_calc;
 		this.room_number_calc = room_number_calc;
 	}
 	}
+
+	public String getCollect_hotel() {
+		return collect_hotel;
+	}
+
+	public void setCollect_hotel(String collect_hotel) {
+		this.collect_hotel = collect_hotel;
+	}
+
+	public boolean isIs_collect_hotel() {
+		return is_collect_hotel;
+	}
+
+	public void setIs_collect_hotel(boolean is_collect_hotel) {
+		this.is_collect_hotel = is_collect_hotel;
+	}
 }
 }

+ 16 - 0
mhotel/src/com/happy/action/AppHomePageAction.java

@@ -171,6 +171,9 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
 
 
     /**
     /**
      * hotelId 酒店id
      * hotelId 酒店id
+     * queryStartTime
+     * queryEndTime
+     * userId
      * 通过酒店的id获取到房间信息
      * 通过酒店的id获取到房间信息
      * @return
      * @return
      */
      */
@@ -193,6 +196,11 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
         Hotel hotel = appHomePageService.getHotelAndHouseByHotelId(hotelId,startDate, endDate);
         Hotel hotel = appHomePageService.getHotelAndHouseByHotelId(hotelId,startDate, endDate);
         hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotelId));
         hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotelId));
 
 
+        // 添加是否已收藏的酒店
+        if (!Func.checkNull(userId))
+           appHomePageService.assignCollect(userId, hotel);
+
+
         // 通过时间区间查询房间信息,并带好是否有房标识给前台
         // 通过时间区间查询房间信息,并带好是否有房标识给前台
         jsonObject.put(B.code,ResultStatusCode.OK.getStatus());
         jsonObject.put(B.code,ResultStatusCode.OK.getStatus());
         jsonObject.put(B.data,ResultUtil.ok(hotel));
         jsonObject.put(B.data,ResultUtil.ok(hotel));
@@ -201,8 +209,12 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
     }
     }
 
 
 
 
+
+
     /**
     /**
      * 通过酒店的id获取到酒店详细信息
      * 通过酒店的id获取到酒店详细信息
+     * hotelId
+     * userId
      * @return
      * @return
      */
      */
     public String getHotelInfoByHotelId()
     public String getHotelInfoByHotelId()
@@ -227,6 +239,10 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
         }
         }
         hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotelId));
         hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotelId));
 
 
+        // 添加是否已收藏的酒店
+        if (!Func.checkNull(userId))
+            appHomePageService.assignCollect(userId, hotel);
+
         jsonObject.put(B.code,ResultStatusCode.OK.getStatus());
         jsonObject.put(B.code,ResultStatusCode.OK.getStatus());
         jsonObject.put(B.data,hotel);
         jsonObject.put(B.data,hotel);
         ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());
         ResponseUtil.writeJson(ServletActionContext.getResponse(),jsonObject.toString());

+ 7 - 0
mhotel/src/com/happy/service/AppHomePageService.java

@@ -39,4 +39,11 @@ public interface AppHomePageService {
      */
      */
     public Hotel getHotelAndHouseByHotelId(String hotelId, String queryStartTime, String queryEndTime);
     public Hotel getHotelAndHouseByHotelId(String hotelId, String queryStartTime, String queryEndTime);
 
 
+    /**
+     * 赋值收藏的酒店
+     * @param userId
+     * @param hotel
+     * @return
+     */
+    Hotel assignCollect(String userId, Hotel hotel);
 }
 }

+ 21 - 0
mhotel/src/com/happy/service/impl/AppHomePageImplService.java

@@ -4,6 +4,7 @@ import com.happy.Model.Booking;
 import com.happy.Model.FileInfo;
 import com.happy.Model.FileInfo;
 import com.happy.Model.Hotel;
 import com.happy.Model.Hotel;
 import com.happy.Model.House;
 import com.happy.Model.House;
+import com.happy.Model.weixin.Users;
 import com.happy.Until.Enum.PayEnum;
 import com.happy.Until.Enum.PayEnum;
 import com.happy.Until.Func;
 import com.happy.Until.Func;
 import com.happy.dao.BookDao;
 import com.happy.dao.BookDao;
@@ -32,6 +33,8 @@ public class AppHomePageImplService implements AppHomePageService {
     public AdminManagerService adminManagerService;
     public AdminManagerService adminManagerService;
     @Resource
     @Resource
     public FileService fileService;
     public FileService fileService;
+    @Resource
+    public UserService userService;
 
 
 
 
     @Override
     @Override
@@ -73,6 +76,24 @@ public class AppHomePageImplService implements AppHomePageService {
     }
     }
 
 
     @Override
     @Override
+    public Hotel assignCollect(String userId, Hotel hotel)
+    {
+        Users users = userService.queryByUserId(userId);
+        if (users == null || hotel == null)
+            throw new RuntimeException("无法查询到当前用户");
+
+        hotel.setCollect_hotel(users.getCollect_hotel());
+
+        boolean flag = false; // 标识是否收获过当前酒店,Collect_hotel为空时未收藏, Collect_hotel未包含hotelid未收藏
+        if (!Func.checkNull(users.getCollect_hotel()))
+        {
+            flag = users.getCollect_hotel().contains(Func.parseStr(hotel.getId()));
+        }
+        hotel.setIs_collect_hotel(flag);
+        return hotel;
+    }
+
+    @Override
     public Hotel getHotelAndHouseByHotelId(String hotelId, String queryStartTime, String queryEndTime) {
     public Hotel getHotelAndHouseByHotelId(String hotelId, String queryStartTime, String queryEndTime) {
         if (Func.checkNull(hotelId))
         if (Func.checkNull(hotelId))
             return new Hotel();
             return new Hotel();