Browse Source

Accept Merge Request #1: (lj0831 -> master)
Merge Request: 接口新增

Created By: @李杰
Accepted By: @李杰
URL: https://chuanghaikeji.coding.net/p/jinganxiangsu/d/Homestay_app_houtai/git/merge/1?initial=true

李杰 2 years ago
parent
commit
67446b195e

+ 10 - 0
mhotel/src/com/happy/Model/Booking.java

@@ -59,6 +59,8 @@ public class Booking {
   private int status_del; // 是否假删除:0删除,1正常
   private int status_del; // 是否假删除:0删除,1正常
   private String liveTime;//入住时间
   private String liveTime;//入住时间
 
 
+  private List<HouseNumber> houseNumbers;//可分配房间号
+
   private String lockTime; // 锁定时间
   private String lockTime; // 锁定时间
 
 
   private Integer hstatus;//酒店营业状态(1 营业 2.休息)
   private Integer hstatus;//酒店营业状态(1 营业 2.休息)
@@ -502,6 +504,14 @@ public class Booking {
     this.status_del = status_del;
     this.status_del = status_del;
   }
   }
 
 
+  public List<HouseNumber> getHouseNumbers() {
+    return houseNumbers;
+  }
+
+  public void setHouseNumbers(List<HouseNumber> houseNumbers) {
+    this.houseNumbers = houseNumbers;
+  }
+
   public Integer getHstatus() {
   public Integer getHstatus() {
     return hstatus;
     return hstatus;
   }
   }

+ 66 - 37
mhotel/src/com/happy/Model/HotelCoupon.java

@@ -1,5 +1,7 @@
 package com.happy.Model;
 package com.happy.Model;
 
 
