Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

Administrator před 2 roky
rodič
revize
197a035725

+ 382 - 343
mhotel/src/com/happy/action/bookAction.java

@@ -1,5 +1,6 @@
 package com.happy.action;
 
+import com.happy.Model.AdminManager;
 import com.happy.Model.Booking;
 import com.happy.Model.House;
 import com.happy.Model.weixin.PayResult;
@@ -10,6 +11,7 @@ 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.dto.IPage;
 import com.happy.service.BookService;
 import com.opensymphony.xwork2.ActionSupport;
 import net.sf.json.JSONObject;
@@ -37,10 +39,10 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
     public int rows;// 每页显示的行数rows
     public Integer id;
     public String status;
-    public String start_time;
-    public String end_time;
-    public String order_name_phone;
     public String dom;
+    public String payStartTime;//支付开始时间
+    public String payEndTime;//支付结束时间
+    public String ledgerParam;//台账列表查询参数
 
     public HttpServletRequest getRequest() {
         return request;
@@ -62,401 +64,438 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
         this.response = response;
     }
 
-    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 Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    public String getStart_time() {
-        return start_time;
-    }
-
-    public void setStart_time(String start_time) {
-        this.start_time = start_time;
-    }
-
-    public String getEnd_time() {
-        return end_time;
-    }
-
-    public void setEnd_time(String end_time) {
-        this.end_time = end_time;
-    }
-
-    public String getOrder_name_phone() {
-        return order_name_phone;
-    }
-
-    public void setOrder_name_phone(String order_name_phone) {
-        this.order_name_phone = order_name_phone;
-    }
-
-    public String getDom() {
-        return dom;
-    }
-
-    public void setDom(String dom) {
-        this.dom = dom;
-    }
-
     // 查看订单
-    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", "订单未支付不能进行其他操作");
+//    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 (booking.getStatus().equals("3")){
-//            resultJson.put("message", "该订单已入住请勿重复办理");
+//        if (!status.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", "该订单已完成不能进行其他操作");
+//        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.getLive_time().equals(TimeExchange.getDate())){
-//            resultJson.put("message", "该订单未到入住时间或已过期,请重新下单");
+////        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;
 //        }
-        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", "订单未支付不能进行其他操作");
+//        if (!status.equals("5")){
+//            resultJson.put("message", "参数有误");
 //            resultJson.put("code", 500);
 //            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //            return null;
 //        }
-//        if (booking.getStatus().equals("3")){
-//            resultJson.put("message", "该订单已入住,请办理退房");
+//        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("4") || booking.getStatus().equals("5") || booking.getStatus().equals("6")){
-//            resultJson.put("message", "该订单已完成不能进行其他操作");
+////        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;
 //        }
-        //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", "退款失败");
+//        if (!status.equals("6")){
+//            resultJson.put("message", "参数有误");
+//            resultJson.put("code", 500);
 //            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //            return null;
 //        }
-//        resultJson.put("code", 200);
-//        resultJson.put("message", "退款申请已提交,请稍候查询");
+//        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 quearyLedgerPage(){
+        JSONObject resultJson = new JSONObject();
+        StringBuilder s1 = new StringBuilder("");
+        s1.append(" and status = 5");
+        s1.append(" and order_num like '%").append(ledgerParam).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> houseIPage = bookService.queryPage(s1.toString(),page,rows);
+        if(houseIPage!=null && !"".equals(houseIPage)){
+            resultJson.put("message", "查询分页成功");
+            resultJson.put("code", 200);
+            resultJson.put("date", houseIPage);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }else{
+            resultJson.put("message", "查询分页失败");
+            resultJson.put("code", 500);
+            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());
+    public String sumLedgerAccount(){
+
         return null;
     }
 
-    // pc处理核销-办理退房
-    public String refund_room() throws ParseException {
+    /**
+     * 描述:根据Id查询订单详细
+     * @return
+     */
+    public String getById(){
         JSONObject resultJson = new JSONObject();
-        if (id==null){
-            resultJson.put("message", "请传id");
+        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);
+        Booking book = bookService.getById(id);
+        if (book != null) {
+            resultJson.put("message", "查询成功");
+            resultJson.put("code", 200);
+            resultJson.put("date", book);
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
-        }
-        Booking booking = bookService.queryBookById(id);
-        if (booking==null){
-            resultJson.put("message", "订单已被删除");
+        }else{
+            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 quearyLedgerPage(){
+    public String toExcel() {
+        JSONObject resultJson = new JSONObject();
+        StringBuilder s1 = new StringBuilder("");
+        s1.append(" and 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("'");
+        }
+        List<Booking> list = bookService.queryList(s1.toString()); // 查询分页
+        // 项目路径地址
+        String path = request.getSession().getServletContext()
+                .getRealPath("/download/");// File.separator
+
+        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");
+            // 导出文件
+            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;
     }
 }

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

@@ -59,4 +59,11 @@ public interface BookDao {
      */
     List<Booking> queryList(String sqlx);
 
+    /**
+     * 描述:汇总查询金额
+     * @param sqlx
+     * @return
+     */
+    Double sumAccount(String sqlx);
+
 }

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

@@ -172,7 +172,7 @@ public class BookImplDao implements BookDao {
     @Override
     public List<Booking> queryPage(String sqlx, int page, int rows) {
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = "SELECT * FROM `booking` WHERE 1=1 "+sqlx+" ORDER BY id DESC limit :start,:rows ";
+        String sql = "SELECT * FROM `booking` WHERE 1=1 "+sqlx+" ORDER BY id DESC,pay_time DESC limit :start,:rows ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("start", start);
         sps.addValue("rows", rows);
@@ -201,4 +201,16 @@ public class BookImplDao implements BookDao {
         if(list != null && list.size()>0) return list;
         return null;
     }
+
+    @Override
+    public Double sumAccount(String sqlx){
+        String sql = "select sum(pay_account) pay_account from booking where 1=1"+sqlx;
+        List<Booking> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Booking.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return list.get(0).getPayAccount();
+    }
 }