Administrator 2 年 前
コミット
e62e3351f9

+ 390 - 131
mhotel/src/com/happy/Model/Booking.java

@@ -1,142 +1,401 @@
 package com.happy.Model;
 
-import com.happy.Until.DataBliu;
+import java.util.Date;
 
+/**
+ * 订单实体类
+ */
 public class Booking {
 
-    public Integer id;
-    public String order_num;
-    public String status;  // 状态:1待支付,2已支付,3已入住,4已取消,5已退款,6已退房
-    public String dom;  // 房号
-    public String card_number;  // 卡号
-    public String user_name;
-    public String phone;
-    public String h_type;  // 预定房型
-    public Double price;  // 房价
-    public String create_time;   // 下单时间
-    public String live_time;  // 居住时间
-    public Double pay_account;  // 支付金额
-    public String end_time;   // 离店时间
-    public Integer h_num;  // 房间数量
-    public Double refund_amount;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getOrder_num() {
-        return order_num;
-    }
-
-    public void setOrder_num(String order_num) {
-        this.order_num = order_num;
-    }
-
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    public String getDom() {
-        return dom;
-    }
-
-    public void setDom(String dom) {
-        this.dom = dom;
-    }
-
-    public String getCard_number() {
-        return card_number;
-    }
-
-    public void setCard_number(String card_number) {
-        this.card_number = card_number;
-    }
-
-    public String getUser_name() {
-        return user_name;
-    }
-
-    public void setUser_name(String user_name) {
-        this.user_name = user_name;
-    }
-
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-
-    public String getH_type() {
-        return h_type;
-    }
-
-    public void setH_type(String h_type) {
-        this.h_type = h_type;
-    }
-
-    public Double getPrice() {
-        return DataBliu.getTwo(price);
-    }
-
-    public void setPrice(Double price) {
-        this.price = price;
-    }
-
-    public String getCreate_time() {
-        return create_time;
-    }
-
-    public void setCreate_time(String create_time) {
-        this.create_time = create_time;
-    }
-
-    public String getLive_time() {
-        return live_time;
-    }
-
-    public void setLive_time(String live_time) {
-        this.live_time = live_time;
-    }
-
-    public Double getPay_account() {
-        return DataBliu.getTwo(pay_account);
-    }
-
-    public void setPay_account(Double pay_account) {
-        this.pay_account = pay_account;
-    }
-
-    public String getEnd_time() {
-        return end_time;
-    }
+  private int id;
+  private String orderNum; // 订单号
+  private String orderStatus; // 状态,1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款
+  private String userIdnumber; // 住客身份号
+  private String userName;//住客姓名
+  private String userPhone;// 住客手机号
+  private String hotelId;// 民宿id
+  private String hotelName;// 民宿名称
+  private String hotelHposition; // 民宿位置
+  private String hotelHpositionWens; // 民宿经纬度
+  private String hotelPhone; // 民宿联系电话
+  private String hotelPerson; // 民宿联系人
+  private String hotelTownship; // 民宿所属乡镇
+  private String hotelConfig; // 民宿配置
+  private String hotelType; // 民宿类型
+  private String hotelIsCanorder; // 是否可取消订单
+  private String houseId; // 房型id
+  private String houseName; // 户型名称
+  private String houseConfig; //房间配置
+  private double houseUnitPrice; // 房间单价
+  private double houseTotalPrice; // 总价
+  private int houseOrderNumber; // 订房数量
+  private String houseAreas; // 房型面积
+  private String houseRemake; // 房型备注
+  private Date orderStartTime; // 订房开始时间
+  private Date orderEndTime; // 订房结束时间
+  private String orderLiveTime;// 订房入住时间合计
+  private String orderRemake; // 订房备注
+  private Date createTime; // 订单创建时间
+  private String createUserid; //订单创建人id
+  private Date updateTime; // 订单更新时间
+  private Date payTime; // 实际支付时间
+  private double payAccount; // 实际支付金额
+  private String payWay; // 支付方式:默认使用微信支付
+  private String refundWay; // 退款方式
+  private double refundAmount; // 退款金额
+  private Date refundTime; // 退款时间
+  private Date checkOutTime; // 离店时间
+  private String remake; // 备注信息
 
-    public void setEnd_time(String end_time) {
-        this.end_time = end_time;
-    }
 
-    public Integer getH_num() {
-        return h_num;
-    }
+  public int getId() {
+    return id;
+  }
 
-    public void setH_num(Integer h_num) {
-        this.h_num = h_num;
-    }
+  public void setId(int id) {
+    this.id = id;
+  }
 
-    public Double getRefund_amount() {
-        return DataBliu.getTwo(refund_amount);
-    }
 
-    public void setRefund_amount(Double refund_amount) {
-        this.refund_amount = refund_amount;
-    }
+  public String getOrderNum() {
+    return orderNum;
+  }
+
+  public void setOrderNum(String orderNum) {
+    this.orderNum = orderNum;
+  }
+
+
+  public String getOrderStatus() {
+    return orderStatus;
+  }
+
+  public void setOrderStatus(String orderStatus) {
+    this.orderStatus = orderStatus;
+  }
+
+
+  public String getUserIdnumber() {
+    return userIdnumber;
+  }
+
+  public void setUserIdnumber(String userIdnumber) {
+    this.userIdnumber = userIdnumber;
+  }
+
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+
+  public String getUserPhone() {
+    return userPhone;
+  }
+
+  public void setUserPhone(String userPhone) {
+    this.userPhone = userPhone;
+  }
+
+
+  public String getHotelId() {
+    return hotelId;
+  }
+
+  public void setHotelId(String hotelId) {
+    this.hotelId = hotelId;
+  }
+
+
+  public String getHotelName() {
+    return hotelName;
+  }
+
+  public void setHotelName(String hotelName) {
+    this.hotelName = hotelName;
+  }
+
+
+  public String getHotelHposition() {
+    return hotelHposition;
+  }
+
+  public void setHotelHposition(String hotelHposition) {
+    this.hotelHposition = hotelHposition;
+  }
+
+
+  public String getHotelHpositionWens() {
+    return hotelHpositionWens;
+  }
+
+  public void setHotelHpositionWens(String hotelHpositionWens) {
+    this.hotelHpositionWens = hotelHpositionWens;
+  }
+
+
+  public String getHotelPhone() {
+    return hotelPhone;
+  }
+
+  public void setHotelPhone(String hotelPhone) {
+    this.hotelPhone = hotelPhone;
+  }
+
+
+  public String getHotelPerson() {
+    return hotelPerson;
+  }
+
+  public void setHotelPerson(String hotelPerson) {
+    this.hotelPerson = hotelPerson;
+  }
+
+
+  public String getHotelTownship() {
+    return hotelTownship;
+  }
+
+  public void setHotelTownship(String hotelTownship) {
+    this.hotelTownship = hotelTownship;
+  }
+
+
+  public String getHotelConfig() {
+    return hotelConfig;
+  }
+
+  public void setHotelConfig(String hotelConfig) {
+    this.hotelConfig = hotelConfig;
+  }
+
+
+  public String getHotelType() {
+    return hotelType;
+  }
+
+  public void setHotelType(String hotelType) {
+    this.hotelType = hotelType;
+  }
+
+
+  public String getHotelIsCanorder() {
+    return hotelIsCanorder;
+  }
+
+  public void setHotelIsCanorder(String hotelIsCanorder) {
+    this.hotelIsCanorder = hotelIsCanorder;
+  }
+
+
+  public String getHouseId() {
+    return houseId;
+  }
+
+  public void setHouseId(String houseId) {
+    this.houseId = houseId;
+  }
+
+
+  public String getHouseName() {
+    return houseName;
+  }
+
+  public void setHouseName(String houseName) {
+    this.houseName = houseName;
+  }
+
+
+  public String getHouseConfig() {
+    return houseConfig;
+  }
+
+  public void setHouseConfig(String houseConfig) {
+    this.houseConfig = houseConfig;
+  }
+
+
+  public double getHouseUnitPrice() {
+    return houseUnitPrice;
+  }
+
+  public void setHouseUnitPrice(double houseUnitPrice) {
+    this.houseUnitPrice = houseUnitPrice;
+  }
+
+
+  public double getHouseTotalPrice() {
+    return houseTotalPrice;
+  }
+
+  public void setHouseTotalPrice(double houseTotalPrice) {
+    this.houseTotalPrice = houseTotalPrice;
+  }
+
+
+  public int getHouseOrderNumber() {
+    return houseOrderNumber;
+  }
+
+  public void setHouseOrderNumber(int houseOrderNumber) {
+    this.houseOrderNumber = houseOrderNumber;
+  }
+
+
+  public String getHouseAreas() {
+    return houseAreas;
+  }
+
+  public void setHouseAreas(String houseAreas) {
+    this.houseAreas = houseAreas;
+  }
+
+
+  public String getHouseRemake() {
+    return houseRemake;
+  }
+
+  public void setHouseRemake(String houseRemake) {
+    this.houseRemake = houseRemake;
+  }
+
+
+  public Date getOrderStartTime() {
+    return orderStartTime;
+  }
+
+  public void setOrderStartTime(Date orderStartTime) {
+    this.orderStartTime = orderStartTime;
+  }
+
+
+  public Date getOrderEndTime() {
+    return orderEndTime;
+  }
+
+  public void setOrderEndTime(Date orderEndTime) {
+    this.orderEndTime = orderEndTime;
+  }
+
+
+  public String getOrderLiveTime() {
+    return orderLiveTime;
+  }
+
+  public void setOrderLiveTime(String orderLiveTime) {
+    this.orderLiveTime = orderLiveTime;
+  }
+
+
+  public String getOrderRemake() {
+    return orderRemake;
+  }
+
+  public void setOrderRemake(String orderRemake) {
+    this.orderRemake = orderRemake;
+  }
+
+
+  public Date getCreateTime() {
+    return createTime;
+  }
+
+  public void setCreateTime(Date createTime) {
+    this.createTime = createTime;
+  }
+
+
+  public String getCreateUserid() {
+    return createUserid;
+  }
+
+  public void setCreateUserid(String createUserid) {
+    this.createUserid = createUserid;
+  }
+
+
+  public Date getUpdateTime() {
+    return updateTime;
+  }
+
+  public void setUpdateTime(Date updateTime) {
+    this.updateTime = updateTime;
+  }
+
+
+  public Date getPayTime() {
+    return payTime;
+  }
+
+  public void setPayTime(Date payTime) {
+    this.payTime = payTime;
+  }
+
+
+  public double getPayAccount() {
+    return payAccount;
+  }
+
+  public void setPayAccount(double payAccount) {
+    this.payAccount = payAccount;
+  }
+
+
+  public String getPayWay() {
+    return payWay;
+  }
+
+  public void setPayWay(String payWay) {
+    this.payWay = payWay;
+  }
+
+
+  public String getRefundWay() {
+    return refundWay;
+  }
+
+  public void setRefundWay(String refundWay) {
+    this.refundWay = refundWay;
+  }
+
+
+  public double getRefundAmount() {
+    return refundAmount;
+  }
+
+  public void setRefundAmount(double refundAmount) {
+    this.refundAmount = refundAmount;
+  }
+
+
+  public Date getRefundTime() {
+    return refundTime;
+  }
+
+  public void setRefundTime(Date refundTime) {
+    this.refundTime = refundTime;
+  }
+
+
+  public Date getCheckOutTime() {
+    return checkOutTime;
+  }
+
+  public void setCheckOutTime(Date checkOutTime) {
+    this.checkOutTime = checkOutTime;
+  }
+
+
+  public String getRemake() {
+    return remake;
+  }
+
+  public void setRemake(String remake) {
+    this.remake = remake;
+  }
+
 }