+import com.happy.Until.DateUtil;
+
 import java.util.Date;
 import java.util.Date;
 
 
 /**
 /**
@@ -10,7 +12,7 @@ import java.util.Date;
 public class HotelCoupon {
 public class HotelCoupon {
 
 
 
 
-    private Integer id; // 主键
+    private String id; // 主键
 
 
     private String hotelIds; // 适用民宿
     private String hotelIds; // 适用民宿
 
 
@@ -26,36 +28,42 @@ public class HotelCoupon {
 
 
     private Integer grantNumber; // 发放数量
     private Integer grantNumber; // 发放数量
 
 
-    private Date limitNumber; // 每人限领
+    private Integer limitNumber; // 每人限领
 
 
-    private Date grantStartDate; // 发放开始时间
+    private String grantStartDate; // 发放开始时间
 
 
-    private Date grantEndDate; // 发放结束时间
+    private String grantEndDate; // 发放结束时间
 
 
     private Double meetPrice; // 满减金额
     private Double meetPrice; // 满减金额
 
 
-    private Date effectiveStartDate; // 有效期开始时间
+    private String effectiveStartDate; // 有效期开始时间
+
+    private String effectiveEndDate; // 有效期结束时间
 
 
-    private Date effectiveEndDate; // 有效期结束时间
+    private Integer effectiveType;//有效期类型
 
 
     private Integer effectiveDay; // 生效时间天数
     private Integer effectiveDay; // 生效时间天数
 
 
-    private Integer loseEffectiveDay; // 失效时间天数
+    private Integer effectiveLoseDay; // 失效时间天数
 
 
     private Integer createId; // 创建人
     private Integer createId; // 创建人
 
 
-    private Date createDate; // 创建时间
+    private String createDate; // 创建时间
 
 
-    private Date modifyDate; // 修改时间
+    private String modifyDate; // 修改时间
 
 
     private Integer status; // 状态(0删除 1正常)
     private Integer status; // 状态(0删除 1正常)
 
 
+    private Integer remainderNumber; //剩余数量
+
+    private Integer reversedNumber; //已核销数量
 
 
-    public Integer getId() {
+
+    public String getId() {
         return id;
         return id;
     }
     }
 
 
-    public void setId(Integer id) {
+    public void setId(String id) {
         this.id = id;
         this.id = id;
     }
     }
 
 
@@ -123,29 +131,29 @@ public class HotelCoupon {
     }
     }
 
 
 
 
-    public Date getLimitNumber() {
+    public Integer getLimitNumber() {
         return limitNumber;
         return limitNumber;
     }
     }
 
 
-    public void setLimitNumber(Date limitNumber) {
+    public void setLimitNumber(Integer limitNumber) {
         this.limitNumber = limitNumber;
         this.limitNumber = limitNumber;
     }
     }
 
 
 
 
-    public Date getGrantStartDate() {
-        return grantStartDate;
+    public String getGrantStartDate() {
+        return DateUtil.convertDateTimeMysql(grantStartDate);
     }
     }
 
 
-    public void setGrantStartDate(Date grantStartDate) {
+    public void setGrantStartDate(String grantStartDate) {
         this.grantStartDate = grantStartDate;
         this.grantStartDate = grantStartDate;
     }
     }
 
 
 
 
-    public Date getGrantEndDate() {
-        return grantEndDate;
+    public String getGrantEndDate() {
+        return DateUtil.convertDateTimeMysql(grantEndDate);
     }
     }
 
 
-    public void setGrantEndDate(Date grantEndDate) {
+    public void setGrantEndDate(String grantEndDate) {
         this.grantEndDate = grantEndDate;
         this.grantEndDate = grantEndDate;
     }
     }
 
 
@@ -159,20 +167,28 @@ public class HotelCoupon {
     }
     }
 
 
 
 
-    public Date getEffectiveStartDate() {
-        return effectiveStartDate;
+    public Integer getEffectiveType() {
+        return effectiveType;
     }
     }
 
 
-    public void setEffectiveStartDate(Date effectiveStartDate) {
+    public void setEffectiveType(Integer effectiveType) {
+        this.effectiveType = effectiveType;
+    }
+
+    public String getEffectiveStartDate() {
+        return DateUtil.convertDateTimeMysql(effectiveStartDate);
+    }
+
+    public void setEffectiveStartDate(String effectiveStartDate) {
         this.effectiveStartDate = effectiveStartDate;
         this.effectiveStartDate = effectiveStartDate;
     }
     }
 
 
 
 
-    public Date getEffectiveEndDate() {
-        return effectiveEndDate;
+    public String getEffectiveEndDate() {
+        return DateUtil.convertDateTimeMysql(effectiveEndDate);
     }
     }
 
 
-    public void setEffectiveEndDate(Date effectiveEndDate) {
+    public void setEffectiveEndDate(String effectiveEndDate) {
         this.effectiveEndDate = effectiveEndDate;
         this.effectiveEndDate = effectiveEndDate;
     }
     }
 
 
@@ -185,16 +201,14 @@ public class HotelCoupon {
         this.effectiveDay = effectiveDay;
         this.effectiveDay = effectiveDay;
     }
     }
 
 
-
-    public Integer getLoseEffectiveDay() {
-        return loseEffectiveDay;
+    public Integer getEffectiveLoseDay() {
+        return effectiveLoseDay;
     }
     }
 
 
-    public void setLoseEffectiveDay(Integer loseEffectiveDay) {
-        this.loseEffectiveDay = loseEffectiveDay;
+    public void setEffectiveLoseDay(Integer effectiveLoseDay) {
+        this.effectiveLoseDay = effectiveLoseDay;
     }
     }
 
 
-
     public Integer getCreateId() {
     public Integer getCreateId() {
         return createId;
         return createId;
     }
     }
@@ -204,23 +218,38 @@ public class HotelCoupon {
     }
     }
 
 
 
 
-    public Date getCreateDate() {
-        return createDate;
+    public String getCreateDate() {
+        return DateUtil.convertDateTimeMysql(createDate);
     }
     }
 
 
-    public void setCreateDate(Date createDate) {
+    public void setCreateDate(String createDate) {
         this.createDate = createDate;
         this.createDate = createDate;
     }
     }
 
 
 
 
-    public Date getModifyDate() {
-        return modifyDate;
+    public String getModifyDate() {
+        return DateUtil.convertDateTimeMysql(modifyDate);
     }
     }
 
 
-    public void setModifyDate(Date modifyDate) {
+    public void setModifyDate(String modifyDate) {
         this.modifyDate = modifyDate;
         this.modifyDate = modifyDate;
     }
     }
 
 
+    public Integer getRemainderNumber() {
+        return remainderNumber;
+    }
+
+    public void setRemainderNumber(Integer remainderNumber) {
+        this.remainderNumber = remainderNumber;
+    }
+
+    public Integer getReversedNumber() {
+        return reversedNumber;
+    }
+
+    public void setReversedNumber(Integer reversedNumber) {
+        this.reversedNumber = reversedNumber;
+    }
 
 
     public Integer getStatus() {
     public Integer getStatus() {
         return status;
         return status;

+ 8 - 68
mhotel/src/com/happy/Model/HotelCouponStatus.java

@@ -1,5 +1,7 @@
 package com.happy.Model;
 package com.happy.Model;
 
 
+import lombok.Data;
+
 import java.util.Date;
 import java.util.Date;
 
 
 /**
 /**
@@ -7,11 +9,10 @@ import java.util.Date;
  * @Author  raojiaolong
  * @Author  raojiaolong
  * @Date 2023-08-21 
  * @Date 2023-08-21 
  */
  */
