Browse Source

Merge branch 'master' of https://e.coding.net/chuanghaikeji/jinganxiangsu/Homestay_app_houtai

# Conflicts:
#	mhotel/src/com/happy/Model/BookingComment.java
#	mhotel/src/com/happy/action/AppBookingCommentAction.java
#	mhotel/src/com/happy/dao/BookingCommentDao.java
#	mhotel/src/com/happy/dao/impl/BookingCommentDaoImpl.java
#	mhotel/src/com/happy/service/BookingCommentService.java
#	mhotel/src/com/happy/service/impl/BookingCommentImplService.java
lijie 2 years ago
parent
commit
4bb1c53eb6

+ 131 - 0
mhotel/src/com/happy/Model/BookingComment.java

@@ -75,4 +75,135 @@ public class BookingComment {
     //    下级评论回复
     //    下级评论回复
     private List<BookingComment> lowCommentList;
     private List<BookingComment> lowCommentList;
 
 
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getCommentId() {
+        return commentId;
+    }
+
+    public void setCommentId(String commentId) {
+        this.commentId = commentId;
+    }
+
+    public String getBookingId() {
+        return bookingId;
+    }
+
+    public void setBookingId(String bookingId) {
+        this.bookingId = bookingId;
+    }
+
+    public String getHotelId() {
+        return hotelId;
+    }
+
+    public void setHotelId(String hotelId) {
+        this.hotelId = hotelId;
+    }
+
+    public String getHouseId() {
+        return houseId;
+    }
+
+    public void setHouseId(String houseId) {
+        this.houseId = houseId;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getCommentStatus() {
+        return commentStatus;
+    }
+
+    public void setCommentStatus(String commentStatus) {
+        this.commentStatus = commentStatus;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public Double getScoreWs() {
+        return scoreWs;
+    }
+
+    public void setScoreWs(Double scoreWs) {
+        this.scoreWs = scoreWs;
+    }
+
+    public Double getScoreFw() {
+        return scoreFw;
+    }
+
+    public void setScoreFw(Double scoreFw) {
+        this.scoreFw = scoreFw;
+    }
+
+    public Double getScoreSs() {
+        return scoreSs;
+    }
+
+    public void setScoreSs(Double scoreSs) {
+        this.scoreSs = scoreSs;
+    }
+
+    public Double getScoreWz() {
+        return scoreWz;
+    }
+
+    public void setScoreWz(Double scoreWz) {
+        this.scoreWz = scoreWz;
+    }
+
+    public Integer getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(Integer createId) {
+        this.createId = createId;
+    }
+
+    public String getCreateUsername() {
+        return createUsername;
+    }
+
+    public void setCreateUsername(String createUsername) {
+        this.createUsername = createUsername;
+    }
+
+    public String getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(String createDate) {
+        this.createDate = createDate;
+    }
+
+    public String getModifyDate() {
+        return modifyDate;
+    }
+
+    public void setModifyDate(String modifyDate) {
+        this.modifyDate = modifyDate;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
 }
 }

+ 144 - 6
mhotel/src/com/happy/action/AppBookingCommentAction.java

@@ -3,8 +3,12 @@ package com.happy.action;
 import com.happy.Model.BookingComment;
 import com.happy.Model.BookingComment;
 import com.happy.Until.Func;
 import com.happy.Until.Func;
 import com.happy.Until.ResUtil;
 import com.happy.Until.ResUtil;
+import com.happy.Until.ResponseUtil;
+import com.happy.dto.IPage;
 import com.happy.dto.OrderRateDto;
 import com.happy.dto.OrderRateDto;
 import com.happy.service.BookingCommentService;
 import com.happy.service.BookingCommentService;
+import com.happy.vo.BookingCommentPageVo;
+import com.happy.vo.EvaluatePageVo;
 import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.ActionSupport;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.ServletActionContext;
@@ -54,6 +58,13 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
     public BookingCommentService bookingCommentService;
     public BookingCommentService bookingCommentService;
 
 
 
 
+    //    回复评论id
+    public String commentId;
+    //    回复主评论id
+    public String commentParentId;
+    //    回复人名称
+    public String commentName;
+
     //    评论订单id
     //    评论订单id
     public String bookingId;
     public String bookingId;
 
 
@@ -66,6 +77,9 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
     //    内容
     //    内容
     public String content;
     public String content;
 
 
+    //    评价状态
+    public String commentStatus;
+
     //    总评分
     //    总评分
     public Double score;
     public Double score;
 
 
@@ -110,6 +124,30 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         this.bookingId = bookingId;
         this.bookingId = bookingId;
     }
     }
 
 
