|
@@ -2,6 +2,7 @@ package com.happy.action;
|
|
|
|
|
|
|
|
import com.baidubce.model.User;
|
|
import com.baidubce.model.User;
|
|
|
import com.happy.Model.Booking;
|
|
import com.happy.Model.Booking;
|
|
|
|
|
+import com.happy.Model.HotelDict;
|
|
|
import com.happy.Model.weixin.Users;
|
|
import com.happy.Model.weixin.Users;
|
|
|
import com.happy.Until.*;
|
|
import com.happy.Until.*;
|
|
|
import com.happy.Until.Excel.toExcel;
|
|
import com.happy.Until.Excel.toExcel;
|
|
@@ -9,6 +10,7 @@ import com.happy.common.http.Message;
|
|
|
import com.happy.dto.BookTypeEto;
|
|
import com.happy.dto.BookTypeEto;
|
|
|
import com.happy.dto.IPage;
|
|
import com.happy.dto.IPage;
|
|
|
import com.happy.service.BookService;
|
|
import com.happy.service.BookService;
|
|
|
|
|
+import com.happy.service.HotelDictService;
|
|
|
import com.happy.service.UserService;
|
|
import com.happy.service.UserService;
|
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
@@ -20,7 +22,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.Vector;
|
|
import java.util.Vector;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
|
|
|
|
@@ -31,6 +35,8 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
public BookService bookService;
|
|
public BookService bookService;
|
|
|
@Resource
|
|
@Resource
|
|
|
public UserService userService;
|
|
public UserService userService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ public HotelDictService hotelDictService;
|
|
|
|
|
|
|
|
public int page; // 当前页
|
|
public int page; // 当前页
|
|
|
public int rows;// 每页显示的行数rows
|
|
public int rows;// 每页显示的行数rows
|
|
@@ -79,14 +85,20 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
}
|
|
}
|
|
|
//根据id获取当前订单信息
|
|
//根据id获取当前订单信息
|
|
|
Booking book = bookService.getById(id);
|
|
Booking book = bookService.getById(id);
|
|
|
- //获取用户openId
|
|
|
|
|
- Users user = userService.queryByUserId(book.getCreateUserid());
|
|
|
|
|
- if(user.getOpenid()==null){
|
|
|
|
|
- resultJson.put("message", "用户openId为空,请用户授权才能操作。");
|
|
|
|
|
- resultJson.put("code", 502);
|
|
|
|
|
|
|
+ if(book==null){
|
|
|
|
|
+ resultJson.put("message", "未查询到订单");
|
|
|
|
|
+ resultJson.put("code", 500);
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+ //获取用户openId
|
|
|
|
|
+// Users user = userService.queryByUserId(book.getCreateUserid());
|
|
|
|
|
+// if(user.getOpenid()==null){
|
|
|
|
|
+// resultJson.put("message", "用户openId为空,请该订单用户授权才能操作。");
|
|
|
|
|
+// resultJson.put("code", 502);
|
|
|
|
|
+// ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+// return null;
|
|
|
|
|
+// }
|
|
|
String msg = "";
|
|
String msg = "";
|
|
|
String sendMsg = "";
|
|
String sendMsg = "";
|
|
|
try{
|
|
try{
|
|
@@ -145,10 +157,10 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
}
|
|
}
|
|
|
int m = bookService.updateBooking(book);
|
|
int m = bookService.updateBooking(book);
|
|
|
if (m > 0) {
|
|
if (m > 0) {
|
|
|
- //推送信息
|
|
|
|
|
- if(!"".equals(sendMsg)){
|
|
|
|
|
- Message.send(user.getOpenid(),book.getOrderNum(),book.getUserName(),sendMsg,book.getCreateTime());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// //推送信息
|
|
|
|
|
+// if(!"".equals(sendMsg)){
|
|
|
|
|
+// Message.send(user.getOpenid(),book.getOrderNum(),book.getUserName(),sendMsg,book.getCreateTime());
|
|
|
|
|
+// }
|
|
|
resultJson.put("message", msg+"成功");
|
|
resultJson.put("message", msg+"成功");
|
|
|
resultJson.put("code", 200);
|
|
resultJson.put("code", 200);
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
@@ -287,7 +299,9 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
JSONObject resultJson = new JSONObject();
|
|
JSONObject resultJson = new JSONObject();
|
|
|
StringBuilder s1 = new StringBuilder("");
|
|
StringBuilder s1 = new StringBuilder("");
|
|
|
s1.append(" and order_status = 5");
|
|
s1.append(" and order_status = 5");
|
|
|
- s1.append(" and hotel_manager_id = '").append(managerId).append("'");
|
|
|
|
|
|
|
+ if(managerId!=null){
|
|
|
|
|
+ s1.append(" and hotel_manager_id = '").append(managerId).append("'");
|
|
|
|
|
+ }
|
|
|
if (ledgerParam!=null){
|
|
if (ledgerParam!=null){
|
|
|
s1.append(" and (order_num like '%").append(ledgerParam).append("%'")
|
|
s1.append(" and (order_num like '%").append(ledgerParam).append("%'")
|
|
|
.append(" or user_name like '%").append(ledgerParam).append("%'")
|
|
.append(" or user_name like '%").append(ledgerParam).append("%'")
|
|
@@ -418,4 +432,81 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 描述:导出台账 管理端
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public String toLedgerAdmimnExcel() {
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ StringBuilder s1 = new StringBuilder("");
|
|
|
|
|
+ s1.append(" and order_status = 5");
|
|
|
|
|
+ if (ledgerParam!=null){
|
|
|
|
|
+ s1.append(" and (order_num like '%").append(ledgerParam).append("%'")
|
|
|
|
|
+ .append(" or user_name like '%").append(ledgerParam).append("%'")
|
|
|
|
|
+ .append(" or user_phone like '%").append(ledgerParam).append("%')");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(payStartTime!=null && payEndTime!=null){
|
|
|
|
|
+ s1.append(" and pay_time >= '").append(payStartTime).append("'")
|
|
|
|
|
+ .append(" and pay_time <= '").append(payEndTime).append("'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(hotelTownship!=null){
|
|
|
|
|
+ s1.append(" and hotel_township = '").append(payStartTime).append("'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(minTotalPrice!=null){
|
|
|
|
|
+ s1.append(" and house_total_price >= '").append(minTotalPrice).append("'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(maxTotalPrice!=null){
|
|
|
|
|
+ s1.append(" and house_total_price <= '").append(maxTotalPrice).append("'");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Booking> list = bookService.queryList(s1.toString()); // 查询列表
|
|
|
|
|
+ List<HotelDict> hotelDicts = hotelDictService.queryList("and code = 10");
|
|
|
|
|
+ Map<Integer, String> dictMap = null;
|
|
|
|
|
+ if(hotelDicts!=null && hotelDicts.size()>0){
|
|
|
|
|
+ dictMap = hotelDicts.stream().collect(Collectors.toMap(HotelDict::getId, HotelDict::getName, (key1, key2) -> key1 ));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ resultJson.put("message", "未查到民宿乡镇信息");
|
|
|
|
|
+ resultJson.put("code", 500);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Vector> vectorsList = new ArrayList<>();
|
|
|
|
|
+ for(Booking book:list){
|
|
|
|
|
+ Vector columnValue = new Vector();
|
|
|
|
|
+ columnValue.add(dictMap.get(Integer.valueOf(book.getHotelTownship())));//所属乡镇
|
|
|
|
|
+ columnValue.add(book.getHotelName());//乡宿名称
|
|
|
|
|
+ columnValue.add(book.getOrderNum());//订单号
|
|
|
|
|
+ columnValue.add(book.getPayAccount());//订单金额
|
|
|
|
|
+ columnValue.add(book.getPayTime());//退房时间
|
|
|
|
|
+ vectorsList.add(columnValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 项目路径地址
|
|
|
|
|
+ String path = request.getSession().getServletContext()
|
|
|
|
|
+ .getRealPath("/download/");// File.separator
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ Vector columnName = new Vector();
|
|
|
|
|
+ columnName.add("所属乡镇");
|
|
|
|
|
+ columnName.add("民宿名称");
|
|
|
|
|
+ columnName.add("订单号");
|
|
|
|
|
+ columnName.add("订单金额(元)");
|
|
|
|
|
+ columnName.add("退房时间");
|
|
|
|
|
+
|
|
|
|
|
+ String filePathName ="台账信息" + UUIDUtil.generateID() +"Report.xls";
|
|
|
|
|
+ // 导出文件
|
|
|
|
|
+ new toExcel().book(vectorsList, path + filePathName,
|
|
|
|
|
+ "sheet1", columnName);
|
|
|
|
|
+ String url = "http://"+request.getServerName()+":"+request.getServerPort() + request.getSession().getServletContext().getContextPath();
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|