-
+@Data
 public class HotelCouponStatus {
 public class HotelCouponStatus {
 
 
-
-	private Integer id; // 主键
+	private String id; // 主键
 
 
 	private Integer complaintId; // 优惠卷id
 	private Integer complaintId; // 优惠卷id
 
 
@@ -19,73 +20,12 @@ public class HotelCouponStatus {
 
 
 	private Integer createId; // 创建人
 	private Integer createId; // 创建人
 
 
-	private Date createDate; // 创建时间
-
-	private Date modifyDate; // 修改时间
-
-	private Integer status; // 状态(0删除/失效 1正常2.已核销已使用)
-
-
-	public Integer getId() {
-		return id;
-	}
-
-	public void setId(Integer id) {
-		this.id = id;
-	}
-
-
-	public Integer getComplaintId() {
-		return complaintId;
-	}
-
-	public void setComplaintId(Integer complaintId) {
-		this.complaintId = complaintId;
-	}
-
+	private String createDate; // 创建时间
 
 
-	public Integer getProgressType() {
-		return progressType;
-	}
+	private String modifyDate; // 修改时间
 
 
-	public void setProgressType(Integer progressType) {
-		this.progressType = progressType;
-	}
+	private String lapseDate; // 失效时间
 
 
-
-	public Integer getCreateId() {
-		return createId;
-	}
-
-	public void setCreateId(Integer createId) {
-		this.createId = createId;
-	}
-
-
-	public Date getCreateDate() {
-		return createDate;
-	}
-
-	public void setCreateDate(Date createDate) {
-		this.createDate = createDate;
-	}
-
-
-	public Date getModifyDate() {
-		return modifyDate;
-	}
-
-	public void setModifyDate(Date modifyDate) {
-		this.modifyDate = modifyDate;
-	}
-
-
-	public Integer getStatus() {
-		return status;
-	}
-
-	public void setStatus(Integer status) {
-		this.status = status;
-	}
+	private Integer status; // 状态(0删除/失效 1正常2.已核销已使用)
 
 
 }
 }

+ 9 - 9
mhotel/src/com/happy/Model/HouseNumber.java

@@ -9,29 +9,29 @@ import java.util.Date;
 
 
 public class HouseNumber {
 public class HouseNumber {
 
 
-	private Integer id; // 主键
-	private Integer houseId; // 房型id
+	private String id; // 主键
+	private String houseId; // 房型id
 	private String numberName; // 房间号
 	private String numberName; // 房间号
-	private Integer createId; // 创建人
+	private String createId; // 创建人
 	private Date createDate; // 创建时间
 	private Date createDate; // 创建时间
 	private Date modifyDate; // 修改时间
 	private Date modifyDate; // 修改时间
 	private Integer status; // 状态(0.删除 1.正常)
 	private Integer status; // 状态(0.删除 1.正常)
 
 
 
 
-	public Integer getId() {
+	public String getId() {
 		return id;
 		return id;
 	}
 	}
 
 
-	public void setId(Integer id) {
+	public void setId(String id) {
 		this.id = id;
 		this.id = id;
 	}
 	}
 
 
 
 
-	public Integer getHouseId() {
+	public String getHouseId() {
 		return houseId;
 		return houseId;
 	}
 	}
 
 
-	public void setHouseId(Integer houseId) {
+	public void setHouseId(String houseId) {
 		this.houseId = houseId;
 		this.houseId = houseId;
 	}
 	}
 
 
@@ -45,11 +45,11 @@ public class HouseNumber {
 	}
 	}
 
 
 
 
-	public Integer getCreateId() {
+	public String getCreateId() {
 		return createId;
 		return createId;
 	}
 	}
 
 
-	public void setCreateId(Integer createId) {
+	public void setCreateId(String createId) {
 		this.createId = createId;
 		this.createId = createId;
 	}
 	}
 
 

+ 18 - 9
mhotel/src/com/happy/Model/HouseNumberStatus.java

@@ -9,31 +9,33 @@ import java.util.Date;
 
 
 public class HouseNumberStatus {
 public class HouseNumberStatus {
 
 
-	private Integer id; // 主键
-	private Integer numberId; // 房间号id
+	private String id; // 主键
+	private String numberId; // 房间号id
 	private Integer closeType; // 关房类型(1.停用房 2.维修房 3.保留房)
 	private Integer closeType; // 关房类型(1.停用房 2.维修房 3.保留房)
+
+	private String bookingId;//订单id
 	private String remark; // 备注
 	private String remark; // 备注
 	private String setDate; // 设置日期
 	private String setDate; // 设置日期
-	private Integer createId; // 创建人
+	private String createId; // 创建人
 	private Date createDate; // 创建时间
 	private Date createDate; // 创建时间
 	private Date modifyDate; // 修改时间
 	private Date modifyDate; // 修改时间
 	private Integer status; // 状态(0删除 1.正常 2.关房 3.脏房 4.净房)
 	private Integer status; // 状态(0删除 1.正常 2.关房 3.脏房 4.净房)
 
 
 
 
-	public Integer getId() {
+	public String getId() {
 		return id;
 		return id;
 	}
 	}
 
 
-	public void setId(Integer id) {
+	public void setId(String id) {
 		this.id = id;
 		this.id = id;
 	}
 	}
 
 
 
 
-	public Integer getNumberId() {
+	public String getNumberId() {
 		return numberId;
 		return numberId;
 	}
 	}
 
 
-	public void setNumberId(Integer numberId) {
+	public void setNumberId(String numberId) {
 		this.numberId = numberId;
 		this.numberId = numberId;
 	}
 	}
 
 
@@ -65,11 +67,11 @@ public class HouseNumberStatus {
 	}
 	}
 
 
 
 
-	public Integer getCreateId() {
+	public String getCreateId() {
 		return createId;
 		return createId;
 	}
 	}
 
 
-	public void setCreateId(Integer createId) {
+	public void setCreateId(String createId) {
 		this.createId = createId;
 		this.createId = createId;
 	}
 	}
 
 
@@ -100,4 +102,11 @@ public class HouseNumberStatus {
 		this.status = status;
 		this.status = status;
 	}
 	}
 
 
+	public String getBookingId() {
+		return bookingId;
+	}
+
+	public void setBookingId(String bookingId) {
+		this.bookingId = bookingId;
+	}
 }
 }

