|
@@ -1,9 +1,13 @@
|
|
|
package com.happy.action;
|
|
package com.happy.action;
|
|
|
|
|
|
|
|
|
|
+import com.happy.Model.Booking;
|
|
|
import com.happy.Model.BookingComplaint;
|
|
import com.happy.Model.BookingComplaint;
|
|
|
import com.happy.Model.Hotel;
|
|
import com.happy.Model.Hotel;
|
|
|
import com.happy.Model.House;
|
|
import com.happy.Model.House;
|
|
|
|
|
+import com.happy.Until.Excel.toExcel;
|
|
|
import com.happy.Until.ResUtil;
|
|
import com.happy.Until.ResUtil;
|
|
|
|
|
+import com.happy.Until.ResponseUtil;
|
|
|
|
|
+import com.happy.Until.UUIDUtil;
|
|
|
import com.happy.common.controller.BaseController;
|
|
import com.happy.common.controller.BaseController;
|
|
|
import com.happy.dto.IPage;
|
|
import com.happy.dto.IPage;
|
|
|
import com.happy.service.BookingComplaintService;
|
|
import com.happy.service.BookingComplaintService;
|
|
@@ -17,6 +21,7 @@ import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Vector;
|
|
|
|
|
|
|
|
public class bookComplainAction extends BaseController implements ServletRequestAware {
|
|
public class bookComplainAction extends BaseController implements ServletRequestAware {
|
|
|
|
|
|
|
@@ -28,9 +33,6 @@ public class bookComplainAction extends BaseController implements ServletRequest
|
|
|
|
|
|
|
|
@Resource(name = "BookingComplaintService")
|
|
@Resource(name = "BookingComplaintService")
|
|
|
private BookingComplaintService bookingComplaintService;
|
|
private BookingComplaintService bookingComplaintService;
|
|
|
- @Resource(name = "HotelService")
|
|
|
|
|
- private HotelService hotelService;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 列表查询
|
|
* 列表查询
|
|
|
* @return
|
|
* @return
|
|
@@ -38,32 +40,32 @@ public class bookComplainAction extends BaseController implements ServletRequest
|
|
|
public String queryPage(){
|
|
public String queryPage(){
|
|
|
JSONObject resultJson = new JSONObject();
|
|
JSONObject resultJson = new JSONObject();
|
|
|
StringBuilder s1 = new StringBuilder("");
|
|
StringBuilder s1 = new StringBuilder("");
|
|
|
|
|
+ StringBuilder s2 = new StringBuilder("");
|
|
|
if (keywords != null){
|
|
if (keywords != null){
|
|
|
- s1.append(" and id like '%").append(keywords).append("%'");
|
|
|
|
|
|
|
+ s1.append(" and (a.id like '%").append(keywords).append("%'");
|
|
|
|
|
+ s2.append(" and (a.id like '%").append(keywords).append("%'");
|
|
|
s1.append(" or title like '%").append(keywords).append("%'");
|
|
s1.append(" or title like '%").append(keywords).append("%'");
|
|
|
|
|
+ s2.append(" or a.title like '%").append(keywords).append("%'");
|
|
|
s1.append(" or content like '%").append(keywords).append("%'");
|
|
s1.append(" or content like '%").append(keywords).append("%'");
|
|
|
|
|
+ s2.append(" or a.content like '%").append(keywords).append("%'");
|
|
|
s1.append(" or booking_id = '").append(keywords).append("' ");
|
|
s1.append(" or booking_id = '").append(keywords).append("' ");
|
|
|
- String sqlx = " and hname like '%" + keywords + "%' ";
|
|
|
|
|
- List<Hotel> hotelList = hotelService.queryList(sqlx);
|
|
|
|
|
- if (hotelList!=null){
|
|
|
|
|
- StringBuilder ids = new StringBuilder();
|
|
|
|
|
- hotelList.forEach(str->{
|
|
|
|
|
- ids.append("'").append(str.getId()).append("',");
|
|
|
|
|
- });
|
|
|
|
|
- ids.deleteCharAt(ids.length()-1);
|
|
|
|
|
- s1.append(" or hotel_id in (").append(ids).append(") ");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ s2.append(" or a.booking_id = '").append(keywords).append("' ");
|
|
|
|
|
+ s1.append(" or h2.hname like '%").append(keywords).append("%')");
|
|
|
|
|
+ s2.append(" or a.hotel_name like '%").append(keywords).append("%')");
|
|
|
}
|
|
}
|
|
|
if (status != null){
|
|
if (status != null){
|
|
|
- s1.append(" and status = ").append(status).append(" ");
|
|
|
|
|
|
|
+ s1.append(" and a.status = ").append(status).append(" ");
|
|
|
|
|
+ s2.append(" and a.status = ").append(status).append(" ");
|
|
|
}
|
|
}
|
|
|
if (complainStartTime != null){
|
|
if (complainStartTime != null){
|
|
|
- s1.append(" and DATE_FORMAT(create_date, '%Y-%m-%d') >= ").append(complainStartTime).append(" ");
|
|
|
|
|
|
|
+ s1.append(" and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '").append(complainStartTime).append("' ");
|
|
|
|
|
+ s2.append(" and DATE_FORMAT(create_date, '%Y-%m-%d') >= '").append(complainStartTime).append("' ");
|
|
|
}
|
|
}
|
|
|
if (complainStartTime != null){
|
|
if (complainStartTime != null){
|
|
|
- s1.append(" and DATE_FORMAT(create_date, '%Y-%m-%d') <= ").append(complainEndTime).append(" ");
|
|
|
|
|
|
|
+ s1.append(" and DATE_FORMAT(a.create_date, '%Y-%m-%d') <= '").append(complainEndTime).append("' ");
|
|
|
|
|
+ s2.append(" and DATE_FORMAT(create_date, '%Y-%m-%d') <= '").append(complainEndTime).append("' ");
|
|
|
}
|
|
}
|
|
|
- IPage<BookingComplaint> bookingComplaintIPage = bookingComplaintService.queryPage(s1.toString(), page, rows);
|
|
|
|
|
|
|
+ IPage<BookingComplaint> bookingComplaintIPage = bookingComplaintService.queryPage(s1.toString(),s2.toString(), page, rows);
|
|
|
if(bookingComplaintIPage!=null && !"".equals(bookingComplaintIPage)){
|
|
if(bookingComplaintIPage!=null && !"".equals(bookingComplaintIPage)){
|
|
|
resultJson.put("message", "查询分页成功");
|
|
resultJson.put("message", "查询分页成功");
|
|
|
resultJson.put("code", 200);
|
|
resultJson.put("code", 200);
|
|
@@ -75,5 +77,95 @@ public class bookComplainAction extends BaseController implements ServletRequest
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 投诉详情
|
|
|
|
|
+ */
|
|
|
|
|
+ public String getById(){
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ BookingComplaint bookingComplaint = bookingComplaintService.getById(id);
|
|
|
|
|
+ if (bookingComplaint != null) {
|
|
|
|
|
+ resultJson.put("message", "查询成功");
|
|
|
|
|
+ resultJson.put("code", 200);
|
|
|
|
|
+ resultJson.put("data", bookingComplaint);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ resultJson.put("message", "未查询到投诉订单信息");
|
|
|
|
|
+ resultJson.put("code", 500);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String toComplainExcel(){
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ StringBuilder s1 = new StringBuilder("");
|
|
|
|
|
+ if (keywords != null){
|
|
|
|
|
+ s1.append(" and a.id like '%").append(keywords).append("%'");
|
|
|
|
|
+ s1.append(" or title like '%").append(keywords).append("%'");
|
|
|
|
|
+ s1.append(" or content like '%").append(keywords).append("%'");
|
|
|
|
|
+ s1.append(" or booking_id = '").append(keywords).append("' ");
|
|
|
|
|
+ s1.append(" or h2.hname like '%").append(keywords).append("%'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (status != null){
|
|
|
|
|
+ s1.append(" and a.status = ").append(status).append(" ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (complainStartTime != null) {
|
|
|
|
|
+ s1.append(" and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '").append(complainStartTime).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (complainStartTime != null){
|
|
|
|
|
+ s1.append(" and DATE_FORMAT(a.create_date, '%Y-%m-%d') <= '").append(complainEndTime).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<BookingComplaint> list = bookingComplaintService.toComplainExcel(s1.toString());
|
|
|
|
|
+ if(list==null){
|
|
|
|
|
+ resultJson.put("code", 500);
|
|
|
|
|
+ resultJson.put("message", "无数据无法导出");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
+ resultJson.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Vector> vectorsList = new ArrayList<>();
|
|
|
|
|
+ for(BookingComplaint bookingComplaint : list){
|
|
|
|
|
+ Vector columnValue = new Vector();
|
|
|
|
|
+ columnValue.add(bookingComplaint.getId());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getTitle());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getContent());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getBookingId());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getHotelName());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getHouseName());
|
|
|
|
|
+ columnValue.add(bookingComplaint.getCreateDate());
|
|
|
|
|
+ vectorsList.add(columnValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 项目路径地址
|
|
|
|
|
+ String path = request.getSession().getServletContext()
|
|
|
|
|
+ .getRealPath("/download/");;// File.separator
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ Vector columnName = new Vector();
|
|
|
|
|
+ columnName.add("投诉id");
|
|
|
|
|
+ columnName.add("投诉标题");
|
|
|
|
|
+ columnName.add("投诉内容");
|
|
|
|
|
+ columnName.add("订单号");
|
|
|
|
|
+ columnName.add("酒店名称");
|
|
|
|
|
+ columnName.add("房型");
|
|
|
|
|
+ columnName.add("投诉时间");
|
|
|
|
|
+
|
|
|
|
|
+ String filePathName ="投诉信息" + UUIDUtil.generateID() +".xls";
|
|
|
|
|
+ // 导出文件
|
|
|
|
|
+ new toExcel().book(vectorsList, path + filePathName,
|
|
|
|
|
+ "sheet1", columnName);
|
|
|
|
|
+ String url = "https://chtech.ncjti.edu.cn/hotelReservation/mhotel";
|
|
|
|
|
+ resultJson.put("downurl", url + "/download/" + filePathName);
|
|
|
|
|
+ resultJson.put("code", 200);
|
|
|
|
|
+ resultJson.put("message", "导出成功");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
+ resultJson.toString());
|
|
|
|
|
+ } catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|