package com.happy.action;

import com.happy.Model.Booking;
import com.happy.Until.ResUtil;
import com.happy.Until.TimeExchange;
import com.happy.service.BookService;
import com.happy.service.ConfigService;
import com.happy.service.HouseService;
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.util.List;

public class autoAction extends ActionSupport implements ServletRequestAware {

    private HttpServletRequest request;
    public HttpServletResponse response;

    @Resource
    public UserService userService;
    @Resource
    public BookService bookService;
    @Resource
    public HouseService houseService;
    @Resource
    public ConfigService configService;

    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 String refund_room(){
//        JSONObject resultjson = new JSONObject();
//        List<Booking> list = bookService.queryEnd(TimeExchange.getDate());
//        if (list!=null){
//            for (int i = 0; i < list.size(); i++) {
////                bookService.update_pay("6", list.get(i).getOrder_num());
//            }
//        }
//        resultjson.put("message", "退房成功");
//        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
        return null;
    }
}