+ 59 - 11
mhotel/src/com/happy/action/bookAction.java

@@ -1,9 +1,7 @@
 package com.happy.action;
 package com.happy.action;
 
 
 import com.baidubce.model.User;
 import com.baidubce.model.User;
-import com.happy.Model.AdminManager;
-import com.happy.Model.Booking;
-import com.happy.Model.HotelDict;
+import com.happy.Model.*;
 import com.happy.Model.weixin.Users;
 import com.happy.Model.weixin.Users;
 import com.happy.Until.*;
 import com.happy.Until.*;
 import com.happy.Until.Enum.TempEnum;
 import com.happy.Until.Enum.TempEnum;
@@ -11,10 +9,7 @@ import com.happy.Until.Excel.toExcel;
 import com.happy.common.http.Message;
 import com.happy.common.http.Message;
 import com.happy.dto.BookTypeEto;
 import com.happy.dto.BookTypeEto;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
-import com.happy.service.AdminManagerService;
-import com.happy.service.BookService;
-import com.happy.service.HotelDictService;
-import com.happy.service.UserService;
+import com.happy.service.*;
 import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.ActionSupport;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.ServletActionContext;
@@ -23,10 +18,10 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 public class bookAction extends ActionSupport implements ServletRequestAware {
 public class bookAction extends ActionSupport implements ServletRequestAware {
@@ -43,6 +38,12 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
     @Resource
     @Resource
     public AdminManagerService adminManagerService;
     public AdminManagerService adminManagerService;
 
 
+    @Resource
+    public HouseNumberStatusService houseNumberStatusService;
+
+    @Resource
+    public HouseNumberService houseNumberService;
+
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
     public Integer id;
     public Integer id;
@@ -55,6 +56,7 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
     public String hotelTownship;//所属乡镇
     public String hotelTownship;//所属乡镇
     public String minTotalPrice;//最小订单总价
     public String minTotalPrice;//最小订单总价
     public String maxTotalPrice;//最大订单总价
     public String maxTotalPrice;//最大订单总价
+    public String houseNumberIds; // 房间号ids
 
 
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
@@ -119,6 +121,50 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
                     book.setUpdateTime(UUIDUtil.getNewDate());
                     book.setUpdateTime(UUIDUtil.getNewDate());
                     msg = "接单";
                     msg = "接单";
                     sendMsg = "商家已接单";
                     sendMsg = "商家已接单";
+                    //验证民宿房态表
+                    List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(book);
+                    List<String> Ids = Arrays.asList(houseNumberIds.split(","));
+                    if (houseNumbers!=null){
+                        for (String id: Ids){
+                            for (HouseNumber houseNumber: houseNumbers){
+                                if (houseNumber.getStatus() != null && houseNumber.getStatus()==3 && id.equals(houseNumber.getId())){
+                                    resultJson.put("message", "选择的房间该时间段已有预定!请重新选择房间!");
+                                    resultJson.put("code", 502);
+                                    ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                                    return null;
+                                }
+                            }
+                        }
+                    }
+                    //添加民宿房态表
+                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                    DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                    LocalDateTime str = LocalDateTime.parse(book.getOrderStartTime(), inputFormatter);
+                    LocalDateTime end = LocalDateTime.parse(book.getOrderEndTime(), inputFormatter);
+                    String a = str.format(formatter);
+                    String B = end.format(formatter);
+                    LocalDate strDate = LocalDate.parse(a, formatter);
+                    LocalDate endDate = LocalDate.parse(B, formatter);
+                    List<HouseNumberStatus> list = new ArrayList<>();
+                    for (String number : Ids){
+                        for (LocalDate date = strDate;!date.isAfter(endDate.minusDays(1));date = date.plusDays(1)){
+                            HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
+                            houseNumberStatus.setNumberId(number);
+                            houseNumberStatus.setRemark("");
+                            houseNumberStatus.setBookingId(String.valueOf(book.getId()));
+                            houseNumberStatus.setSetDate(date.format(formatter));
+                            houseNumberStatus.setStatus(5);//状态(0删除 1.正常 2.关房 3.脏房 4.净房 5.预定 6.入住)
+                            list.add(houseNumberStatus);
+                        }
+                    }
+
+                    int m = houseNumberStatusService.saveBatch(list);
+                    if (m == 0){
+                        resultJson.put("message", "确认失败");
+                        resultJson.put("code", 502);
+                        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                        return null;
+                    }
                     break;
                     break;
                 case 2://入住
                 case 2://入住
                     if(!"3".equals(book.getOrderStatus())){
                     if(!"3".equals(book.getOrderStatus())){
@@ -371,6 +417,8 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
             return null;
             return null;
         }
         }
         Booking book = bookService.getById(id);
         Booking book = bookService.getById(id);
+        List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(book);
+        book.setHouseNumbers(houseNumbers);
         if (book != null) {
         if (book != null) {
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);

+ 141 - 4
mhotel/src/com/happy/action/hotelCoupomAction.java

@@ -1,25 +1,44 @@
 package com.happy.action;
 package com.happy.action;
 
 
 import com.baidubce.services.media.model.Job;
 import com.baidubce.services.media.model.Job;
+import com.google.common.base.Joiner;
 import com.google.gson.Gson;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.google.gson.reflect.TypeToken;
+import com.happy.Model.Admin;
 import com.happy.Model.AdminManager;
 import com.happy.Model.AdminManager;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelDict;
 import com.happy.Model.HotelDict;
+import com.happy.Until.Func;
 import com.happy.Until.GetHttpParam;
 import com.happy.Until.GetHttpParam;
 import com.happy.Until.ResUtil;
 import com.happy.Until.ResUtil;
+import com.happy.Until.UUIDUtil;
 import com.happy.common.controller.BaseController;
 import com.happy.common.controller.BaseController;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
 import com.happy.service.HotelCoupomService;
 import com.happy.service.HotelCoupomService;
+import com.happy.service.HotelCoupomStatusService;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.interceptor.ServletRequestAware;
 import org.apache.struts2.interceptor.ServletRequestAware;
 
 
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+
 public class hotelCoupomAction extends BaseController implements ServletRequestAware {
 public class hotelCoupomAction extends BaseController implements ServletRequestAware {
 
 
+
+    public List<String> ids; //优惠卷id
+    public String name; //优惠卷名称
+    public String type; //类型
+    public String grantStartDate;//发放时间
+    public String grantEndDate;//发放时间
+
+    @Resource(name = "hotelCoupomService")
     private HotelCoupomService hotelCoupomService;
     private HotelCoupomService hotelCoupomService;
 
 
+    @Resource(name = "hotelCoupomStatusService")
+    private HotelCoupomStatusService hotelCoupomStatusService;
     /**
     /**
      * 描述:新增优惠卷
      * 描述:新增优惠卷
      * @return
      * @return
@@ -35,13 +54,26 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
         }
         }
         HotelCoupon hotelCoupon = null;
         HotelCoupon hotelCoupon = null;
         try{
         try{
-            hotelCoupon = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
+            hotelCoupon = gson.fromJson(json.toString(), new TypeToken<HotelCoupon>() {}.getType());
             if(hotelCoupon==null){
             if(hotelCoupon==null){
                 resultJson.put("message", "数据为空");
                 resultJson.put("message", "数据为空");
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            //格式化
+            hotelCoupon.setRemainderNumber(hotelCoupon.getGrantNumber());
+            hotelCoupon.setReversedNumber(0);
+            int m = hotelCoupomService.insert(hotelCoupon);
+            if (m > 0) {
+                resultJson.put("message", "添加成功");
+                resultJson.put("code", 200);
+            } else {
+                resultJson.put("message", "添加失败");
+                resultJson.put("code", 502);
+            }
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
             resultJson.put("message", "未知异常:"+ e);
             resultJson.put("message", "未知异常:"+ e);
@@ -69,7 +101,28 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
         }
         }
         HotelCoupon hotelCoupon = null;
         HotelCoupon hotelCoupon = null;
         try{
         try{
-            hotelCoupon = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
+            hotelCoupon = gson.fromJson(json.toString(), new TypeToken<HotelCoupon>() {}.getType());
+            if (hotelCoupon.getId()==null || "".equals(hotelCoupon.getId())){
+                resultJson.put("message", "请传入优惠卷id");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            HotelCoupon h1 = hotelCoupomService.getById(hotelCoupon.getId());
+            if (h1==null){
+                resultJson.put("message", "修改失败,未查询到优惠卷");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            int m = hotelCoupomService.update(hotelCoupon);
+            if (m > 0) {
+                resultJson.put("message", "修改成功");
+                resultJson.put("code", 200);
+            } else {
+                resultJson.put("message", "修改失败");
+                resultJson.put("code", 502);
+            }
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
             resultJson.put("message", "未知异常:"+ e);
             resultJson.put("message", "未知异常:"+ e);
@@ -89,7 +142,27 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
     public String queryPage(){
     public String queryPage(){
         JSONObject resultJson = new JSONObject();
         JSONObject resultJson = new JSONObject();
         StringBuilder s1 = new StringBuilder("");
         StringBuilder s1 = new StringBuilder("");
-        IPage<HotelCoupon> adminIPage = hotelCoupomService.queryPage(s1.toString(),page,rows);
+        if (name != null){
+            s1.append(" and name like '%").append(name).append("%' ");
+        }
+        if (status != null){
+            s1.append(" and status = ").append(status).append(" ");
+        }
+        if (grantStartDate != null && grantEndDate != null){
+            s1.append(" and DATE_FORMAT(grant_start_date,'%Y-%m-%d') >= '").append(grantStartDate).append("' ");
+            s1.append(" and DATE_FORMAT(grant_end_date,'%Y-%m-%d') <= '").append(grantEndDate).append("' ");
+        }
+        IPage<HotelCoupon> hotelCouponIPage = hotelCoupomService.queryPage(s1.toString(),page,rows);
+        if(hotelCouponIPage!=null && !"".equals(hotelCouponIPage)){
+            resultJson.put("message", "查询分页成功");
+            resultJson.put("code", 200);
+            resultJson.put("data", hotelCouponIPage);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }else{
+            resultJson.put("message", "查询分页失败");
+            resultJson.put("code", 500);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }
         return null;
         return null;
     }
     }
 
 
@@ -99,13 +172,63 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
      */
      */
     public String getById(){
     public String getById(){
         JSONObject resultJson = new JSONObject();
         JSONObject resultJson = new JSONObject();
-        if (id==null && id == 0) {
+        if (id==null || "".equals(id)) {
             resultJson.put("message", "请传入id");
             resultJson.put("message", "请传入id");
             resultJson.put("code", 500);
             resultJson.put("code", 500);
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
             return null;
         }
         }
         HotelCoupon hotelCoupon = hotelCoupomService.getById(id);
         HotelCoupon hotelCoupon = hotelCoupomService.getById(id);
+        if (hotelCoupon != null) {
+            resultJson.put("message", "查询成功");
+            resultJson.put("code", 200);
+            resultJson.put("data", hotelCoupon);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }else{
+            resultJson.put("message", "未查询到优惠卷信息");
+            resultJson.put("code", 500);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+    }
+
+    /**
+     * 描述:优惠卷批量失效
+     */
+    public String saveBatchLapse(){
+        JSONObject resultJson = new JSONObject();
+        Gson gson = new Gson();
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
+        if (json == null) {
+            resultJson.put("message", "请传入参数");
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        HotelCoupon hotelCoupon = null;
+        try {
+            hotelCoupon = gson.fromJson(json.toString(), new TypeToken<HotelCoupon>() {}.getType());
+            if (ids == null){
+                resultJson.put("message", "请传入优惠卷id");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            int m = hotelCoupomService.updateLapse(ids);
+            //TODO 修改用户领取的优惠卷
+            int n = hotelCoupomStatusService.updateLapse(ids);
+            resultJson.put("message", "修改成功");
+            resultJson.put("code", 200);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }catch (Exception e){
+            e.printStackTrace();
+            resultJson.put("message", "未知异常:"+ e);
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }
+        resultJson.put("message", "未知异常");
+        resultJson.put("code", 205);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
         return null;
     }
     }
 
 
@@ -113,6 +236,20 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
      * 描述:定时任务修改优惠卷状态
      * 描述:定时任务修改优惠卷状态
      */
      */
     public void setCoupomStatus(){
     public void setCoupomStatus(){
+        JSONObject resultJson = new JSONObject();
+        try {
+            int n =  hotelCoupomService.updateExpire();
+            int m =   hotelCoupomStatusService.updateExpir();
+            resultJson.put("message", "修改成功");
+            resultJson.put("code", 200);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+
+        }catch (Exception e){
+            e.printStackTrace();
+            resultJson.put("message", "未知异常:"+ e);
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        }
         System.out.println(1111);
         System.out.println(1111);
     }
     }
 
 

+ 42 - 5
mhotel/src/com/happy/action/houseAction.java

@@ -7,10 +7,7 @@ import com.happy.Model.*;
 import com.happy.Until.*;
 import com.happy.Until.*;
 import com.happy.dto.HouseSumEto;
 import com.happy.dto.HouseSumEto;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
-import com.happy.service.BookService;
-import com.happy.service.FileService;
-import com.happy.service.HotelDictService;
-import com.happy.service.HouseService;
+import com.happy.service.*;
 import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.ActionSupport;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.ServletActionContext;
@@ -19,6 +16,8 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
 
 
@@ -35,6 +34,8 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
     public FileService fileService;
     public FileService fileService;
     @Resource
     @Resource
     public HotelDictService hotelDictService;
     public HotelDictService hotelDictService;
+    @Resource
+    public HouseNumberService houseNumberService;
 
 
     public Integer id;
     public Integer id;
     public Integer managerId;
     public Integer managerId;
@@ -44,6 +45,7 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
     public String orderTime;//住房时间
     public String orderTime;//住房时间
 
 
     public String fileListJson;
     public String fileListJson;
+    public String houseNumber; // 房间号
 
 
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
@@ -100,6 +102,8 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
 //                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //                return null;
 //                return null;
 //            }
 //            }
+//            List<String> numberList = JSONArray.parseArray(houseNumberList, String.class);
+
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'")
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'")
                     .append(" and manager_id = '").append(house.getManagerId()).append("'");
                     .append(" and manager_id = '").append(house.getManagerId()).append("'");
@@ -110,7 +114,27 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            house.setId(Math.toIntExact(UUIDUtil.generateID()));
+            //房型验证成功添加房号
+            Long id = UUIDUtil.generateID();
+            List<String> houseNumberList = Arrays.asList(houseNumber.split(","));
+            List<HouseNumber> houseNumbers = new ArrayList<HouseNumber>();
+            long count = houseNumberList.stream().distinct().count();
+            if (count != houseNumberList.size()){
+                resultJson.put("message", "房号不可重复");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            for (String s : houseNumberList){
+                HouseNumber h1 = new HouseNumber();
+                h1.setHouseId(Long.toString(id));
+                h1.setNumberName(s);
+                h1.setStatus(1);
+                houseNumbers.add(h1);
+            }
+            //执行批量房间号表操作
+            int a = houseNumberService.saveBatch(houseNumbers);
+            house.setId(Math.toIntExact(id));
             int m = houseService.insertHouse(house);
             int m = houseService.insertHouse(house);
             if (m > 0) {
             if (m > 0) {
                 for(FileInfo file : fileList){
                 for(FileInfo file : fileList){
@@ -182,6 +206,8 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
 //                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //                return null;
 //                return null;
 //            }
 //            }
+//            List<String> numberList = JSONArray.parseArray(houseNumberList, String.class);
+
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and manager_id = '").append(house.getManagerId()).append("'");
             getOneSqlx.append(" and manager_id = '").append(house.getManagerId()).append("'");
@@ -193,6 +219,17 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            //验证成功修改房号表
+            List<String> houseNumberList = Arrays.asList(houseNumber.split(","));
+            List<HouseNumber> houseNumbers = new ArrayList<HouseNumber>();
+            for (String s : houseNumberList){
+                HouseNumber h1 = new HouseNumber();
+                h1.setHouseId(Long.toString(house.getId()));
+                h1.setNumberName(s);
+                h1.setStatus(1);
+                houseNumbers.add(h1);
+            }
+            int a = houseNumberService.updateBatch(houseNumbers);
             int m = houseService.updateHouse(house);
             int m = houseService.updateHouse(house);
             if (m > 0) {
             if (m > 0) {
                 if(house.getId()!= null){
                 if(house.getId()!= null){

+ 5 - 1
mhotel/src/com/happy/dao/HotelCouponDao.java

@@ -32,7 +32,7 @@ public interface HotelCouponDao {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
-    HotelCoupon getById(Integer id);
+    HotelCoupon getById(String id);
 
 
     /**
     /**
      * 描述:分页查询
      * 描述:分页查询
@@ -57,4 +57,8 @@ public interface HotelCouponDao {
      */
      */
     List<HotelCoupon> queryList(String sqlx);
     List<HotelCoupon> queryList(String sqlx);
 
 
+    int updateExpire();
+
+    int updateLapse(List<String> coupomIds);
+
 }
 }

File diff suppressed because it is too large
+ 77 - 8
mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java


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

@@ -82,7 +82,7 @@ public class HouseImplDao implements HouseDao {
 
 
     @Override
     @Override
     public int delHouse(int id) {
     public int delHouse(int id) {
-        String sql = "update `house` set status=0 where id=:id";
+        String sql = "update `house` set status = 0 where id=:id";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("id",id);
         sps.addValue("id",id);
         int num = 0;
         int num = 0;

+ 4 - 1
mhotel/src/com/happy/service/HotelCoupomService.java

@@ -33,7 +33,7 @@ public interface HotelCoupomService {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
-    HotelCoupon getById(Integer id);
+    HotelCoupon getById(String id);
 
 
     /**
     /**
      * 描述:分页查询
      * 描述:分页查询
@@ -51,4 +51,7 @@ public interface HotelCoupomService {
      */
      */
     List<HotelCoupon> queryList(String sqlx);
     List<HotelCoupon> queryList(String sqlx);
 
 
+    int updateExpire();
+
+    int updateLapse(List<String> coupomIds);
 }
 }

+ 15 - 2
mhotel/src/com/happy/service/impl/HotelCoupomImplService.java

@@ -2,13 +2,16 @@ package com.happy.service.impl;
 
 
 import com.happy.Model.AdminManager;
 import com.happy.Model.AdminManager;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
+import com.happy.Until.DateUtil;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
 import com.happy.service.HotelCoupomService;
 import com.happy.service.HotelCoupomService;
+import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
-
+@Service("hotelCoupomService")
 public class HotelCoupomImplService implements HotelCoupomService {
 public class HotelCoupomImplService implements HotelCoupomService {
 
 
     @Resource
     @Resource
@@ -30,7 +33,7 @@ public class HotelCoupomImplService implements HotelCoupomService {
     }
     }
 
 
     @Override
     @Override
-    public HotelCoupon getById(Integer id) {
+    public HotelCoupon getById(String id) {
         return hotelCouponDao.getById(id);
         return hotelCouponDao.getById(id);
     }
     }
 
 
@@ -51,4 +54,14 @@ public class HotelCoupomImplService implements HotelCoupomService {
     public List<HotelCoupon> queryList(String sqlx) {
     public List<HotelCoupon> queryList(String sqlx) {
         return hotelCouponDao.queryList(sqlx);
         return hotelCouponDao.queryList(sqlx);
     }
     }
+
+    @Override
+    public  int updateExpire() {
+        return hotelCouponDao.updateExpire();
+    }
+
+    @Override
+    public int updateLapse(List<String> coupomIds) {
+        return hotelCouponDao.updateLapse(coupomIds);
+    }
 }
 }

+ 2 - 0
mhotel/src/struts.xml

@@ -29,6 +29,8 @@
 		</action>
 		</action>
 		<action name="hotel*" method = "{1}" class="com.happy.action.hotelAction">
 		<action name="hotel*" method = "{1}" class="com.happy.action.hotelAction">
 		</action>
 		</action>
+		<action name="Coupom*" method = "{1}" class="com.happy.action.hotelCoupomAction">
+		</action>
 		<action name="house*" method = "{1}" class="com.happy.action.houseAction">
 		<action name="house*" method = "{1}" class="com.happy.action.houseAction">
 		</action>
 		</action>
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">