Ver código fonte

订单接口提交

raojiaolong@163.com 2 anos atrás
pai
commit
9a10382e56

+ 37 - 22
mhotel/src/com/happy/Model/Booking.java

@@ -1,6 +1,5 @@
 package com.happy.Model;
 
-import java.util.Date;
 
 /**
  * 订单实体类
@@ -10,10 +9,12 @@ public class Booking {
   private Integer id;
   private String orderNum; // 订单号
   private String orderStatus; // 状态,1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款
+  private String orderName; // 状态名称,1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款
   private String userIdnumber; // 住客身份号
   private String userName;//住客姓名
   private String userPhone;// 住客手机号
   private String hotelId;// 民宿id
+  private String hotelManagerId;//所属商户Id
   private String hotelName;// 民宿名称
   private String hotelHposition; // 民宿位置
   private String hotelHpositionWens; // 民宿经纬度
@@ -31,20 +32,20 @@ public class Booking {
   private int houseOrderNumber; // 订房数量
   private String houseAreas; // 房型面积
   private String houseRemake; // 房型备注
-  private Date orderStartTime; // 订房开始时间
-  private Date orderEndTime; // 订房结束时间
+  private String orderStartTime; // 订房开始时间
+  private String orderEndTime; // 订房结束时间
   private String orderLiveTime;// 订房入住时间合计
   private String orderRemake; // 订房备注
-  private Date createTime; // 订单创建时间
+  private String createTime; // 订单创建时间
   private String createUserid; //订单创建人id
-  private Date updateTime; // 订单更新时间
-  private Date payTime; // 实际支付时间
+  private String updateTime; // 订单更新时间
+  private String payTime; // 实际支付时间
   private double payAccount; // 实际支付金额
   private String payWay; // 支付方式:默认使用微信支付
   private String refundWay; // 退款方式
   private double refundAmount; // 退款金额
-  private Date refundTime; // 退款时间
-  private Date checkOutTime; // 离店时间
+  private String refundTime; // 退款时间
+  private String checkOutTime; // 离店时间
   private String remake; // 备注信息
 
 
@@ -74,6 +75,13 @@ public class Booking {
     this.orderStatus = orderStatus;
   }
 
+  public String getOrderName() {
+    return orderName;
+  }
+
+  public void setOrderName(String orderName) {
+    this.orderName = orderName;
+  }
 
   public String getUserIdnumber() {
     return userIdnumber;
@@ -101,6 +109,13 @@ public class Booking {
     this.userPhone = userPhone;
   }
 
+  public String getHotelManagerId() {
+    return hotelManagerId;
+  }
+
+  public void setHotelManagerId(String hotelManagerId) {
+    this.hotelManagerId = hotelManagerId;
+  }
 
   public String getHotelId() {
     return hotelId;
@@ -264,20 +279,20 @@ public class Booking {
   }
 
 
-  public Date getOrderStartTime() {
+  public String getOrderStartTime() {
     return orderStartTime;
   }
 
-  public void setOrderStartTime(Date orderStartTime) {
+  public void setOrderStartTime(String orderStartTime) {
     this.orderStartTime = orderStartTime;
   }
 
 
-  public Date getOrderEndTime() {
+  public String getOrderEndTime() {
     return orderEndTime;
   }
 
-  public void setOrderEndTime(Date orderEndTime) {
+  public void setOrderEndTime(String orderEndTime) {
     this.orderEndTime = orderEndTime;
   }
 
@@ -300,11 +315,11 @@ public class Booking {
   }
 
 
-  public Date getCreateTime() {
+  public String getCreateTime() {
     return createTime;
   }
 
-  public void setCreateTime(Date createTime) {
+  public void setCreateTime(String createTime) {
     this.createTime = createTime;
   }
 
@@ -318,20 +333,20 @@ public class Booking {
   }
 
 
-  public Date getUpdateTime() {
+  public String getUpdateTime() {
     return updateTime;
   }
 
-  public void setUpdateTime(Date updateTime) {
+  public void setUpdateTime(String updateTime) {
     this.updateTime = updateTime;
   }
 
 
-  public Date getPayTime() {
+  public String getPayTime() {
     return payTime;
   }
 
-  public void setPayTime(Date payTime) {
+  public void setPayTime(String payTime) {
     this.payTime = payTime;
   }
 
@@ -372,20 +387,20 @@ public class Booking {
   }
 
 
-  public Date getRefundTime() {
+  public String getRefundTime() {
     return refundTime;
   }
 
-  public void setRefundTime(Date refundTime) {
+  public void setRefundTime(String refundTime) {
     this.refundTime = refundTime;
   }
 
 
-  public Date getCheckOutTime() {
+  public String getCheckOutTime() {
     return checkOutTime;
   }
 
-  public void setCheckOutTime(Date checkOutTime) {
+  public void setCheckOutTime(String checkOutTime) {
     this.checkOutTime = checkOutTime;
   }
 

+ 153 - 355
mhotel/src/com/happy/action/bookAction.java

@@ -1,18 +1,15 @@
 package com.happy.action;
 
-import com.happy.Model.AdminManager;
+import com.baidubce.model.User;
 import com.happy.Model.Booking;
-import com.happy.Model.House;
-import com.happy.Model.weixin.PayResult;
-import com.happy.Model.weixin.WechatUnifiedOrder;
-import com.happy.Model.weixin.WeiXinUtil;
+import com.happy.Model.weixin.Users;
 import com.happy.Until.*;
 import com.happy.Until.Excel.toExcel;
-import com.happy.Until.weixin.JaxbUtil;
-import com.happy.Until.weixin.PayWxUtil;
-import com.happy.common.wx.WxUtil;
+import com.happy.common.http.Message;
+import com.happy.dto.BookTypeEto;
 import com.happy.dto.IPage;
 import com.happy.service.BookService;
+import com.happy.service.UserService;
 import com.opensymphony.xwork2.ActionSupport;
 import net.sf.json.JSONObject;
 import org.apache.struts2.ServletActionContext;
@@ -21,10 +18,7 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.text.ParseException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Vector;
 
 public class bookAction extends ActionSupport implements ServletRequestAware {
@@ -34,12 +28,15 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
 
     @Resource
     public BookService bookService;
+    @Resource
+    public UserService userService;
 
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public Integer id;
-    public String status;
-    public String dom;
+    public Integer type;
+    public String orderStatus;//订单状态
+    public String manager_id;//商户Id
     public String payStartTime;//支付开始时间
     public String payEndTime;//支付结束时间
     public String ledgerParam;//台账列表查询参数
@@ -64,355 +61,79 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
         this.response = response;
     }
 
-    // 查看订单
-//    public String list() {
-//        JSONObject resultJson = new JSONObject();
-//        StringBuilder s1 = new StringBuilder("");
-//        if (status!=null){
-//            s1.append(" and status = '").append(this.status).append("' ");
-//        }
-//        if (start_time!=null){
-//            s1.append(" and create_time>'").append(this.start_time).append("' ");
-//        }
-//        if (end_time!=null){
-//            s1.append(" and create_time<'").append(this.end_time).append("' ");
-//        }
-//        if (order_name_phone!=null){
-//            s1.append(" and ( order_num like '%").append(this.order_name_phone)
-//                    .append("%' or user_name like '%").append(this.order_name_phone)
-//                    .append("%' or phone like '%").append(this.order_name_phone).append("%' ) ");
-//        }
-//        int total = bookService.queryBookTotal(s1.toString()); // 查询表中的总记录数
-//        List<Booking> listPage = bookService.queryBookPage(s1.toString(), page, rows); // 查询分页
-//
-//        if (listPage == null) {
-//            resultJson.put("rows", "");
-//            resultJson.put("total", 0);
-//        } else {
-//            resultJson.put("code", 200);
-//            resultJson.put("rows", listPage);
-//            // int total = listAll.size();
-//            resultJson.put("total", total);// 总记录数
-//            int totalPage = total % rows == 0 ? (total / rows)
-//                    : (total / rows) + 1;// 总页数
-//            resultJson.put("totalPage", totalPage);
-//            resultJson.put("currentPage", page);// 当前页
-//            resultJson.put("numPerPage", rows);// 每页数
-//            resultJson.put("nextPage", totalPage - page == 0 ? page : page + 1);// 下一页
-//            resultJson.put("previousPage", page - 0 == 1 ? page : page - 1);// 上一页
-//            resultJson.put("hasPreviousPage", true);// 有上一页
-//            resultJson.put("hasNextPage", true);// 有下一页
-//            resultJson.put("firstPage", true);// 首页
-//            resultJson.put("lastPage", true);// 尾页
-//        }
-//        ResponseUtil.writeJson(ServletActionContext.getResponse(),
-//                resultJson.toString());
-//        return null;
-//    }
-//
-//    // 导出列表
-//    public String to_excel() {
-//        JSONObject resultJson = new JSONObject();
-//        StringBuilder s1 = new StringBuilder("");
-//        if (status!=null){
-//            s1.append(" and status = '").append(this.status).append("' ");
-//        }
-//        if (start_time!=null){
-//            s1.append(" and create_time>'").append(this.start_time).append("' ");
-//        }
-//        if (end_time!=null){
-//            s1.append(" and create_time<'").append(this.end_time).append("' ");
-//        }
-//        if (order_name_phone!=null){
-//            s1.append(" and ( order_num like '%").append(this.order_name_phone)
-//                    .append("%' or user_name like '%").append(this.order_name_phone)
-//                    .append("%' or phone like '%").append(this.order_name_phone).append("%' ) ");
-//        }
-//        List<Booking> list = bookService.queryBooks(s1.toString()); // 查询分页
-//        // 项目路径地址
-//        String path = request.getSession().getServletContext()
-//                .getRealPath("/download/");// File.separator
-//
-//        try{
-//            Vector columnName = new Vector();
-//            columnName.add("order_num");
-//            columnName.add("status");
-//            columnName.add("dom");
-//            columnName.add("user_name");
-//            columnName.add("phone");
-//            columnName.add("h_type");
-//            columnName.add("price");
-//            columnName.add("create_time");
-//            columnName.add("pay_account");
-//            // 导出文件
-//            new toExcel().book(list, path + "订单信息" + "Report.xls",
-//                    "sheet1", columnName);
-//            String url = request.getSession().getServletContext().getContextPath();
-//            resultJson.put("downurl", url+"/download/订单信息" + "Report.xls");
-//            resultJson.put("code", 200);
-//            resultJson.put("message", "导出成功");
-//            ResponseUtil.writeJson(ServletActionContext.getResponse(),
-//                    resultJson.toString());
-//        } catch (Exception e){
-//            e.printStackTrace();
-//        }
-//        return null;
-//    }
-//
-//    // pc处理核销-办理入住
-//    public String operate_live() throws ParseException {
-//        JSONObject resultJson = new JSONObject();
-//        if (id==null){
-//            resultJson.put("message", "请传id");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (!status.equals("3")){
-//            resultJson.put("message", "参数有误");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        Booking booking = bookService.queryBookById(id);
-//        if (booking==null){
-//            resultJson.put("message", "订单已被删除");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-////        if (booking.getStatus().equals("1")){
-////            resultJson.put("message", "订单未支付不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("3")){
-////            resultJson.put("message", "该订单已入住请勿重复办理");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("4") || booking.getStatus().equals("5") || booking.getStatus().equals("6")){
-////            resultJson.put("message", "该订单已完成不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (!booking.getLive_time().equals(TimeExchange.getDate())){
-////            resultJson.put("message", "该订单未到入住时间或已过期,请重新下单");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-//        int m = bookService.update(status,dom,id);
-//        if(m>0){
-//            resultJson.put("message", "操作成功");
-//            resultJson.put("code", 200);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        resultJson.put("message", "操作失败");
-//        resultJson.put("code", 205);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//        return null;
-//    }
-//
-//    // pc处理核销-办理退款
-//    public String refund_money() throws Exception {
-//        JSONObject resultJson = new JSONObject();
-//        if (id==null){
-//            resultJson.put("message", "请传id");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (!status.equals("5")){
-//            resultJson.put("message", "参数有误");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        Booking booking = bookService.queryBookById(id);
-//        if (booking==null){
-//            resultJson.put("message", "订单已被删除");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-////        if (booking.getStatus().equals("1")){
-////            resultJson.put("message", "订单未支付不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("3")){
-////            resultJson.put("message", "该订单已入住,请办理退房");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("4") || booking.getStatus().equals("5") || booking.getStatus().equals("6")){
-////            resultJson.put("message", "该订单已完成不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-//        //String ip = request.getParameter("ip");
-//        String ip = "171.34.223.11";
-////        double money = booking.getPay_account();
-////        int a = (int) (money * 100);
-////        WechatUnifiedOrder w = new WechatUnifiedOrder();
-////        w.setAppid(WeiXinUtil.appid_c);
-////        w.setAttach("chengxin");
-////        w.setBody("chengxin");
-////        w.setMch_id(WeiXinUtil.account);
-////        w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-////        w.setNotify_url(WeiXinUtil.ip_h + "/bookrefundResulet.action");// 支付结果回调地址
-////        w.setOpenid("");
-////        w.setOut_trade_no(booking.getOrder_num());
-////        String refund_order = WxUtil.mchOrderNo();
-////        w.setOut_refund_no(refund_order);   // 退款单号
-////        w.setSpbill_create_ip(ip);
-////        w.setTotal_fee(a);
-////        w.setRefund_fee(a);   // 退款金额
-////        w.setTrade_type("JSAPI");
-////        Map<String, String> params = new HashMap<String, String>();
-////        params.put("attach", w.getAttach());
-////        params.put("appid", w.getAppid());
-////        params.put("mch_id", w.getMch_id());
-////        params.put("nonce_str", w.getNonce_str());
-////        params.put("body", w.getBody());
-////        params.put("out_trade_no", w.getOut_trade_no());
-////        params.put("out_refund_no", w.getOut_refund_no());   // 退款单号
-////        params.put("total_fee", w.getTotal_fee() + "");
-////        params.put("refund_fee",w.getRefund_fee()+"");  // 退款金额
-////        params.put("spbill_create_ip", w.getSpbill_create_ip());
-////        params.put("notify_url", w.getNotify_url());
-////        params.put("trade_type", w.getTrade_type());
-////        params.put("openid", w.getOpenid());
-////        w.setSign(PayWxUtil.getSign(params, WeiXinUtil.APIid));
-////        params.put("sign", w.getSign());
-////        String retXml = JaxbUtil.getRequestXml(params);
-////        String msg = HttpUtils.post("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
-////        System.out.println(msg);
-////        if (msg.indexOf("FAIL") > -1) {
-////            resultJson.put("code", 507);
-////            resultJson.put("message", "退款失败");
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        resultJson.put("code", 200);
-////        resultJson.put("message", "退款申请已提交,请稍候查询");
-////        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//        return null;
-//    }
-//
-//    // 退款回调
-//    public String refundResulet(){
-//        JSONObject resultjson = new JSONObject();
-//        com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
-//        try{
-//            JaxbUtil requestBinder = new JaxbUtil(PayResult.class, PayResult.class);
-//            PayResult result = requestBinder.fromXml(json.toString());// Xml到Java,用fromXML()方法
-//            String order_num = result.getOut_trade_no();
-//            System.out.println("退款成功回调,订单号:"+order_num);
-//            // 支付成功
-//            if (result.getResult_code().equals("SUCCESS")) {
-//                bookService.update_pay("5", order_num);
-//                resultjson.put("message", "退款成功");
-//                resultjson.put("code", 200);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//        } catch (Exception e){
-//            resultjson.put("message", "退款失败");
-//            resultjson.put("code", 205);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//            return null;
-//        }
-//        resultjson.put("message", "退款失败");
-//        resultjson.put("code", 205);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//        return null;
-//    }
-//
-//    // pc处理核销-办理退房
-//    public String refund_room() throws ParseException {
-//        JSONObject resultJson = new JSONObject();
-//        if (id==null){
-//            resultJson.put("message", "请传id");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (!status.equals("6")){
-//            resultJson.put("message", "参数有误");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        Booking booking = bookService.queryBookById(id);
-//        if (booking==null){
-//            resultJson.put("message", "订单已被删除");
-//            resultJson.put("code", 500);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-////        if (booking.getStatus().equals("1")){
-////            resultJson.put("message", "订单未支付不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("2")){
-////            resultJson.put("message", "该订单未入住,请办理退款");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-////        if (booking.getStatus().equals("4") || booking.getStatus().equals("5") || booking.getStatus().equals("6")){
-////            resultJson.put("message", "该订单已完成不能进行其他操作");
-////            resultJson.put("code", 500);
-////            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-////            return null;
-////        }
-//        int m = bookService.update(status,dom,id);
-//        if(m>0){
-//            resultJson.put("message", "操作成功");
-//            resultJson.put("code", 200);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        resultJson.put("message", "操作失败");
-//        resultJson.put("code", 205);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//        return null;
-//    }
+    /**
+     * 描述:修改订单状态接单、入住、退房、退单、退款
+     * @return
+     */
+    public String updateBookStatus(){
+        JSONObject resultJson = new JSONObject();
+        if (id == null) {
+            resultJson.put("message", "请传入订单id");
+            resultJson.put("code", 500);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        //根据id获取当前订单信息
+        Booking book = bookService.getById(id);
+        //获取用户openId
+        Users user = userService.queryByUserId(book.getCreateUserid());
+        try{
+            switch (type){
+                case 1://接单
+                    book.setOrderStatus("3");
+                    //推送信息
+                    Message.send(user.getOpenid(),book.getOrderNum(),book.getUserName(),"商家已接单",book.getCreateTime());
+                    break;
+                case 2://入住
+                    book.setOrderStatus("4");
+                    break;
+                case 3://退房
+                    book.setOrderStatus("5");
+                    break;
+                case 4://退单
+                    book.setOrderStatus("8");
+                    break;
+                case 5://退款
+                    book.setOrderStatus("9");
+                    break;
+            }
+        }catch (Exception e){
+
+        }
+
+        bookService.updateBooking(book);
+        return null;
+    }
 
     /**
-     * 描述:分页查询台账(查询以消费订单数据)
+     * 描述:分页查询订单
      * @return
      */
-    public String quearyLedgerPage(){
+    public String quearyBookPage(){
         JSONObject resultJson = new JSONObject();
         StringBuilder s1 = new StringBuilder("");
-        s1.append(" and status = 5");
-        s1.append(" and order_num like '%").append(ledgerParam).append("'");
+        s1.append(" and hotel_manager_id like '%").append(manager_id).append("'");
         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("')");
+                    .append(" or user_name like '%").append(ledgerParam).append("'")
+                    .append(" or user_phone like '%").append(ledgerParam).append("')");
+        }
+        if(orderStatus!=null){
+            s1.append(" and order_status = ").append(orderStatus);
         }
         if(payStartTime!=null && payEndTime!=null){
             s1.append(" and pay_time >= '").append(payStartTime).append("'")
                     .append(" and pay_time <= '").append(payEndTime).append("'");
         }
-        IPage<Booking> houseIPage = bookService.queryPage(s1.toString(),page,rows);
-        if(houseIPage!=null && !"".equals(houseIPage)){
+        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows);
+        //获取订单汇总信息
+        BookTypeEto bookTypeEto = bookService.getBookStatusSum(s1.toString());
+        bookTypeEto.setBookIPage(bookIPage);
+
+        if(bookTypeEto!=null && !"".equals(bookTypeEto)){
             resultJson.put("message", "查询分页成功");
             resultJson.put("code", 200);
-            resultJson.put("date", houseIPage);
+            resultJson.put("date", bookTypeEto);
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         }else{
             resultJson.put("message", "查询分页失败");
@@ -422,8 +143,85 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
         return null;
     }
 
-    public String sumLedgerAccount(){
+    /**
+     * 描述:导出订单
+     * @return
+     */
+    public String toBookExcel() {
+        JSONObject resultJson = new JSONObject();
+        StringBuilder s1 = new StringBuilder("");
+        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(orderStatus!=null){
+            s1.append(" and order_status = ").append(orderStatus);
+        }
+        if(payStartTime!=null && payEndTime!=null){
+            s1.append(" and pay_time >= '").append(payStartTime).append("'")
+                    .append(" and pay_time <= '").append(payEndTime).append("'");
+        }
+        List<Booking> list = bookService.queryList(s1.toString()); // 查询分页
+        // 项目路径地址
+        String path = request.getSession().getServletContext()
+                .getRealPath("/download/");// File.separator
+        try{
+            Vector columnName = new Vector();
+            columnName.add("orderNum");
+            columnName.add("orderName");
+            columnName.add("userName");
+            columnName.add("userPhone");
+            columnName.add("houseName");
+            columnName.add("houseTotalPrice");
+            columnName.add("payTime");
+            // 导出文件
+            new toExcel().book(list, path + "订单信息" + "Report.xls",
+                    "sheet1", columnName);
+            String url = request.getSession().getServletContext().getContextPath();
+            resultJson.put("downurl", url+"/download/订单信息" + "Report.xls");
+            resultJson.put("code", 200);
+            resultJson.put("message", "导出成功");
+            ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                    resultJson.toString());
+        } catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
 
+    /**
+     * 描述:分页查询台账(查询以消费订单数据)
+     * @return
+     */
+    public String quearyLedgerPage(){
+        JSONObject resultJson = new JSONObject();
+        StringBuilder s1 = new StringBuilder("");
+        s1.append(" and order_status = 5");
+        s1.append(" and hotel_manager_id like '%").append(manager_id).append("'");
+        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("'");
+        }
+        IPage<Booking> bookIPage = bookService.queryPage(s1.toString(),page,rows);
+        //获取订单汇总信息
+        BookTypeEto bookTypeEto = bookService.getBookStatusSum(s1.toString());
+        bookTypeEto.setBookIPage(bookIPage);
+        if(bookTypeEto!=null && !"".equals(bookTypeEto)){
+            resultJson.put("message", "查询分页成功");
+            resultJson.put("code", 200);
+            resultJson.put("date", bookTypeEto);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }else{
+            resultJson.put("message", "查询分页失败");
+            resultJson.put("code", 500);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }
         return null;
     }
 
@@ -458,7 +256,7 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
      * 描述:导出台账
      * @return
      */
-    public String toExcel() {
+    public String toLedgerExcel() {
         JSONObject resultJson = new JSONObject();
         StringBuilder s1 = new StringBuilder("");
         s1.append(" and status = 5");
@@ -478,12 +276,12 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
 
         try{
             Vector columnName = new Vector();
-            columnName.add("order_num");
-            columnName.add("user_name");
-            columnName.add("user_phone");
-            columnName.add("house_order_number");
-            columnName.add("pay_account");
-            columnName.add("pay_time");
+            columnName.add("orderNum");
+            columnName.add("userName");
+            columnName.add("userPhone");
+            columnName.add("houseOrderNumber");
+            columnName.add("payAccount");
+            columnName.add("payTime");
             // 导出文件
             new toExcel().book(list, path + "台账信息" + "Report.xls",
                     "sheet1", columnName);

+ 8 - 0
mhotel/src/com/happy/dao/BookDao.java

@@ -2,6 +2,7 @@ package com.happy.dao;
 
 import com.happy.Model.Booking;
 import com.happy.Model.Booking;
+import com.happy.dto.BookTypeEto;
 
 import java.util.List;
 
@@ -66,4 +67,11 @@ public interface BookDao {
      */
     Double sumAccount(String sqlx);
 
+    /**
+     * 描述:查询订单类型汇总
+     * @param sqlx
+     * @return
+     */
+    BookTypeEto getBookStatusSum(String sqlx);
+
 }

+ 17 - 1
mhotel/src/com/happy/dao/impl/BookImplDao.java

@@ -5,6 +5,7 @@ import com.happy.Model.Booking;
 import com.happy.Model.House;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.BookDao;
+import com.happy.dto.BookTypeEto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -191,7 +192,7 @@ public class BookImplDao implements BookDao {
 
     @Override
     public List<Booking> queryList(String sqlx) {
-        String sql = "SELECT * FROM `booking` WHERE 1=1 "+sqlx;
+        String sql = "SELECT *,case when order_status=1 then '待支付' when order_status=2 then '已支付' when order_status=3 then '待入住' when order_status=4 then '已入住' when order_status=5 then '已消费' when order_status=6 then '支付超时' when order_status=7 then '已取消' when order_status=8 then '已退单' when order_status=9 then '已退款' else '无状态' end order_name FROM `booking` WHERE 1=1 "+sqlx;
         List<Booking> list = null;
         try{
             list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Booking.class));
@@ -213,4 +214,19 @@ public class BookImplDao implements BookDao {
         }
         return list.get(0).getPayAccount();
     }
+
+    @Override
+    public BookTypeEto getBookStatusSum(String sqlx){
+        String sql = "select sum(case when  order_status = 2 then 1 else 0 end) pendingOrderSum,count(1) orderSum,sum(case when  order_status = 5 then 1 else 0 end) consumerOrderSum,sum(case when  order_status = 5 then pay_account else 0 end) sumAccount from booking where 1=1"+sqlx;
+        List<BookTypeEto> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BookTypeEto.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return list.get(0);
+    }
+
+
+
 }

+ 56 - 0
mhotel/src/com/happy/dto/BookTypeEto.java

@@ -0,0 +1,56 @@
+package com.happy.dto;
+
+import com.happy.Model.Booking;
+
+public class BookTypeEto {
+
+    private int pendingOrderSum;//待接单数
+
+    private int orderSum;//订单总数
+
+    private int consumerOrderSum;//已消费订单
+
+    private Double sumAccount;//已消费订单总金额
+
+    private IPage<Booking> bookIPage;//分页数据
+
+    public int getPendingOrderSum() {
+        return pendingOrderSum;
+    }
+
+    public void setPendingOrderSum(int pendingOrderSum) {
+        this.pendingOrderSum = pendingOrderSum;
+    }
+
+    public int getOrderSum() {
+        return orderSum;
+    }
+
+    public void setOrderSum(int orderSum) {
+        this.orderSum = orderSum;
+    }
+
+    public int getConsumerOrderSum() {
+        return consumerOrderSum;
+    }
+
+    public void setConsumerOrderSum(int consumerOrderSum) {
+        this.consumerOrderSum = consumerOrderSum;
+    }
+
+    public Double getSumAccount() {
+        return sumAccount;
+    }
+
+    public void setSumAccount(Double sumAccount) {
+        this.sumAccount = sumAccount;
+    }
+
+    public IPage<Booking> getBookIPage() {
+        return bookIPage;
+    }
+
+    public void setBookIPage(IPage<Booking> bookIPage) {
+        this.bookIPage = bookIPage;
+    }
+}

+ 15 - 0
mhotel/src/com/happy/service/BookService.java

@@ -2,6 +2,7 @@ package com.happy.service;
 
 import com.happy.Model.Booking;
 import com.happy.Model.Booking;
+import com.happy.dto.BookTypeEto;
 import com.happy.dto.IPage;
 
 import java.util.List;
@@ -59,4 +60,18 @@ public interface BookService {
      */
     Booking getOen(String sqlx);
 
+    /**
+     * 描述:汇总查询金额
+     * @param sqlx
+     * @return
+     */
+    Double sumAccount(String sqlx);
+
+    /**
+     * 描述:查询订单类型汇总
+     * @param sqlx
+     * @return
+     */
+    BookTypeEto getBookStatusSum(String sqlx);
+
 }

+ 11 - 0
mhotel/src/com/happy/service/impl/BookImplService.java

@@ -2,6 +2,7 @@ package com.happy.service.impl;
 
 import com.happy.Model.Booking;
 import com.happy.dao.BookDao;
+import com.happy.dto.BookTypeEto;
 import com.happy.dto.IPage;
 import com.happy.service.BookService;
 import org.springframework.stereotype.Service;
@@ -59,4 +60,14 @@ public class BookImplService implements BookService {
         if(list!=null && list.size()>0) return list.get(0);
         return null;
     }
+
+    @Override
+    public Double sumAccount(String sqlx){
+        return bookDao.sumAccount(sqlx);
+    }
+
+    @Override
+    public BookTypeEto getBookStatusSum(String sqlx){
+        return bookDao.getBookStatusSum(sqlx);
+    }
 }