+ 21 - 1
mhotel/src/com/happy/Model/weixin/Users.java

@@ -1,9 +1,12 @@
 package com.happy.Model.weixin;
 
+/**
+ * 游客表,
+ */
 public class Users {
 
     public int id;
-    public String card_number;  // 微校卡号
+    public String card_number;  // 身份证
     public String user_name;
     public String user_phone;
     public String user_zz;   // 职务
@@ -11,6 +14,8 @@ public class Users {
     public String create_time;
     public String remark;   // 备注
     public int identity_type;   // 用户分类
+    private int contactId;   // 关联人id(用于常联系人关联)
+    private int contactName;   // 关联人姓名(用于常联系人关联)
 
     public int getId() {
         return id;
@@ -84,4 +89,19 @@ public class Users {
         this.identity_type = identity_type;
     }
 
+    public int getContactId() {
+        return contactId;
+    }
+
+    public void setContactId(int contactId) {
+        this.contactId = contactId;
+    }
+
+    public int getContactName() {
+        return contactName;
+    }
+
+    public void setContactName(int contactName) {
+        this.contactName = contactName;
+    }
 }

+ 394 - 0
mhotel/src/com/happy/Until/DateUtil.java

@@ -0,0 +1,394 @@
+package com.happy.Until;
+
+
+import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @author xieli
+ * @date 2023/8/1 17:34
+ * @description 时间工具类
+ */
+public class DateUtil
+{
+    public DateUtil() {
+
+    }
+
+    public static String Time_Formatter_Day = "yyyy/MM/dd";
+    public static String Time_Formatter_Second = "yyyy-MM-dd HH:mm:ss";
+
+    public static String getCurrentYear() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+        Date date = new Date();
+        return sdf.format(date);
+    }
+
+    /**
+     * 判断 firstDate 是否在 secondDate 之前或相等.
+     * @param firstDate .
+     * @param secondDate .
+     * @return firstDate 在 secondDate 之前或相等时返回 true,否则返回 false.
+     */
+    public static boolean isBeforeOrEqual(Date firstDate, Date secondDate) {
+        if (secondDate == null) {
+            return true;
+        }
+        if (firstDate.compareTo(secondDate) <= 0) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * 比较日期
+     * @param firstDate 第一个
+     * @param secondDate 第二个
+     * @return boolean
+     */
+    public static boolean isAfterOrEqual(Date firstDate, Date secondDate) {
+        if (secondDate == null) {
+            return true;
+        }
+        if (firstDate.compareTo(secondDate) >= 0) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * 验证日期格式是否正确.
+     * @param datestr .
+     * @return .
+     */
+    public static boolean isISO8601Date(String datestr) {
+        return Pattern
+                .compile(
+                        "^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$")
+                .matcher(datestr).matches();
+    }
+
+    /**
+     * 获取两个指定日期相差的天数.
+     * @param firstDate .
+     * @param secondDate .
+     * @return .
+     */
+    public static int getBetweenDay(Date firstDate, Date secondDate) {
+        // 时间格式相同,获取两时间差的秒数
+        long betweendDateBySeconds = firstDate.getTime() - secondDate.getTime();
+        // 得到天数(保持正负号)
+        return (int) (betweendDateBySeconds / (1000 * 3600 * 24));
+    }
+
+    /**
+     * 获取系统当前时间.
+     * @return .
+     */
+    public static Date getCurrentDate() {
+        return new Date();
+    }
+
+    /**
+     * 年份
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getYear(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.YEAR);
+    }
+
+    /**
+     * 月份
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getMonth(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.MONTH) + 1;
+    }
+
+    /**
+     * 日
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getDay(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.DAY_OF_MONTH);
+    }
+
+    /**
+     * 小时
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getHour(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.HOUR_OF_DAY);
+    }
+
+    /**
+     * 分钟
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getMinute(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.MINUTE);
+    }
+
+    /**
+     * 秒数
+     * @param datIn 日期
+     * @return int
+     */
+    public static int getSecond(Date datIn) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(datIn);
+
+        return calendar.get(Calendar.SECOND);
+    }
+
+    /**
+     * 格式化日期
+     * @param patern 格式字符
+     * @return String
+     */
+    public static String getFormatDate(String patern) {
+        return new SimpleDateFormat(patern).format(new Date());
+    }
+
+    /**
+     * 格式化日期
+     * @param datIn 日期
+     * @return String
+     */
+    public static String getFormatPaternDate(Date datIn) {
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(datIn);
+    }
+
+    /**
+     * 将指定字符串,通过指定格式转换为日期对象.
+     * @param dateStr 字符串
+     * @return Date
+     */
+    public static Date parseDate(String dateStr, String formatter) {
+
+        try {
+            if (Func.checkNullOrEmpty(dateStr)) {
+                return null;
+            }
+            return new SimpleDateFormat(formatter).parse(dateStr);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 将指定字符串,通过指定格式转换为日期对象.
+     * @param dateStr 字符串
+     * @return Date
+     */
+    public static Date parseDateOnly(String dateStr) {
+        if (Func.checkNullOrEmpty(dateStr)) {
+            return null;
+        }
+
+        try {
+            return new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
+        } catch (ParseException e) {
+            try {
+                return new SimpleDateFormat("yyyy/MM/dd").parse(dateStr);
+            } catch (Exception e2) {
+                new Exception("时间格式错误:" + e2.getMessage()).printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 将日期date转化成string
+     * @param date
+     * @return
+     */
+    public static String parseDateToStr(Date date, String formatter) {
+        SimpleDateFormat sdf = new SimpleDateFormat(formatter);
+        return sdf.format(date);
+    }
+
+    /**
+     * 增加日期
+     * @param date 日期
+     * @param dateField 字段
+     * @param dateAmount 数量
+     * @return Date
+     */
+    public static Date addDate(Date date, int dateField, int dateAmount) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(dateField, dateAmount);
+
+        return calendar.getTime();
+    }
+
+    /**
+     * 格式化指定日期格式
+     * @param datIn 日期内容
+     * @param formatStr 格式化字符
+     * @return 格式化之后的日期对象
+     * @throws ParseException 转换异常
+     */
+    public static Date formateDate(Date datIn, String formatStr) throws ParseException {
+        String dateStr = new SimpleDateFormat(formatStr).format(datIn);
+
+        return new SimpleDateFormat(formatStr).parse(dateStr);
+    }
+
+    /**
+     *  获取两个日期相差的月数
+     * @param c1    较大的日期
+     * @param c2    较小的日期
+     * @return  如果d1>d2返回 月数差 否则返回0
+     */
+    public static int getMonthDiff(Calendar c1, Calendar c2) {
+        if (c1.getTimeInMillis() < c2.getTimeInMillis()) {
+            return 0;
+        }
+        int year1 = c1.get(Calendar.YEAR);
+        int year2 = c2.get(Calendar.YEAR);
+        int month1 = c1.get(Calendar.MONTH);
+        int month2 = c2.get(Calendar.MONTH);
+        int day1 = c1.get(Calendar.DAY_OF_MONTH);
+        int day2 = c2.get(Calendar.DAY_OF_MONTH);
+        // 获取年的差值 假设 d1 = 2015-8-16  d2 = 2011-9-30
+        int yearInterval = year1 - year2;
+        // 如果 d1的 月-日 小于 d2的 月-日 那么 yearInterval-- 这样就得到了相差的年数
+        if (month1 < month2 || month1 == month2 && day1 < day2) {
+            yearInterval--;
+        }
+        // 获取月数差值
+        int monthInterval = (month1 + 12) - month2;
+        if (day1 < day2) {
+            monthInterval--;
+        }
+        monthInterval %= 12;
+        return yearInterval * 12 + monthInterval;
+    }
+
+    /**
+     * 获得两个日期之间的所有月份
+     * @param minDate minDate
+     * @param maxDate maxDate
+     * @return List<String>
+     * @throws ParseException ParseException
+     */
+    public static List<String> getMonthBetween(String minDate, String maxDate) throws ParseException {
+        ArrayList<String> result = new ArrayList<String>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月
+
+        Calendar min = Calendar.getInstance();
+        Calendar max = Calendar.getInstance();
+
+        min.setTime(sdf.parse(minDate));
+        min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
+
+        max.setTime(sdf.parse(maxDate));
+        max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
+
+        Calendar curr = min;
+        while (curr.before(max)) {
+            result.add(sdf.format(curr.getTime()));
+            curr.add(Calendar.MONTH, 1);
+        }
+
+        return result;
+    }
+
+    /**
+     * 转换日期
+     * @param str 对象
+     * @return boolean
+     */
+    @SuppressWarnings("deprecation")
+    public static boolean isDateStr(String str, boolean hasDay) {
+
+        boolean convertSuccess = true;
+        // 指定日期格式为四位年/两位月份/两位日期,注意yyyy/MM/dd区分大小写;
+        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
+        if (!hasDay) {
+            format = new SimpleDateFormat("yyyy/MM");
+        }
+        try {
+            // 设置lenient为false.
+            // 否则SimpleDateFormat会比较宽松地验证日期,比如2007/02/29会被接受,并转换成2007/03/01
+            format.setLenient(false);
+            format.parse(str);
+        } catch (ParseException e) {
+            try {
+                SimpleDateFormat formatt = new SimpleDateFormat("yyyy-MM-dd");
+                if (!hasDay) {
+                    formatt = new SimpleDateFormat("yyyy-MM");
+                }
+                formatt.setLenient(false);
+                Date tempDate = formatt.parse(str);
+                // 年份大于9999年 则视为非法;
+                if (tempDate.getYear() > 8099) {
+                    convertSuccess = false;
+                }
+            } catch (Exception e2) {
+                convertSuccess = false;
+            }
+        }
+        return convertSuccess;
+    }
+
+    /**
+     * 根据当前时间获取文件夹
+     * @return String
+     */
+    public static String getCurrentDateFolder() {
+        Calendar now = Calendar.getInstance();
+        int year = now.get(Calendar.YEAR);
+        int month = now.get(Calendar.MONTH) + 1;
+        int day = now.get(Calendar.DAY_OF_MONTH);
+        return year + File.separator + month + File.separator + day + File.separator;
+    }
+
+    /**
+     * 对比时间(精确到天)
+     * @param date1
+     * @param date2
+     */
+    public static boolean compareDateTimeSpecial(String date1, String date2, String order) {
+        Date d1 = parseDateOnly(date1);
+        Date d2 = parseDateOnly(date2);
+        if (d1.equals(d2)) {
+            return false;
+        } else if (d1.before(d2)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}

+ 9 - 9
mhotel/src/com/happy/Until/Excel/toExcel.java

@@ -42,15 +42,15 @@ public class toExcel {
             // 将结果集写入
             for (int i = 0; i < list.size(); i++) {
                 Vector col = new Vector(); // 用以保存一行数据
-                col.add(list.get(i).getOrder_num());
-                col.add(list.get(i).getStatus());
-                col.add(list.get(i).getDom());
-                col.add(list.get(i).getUser_name());
-                col.add(list.get(i).getPhone());
-                col.add(list.get(i).getH_type());
-                col.add(list.get(i).getPrice());
-                col.add(list.get(i).getCreate_time());
-                col.add(list.get(i).getPay_account());
+//                col.add(list.get(i).getOrder_num());
+//                col.add(list.get(i).getStatus());
+//                col.add(list.get(i).getDom());
+//                col.add(list.get(i).getUser_name());
+//                col.add(list.get(i).getPhone());
+//                col.add(list.get(i).getH_type());
+//                col.add(list.get(i).getPrice());
+//                col.add(list.get(i).getCreate_time());
+//                col.add(list.get(i).getPay_account());
                 // 写入Excel
                 this.writeCol(sheet, col, rowNum++);
             }

ファイルの差分が大きいため隠しています
+ 1308 - 0
mhotel/src/com/happy/Until/Func.java


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

@@ -0,0 +1,105 @@
+package com.happy.action;
+
+import com.happy.common.util.CommonResult;
+import com.happy.service.AppHomePageService;
+import com.happy.service.BookService;
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.interceptor.ServletRequestAware;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 首页进去Action请求交互
+ */
+public class AppBookingAction extends ActionSupport implements ServletRequestAware {
+
+    private HttpServletRequest request;
+    public HttpServletResponse response;
+
+    @Resource
+    public BookService bookService;
+
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public Integer id;
+    public String status;
+
+    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;
+    }
+
+
+    /**
+     * 用户点击订房操作,生成订单
+     */
+    public String createOrder()
+    {
+        // 插入订单数据到表中
+
+        return null;
+    }
+
+    /**
+     * 用户支付操作
+     * @return
+     */
+    public String pay()
+    {
+        return null;
+    }
+
+
+
+
+
+}

+ 177 - 0
mhotel/src/com/happy/action/AppHomePageAction.java

@@ -0,0 +1,177 @@
+package com.happy.action;
+
+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.Until.*;
+import com.happy.Until.Excel.toExcel;
+import com.happy.Until.weixin.JaxbUtil;
+import com.happy.Until.weixin.PayWxUtil;
+import com.happy.common.util.CommonResult;
+import com.happy.common.wx.WxUtil;
+import com.happy.service.AppHomePageService;
+import com.happy.service.BookService;
+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.text.ParseException;
+import java.util.*;
+
+/**
+ * 首页进去Action请求交互
+ */
+public class AppHomePageAction extends ActionSupport implements ServletRequestAware {
+
+    private HttpServletRequest request;
+    public HttpServletResponse response;
+
+    @Resource
+    public BookService bookService;
+    @Resource
+    public AppHomePageService appHomePageService;
+
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+
+    public Integer id = new Integer(0);
+    public String status;
+    private int hotelId = 0; //选择的当前酒店的id
+
+    public String userCode; // 第一次进来获取用户的code
+    public String queryValue; // 首页查寻搜索关键词
+    private Date startTimeQuery; // 查询订房开始时间
+    private Date endTimeQuery; // 查询订房结束时间
+
+    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;
+    }
+
+
+
+    /**
+     * 进入首页,展示民宿数据列表
+     * queryValue 查询字段
+     * @return
+     */
+    public String homePage()
+    {
+        // 第一次进入首页,获取用户信息
+        //getUserInfo();
+
+        // 获取民宿列表
+       appHomePageService.getHotelList(queryValue,rows,page);
+
+        return null;
+    }
+
+    /**
+     * 通过酒店的id获取到房间信息
+     * @return
+     */
+    public String getHouseByHotelId()
+    {
+        // 如果未赋值,则直接跳出
+        if (hotelId == 0 )
+            return null;
+
+        // 通过时间区间查询房间信息,并带好是否有房标识给前台
+
+        return null;
+    }
+
+
+
+    public String getUserCode() {
+        return userCode;
+    }
+
+    public void setUserCode(String userCode) {
+        this.userCode = userCode;
+    }
+
+    public String getQueryValue() {
+        return queryValue;
+    }
+
+    public void setQueryValue(String queryValue) {
+        this.queryValue = queryValue;
+    }
+
+    public int getHotelId() {
+        return hotelId;
+    }
+
+    public void setHotelId(int hotelId) {
+        this.hotelId = hotelId;
+    }
+
+    public Date getStartTimeQuery() {
+        return startTimeQuery;
+    }
+
+    public void setStartTimeQuery(Date startTimeQuery) {
+        this.startTimeQuery = startTimeQuery;
+    }
+
+    public Date getEndTimeQuery() {
+        return endTimeQuery;
+    }
+
+    public void setEndTimeQuery(Date endTimeQuery) {
+        this.endTimeQuery = endTimeQuery;
+    }
+}

+ 119 - 0
mhotel/src/com/happy/action/AppMePageAction.java

@@ -0,0 +1,119 @@
+package com.happy.action;
+
+import com.happy.common.util.CommonResult;
+import com.happy.service.AppHomePageService;
+import com.happy.service.BookService;
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.interceptor.ServletRequestAware;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 首页进去Action请求交互
+ */
+public class AppMePageAction extends ActionSupport implements ServletRequestAware {
+
+    private HttpServletRequest request;
+    public HttpServletResponse response;
+
+    @Resource
+    public BookService bookService;
+    @Resource
+    public AppHomePageService appHomePageService;
+
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public Integer id;
+    public String status;
+
+    private String userCode; // 第一次进来获取用户的code
+    private String queryValue; // 首页查寻搜索关键词
+
+    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 CommonResult homePage()
+    {
+        // 第一次进入首页,获取用户信息
+        //getUserInfo();
+
+        // 获取民宿列表
+       appHomePageService.getHotelList(queryValue,rows,page);
+
+        return null;
+    }
+
+
+    public String getUserCode() {
+        return userCode;
+    }
+
+    public void setUserCode(String userCode) {
+        this.userCode = userCode;
+    }
+
+    public String getQueryValue() {
+        return queryValue;
+    }
+
+    public void setQueryValue(String queryValue) {
+        this.queryValue = queryValue;
+    }
+}

+ 1 - 1
mhotel/src/com/happy/action/autoAction.java

@@ -56,7 +56,7 @@ public class autoAction extends ActionSupport implements ServletRequestAware {
         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());
+//                bookService.update_pay("6", list.get(i).getOrder_num());
             }
         }
         resultjson.put("message", "退房成功");

+ 105 - 105
mhotel/src/com/happy/action/bookAction.java

@@ -243,30 +243,30 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
             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;
-        }
+//        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", "操作成功");
@@ -302,71 +302,71 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
             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.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());
+//        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;
     }
 
@@ -421,24 +421,24 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
             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;
-        }
+//        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", "操作成功");

+ 40 - 40
mhotel/src/com/happy/action/houseAction.java

@@ -121,24 +121,24 @@
 ////                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
 ////                return null;
 ////            }
-//            int m = houseService.insert(house);
-//            if (m > 0) {
-//                resultjson.put("message", "添加成功");
-//                resultjson.put("code", 200);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            } else {
-//                resultjson.put("message", "添加失败");
-//                resultjson.put("code", 502);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        resultjson.put("message", "未知异常");
-//        resultjson.put("code", 205);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
+////            int m = houseService.insert(house);
+////            if (m > 0) {
+////                resultjson.put("message", "添加成功");
+////                resultjson.put("code", 200);
+////                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
+////                return null;
+////            } else {
+////                resultjson.put("message", "添加失败");
+////                resultjson.put("code", 502);
+////                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
+////                return null;
+////            }
+////        } catch (Exception e) {
+////            e.printStackTrace();
+////        }
+////        resultjson.put("message", "未知异常");
+////        resultjson.put("code", 205);
+////        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
 //        return null;
 //    }
 //
@@ -244,29 +244,29 @@
 //        if (h_type!=null){
 //            s1.append(" and h_type like '%").append(this.h_type).append("%' ");
 //        }
-//        int total = houseService.queryHouseTotal(s1.toString()); // 查询表中的总记录数
-//        List<House> listPage = houseService.queryHousePage(s1.toString(),page,rows); // 查询分页
+////        int total = houseService.queryHouseTotal(s1.toString()); // 查询表中的总记录数
+////        List<House> listPage = houseService.queryHousePage(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);// 尾页
-//        }
+////        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;

+ 35 - 0
mhotel/src/com/happy/common/util/BaseResult.java

@@ -0,0 +1,35 @@
+package com.happy.common.util;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author: codingliang
+ * @Description: 接口统一返回基类
+ * @Date: 20230731
+ * @Version: V1.0
+ **/
+@Data
+public abstract class BaseResult<T> implements Serializable {
+
+    /**
+     * 接口调用结果标识
+     */
+    private boolean success = false;
+
+    /**
+     * 接口调用结果信息
+     */
+    private String message;
+
+    /**
+     * 接口调用业务码
+     */
+    private String code;
+
+    /**
+     * 接口调用返回数据
+     */
+    private T data;
+}

+ 7 - 0
mhotel/src/com/happy/common/util/Code.java

@@ -0,0 +1,7 @@
+package com.happy.common.util;
+
+public interface Code {
+    Integer getStatus();
+    Boolean getSuccess();
+    String getMsg();
+}

+ 134 - 0
mhotel/src/com/happy/common/util/CommonResult.java

@@ -0,0 +1,134 @@
+package com.happy.common.util;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @Author: codingliang
+ * @Description: 接口统一返回
+ * @Date: 20230731
+ * @Version: V1.0
+ **/
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CommonResult<T> extends BaseResult implements Serializable {
+
+
+    private Integer status;
+    // 调用是否成功
+    private Boolean success;
+    // 响应消息,可以为成功或者失败的消息
+    private String msg;
+
+    private T data;
+
+    private static final long serialVersionUID = 3616484754899974346L;
+
+
+    public static CommonResult ok() {
+        return ok(Integer.toString(ResponseStatusEnum.SUCCESS.getStatus()), ResponseStatusEnum.SUCCESS.getMsg());
+    }
+
+    public static <T> CommonResult<T> ok(T data) {
+        CommonResult<T> result = new CommonResult<T>(data);
+        return result;
+    }
+
+    public static <T> CommonResult<T> ok(String code, String msg) {
+        return baseCreate(code, msg, true);
+    }
+
+    public static CommonResult fail() {
+        return fail(Integer.toString(ResponseStatusEnum.FAILED.getStatus()), ResponseStatusEnum.FAILED.getMsg());
+    }
+
+    public static CommonResult fail(String code, String msg) {
+        return baseCreate(code, msg, false);
+    }
+
+    public static CommonResult fail(ResponseStatusEnum EnumCode){
+        return baseCreate(Integer.toString(EnumCode.getStatus()), EnumCode.getMsg(), false);
+    }
+
+    public CommonResult() {}
+
+    /**
+     * 用Code自定义返回信息
+     * 并把数据返回
+     */
+    public CommonResult(Code code, T data) {
+        this.status = code.getStatus();
+        this.msg = code.getMsg();
+        this.success = code.getSuccess();
+        this.data = data;
+    }
+
+    /**
+     * 成功的返回信息
+     */
+    public CommonResult(T data) {
+        this.setCode(Integer.toString(ResponseStatusEnum.SUCCESS.status()));
+        this.setMessage(ResponseStatusEnum.SUCCESS.msg());
+        this.setSuccess(ResponseStatusEnum.SUCCESS.success());
+        this.setData(data);
+    }
+
+
+
+    /**
+     * 自定义错误返回信息
+     * @param EnumCode 枚举错误信息
+     * @return
+     */
+    public CommonResult(ResponseStatusEnum EnumCode) {
+        this.setCode(Integer.toString(EnumCode.status()));
+        this.setMessage(EnumCode.msg());
+        this.setSuccess(EnumCode.success());
+    }
+
+
+    private static <T> CommonResult<T> baseCreate(String code, String msg, boolean success) {
+        CommonResult result = new CommonResult();
+        result.setCode(code);
+        result.setSuccess(success);
+        result.setMessage(msg);
+        return result;
+    }
+
+    public static CommonResult resultValue(ResponseStatusEnum responseStatus) {
+        return new CommonResult(responseStatus);
+    }
+
+    /**
+     * 错误返回,map中包含了多条错误信息,可以用于表单验证,把错误统一的全部返回出去
+     *
+     * @param map
+     * @return
+     */
+    public static CommonResult errorMap(Map map) {
+        return new CommonResult(ResponseStatusEnum.FAILED, map);
+    }
+
+    /**
+     * 错误返回,直接返回错误的消息
+     *
+     * @param msg 提示信息
+     * @return
+     */
+    public static CommonResult errorMsg(String msg) {
+        return new CommonResult(ResponseStatusEnum.FAILED, msg);
+    }
+
+    public CommonResult<T> setResult(T data) {
+        this.setData(data);
+        return this;
+    }
+
+    @Override
+    public T getData() {
+        return (T) super.getData();
+    }
+}

+ 78 - 0
mhotel/src/com/happy/common/util/ResponseStatusEnum.java

@@ -0,0 +1,78 @@
+package com.happy.common.util;
+
+/**
+ * 响应结果枚举,用于提供给GraceJSONResult返回给前端的
+ * 本枚举类中包含了很多的不同的状态码供使用,可以自定义
+ * 便于更优雅的对状态码进行管理,一目了然
+ */
+public enum ResponseStatusEnum implements Code{
+
+    EXISTS(999,false,"已存在"),
+    SUCCESS(200, true, "操作成功!"),
+    FAILED(500, false, "操作失败!"),
+    SEND_PARAMS(501,false,"传入参数数据结构错误"),
+    SEND_PARAMS_TYPE(502,false,"传入参数数据数据类型错误"),
+    UN_SERVICES_ERROR(505,false,"操作失败,请联系管理员"),
+
+    // 自定义系统级别异常 54x
+    SYSTEM_ERROR(540, false, "系统错误,错误未知!"),
+    SYSTEM_INDEX_OUT_OF_BOUNDS(541, false, "系统错误,数组越界!"),
+    SYSTEM_ARITHMETIC_BY_ZERO(542, false, "系统错误,无法除零!"),
+    SYSTEM_NULL_POINTER(543, false, "系统错误,空指针!"),
+    SYSTEM_NUMBER_FORMAT(544, false, "系统错误,数字转换异常!"),
+    SYSTEM_PARSE(545, false, "系统错误,解析异常!"),
+    SYSTEM_IO(546, false, "系统错误,IO输入输出异常!"),
+    SYSTEM_FILE_NOT_FOUND(547, false, "系统错误,文件未找到!"),
+    SYSTEM_CLASS_CAST(548, false, "系统错误,类型强制转换错误!"),
+    SYSTEM_PARSER_ERROR(549, false, "系统错误,解析出错!"),
+    SYSTEM_DATE_PARSER_ERROR(550, false, "系统错误,日期解析出错!"),
+    SYSTEM_ERROR_GLOBAL(551, false, "系统繁忙,请稍后再试!"),
+    SYSTEM_ERROR_ZUUL(552, false, "请求系统过于繁忙,请稍后再试!"),
+    SYSTEM_REQUEST_METHOD_ERROR(553, false, "请求类型错误"),
+    SYSTEM_MYSQL_TIMEOUT_ERROR(554, false, "Mysql连接超时"),
+    SYSTEM_MONGO_TIMEOUT_ERROR(555, false, "Mongo连接超时"),
+    SYSTEM_PHONE_ERROR(556,false,"手机号格式错误"),
+    SYSTEM_SEND_PHONE_ERROR(557,false,"发送验证码失败"),
+    SYSTEM_TOKEN_ERROR(558,false,"token为空"),
+    SYSTEM_LOGIN_ERROR(559,false,"无效token");
+
+    // 响应业务状态
+    private Integer status;
+    // 调用是否成功
+    private Boolean success;
+    // 响应消息,可以为成功或者失败的消息
+    private String msg;
+
+    ResponseStatusEnum(Integer status, Boolean success, String msg) {
+        this.status = status;
+        this.success = success;
+        this.msg = msg;
+    }
+
+    public Integer status() {
+        return status;
+    }
+    public Boolean success() {
+        return success;
+    }
+    public String msg() {
+        return msg;
+    }
+
+    @Override
+    public Integer getStatus() {
+        return status;
+    }
+
+    @Override
+    public Boolean getSuccess() {
+        return success;
+    }
+
+    @Override
+    public String getMsg() {
+        return msg;
+    }
+
+
+}

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

@@ -29,18 +29,18 @@ public class BookImplDao implements BookDao {
     public int insert(Booking booking){
         String sql = "insert into `booking`(order_num,status,dom,card_number,user_name,phone,h_type,price,create_time,live_time,pay_account,end_time) values(:order_num,:status,:dom,:card_number,:user_name,:phone,:h_type,:price,:create_time,:live_time,:pay_account,:end_time) ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("order_num", booking.getOrder_num());
-        sps.addValue("status", booking.getStatus());
-        sps.addValue("dom", booking.getDom());
-        sps.addValue("card_number", booking.getCard_number());
-        sps.addValue("user_name", booking.getUser_name());
-        sps.addValue("phone", booking.getPhone());
-        sps.addValue("h_type", booking.getH_type());
-        sps.addValue("price", booking.getPrice());
-        sps.addValue("create_time", booking.getCreate_time());
-        sps.addValue("live_time", booking.getLive_time());
-        sps.addValue("pay_account", booking.getPay_account());
-        sps.addValue("end_time", booking.getEnd_time());
+//        sps.addValue("order_num", booking.getOrder_num());
+//        sps.addValue("status", booking.getStatus());
+//        sps.addValue("dom", booking.getDom());
+//        sps.addValue("card_number", booking.getCard_number());
+//        sps.addValue("user_name", booking.getUser_name());
+//        sps.addValue("phone", booking.getPhone());
+//        sps.addValue("h_type", booking.getH_type());
+//        sps.addValue("price", booking.getPrice());
+//        sps.addValue("create_time", booking.getCreate_time());
+//        sps.addValue("live_time", booking.getLive_time());
+//        sps.addValue("pay_account", booking.getPay_account());
+//        sps.addValue("end_time", booking.getEnd_time());
         int num = 0;
         try{
             num = namedParameterJdbcTemplate.update(sql, sps);

+ 22 - 0
mhotel/src/com/happy/service/AppHomePageService.java

@@ -0,0 +1,22 @@
+package com.happy.service;
+
+import com.happy.Model.Booking;
+
+import java.util.List;
+
+/**
+ * 首页业务层
+ */
+public interface AppHomePageService {
+
+
+    /**
+     * APP端进入首页查询功能
+     * @param queryValue
+     * @param page
+     * @param rows
+     * @return
+     */
+    public List getHotelList(String queryValue,int page, int rows);
+
+}

+ 45 - 0
mhotel/src/com/happy/service/impl/AppHomePageImplService.java

@@ -0,0 +1,45 @@
+package com.happy.service.impl;
+
+import com.happy.Model.Booking;
+import com.happy.Model.House;
+import com.happy.Until.Func;
+import com.happy.Until.TimeExchange;
+import com.happy.dao.BookDao;
+import com.happy.dao.HouseDao;
+import com.happy.dto.IPage;
+import com.happy.service.AppHomePageService;
+import com.happy.service.BookService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("AppHomePageService")
+public class AppHomePageImplService implements AppHomePageService {
+
+    @Resource
+    public BookDao bookDao;
+    @Resource
+    public HouseDao houseDao;
+
+
+    @Override
+    public List getHotelList(String queryValue, int page, int rows) {
+
+//        IPage<House> iPage = new IPage();
+//        StringBuilder s1 = new StringBuilder("");
+//        if (!Func.checkNull(queryValue)){
+//            s1.append(" and hname like '%").append(queryValue).append("%' ");
+//        }
+//
+//        int total = hotel.queryHouseTotal(s1.toString()); // 查询表中的总记录数
+//        List<House> houseList = houseDao.queryPage(sqlx,page,rows);
+//        int total = houseDao.queryTotal(sqlx);
+//        iPage.setPageList(houseList);
+//        iPage.setPageCount( (int)Math.ceil((double)total/rows));
+//        iPage.setRows(rows);
+//        iPage.setTotal(total);
+//        return iPage;
+        return null;
+    }
+}