Browse Source

删除 AppBookingAction.java

陈士柏 2 years ago
parent
commit
945b6ea085
1 changed files with 0 additions and 779 deletions
  1. 0 779
      mhotel/src/com/happy/action/AppBookingAction.java

+ 0 - 779
mhotel/src/com/happy/action/AppBookingAction.java

@@ -1,779 +0,0 @@
-package com.happy.action;
-
-import com.happy.Model.AdminManager;
-import com.happy.Model.Booking;
-import com.happy.Model.weixin.PayResult;
-import com.happy.Model.weixin.Users;
-import com.happy.Model.weixin.WechatUnifiedOrder;
-import com.happy.Model.weixin.WeiXinUtil;
-import com.happy.Until.*;
-import com.happy.Until.Enum.B;
-import com.happy.Until.Enum.OrderEnum;
-import com.happy.Until.Enum.PayEnum;
-import com.happy.Until.weixin.EndPay;
-import com.happy.Until.weixin.JaxbUtil;
-import com.happy.Until.weixin.PayWxUtil;
-import com.happy.Until.weixin.TongYiReturn;
-import com.happy.common.http.Message;
-import com.happy.common.http.Message2;
-import com.happy.common.wx.WxUtil;
-import com.happy.constant.ResultStatusCode;
-import com.happy.service.AdminManagerService;
-import com.happy.service.AppBookService;
-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;
-import org.apache.struts2.interceptor.ServletRequestAware;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.io.PrintWriter;
-import java.text.ParseException;
-import java.util.*;
-
-/**
- * 订单进去Action请求交互
- */
-public class AppBookingAction extends ActionSupport implements ServletRequestAware {
-
-    private HttpServletRequest request;
-    public HttpServletResponse response;
-
-    @Resource
-    public BookService bookService;
-    @Resource
-    public UserService userService;
-    @Resource
-    public AppBookService appBookService;
-    @Resource
-    public AdminManagerService adminManagerService;
-
-    public int page; // 当前页
-    public int rows;// 每页显示的行数rows
-    public Integer id;
-    public String status;
-    public String hotelId; // 酒店id
-    public String houseId; // 房型id
-    public String startTime; // 订房开始时间
-    public String endTime;   // 订房结束时间
-    public String houseOrderNumber; // 订房数量
-    public String userName; // 住客姓名
-    public String userPhone; // 住客联系电话
-    public String userId; // 下单人id
-
-    public String getBookingId() {
-        return bookingId;
-    }
-
-    public void setBookingId(String bookingId) {
-        this.bookingId = bookingId;
-    }
-
-    private String bookingId; // 订单Id
-    private String open_id; // 用户open_Id
-
-    public HttpServletRequest getRequest() {
-        return request;
-    }
-
-    public void setRequest(HttpServletRequest request) {
-        this.request = request;
-    }
-
-    public void setServletRequest(HttpServletRequest request) {
-        this.request = request;
-    }
-
-    public HttpServletResponse getResponse() {
-        return response;
-    }
-
-    public void setResponse(HttpServletResponse response) {
-        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;
-    }
-
-
-
-
-    /**
-     * 定时任务
-     * @return
-     */
-    public String scheduledTasks()
-    {
-        // 获取所有的订单待支付状态
-        StringBuffer strSqlBook = new StringBuffer();
-        strSqlBook.append(" and order_status = '").append(PayEnum.ONE.getNum()).append("' ");
-        List<Booking> bookingList = bookService.queryList(strSqlBook.toString());
-        if (bookingList == null || bookingList.size() <= 0){
-            return null;
-        }
-
-        try {
-            for (Booking booking: bookingList) {
-                if (booking == null  || Func.checkNull(booking.getCreateTime()) || Func.checkNull(booking.getLockTime()))
-                    continue;
-
-                Date createTime = DateUtil.parseDate(booking.getCreateTime(),DateUtil.Time_Formatter_Second);
-                // 对订单时间进行累加
-                String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime),Func.parseInt(booking.getLockTime()));
-                // 当前时间 大于 锁定时间 为true
-                boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
-                if (flag)
-                {
-                    // 如果超时,则将订单状态修改为已超时
-                    booking.setOrderStatus(Func.parseStr(PayEnum.SIX.getNum()));
-                    booking.setUpdateTime(TimeExchange.getDate());
-                    bookService.updateBooking(booking);
-                    System.out.println("已将订单"+booking.getOrderNum()+"标识为支付超时");
-                }
-            }
-
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
-
-        return null;
-    }
-
-
-
-    /**
-     * houseId; // 房型id
-     * startTime; // 订房开始时间 2023/08/04
-     * endTime;   // 订房结束时间 2023/08/05
-     * houseOrderNumber; // 订房数量
-     * userName; // 住客姓名
-     * userPhone; // 住客联系电话
-     * userId; // 下单人id
-     * 用户点击订房操作,生成订单
-     */
-    public String createOrder() {
-        // 插入订单数据到表中
-        JSONObject jsonObject = new JSONObject();
-        if (Func.checkNull(houseId) || Func.checkNull(startTime) || Func.checkNull(endTime)
-                || Func.checkNull(houseOrderNumber) || Func.checkNull(userName) || Func.checkNull(userPhone) || Func.checkNull(userId)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        // 将时间统一转化为 yyyy/MM/dd
-        String startDate = DateUtil.parseDateToStr((Func.parseDate(startTime)), DateUtil.Time_Formatter_Day);
-        String endDate = DateUtil.parseDateToStr((Func.parseDate(endTime)), DateUtil.Time_Formatter_Day);
-
-        // 创建订单之前,先验证是否有房间
-        String backMessage = appBookService.varificationHouse(houseId, startDate, endDate);
-        if (!Func.checkNull(backMessage)) {
-            jsonObject.put(B.code, ResultStatusCode.CANNTBOOKING.getStatus());
-            jsonObject.put(B.message, backMessage);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        String  bookingId= Func.parseStr(UUIDUtil.generateID());
-        String mess = appBookService.createOrder(bookingId, houseId, startDate, endDate, houseOrderNumber, userName, userPhone, userId);
-        if (!Func.checkNull(mess)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, mess);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
-        jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
-        jsonObject.put(B.data, bookingId);
-        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-        return null;
-    }
-
-    /**
-     * 再次预订
-     *
-     * @return
-     */
-    public String reCreateOrder() {
-        // 插入订单数据到表中
-        JSONObject jsonObject = new JSONObject();
-        if (Func.checkNull(houseId) || Func.checkNull(startTime) || Func.checkNull(endTime)
-                || Func.checkNull(houseOrderNumber) || Func.checkNull(userName) || Func.checkNull(userPhone) || Func.checkNull(userId)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        // 将时间统一转化为 yyyy/MM/dd
-        String startDate = DateUtil.parseDateToStr((Func.parseDate(startTime)), DateUtil.Time_Formatter_Day);
-        String endDate = DateUtil.parseDateToStr((Func.parseDate(endTime)), DateUtil.Time_Formatter_Day);
-
-        // 创建订单之前,先验证是否有房间
-        String backMessage = appBookService.varificationHouse(houseId, startDate, endDate);
-        if (Func.checkNull(backMessage)) {
-            jsonObject.put(B.code, ResultStatusCode.CANNTBOOKING.getStatus());
-            jsonObject.put(B.message, backMessage);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        appBookService.reCreateOrder(houseId, startTime, endTime, houseOrderNumber, userName, userPhone, userId);
-
-        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
-        jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
-        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-        return null;
-    }
-
-    /**
-     * bookingId 订单id
-     * open_id
-     * 取消订单功能:
-     * //1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款
-     *
-     * @return
-     */
-    public String cancelBooking() throws Exception {
-        if (Func.checkNull(getBookingId()))
-            return null;
-
-        JSONObject jsonObject = new JSONObject();
-
-        // 取消订单,修改订单的支付状态
-        String mess = bookService.cancelBooking(getBookingId());
-        if (!Func.checkNull(mess)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, mess);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        Booking booking = bookService.getById(Func.parseInt(this.bookingId));
-        if (booking == null || Func.checkNull(booking.getRefundWay()))
-            return null;
-
-        // 进行判断如果订单是已取消,并且标识字段微信退款,则进入退款流程
-        if (Func.parseStr(PayEnum.SEVEN.getNum()).equals(booking.getOrderStatus()) && OrderEnum.微信退款.toString().equals(booking.getRefundWay())) {
-            if (Func.checkNull(this.open_id) || Func.checkNull(this.bookingId)) {
-                jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-                jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-                ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-                return null;
-            }
-
-            Users users = userService.queryByOpenid(open_id); // 用户信息
-            if (users == null || booking == null) {
-                jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-                jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-                ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-                return null;
-            }
-
-            String ip = WeiXinUtil.ip;
-            double money = booking.getPayAccount();
-            int a = (int) (money * 100);
-            WechatUnifiedOrder w = new WechatUnifiedOrder();
-            w.setAppid(WeiXinUtil.appid_c);
-            w.setAttach("chuanghai");
-            w.setBody("chuanghai");
-            w.setMch_id(WeiXinUtil.account);
-            w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-            w.setNotify_url(WeiXinUtil.ip_h + "/appquery_refund.action");// 支付结果回调地址
-            w.setOpenid(open_id);
-            w.setOut_trade_no(booking.getOrderNum());
-            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");
-            SortedMap<String, String> params = new TreeMap<>();
-            params.put("appid", w.getAppid());
-            params.put("mch_id", w.getMch_id());
-            params.put("nonce_str", w.getNonce_str());
-            params.put("notify_url", w.getNotify_url());
-            params.put("out_refund_no", w.getOut_refund_no());   // 退款单号
-            params.put("out_trade_no", w.getOut_trade_no());
-            params.put("refund_fee",w.getRefund_fee()+"");  // 退款金额
-            params.put("total_fee", w.getTotal_fee() + "");
-
-            w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
-            params.put("sign", w.getSign());
-            //String retXml = JaxbUtil.getRequestXml(params);
-            String xml = "<xml>" +
-                    "<appid>" + w.getAppid() + "</appid>" +
-                    "<mch_id>" + w.getMch_id() + "</mch_id>" +
-                    "<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
-                    "<notify_url>" + w.getNotify_url() + "</notify_url>" +
-                    "<out_refund_no>" + w.getOut_refund_no() + "</out_refund_no>" +
-                    "<out_trade_no>" + w.getOut_trade_no() + "</out_trade_no>"	+
-                    "<refund_fee>" + w.getRefund_fee()+"" + "</refund_fee>" +
-                    "<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
-                    "<sign>" + w.getSign() + "</sign>"	+
-                    "</xml>";
-            //String msg = HttpsClient.sendPost2("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
-            String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
-            if (msg.indexOf("FAIL") > -1) {
-                jsonObject.put("code", 507);
-                jsonObject.put("message", "退款失败");
-                ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-                return null;
-            }
-
-            // 设置订单状态为退款中
-            booking.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
-            booking.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
-            bookService.updateBooking(booking);  // 退款中
-
-            jsonObject.put("code", 200);
-            jsonObject.put("message", "退款申请已提交,请稍候查询");
-            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
-        jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
-        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-        return null;
-    }
-
-    /**
-     * open_id
-     * bookingId
-     * 微信退款功能
-     */
-    public String refundBooking() throws Exception {
-        JSONObject resultJson = new JSONObject();
-        if (Func.checkNull(this.open_id) || Func.checkNull(this.bookingId)) {
-            resultJson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            resultJson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-            return null;
-        }
-
-        Users users = userService.queryByOpenid(open_id); // 用户信息
-        Booking booking = bookService.getById(Func.parseInt(bookingId)); // 订单信息
-        if (users == null || booking == null) {
-            resultJson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            resultJson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-            return null;
-        }
-
-        String ip = WeiXinUtil.ip;
-        double money = booking.getPayAccount();
-        int a = (int) (money * 100);
-        WechatUnifiedOrder w = new WechatUnifiedOrder();
-        w.setAppid(WeiXinUtil.appid_c);
-        w.setAttach("chuanghai");
-        w.setBody("chuanghai");
-        w.setMch_id(WeiXinUtil.account);
-        w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-        w.setNotify_url(WeiXinUtil.ip_h + "/appquery_refund.action");// 支付结果回调地址
-        w.setOpenid(open_id);
-        w.setOut_trade_no(booking.getOrderNum());
-        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");
-        SortedMap<String, String> params = new TreeMap<>();
-        params.put("appid", w.getAppid());
-        params.put("mch_id", w.getMch_id());
-        params.put("nonce_str", w.getNonce_str());
-        params.put("notify_url", w.getNotify_url());
-        params.put("out_refund_no", w.getOut_refund_no());   // 退款单号
-        params.put("out_trade_no", w.getOut_trade_no());
-        params.put("refund_fee",w.getRefund_fee()+"");  // 退款金额
-        params.put("total_fee", w.getTotal_fee() + "");
-
-        w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
-        params.put("sign", w.getSign());
-        //String retXml = JaxbUtil.getRequestXml(params);
-        String xml = "<xml>" +
-                "<appid>" + w.getAppid() + "</appid>" +
-                "<mch_id>" + w.getMch_id() + "</mch_id>" +
-                "<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
-                "<notify_url>" + w.getNotify_url() + "</notify_url>" +
-                "<out_refund_no>" + w.getOut_refund_no() + "</out_refund_no>" +
-                "<out_trade_no>" + w.getOut_trade_no() + "</out_trade_no>"	+
-                "<refund_fee>" + w.getRefund_fee()+"" + "</refund_fee>" +
-                "<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
-                "<sign>" + w.getSign() + "</sign>"	+
-                "</xml>";
-        //String msg = HttpsClient.sendPost2("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
-        String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
-        if (msg.indexOf("FAIL") > -1) {
-            resultJson.put("code", 507);
-            resultJson.put("message", "退款失败");
-            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-            return null;
-        }
-
-        // 设置订单状态为退款中
-        booking.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
-        booking.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
-        bookService.updateBooking(booking);  // 退款中
-
-        resultJson.put("code", 200);
-        resultJson.put("message", "退款申请已提交,请稍候查询");
-        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-        return null;
-    }
-
-    /* 退款回调 */
-    public String query_refund() throws Exception {
-
-        // 查询本地数据库中,正在退款中
-        StringBuffer strSqlBook = new StringBuffer();
-        strSqlBook.append(" and order_status = '").append(PayEnum.TEN.getNum()).append("' ");
-        List<Booking> booking = bookService.queryList(strSqlBook.toString());
-        if (booking==null){
-            return null;
-        }
-        WechatUnifiedOrder w = new WechatUnifiedOrder();
-        Map<String, String> params = new HashMap<String, String>();
-        Booking book = new Booking();
-        for (int i = 0; i < booking.size(); i++) {
-            if (booking.get(i) == null)
-                continue;
-            book = booking.get(i);
-            w = new WechatUnifiedOrder();
-            w.setAppid(WeiXinUtil.appid_c);
-            w.setAttach("chuanghai");
-            w.setBody("chuanghai");
-            w.setMch_id(WeiXinUtil.account);
-            w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-            w.setOut_trade_no(book.getOrderNum());
-            w.setTrade_type("JSAPI");
-            params = new HashMap<String, String>();
-            params.put("appid", w.getAppid());
-            params.put("mch_id", w.getMch_id());
-            params.put("out_trade_no", w.getOut_trade_no());
-            params.put("nonce_str", w.getNonce_str());
-            w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
-            params.put("sign", w.getSign());
-            String retXml = JaxbUtil.getRequestXml(params);
-            String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/refundquery", retXml);
-            if (msg.indexOf("<refund_status_0><![CDATA[SUCCESS]]></refund_status_0>")>0) {
-                // 退款成功,将数据写入本地数据库
-                book.setRefundTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
-                book.setRefundAmount(book.getHouseTotalPrice());
-                book.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
-                bookService.updateBooking(book);
-
-
-                // 发送成功消息给商家和用户
-                AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
-                Users users = userService.queryByUserId(book.getCreateUserid());
-                String sendMsg = "订单:"+ book.getOrderNum() +"已退款成功,请注意查看";
-                // 推给商家
-                Message.send(adminManager.getOpenid(),book.getOrderNum(),book.getUserName(),sendMsg,book.getCreateTime());
-                // 推给用户
-                Message.send(users.getOpenid(),book.getOrderNum(),book.getUserName(),sendMsg,book.getCreateTime());
-
-            }
-        }
-        String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
-        HttpServletResponse response = ServletActionContext.getResponse();
-        response.setContentType("text/html;charset=utf-8");
-        PrintWriter out = response.getWriter();
-        out.println(returnMsg);
-        out.flush();
-        out.close();
-
-        return null;
-    }
-
-
-
-    /**
-     * bookingId 订单id
-     * 删除订单功能(假删除)
-     *
-     * @return
-     */
-    public String delBooking() {
-        if (Func.checkNull(getBookingId()))
-            return null;
-
-        JSONObject jsonObject = new JSONObject();
-
-        String mess = bookService.delBooking(getBookingId());
-        if (!Func.checkNull(mess)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, mess);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
-        jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
-        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-        return null;
-    }
-
-
-    /**
-     * 验证是否有房间
-     * houseId, 房型id
-     * startTime, 开始时间
-     * endTime 结束时间
-     *
-     * @return
-     */
-    public String varificationHouse() {
-        JSONObject jsonObject = new JSONObject();
-        if (Func.checkNull(houseId) || Func.checkNull(startTime) || Func.checkNull(endTime)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        String backMessage = appBookService.varificationHouse(houseId, startTime, endTime);
-
-        if (!Func.checkNull(backMessage)) {
-            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            jsonObject.put(B.message, backMessage);
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-            return null;
-        }
-
-        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
-        jsonObject.put(B.message, OrderEnum.有空房.toString());
-        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
-        return null;
-    }
-
-
-    /**
-     * open_id
-     * bookingId
-     * 用户支付操作
-     *
-     * @return
-     */
-    public String pay() {
-        JSONObject resultjson = new JSONObject();
-        if (Func.checkNull(this.open_id) || Func.checkNull(this.bookingId)) {
-            resultjson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            resultjson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-            return null;
-        }
-
-        Users users = userService.queryByOpenid(open_id); // 用户信息
-        Booking booking = bookService.getById(Func.parseInt(bookingId)); // 订单信息
-        if (users == null || booking == null) {
-            resultjson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            resultjson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-            return null;
-        }
-
-        try {
-            // 支付费用
-            double totalPrice = booking.getHouseTotalPrice() ;
-            int totalfee = Func.parseInt(totalPrice * 100);
-
-            WechatUnifiedOrder w = new WechatUnifiedOrder();
-            w.setAppid(WeiXinUtil.appid_c);
-            w.setAttach("chuanghai");
-            w.setBody("chuanghai");
-            w.setMch_id(WeiXinUtil.account);
-            w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-            w.setNotify_url(WeiXinUtil.ip_h + "/abkpayResulet.action");// 支付结果回调地址
-            w.setOpenid(this.open_id);
-            String orderNo = booking.getOrderNum(); // 订单编号
-            w.setOut_trade_no(orderNo);
-            w.setSpbill_create_ip(WeiXinUtil.ip);
-            w.setTotal_fee(totalfee);
-            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("total_fee", Func.parseStr(w.getTotal_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.key));
-            params.put("sign", w.getSign());
-            String retXml = JaxbUtil.getRequestXml(params);
-            String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/unifiedorder", retXml);
-            System.out.println(msg);
-            // 支付失败
-            if (msg.indexOf("FAIL") > -1) {
-                resultjson.put("code", "205");
-                resultjson.put("message", "支付异常205");
-                ResUtil.write(resultjson, ServletActionContext.getResponse());
-                return null;
-            }
-
-            JaxbUtil requestBinder = new JaxbUtil(TongYiReturn.class, JaxbUtil.CollectionWrapper.class);
-            TongYiReturn to = requestBinder.fromXml(msg);
-            // 支付成功
-            if (to.getReturn_code().equals("SUCCESS") && to.getResult_code().equals("SUCCESS")) {
-                EndPay pay = new EndPay();
-                pay.setAppId(WeiXinUtil.appid_c);
-                pay.setSignType("MD5");
-                pay.setTimeStamp(System.currentTimeMillis() / 1000 + "");
-                pay.setPrepay_id(to.getPrepay_id());
-                pay.setNonceStr(PayWxUtil.getNonceStr());
-                Map<String, String> requestMap = new HashMap<String, String>();
-                requestMap.put("appId", pay.getAppId());
-                requestMap.put("timeStamp", pay.getTimeStamp());
-                requestMap.put("nonceStr", pay.getNonceStr());
-                requestMap.put("package", "prepay_id=" + pay.getPrepay_id());
-                requestMap.put("signType", "MD5");
-                pay.setPaySign(PayWxUtil.getSign(requestMap, WeiXinUtil.key));
-                // 保存支付信息
-                booking.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
-                booking.setOrderStatus(Func.parseStr(PayEnum.ONE.getNum()));
-                booking.setPayTime(DateUtil.getFormatPaternDate(new Date()));
-                booking.setPayAccount(totalPrice);
-                booking.setPayWay(OrderEnum.微信支付.toString());
-                bookService.updateBooking(booking);
-
-                resultjson.put(B.code, ResultStatusCode.OK.getStatus());
-                resultjson.put(B.message, "返回成功");
-                resultjson.put(B.data, pay);
-                ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-            }
-        } catch (Exception e) {
-            resultjson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
-            resultjson.put(B.message, e.getMessage());
-            ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-        }
-        return null;
-    }
-
-    /**
-     *  支付成功后回调,推送消息给商家
-     *
-     */
-    public String payResulet(){
-        System.out.println("进入支付回调====");
-        JSONObject resultjson = new JSONObject();
-        try{
-            BufferedReader reader = null;// BufferedReader 字符输入流
-            reader = request.getReader();
-            String line = "";
-            String xmlString = null;
-            StringBuilder inputString = new StringBuilder();
-            while ((line = reader.readLine()) != null) {
-                inputString.append(line);
-            }
-            xmlString = inputString.toString();
-            request.getReader().close();
-            JaxbUtil requestBinder = new JaxbUtil(PayResult.class, PayResult.class);
-            PayResult result = requestBinder.fromXml(xmlString);// Xml到Java,用fromXML()方法
-            String order_num = result.getOut_trade_no();
-            System.out.println("支付成功回调,订单号:"+order_num);
-            Booking booking = bookService.queryByOrder(order_num);
-            // 支付成功
-            if (result.getResult_code().equals("SUCCESS") && booking!=null && booking.getOrderStatus().equals("1")) {
-                // 保存支付信息
-                booking.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
-                booking.setOrderStatus(Func.parseStr(PayEnum.TWO.getNum()));
-                booking.setPayTime(DateUtil.getFormatPaternDate(new Date()));
-                booking.setPayWay(OrderEnum.微信支付.toString());
-                // 进行业务判断,如果是商家设定了自动接单,则支付状态直接变为待入住  接单设置(1自动接单 2手动接单)
-                if ("1".equals(booking.getHotelIsCanorder()))
-                {
-                    // 自动接单,订单状态修改为待入住
-                    booking.setOrderStatus(Func.parseStr(PayEnum.THREE.getNum()));
-//                    String userId = booking.getCreateUserid();
-//                    Users users = userService.queryByUserId(userId);
-//                    String mess = "您已成功订房,订单号:"+order_num;
-//                    Message.send(users.getOpenid(),order_num, users.getUser_name(),mess, booking.getPayTime());
-                }
-
-                // 手动接单,发消息给商家
-                AdminManager adminManager = adminManagerService.getById(Func.parseInt(booking.getHotelManagerId()));
-                String live_end = booking.getOrderStartTime().substring(0,10)  +"~"+  booking.getOrderEndTime().substring(0,10);
-                String hotelName = "";
-                if (Func.checkNull(booking.getHotelName()))
-                {
-                    hotelName = booking.getHouseName();
-                }
-
-                Message2.send(adminManager.getOpenid(),order_num,booking.getHouseName(),live_end,booking.getUserName(),hotelName);
-
-                int m = bookService.updateBooking(booking);
-                if (m>0){
-                    String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
-                    HttpServletResponse response = ServletActionContext.getResponse();
-                    response.setContentType("text/html;charset=utf-8");
-                    PrintWriter out = response.getWriter();
-                    out.println(returnMsg);
-                    out.flush();
-                    out.close(); // 发送成功消息给商家
-                }
-                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;
-    }
-
-
-
-
-    public String getOpen_id() {
-        return open_id;
-    }
-
-    public void setOpen_id(String open_id) {
-        this.open_id = open_id;
-    }
-}