| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 |
- package com.happy.action;
- import com.google.gson.Gson;
- import com.google.gson.reflect.TypeToken;
- import com.happy.Model.BookingComment;
- import com.happy.Model.weixin.Users;
- import com.happy.Until.*;
- import com.happy.dto.BookCommentDto;
- import com.happy.dto.HotelEto;
- import com.happy.dto.IPage;
- import com.happy.dto.OrderRateDto;
- import com.happy.service.BookingCommentService;
- import com.happy.service.UserService;
- import com.happy.vo.*;
- import com.opensymphony.xwork2.ActionSupport;
- import com.alibaba.fastjson.JSONObject;
- import org.apache.struts2.ServletActionContext;
- import org.apache.struts2.interceptor.ServletRequestAware;
- import org.springframework.beans.BeanUtils;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * 评价
- */
- public class AppBookingCommentAction extends ActionSupport implements ServletRequestAware {
- private HttpServletRequest request;
- public HttpServletResponse response;
- public HttpServletRequest getRequest() {
- return request;
- }
- public void setRequest(HttpServletRequest request) {
- this.request = request;
- }
- @Override
- public void setServletRequest(HttpServletRequest request) {
- this.request = request;
- }
- public HttpServletResponse getResponse() {
- return response;
- }
- public void setResponse(HttpServletResponse response) {
- this.response = response;
- }
- @Resource
- public BookingCommentService bookingCommentService;
- @Resource
- public UserService userService;
- // 回复评论id
- public String commentId;
- // 回复主评论id
- public String commentParentId;
- // 回复人名称
- public String commentName;
- // 评论订单id
- public String bookingId;
- // 评论民宿id
- public String hotelId;
- // 评论房型id
- public String houseId;
- // 内容
- public String content;
- // 评价状态
- public String commentStatus;
- // 总评分
- public Double score;
- // 卫生评分
- public Double scoreWs;
- // 服务评分
- public Double scoreFw;
- // 设施评分
- public Double scoreSs;
- // 位置评分
- public Double scoreWz;
- // 创建人
- public Integer createId;
- public String createUsername;
- // 创建时间
- public String createDate;
- // 修改时间
- public String modifyDate;
- public List<String> pictureList;
- public List<String> getPictureList() {
- return pictureList;
- }
- public void setPictureList(List<String> pictureList) {
- this.pictureList = pictureList;
- }
- public String getBookingId() {
- return bookingId;
- }
- public void setBookingId(String 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() {
- 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 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 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;
- }
- public String bookingCommentId;
- public String getBookingCommentId() {
- return bookingCommentId;
- }
- public void setBookingCommentId(String bookingCommentId) {
- this.bookingCommentId = bookingCommentId;
- }
- public String usersId;
- public String getUsersId() {
- return usersId;
- }
- public void setUsersId(String usersId) {
- this.usersId = usersId;
- }
- public Integer userId;
- public Integer getUserId() {
- return userId;
- }
- public void setUserId(Integer userId) {
- this.userId = userId;
- }
- /**
- * 添加评论
- */
- public JSONObject orderRate() {
- JSONObject jsonObject = new JSONObject();
- JSONObject json = GetHttpParam.getHttpParam(request);
- System.out.println("参数:"+json.toString());
- if (json == null) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "缺少数据---orderRate");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- OrderRateDto orderRateDto = JSONObject.parseObject(json.toString(), OrderRateDto.class);
- if (Func.checkNull(orderRateDto.toString())) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "缺少数据---orderRate");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- if (orderRateDto.getScore() == null || orderRateDto.getScore() < 0 || orderRateDto.getScoreFw() == null || orderRateDto.getScoreFw() < 0 || orderRateDto.getScoreSs() == null || orderRateDto.getScoreSs() < 0 || orderRateDto.getScoreWs() == null || orderRateDto.getScoreWs() < 0 || orderRateDto.getScoreWz() == null || orderRateDto.getScoreWz() < 0 || orderRateDto.getBookingId() == null || orderRateDto.getHotelId() == null || orderRateDto.getHouseId() == null) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "缺少数据---orderRate");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- BookingComment bookingComment = BookingComment.builder().bookingId(orderRateDto.getBookingId())
- .hotelId(orderRateDto.getHotelId()).houseId(orderRateDto.getHouseId()).content(orderRateDto.getContent()).commentStatus(orderRateDto.getCommentStatus())
- .score(orderRateDto.getScore()).scoreWs(orderRateDto.getScoreWs()).scoreFw(orderRateDto.getScoreFw())
- .scoreSs(orderRateDto.getScoreSs()).scoreWz(orderRateDto.getScoreWz()).createId(orderRateDto.getCreateId())
- .createUsername(orderRateDto.getCreateUsername()).createDate(orderRateDto.getCreateDate())
- .modifyDate(orderRateDto.getModifyDate()).build();
- int a = bookingCommentService.orderRate(bookingComment,orderRateDto.getPictureList());
- if (a > 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("success", false);
- jsonObject.put("code", 205);
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- public JSONObject unevaluatedOrder(){
- JSONObject jsonObject = new JSONObject();
- if (page <= 0 || rows <= 0) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入page,rows数据---unevaluatedOrder");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- if (Func.checkNull(hotelId)||Func.checkNull(userId+"")) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入hotelId,usersId数据---unevaluatedOrder");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- UnevaluatedOrder vo=userService.collect(hotelId,userId);
- IPage<PersonageCommentVo> iPage = bookingCommentService.personageComment(0, userId+"", page, rows);
- vo.setPage(iPage);
- jsonObject.put("code", 200);
- jsonObject.put("message", "查看成功");
- jsonObject.put("success", true);
- jsonObject.put("data", vo);
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- /**
- * 评价列表
- *
- * @return
- */
- public JSONObject evaluatePage() {
- JSONObject jsonObject = new JSONObject();
- if (Func.checkNull(hotelId)) {
- jsonObject.put("code", 400);
- 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());
- 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)||Func.checkNull(commentId)) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "缺少数据---replyComment");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- String commentName=this.commentName;
- BookingComment byId = bookingCommentService.getBycommentId(commentId);
- if (byId!=null) {
- Integer createId1 = byId.getCreateId();
- Users users = userService.queryByUserId(createId1 + "");
- if (users!=null) {
- commentName=users.getUser_name();
- }
- }
- 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
- */
- public JSONObject commentDetails() {
- JSONObject jsonObject = new JSONObject();
- if (Func.checkNull(bookingCommentId)) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入bookingCommentId数据---commentDetails");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- // 评论
- List<CommentVo> commentVoList = bookingCommentService.commentVoList(bookingCommentId);
- List<CommentListVo> commentListVos=null;
- if (commentVoList!=null&&commentVoList.size()>0) {
- commentListVos = TreeRecordsUtil.queryCommentTreeRecords(bookingCommentId, commentVoList);
- }
- // 详情
- CommentDetailsVo commentDetailsVo =bookingCommentService.commentDetails(bookingCommentId);
- if (commentDetailsVo.getCommentTime()!=null) {
- commentDetailsVo.setCommentTime(DateUtil.parseDateToStr((Func.parseDate(commentDetailsVo.getCommentTime())), DateUtil.Time_Formatter_Day));
- }
- if (commentDetailsVo.getLiveTime()!=null) {
- commentDetailsVo.setLiveTime(DateUtil.parseDateToStr((Func.parseDate(commentDetailsVo.getLiveTime())), DateUtil.Time_Formatter_Day));
- }
- jsonObject.put("code", 200);
- jsonObject.put("message", "成功");
- jsonObject.put("success", true);
- jsonObject.put("comment",commentListVos);
- jsonObject.put("commentDetails",commentDetailsVo);
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- /**
- * 个人评论分页数据
- * @return
- */
- public JSONObject personageComment(){
- JSONObject jsonObject = new JSONObject();
- if (Func.checkNull(usersId)) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入usersIdId数据---personageComment");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- if (Func.checkNull(status + "")) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入status数据---personageComment");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- if (page <= 0 || rows <= 0) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入page,rows数据---personageComment");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- IPage<PersonageCommentVo> ipage=bookingCommentService.personageComment(status, usersId, page, rows);
- IPage<CommentDetailsVo> voIPage = new IPage<>();
- BeanUtils.copyProperties(ipage,voIPage);
- List<PersonageCommentVo> pageList = ipage.getPageList();
- PersonageCommentCountVo vo = bookingCommentService.personageCommentCount(usersId);
- if (pageList == null || pageList.size() <= 0 ||status==0) {
- jsonObject.put("code", 200);
- jsonObject.put("message", "成功");
- jsonObject.put("success", true);
- jsonObject.put("page", voIPage);
- jsonObject.put("data", vo);
- ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- ArrayList<CommentDetailsVo> commentDetailsVos = new ArrayList<>();
- for (PersonageCommentVo personageCommentVo : pageList) {
- String bookingCommentId1 = personageCommentVo.getBookingCommentId();
- CommentDetailsVo commentDetailsVo =bookingCommentService.commentDetails(bookingCommentId1);
- commentDetailsVo.setVo(personageCommentVo);
- commentDetailsVos.add(commentDetailsVo);
- }
- voIPage.setPageList(commentDetailsVos);
- jsonObject.put("code", 200);
- jsonObject.put("message", "成功");
- jsonObject.put("success", true);
- jsonObject.put("page", voIPage);
- jsonObject.put("data", vo);
- ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- /**
- * 个人评论详情
- * @return
- */
- public JSONObject personageDetails(){
- JSONObject jsonObject = new JSONObject();
- if (Func.checkNull(bookingCommentId)) {
- jsonObject.put("code", 400);
- jsonObject.put("success", false);
- jsonObject.put("message", "未传入bookingCommentId数据---commentDetails");
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- // 评论
- List<CommentVo> commentVoList = bookingCommentService.commentVoList(bookingCommentId);
- List<CommentListVo> commentListVos=null;
- if (commentVoList!=null&&commentVoList.size()>0) {
- commentListVos = TreeRecordsUtil.queryCommentTreeRecords(bookingCommentId, commentVoList);
- }
- // 详情
- PersonageDetailsVo personageDetailsVo =bookingCommentService.personageDetails(bookingCommentId);
- if (personageDetailsVo.getCommentTime()!=null) {
- personageDetailsVo.setCommentTime(DateUtil.parseDateToStr((Func.parseDate(personageDetailsVo.getCommentTime())), DateUtil.Time_Formatter_Day));
- }
- if (personageDetailsVo.getLiveTime()!=null) {
- personageDetailsVo.setLiveTime(DateUtil.parseDateToStr((Func.parseDate(personageDetailsVo.getLiveTime())), DateUtil.Time_Formatter_Day));
- }
- if (personageDetailsVo.getCheckOutTime()!=null) {
- personageDetailsVo.setCheckOutTime(DateUtil.parseDateToStr((Func.parseDate(personageDetailsVo.getCheckOutTime())), DateUtil.Time_Formatter_Day));
- }
- jsonObject.put("code", 200);
- jsonObject.put("message", "成功");
- jsonObject.put("success", true);
- jsonObject.put("comment",commentListVos);
- jsonObject.put("commentDetails",personageDetailsVo);
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
- return null;
- }
- }
|