Skip to content

Commit

Permalink
完善了评价功能 只能够评价一次
Browse files Browse the repository at this point in the history
  • Loading branch information
lishangpeng committed Oct 14, 2018
1 parent befe2cf commit c69d6ad
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,22 @@ public ModelAndView userOrder(HttpServletRequest req,Integer curr) throws ParseE
if (ord.getOrderType() == null) {
ord.setOrderType("未付款");
}
//判断是否评价过
Comment comment = new Comment();
comment.setUserId(user.getId());
comment.setCheckInDate(ord.getCheckInDate());
comment.setCheckOutDate(ord.getCheckInDate());
comment.setHotelId(ord.getHotelId());
comment.setRoomId(ord.getRoomId());

if (commentService.isExisted(comment)) {
ord.setCommented(true);
}else {
ord.setCommented(false);
}
}

//调用redis 查询订单目前的状态,查询数据库查看是否付款
//key相等就是一种状态 而且order中的信息也相等
//orderId type


modelAndView.addObject("roomList", roomList);
modelAndView.addObject("hotelList", hotelList);
Expand Down Expand Up @@ -408,6 +419,8 @@ public ModelAndView commentSubmit(Order order,String comment,HttpServletResponse
Room room = roomService.selectOne(order.getRoomId());
pojo.setRoomName(room.getRoomName());
pojo.setUserId(user.getId());
pojo.setCheckInDate(order.getCheckInDate());
pojo.setCheckOutDate(order.getCheckOutDate());
commentService.insert(pojo);

ModelAndView modelAndView = new ModelAndView("redirect:/user/userOrder");
Expand Down
7 changes: 6 additions & 1 deletion lsp-Front/src/main/webapp/WEB-INF/jsp/user/userOrder.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@
<a href="javascript:void(0)">
<c:out value="${order.orderType }"></c:out>
</a>
<a href="<%=contxtPath %>/user/comment?hotelId=${order.hotelId }&roomId=${order.roomId }&checkInDate=${inDate }&checkOutDate=${outDate}">评论</a>
<c:if test="${order.commented }">
已评价
</c:if>
<c:if test="${not order.commented }">
<a href="<%=contxtPath %>/user/comment?hotelId=${order.hotelId }&roomId=${order.roomId }&checkInDate=${inDate }&checkOutDate=${outDate}">去评论</a>
</c:if>
<br/>
</c:if>
<c:if test="${order.orderType eq '已失效' }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</select>

<insert id="insert" parameterType="Comment">
insert into t_comments(hotelId,userId,createTime,comment,roomId,isDeleted,roomName,phoneNum)
values(#{hotelId},#{userId},#{createTime},#{comment},#{roomId},0,#{roomName},#{phoneNum})
insert into t_comments(hotelId,userId,createTime,comment,roomId,isDeleted,roomName,phoneNum,checkInDate,checkOutDate)
values(#{hotelId},#{userId},#{createTime},#{comment},#{roomId},0,#{roomName},#{phoneNum},#{checkInDate},#{checkOutDate})
</insert>
</mapper>
14 changes: 14 additions & 0 deletions lsp-Pojo/src/main/java/top/lspa/pojo/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ public class Comment implements Serializable{
private Long roomId;
private String roomName;
private String phoneNum;
private Date checkInDate;//为了使这个评价 只有一次
public Date getCheckInDate() {
return checkInDate;
}
public void setCheckInDate(Date checkInDate) {
this.checkInDate = checkInDate;
}
public Date getCheckOutDate() {
return checkOutDate;
}
public void setCheckOutDate(Date checkOutDate) {
this.checkOutDate = checkOutDate;
}
private Date checkOutDate;
public String getPhoneNum() {
return phoneNum;
}
Expand Down
8 changes: 8 additions & 0 deletions lsp-Pojo/src/main/java/top/lspa/pojo/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public class Order implements Serializable{
private Date checkOutDate;
private Boolean payOrNot;
private String orderType;
private Boolean commented;

public Boolean getCommented() {
return commented;
}
public void setCommented(Boolean commented) {
this.commented = commented;
}
public String getOrderType() {
return orderType;
}
Expand Down

0 comments on commit c69d6ad

Please sign in to comment.