+    public String getCommentId() {
+        return commentId;
+    }
+
+    public void setCommentId(String commentId) {
+        this.commentId = commentId;
+    }
+
+    public String getCommentParentId() {
+        return commentParentId;
+    }
+
+    public void setCommentParentId(String commentParentId) {
+        this.commentParentId = commentParentId;
+    }
+
+    public String getCommentName() {
+        return commentName;
+    }
+
+    public void setCommentName(String commentName) {
+        this.commentName = commentName;
+    }
+
     public String getHotelId() {
     public String getHotelId() {
         return hotelId;
         return hotelId;
     }
     }
@@ -206,6 +244,34 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         this.modifyDate = modifyDate;
         this.modifyDate = modifyDate;
     }
     }
 
 
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public int status; //状态,0显示全部,1显示有附件,2显示有回复
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getRows() {
+        return rows;
+    }
+
+    public void setRows(int rows) {
+        this.rows = rows;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
     /**
     /**
      * 添加评论
      * 添加评论
      */
      */
@@ -213,28 +279,32 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         JSONObject jsonObject = new JSONObject();
         JSONObject jsonObject = new JSONObject();
         if (score == null || score < 0 || scoreFw == null || scoreFw < 0 || scoreSs == null || scoreSs < 0 || scoreWs == null || scoreWs < 0 || scoreWz == null || scoreWz < 0 || bookingId == null || hotelId == null || houseId == null) {
         if (score == null || score < 0 || scoreFw == null || scoreFw < 0 || scoreSs == null || scoreSs < 0 || scoreWs == null || scoreWs < 0 || scoreWz == null || scoreWz < 0 || bookingId == null || hotelId == null || houseId == null) {
             jsonObject.put("code", 400);
             jsonObject.put("code", 400);
-            jsonObject.put("message", "未传入orderRateDto数据---orderRate");
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---orderRate");
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
             return null;
         }
         }
 
 
         BookingComment bookingComment = BookingComment.builder().bookingId(bookingId)
         BookingComment bookingComment = BookingComment.builder().bookingId(bookingId)
-                .hotelId(hotelId).houseId(houseId).content(content)
+                .hotelId(hotelId).houseId(houseId).content(content).commentStatus(commentStatus)
                 .score(score).scoreWs(scoreWs).scoreFw(scoreFw)
                 .score(score).scoreWs(scoreWs).scoreFw(scoreFw)
                 .scoreSs(scoreSs).scoreWz(scoreWz).createId(String.valueOf(createId))
                 .scoreSs(scoreSs).scoreWz(scoreWz).createId(String.valueOf(createId))
                 .createUsername(createUsername).createDate(createDate)
                 .createUsername(createUsername).createDate(createDate)
                 .modifyDate(modifyDate).build();
                 .modifyDate(modifyDate).build();
 
 
 
 
-        int a = bookingCommentService.orderRate(bookingComment,pictureList);
+        int a = bookingCommentService.orderRate(bookingComment, pictureList);
 
 
-        if (a>0) {
+
+        if (a > 0) {
             jsonObject.put("code", 200);
             jsonObject.put("code", 200);
             jsonObject.put("message", "添加成功");
             jsonObject.put("message", "添加成功");
+            jsonObject.put("success", true);
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
             return null;
         }
         }
         jsonObject.put("message", "未知异常");
         jsonObject.put("message", "未知异常");
+        jsonObject.put("success", false);
         jsonObject.put("code", 205);
         jsonObject.put("code", 205);
         ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
         ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
         return null;
         return null;
@@ -246,16 +316,84 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
      *
      *
      * @return
      * @return
      */
      */
-    public JSONObject evaluateList() {
+    public JSONObject evaluatePage() {
         JSONObject jsonObject = new JSONObject();
         JSONObject jsonObject = new JSONObject();
         if (Func.checkNull(hotelId)) {
         if (Func.checkNull(hotelId)) {
             jsonObject.put("code", 400);
             jsonObject.put("code", 400);
-            jsonObject.put("message", "未传入hotel_id数据---evaluateList");
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入hotel_id数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        if (Func.checkNull(status + "")) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入status数据---evaluatePage");
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
             return null;
         }
         }
 
 
+        if (page <= 0 || rows <= 0) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入page,rows数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+//        获取分页数据
+        IPage<BookingCommentPageVo> iPage = bookingCommentService.evaluatePage(status, hotelId, page, rows);
+//        计算评分
+        EvaluatePageVo vo = bookingCommentService.evaluateScore(hotelId);
+
+        jsonObject.put("code", 200);
+        jsonObject.put("message", "成功");
+        jsonObject.put("success", true);
+        jsonObject.put("page", iPage);
+        jsonObject.put("score", vo);
+
+        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+
+
+        return null;
 
 
+    }
+
+    /**
+     * 回复评论
+     *
+     * @return
+     */
+    public JSONObject replyComment() {
+        JSONObject jsonObject = new JSONObject();
+        if (Func.checkNull(content) || Func.checkNull(commentParentId)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---replyComment");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        BookingComment bookingComment = BookingComment.builder().commentId(commentId).commentParentId(commentParentId).commentName(commentName).bookingId(bookingId)
+                .hotelId(hotelId).houseId(houseId).content(content).commentStatus(commentStatus)
+                .score(score).scoreWs(scoreWs).scoreFw(scoreFw)
+                .scoreSs(scoreSs).scoreWz(scoreWz).createId(createId)
+                .createUsername(createUsername).createDate(createDate)
+                .modifyDate(modifyDate).build();
+
+
+        int i = bookingCommentService.replyComment(bookingComment);
+        if (i > 0) {
+            jsonObject.put("code", 200);
+            jsonObject.put("message", "回复成功");
+            jsonObject.put("success", true);
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+        jsonObject.put("message", "未知异常");
+        jsonObject.put("code", 205);
+        jsonObject.put("success", false);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
         return null;
         return null;
 
 
     }
     }

+ 19 - 0
mhotel/src/com/happy/dao/BookingCommentDao.java

@@ -1,6 +1,11 @@
 package com.happy.dao;
 package com.happy.dao;
 
 
 import com.happy.Model.BookingComment;
 import com.happy.Model.BookingComment;
+import com.happy.dto.IPage;
+import com.happy.vo.BookingCommentPageVo;
+import com.happy.vo.EvaluatePageVo;
+
+import java.util.List;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -20,4 +25,18 @@ public interface BookingCommentDao {
     int insterCommpent(BookingComment bookingComment);
     int insterCommpent(BookingComment bookingComment);
 
 
     int updateCommpentStatus(BookingComment bookingComment);
     int updateCommpentStatus(BookingComment bookingComment);
+    List<BookingCommentPageVo> evaluatePage(String hotelId, int page, int rows);
+
+    int evaluateTotal(String hotelId);
+
+    List<BookingCommentPageVo> evaluatePagepicture(String hotelId, int page, int rows);
+
+    int evaluateTotalpicture(String hotelId);
+
+    List<BookingCommentPageVo> evaluatePageComment(String hotelId, int page, int rows);
+
+    int evaluateTotalComment(String hotelId);
+
+    EvaluatePageVo evaluateScore(String hotelId);
+
 }
 }

File diff suppressed because it is too large
+ 156 - 36
mhotel/src/com/happy/dao/impl/BookingCommentDaoImpl.java


+ 9 - 0
mhotel/src/com/happy/service/BookingCommentService.java

@@ -2,6 +2,8 @@ package com.happy.service;
 
 
 import com.happy.Model.BookingComment;
 import com.happy.Model.BookingComment;
 import com.happy.Model.FileInfo;
 import com.happy.Model.FileInfo;
+import com.happy.dto.IPage;
+import com.happy.vo.EvaluatePageVo;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
 import com.happy.dto.BookCommentDto;
 import com.happy.dto.BookCommentDto;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
@@ -13,6 +15,13 @@ public interface BookingCommentService {
 
 
     int orderRate( BookingComment bookingComment,List<String> pictureList);
     int orderRate( BookingComment bookingComment,List<String> pictureList);
 
 
+    IPage evaluatePage(int status,String hotelId, int page, int rows);
+
+    int replyComment(BookingComment bookingComment);
+
+    EvaluatePageVo evaluateScore(String hotelId);
+
+
     /**
     /**
      * 描述:查询订单下的所有评论 根据订单id与comment_parent_id为空查询
      * 描述:查询订单下的所有评论 根据订单id与comment_parent_id为空查询
      * @param bookId 订单Id
      * @param bookId 订单Id

+ 44 - 7
mhotel/src/com/happy/service/impl/BookingCommentImplService.java

@@ -1,14 +1,10 @@
 package com.happy.service.impl;
 package com.happy.service.impl;
 
 
-import com.happy.Model.*;
+import com.happy.Model.BookingComment;
+import com.happy.Model.FileInfo;
 import com.happy.dao.BookingCommentDao;
 import com.happy.dao.BookingCommentDao;
-import com.happy.dao.FileInfoDao;
-import com.happy.dto.BookCommentDto;
-import com.happy.dto.IPage;
-import com.happy.service.BookService;
 import com.happy.service.BookingCommentService;
 import com.happy.service.BookingCommentService;
 import com.happy.service.FileService;
 import com.happy.service.FileService;
-import com.happy.service.HouseService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
@@ -17,6 +13,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 @Service("BookingCommentService")
 @Service("BookingCommentService")
+
 public class BookingCommentImplService implements BookingCommentService {
 public class BookingCommentImplService implements BookingCommentService {
 
 
     @Resource
     @Resource
@@ -67,7 +64,47 @@ public class BookingCommentImplService implements BookingCommentService {
         }
         }
         if (Long.valueOf(id) > 0 && i > 0) {
         if (Long.valueOf(id) > 0 && i > 0) {
             return i;
             return i;
-        }else {
+        } else {
+            return 0;
+        }
+
+    }
+
+    @Override
+    public IPage evaluatePage(int status, String hotelId, int page, int rows) {
+        IPage<BookingCommentPageVo> iPage = new IPage();
+        List<BookingCommentPageVo> vos = null;
+        int total = 0;
+//      ȫ��
+        if (status == 0) {
+            vos = bookingCommentDao.evaluatePage(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotal(hotelId);
+        } else if (status == 1) {
+//            ��ͼ
+            vos = bookingCommentDao.evaluatePagepicture(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotalpicture(hotelId);
+        } else if (status == 2) {
+            vos = bookingCommentDao.evaluatePageComment(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotalComment(hotelId);
+        }
+        iPage.setPage(page);
+        iPage.setTotalPage((int) Math.ceil((double) total / rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        iPage.setPageList(vos);
+        return iPage;
+
+
+    }
+
+    @Override
+    public int replyComment(BookingComment bookingComment) {
+//
+        String id = bookingCommentDao.insertBookingComment(bookingComment);
+
+        if (Long.valueOf(id) > 0) {
+            return 1;
+        } else {
             return 0;
             return 0;
         }
         }
 
 

+ 121 - 0
mhotel/src/com/happy/vo/BookingCommentPageVo.java

@@ -0,0 +1,121 @@
+package com.happy.vo;
+
+public class BookingCommentPageVo {
+
+    private String id;
+//    评分
+    private Double score;
+//  用户名
+    private String userName;
+//    头像
+    private String headPhoto;
+//   入住时间
+    private String liveTime;
+//    评论时间
+    private String commentTime;
+//  房型
+    private String houseName;
+//    内容
+    private String content;
+//    照片
+    private String url;
+//    评论次数
+    private int commentCount;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getHeadPhoto() {
+        return headPhoto;
+    }
+
+    public void setHeadPhoto(String headPhoto) {
+        this.headPhoto = headPhoto;
+    }
+
+    public String getLiveTime() {
+        return liveTime;
+    }
+
+    public void setLiveTime(String liveTime) {
+        this.liveTime = liveTime;
+    }
+
+    public String getCommentTime() {
+        return commentTime;
+    }
+
+    public void setCommentTime(String commentTime) {
+        this.commentTime = commentTime;
+    }
+
+    public String getHouseName() {
+        return houseName;
+    }
+
+    public void setHouseName(String houseName) {
+        this.houseName = houseName;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public int getCommentCount() {
+        return commentCount;
+    }
+
+    public void setCommentCount(int commentCount) {
+        this.commentCount = commentCount;
+    }
+
+    @Override
+    public String toString() {
+        return "BookingCommentPageVo{" +
+                "id='" + id + '\'' +
+                ", score=" + score +
+                ", userName='" + userName + '\'' +
+                ", headPhoto='" + headPhoto + '\'' +
+                ", liveTime='" + liveTime + '\'' +
+                ", commentTime='" + commentTime + '\'' +
+                ", houseName='" + houseName + '\'' +
+                ", content='" + content + '\'' +
+                ", url='" + url + '\'' +
+                ", commentCount=" + commentCount +
+                '}';
+    }
+}

+ 67 - 0
mhotel/src/com/happy/vo/EvaluatePageVo.java

@@ -0,0 +1,67 @@
+package com.happy.vo;
+
+
+public class EvaluatePageVo {
+
+//    总评分
+    private Double score;
+//    位置评分
+    private Double scoreWz;
+//    卫生评分
+    private Double scoreWs;
+//    设施评分
+    private Double scoreSs;
+//    服务评分
+    private Double scoreFw;
+
+    @Override
+    public String toString() {
+        return "EvaluatePageVo{" +
+                "score=" + score +
+                ", scoreWz=" + scoreWz +
+                ", scoreWs=" + scoreWs +
+                ", scoreSs=" + scoreSs +
+                ", scoreFw=" + scoreFw +
+                '}';
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public Double getScoreWz() {
+        return scoreWz;
+    }
+
+    public void setScoreWz(Double scoreWz) {
+        this.scoreWz = scoreWz;
+    }
+
+    public Double getScoreWs() {
+        return scoreWs;
+    }
+
+    public void setScoreWs(Double scoreWs) {
+        this.scoreWs = scoreWs;
+    }
+
+    public Double getScoreSs() {
+        return scoreSs;
+    }
+
+    public void setScoreSs(Double scoreSs) {
+        this.scoreSs = scoreSs;
+    }
+
+    public Double getScoreFw() {
+        return scoreFw;
+    }
+
+    public void setScoreFw(Double scoreFw) {
+        this.scoreFw = scoreFw;
+    }
+}