Pārlūkot izejas kodu

我的卡卷,领券中心,指定名宿,领券优惠券,可用优惠券,使用优惠券。锁定优惠券

liu 2 gadi atpakaļ
vecāks
revīzija
d3158a466a
28 mainītis faili ar 1439 papildinājumiem un 10 dzēšanām
  1. 1 1
      mhotel/src/com/happy/Model/Hotel.java
  2. 2 2
      mhotel/src/com/happy/Model/HotelCouponStatus.java
  3. 92 0
      mhotel/src/com/happy/Until/Enum/ProgressEnum.java
  4. 11 1
      mhotel/src/com/happy/action/AppBookingAction.java
  5. 3 4
      mhotel/src/com/happy/action/AppHomePageAction.java
  6. 516 0
      mhotel/src/com/happy/action/AppHotelCouponAction.java
  7. 8 0
      mhotel/src/com/happy/dao/HotelCoupomStatusDao.java
  8. 20 0
      mhotel/src/com/happy/dao/HotelCouponDao.java
  9. 73 0
      mhotel/src/com/happy/dao/impl/HotelCoupomStatusImplDao.java
  10. 206 0
      mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java
  11. 11 0
      mhotel/src/com/happy/dto/CancelUseCouponsDto.java
  12. 26 0
      mhotel/src/com/happy/dto/OrderComplaintDto.java
  13. 9 0
      mhotel/src/com/happy/dto/UpdateHotelCouponDto.java
  14. 10 0
      mhotel/src/com/happy/dto/UseCouponsDto.java
  15. 1 1
      mhotel/src/com/happy/service/AppBookService.java
  16. 41 0
      mhotel/src/com/happy/service/HotelCoupomService.java
  17. 13 0
      mhotel/src/com/happy/service/HotelCoupomStatusService.java
  18. 51 1
      mhotel/src/com/happy/service/impl/AppBookImplService.java
  19. 162 0
      mhotel/src/com/happy/service/impl/HotelCoupomImplService.java
  20. 16 0
      mhotel/src/com/happy/service/impl/HotelCoupomStatusImplService.java
  21. 28 0
      mhotel/src/com/happy/vo/CardCouponPageVo.java
  22. 33 0
      mhotel/src/com/happy/vo/CouponCollectionVo.java
  23. 8 0
      mhotel/src/com/happy/vo/DesignatedHotelVo.java
  24. 20 0
      mhotel/src/com/happy/vo/DetailsVo.java
  25. 25 0
      mhotel/src/com/happy/vo/ProgressDetailsVo.java
  26. 13 0
      mhotel/src/com/happy/vo/QuotaVo.java
  27. 13 0
      mhotel/src/com/happy/vo/UseCouponsVo.java
  28. 27 0
      mhotel/src/com/happy/vo/UsefulCouponVo.java

+ 1 - 1
mhotel/src/com/happy/Model/Hotel.java

@@ -363,7 +363,7 @@ public class Hotel {
 		this.status = status;
 		this.status = status;
 	}
 	}
 
 
-	public List getHouseList() {
+	public List<House> getHouseList() {
 		return houseList;
 		return houseList;
 	}
 	}
 
 

+ 2 - 2
mhotel/src/com/happy/Model/HotelCouponStatus.java

@@ -14,9 +14,9 @@ public class HotelCouponStatus {
 
 
 	private String id; // 主键
 	private String id; // 主键
 
 
-	private Integer complaintId; // 优惠卷id
+	private String complaintId; // 优惠卷id
 
 
-	private Integer progressType; // 用户id
+	private String userId; // 用户id
 
 
 	private Integer createId; // 创建人
 	private Integer createId; // 创建人
 
 

+ 92 - 0
mhotel/src/com/happy/Until/Enum/ProgressEnum.java

@@ -0,0 +1,92 @@
+package com.happy.Until.Enum;
+
+import com.happy.Until.Func;
+
+import static com.happy.Until.Enum.PayEnum.状态异常;
+
+public enum ProgressEnum {
+
+    待处理(1,"待处理"),处理中(2,"处理中"),已处理(3,"已处理");
+    private int num;
+    private String progressType;
+
+    ProgressEnum(int num, String progressType) {
+
+        this.num = num;
+        this.progressType = progressType;
+    }
+
+    /**
+     * 遍历枚举类
+     * @param num
+     * @return
+     */
+    public static String getKeyBykey(int num) {
+        try {
+            for (ProgressEnum type : ProgressEnum.values()) {
+                if (Func.parseInt(type.getNum()) == num) {
+                    return Func.parseStr(type.getNum());
+                }
+            }
+        } catch (Exception e) {
+            return Func.parseStr(状态异常.getNum());
+        }
+        return Func.parseStr(状态异常.getNum());
+    }
+
+    /**
+     * 遍历枚举类
+     * @param num
+     * @return
+     */
+    public static String getValueBykey(int num) {
+        try {
+            for (ProgressEnum type : ProgressEnum.values()) {
+                if (Func.parseInt(type.getNum()) == num) {
+                    return type.getProgressType();
+                }
+            }
+        } catch (Exception e) {
+            return 状态异常.getPayStatus();
+        }
+        return 状态异常.getPayStatus();
+    }
+
+    /**
+     * 遍历枚举类
+     * @param value
+     * @return
+     */
+    public static int getKeyByValue(String value) {
+        try {
+            if (Func.checkNull(value))
+                return 状态异常.getNum();
+
+            for (PayEnum type : PayEnum.values()) {
+                if (value.equals(Func.parseStr(type.getPayStatus()))) {
+                    return type.getNum();
+                }
+            }
+        } catch (Exception e) {
+            return 状态异常.getNum();
+        }
+        return 状态异常.getNum();
+    }
+
+
+    public int getNum() {
+        return num;
+    }
+
+    public void setNum(int num) {
+        this.num = num;
+    }
+
+    public String getProgressType() {
+        return progressType;
+    }
+
+    public void setProgressType(String progressType) {
+        this.progressType = progressType;
+    }
+}

+ 11 - 1
mhotel/src/com/happy/action/AppBookingAction.java

@@ -128,6 +128,16 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
         this.status = status;
         this.status = status;
     }
     }
 
 
+    public String complaintId;
+
+    public String getComplaintId() {
+        return complaintId;
+    }
+
+    public void setComplaintId(String complaintId) {
+        this.complaintId = complaintId;
+    }
+
     /**
     /**
      * 定时任务
      * 定时任务
      * @return
      * @return
@@ -253,7 +263,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
         }
         }
 
 
         String  bookingId= Func.parseStr(UUIDUtil.generateID());
         String  bookingId= Func.parseStr(UUIDUtil.generateID());
-        String mess = appBookService.createOrder(bookingId, houseId, startDate, endDate, houseOrderNumber, userName, userPhone, userId);
+        String mess = appBookService.createOrder(bookingId, houseId, startDate, endDate, houseOrderNumber, userName, userPhone, userId,complaintId);
         if (!Func.checkNull(mess)) {
         if (!Func.checkNull(mess)) {
             jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             jsonObject.put(B.message, mess);
             jsonObject.put(B.message, mess);

+ 3 - 4
mhotel/src/com/happy/action/AppHomePageAction.java

@@ -184,8 +184,7 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
      * 通过酒店的id获取到房间信息
      * 通过酒店的id获取到房间信息
      * @return
      * @return
      */
      */
-    public String getHouseByHotelId()
-    {
+    public String getHouseByHotelId() throws ParseException {
         JSONObject jsonObject = new JSONObject();
         JSONObject jsonObject = new JSONObject();
         // 如果未赋值,则直接跳出
         // 如果未赋值,则直接跳出
         if (Func.checkNull(hotelId) || Func.checkNull(queryStartTime) || Func.checkNull(queryEndTime))
         if (Func.checkNull(hotelId) || Func.checkNull(queryStartTime) || Func.checkNull(queryEndTime))
@@ -242,8 +241,8 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
             String date = TimeExchange.TimeDesD(queryStartTime, i);
             String date = TimeExchange.TimeDesD(queryStartTime, i);
             dateStrs.add(date);
             dateStrs.add(date);
         }
         }
-
-        for (House houseData : hotel.getHouseList()) {
+        List<House> houseList = hotel.getHouseList();
+        for (House houseData : houseList) {
             for (String dateStr:dateStrs){
             for (String dateStr:dateStrs){
                 Optional<HousePriceOneDataVo> oneData = oneDatas.stream().filter(e -> e.getHouseId().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate,Comparator.reverseOrder())).findFirst();
                 Optional<HousePriceOneDataVo> oneData = oneDatas.stream().filter(e -> e.getHouseId().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate,Comparator.reverseOrder())).findFirst();
                 if(oneData != null && oneData.isPresent()){
                 if(oneData != null && oneData.isPresent()){

+ 516 - 0
mhotel/src/com/happy/action/AppHotelCouponAction.java

@@ -0,0 +1,516 @@
+package com.happy.action;
+
+import com.happy.Model.Booking;
+import com.happy.Model.HotelCoupon;
+import com.happy.Model.HotelCouponStatus;
+import com.happy.Until.DateUtil;
+import com.happy.Until.Func;
+import com.happy.Until.GetHttpParam;
+import com.happy.Until.ResUtil;
+import com.happy.dto.*;
+import com.happy.service.*;
+import com.happy.vo.*;
+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.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+public class AppHotelCouponAction extends ActionSupport implements ServletRequestAware {
+    public HttpServletRequest request;
+
+    public HttpServletResponse response;
+
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    @Override
+    public void setServletRequest(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+
+    public void setResponse(HttpServletResponse response) {
+        this.response = response;
+    }
+
+    @Resource
+    HotelCoupomService hotelCoupomService;
+
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public String types; //状态,1,2显示全部,1带金券,2折扣券
+
+    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 String getTypes() {
+        return types;
+    }
+
+    public void setTypes(String types) {
+        this.types = types;
+    }
+
+    public String hotelIds;
+
+    public String getHotelIds() {
+        return hotelIds;
+    }
+
+    public void setHotelIds(String hotelIds) {
+        this.hotelIds = hotelIds;
+    }
+
+    public String userId;
+
+    public int type;
+
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    private String hotelId;
+
+    public String getHotelId() {
+        return hotelId;
+    }
+
+    public void setHotelId(String hotelId) {
+        this.hotelId = hotelId;
+    }
+
+    private String complaintId;
+    private String bookingId;
+
+    public String getComplaintId() {
+        return complaintId;
+    }
+
+    public void setComplaintId(String complaintId) {
+        this.complaintId = complaintId;
+    }
+
+    public String getBookingId() {
+        return bookingId;
+    }
+
+    public void setBookingId(String bookingId) {
+        this.bookingId = bookingId;
+    }
+
+    @Resource
+    BookService bookService;
+
+    @Resource
+    HotelCoupomStatusService hotelCoupomStatusService;
+
+    /**
+     * 我的卡券
+     *
+     * @return
+     */
+    public JSONObject cardCouponPage() {
+        JSONObject jsonObject = new JSONObject();
+
+        if (Func.checkNull(types) || Func.checkNull(userId)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入usersId数据---complaintPage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        if (page <= 0 || rows <= 0) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入page,rows数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        IPage<CardCouponPageVo> iPage = hotelCoupomService.cardCouponPage(types, userId, page, rows);
+
+        jsonObject.put("code", 200);
+        jsonObject.put("success", true);
+        jsonObject.put("message", "成功");
+        jsonObject.put("page", iPage);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+    }
+
+    /**
+     * 领券中心
+     *
+     * @return
+     */
+    public JSONObject couponCollection() {
+        JSONObject jsonObject = new JSONObject();
+        if (page <= 0 || rows <= 0) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入page,rows数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+        String date = DateUtil.getFormatPaternDate(new Date());
+        IPage<CouponCollectionVo> iPage = hotelCoupomService.couponCollection(date, page, rows);
+        jsonObject.put("code", 200);
+        jsonObject.put("success", true);
+        jsonObject.put("message", "成功");
+        jsonObject.put("page", iPage);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+
+    }
+
+    /**
+     * 指定名宿
+     *
+     * @return
+     */
+    public JSONObject designatedHotel() {
+        JSONObject jsonObject = new JSONObject();
+        if (Func.checkNull(hotelIds)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入hotelIds数据---designatedHotel");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+//根据id找对应的名字
+        DesignatedHotelVo vo = hotelCoupomService.designatedHotel(hotelIds);
+        jsonObject.put("code", 200);
+        jsonObject.put("success", true);
+        jsonObject.put("message", "成功");
+        jsonObject.put("data", vo);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+    }
+
+
+    /**
+     * 领券
+     *
+     * @return
+     */
+    public JSONObject getCoupon() {
+        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
+
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
+        if (json == null) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---getCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        HotelCouponStatus hotelCouponStatus = com.alibaba.fastjson.JSONObject.parseObject(json.toString(), HotelCouponStatus.class);
+        String complaintId = hotelCouponStatus.getComplaintId();
+        if (hotelCouponStatus == null || Func.checkNull(complaintId)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---getCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+//        通过优惠券id判断领券的张数是否大于等于每人限领次数,并且剩余张数不能为0
+        Boolean quota = hotelCoupomService.quota(complaintId);
+        if (!quota) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "此券领取次数已达上限");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+//        领取优惠券
+        int num = hotelCoupomService.coupon(hotelCouponStatus);
+        if (num > 0) {
+            jsonObject.put("code", 200);
+            jsonObject.put("message", "领取成功");
+            jsonObject.put("success", true);
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+        jsonObject.put("message", "未知异常");
+        jsonObject.put("success", false);
+        jsonObject.put("code", 205);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+    }
+
+
+    /**
+     * 可用优惠券
+     *
+     * @return
+     */
+    public JSONObject usefulCoupon() {
+        JSONObject jsonObject = new JSONObject();
+
+        if (Func.checkNull(hotelId) && Func.checkNull(userId)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据hotelId或userId---usefulCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        if (page <= 0 || rows <= 0) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入page,rows数据---usefulCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        IPage<UsefulCouponVo> iPage = hotelCoupomService.usefulCoupon(hotelId, userId, page, rows);
+
+        jsonObject.put("code", 200);
+        jsonObject.put("success", true);
+        jsonObject.put("message", "成功");
+        jsonObject.put("page", iPage);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+
+
+    }
+
+
+    /**
+     * 使用优惠券
+     *
+     * @return
+     */
+    public JSONObject useCoupons() {
+        JSONObject jsonObject = new JSONObject();
+
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
+        if (json == null) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---getCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        UseCouponsDto dto = com.alibaba.fastjson.JSONObject.parseObject(json.toString(), UseCouponsDto.class);
+
+        if (dto == null) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---useCoupons");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        String id = dto.getId();
+        Double totalPrice = dto.getTotalPrice();
+        String complaintId = dto.getComplaintId();
+
+        if (Func.checkNull(complaintId) && totalPrice <= 0 && totalPrice == null && Func.checkNull(id)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据id,complaintId,bookingId---useCoupons");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        UseCouponsVo useCouponsVo = new UseCouponsVo();
+        useCouponsVo.setComplaintId(complaintId);
+        useCouponsVo.setId(id);
+//        优惠券
+        HotelCoupon hotelCoupon = hotelCoupomService.getById(complaintId);
+
+//        优惠券状态,1.优惠卷,需看是否满足满减 2.折扣卷,需判断是否大于最大减免金额
+        Integer type1 = hotelCoupon.getType();
+//          订单金额
+        BigDecimal houseTotalPriceBigDecimal = new BigDecimal(totalPrice);
+
+        useCouponsVo.setCapitalSum(totalPrice);
+        if (1 == type1) {
+//            满减金额
+            Double meetPrice = hotelCoupon.getMeetPrice();
+            BigDecimal meetPriceBigDecimal = new BigDecimal(meetPrice);
+
+            if (meetPrice > totalPrice) {
+                BigDecimal subtract = meetPriceBigDecimal.subtract(houseTotalPriceBigDecimal);
+                double v = subtract.doubleValue();
+                jsonObject.put("code", 400);
+                jsonObject.put("success", false);
+                jsonObject.put("message", "还差" + v + "元可使用");
+                ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+                return null;
+            }
+//            减免金额
+            Double deductionPrice = hotelCoupon.getDeductionPrice();
+            BigDecimal deductionPriceBigDecimal = new BigDecimal(deductionPrice);
+
+//            实付金额
+            BigDecimal subtract = houseTotalPriceBigDecimal.subtract(deductionPriceBigDecimal);
+
+
+            useCouponsVo.setTypeName("优惠卷");
+            useCouponsVo.setHotelCouponName(hotelCoupon.getName());
+            useCouponsVo.setDiscountAmount(deductionPrice);
+
+        } else if (2 == type1) {
+//            享受的折扣
+            Double rebatePrice = hotelCoupon.getRebatePrice();
+            BigDecimal rebatePriceBigDecimal = new BigDecimal(rebatePrice/10);
+
+//            最大减免金额
+            Double maxDeduction = hotelCoupon.getMaxDeduction();
+            BigDecimal maxDeductionBigDecimal = new BigDecimal(maxDeduction);
+
+//            折扣后的价格
+            BigDecimal bigDecimal = houseTotalPriceBigDecimal.multiply(rebatePriceBigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
+            double v = bigDecimal.doubleValue();
+
+//            减去最大折扣后的价格
+            BigDecimal subtract = houseTotalPriceBigDecimal.subtract(maxDeductionBigDecimal);
+            double v1 = subtract.doubleValue();
+
+            if (v > v1) {
+                BigDecimal subtract1 = houseTotalPriceBigDecimal.subtract(bigDecimal);
+                useCouponsVo.setDiscountAmount(subtract1.doubleValue());
+            } else if (v < v1) {
+                useCouponsVo.setDiscountAmount(maxDeduction);
+            }
+
+            useCouponsVo.setTypeName("优惠卷");
+            useCouponsVo.setHotelCouponName(hotelCoupon.getName());
+
+
+        } else {
+            jsonObject.put("message", "未知异常");
+            jsonObject.put("success", false);
+            jsonObject.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        jsonObject.put("code", 200);
+        jsonObject.put("success", true);
+        jsonObject.put("message", "成功");
+        jsonObject.put("data", useCouponsVo);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+
+
+        return null;
+    }
+
+    /**
+     * 锁定优惠券
+     *
+     * @return
+     */
+    public JSONObject lockCoupon() {
+        JSONObject jsonObject = new JSONObject();
+
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
+        if (json == null) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---getCoupon");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        CancelUseCouponsDto dto = com.alibaba.fastjson.JSONObject.parseObject(json.toString(), CancelUseCouponsDto.class);
+
+        if (dto == null) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---cancelUseCoupons");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        //无优惠券金额
+        Double discountAmount = dto.getCapitalSum();
+//        优惠券id
+        String complaintId = dto.getComplaintId();
+//        领取的优惠券id
+        String id = dto.getId();
+
+        if (discountAmount != null && discountAmount > 0 && Func.checkNull(complaintId) && Func.checkNull(id)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少bookingId,discountAmount,complaintId,id数据---cancelUseCoupons");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+
+        //        优惠券
+        HotelCoupon hotelCoupon = hotelCoupomService.getById(complaintId);
+
+//      领取的优惠
+        HotelCouponStatus hotelCouponStatus = hotelCoupomStatusService.getById(id);
+
+        hotelCoupon.setReversedNumber(hotelCoupon.getReversedNumber() + 1);
+        hotelCouponStatus.setStatus(2);
+
+        int i = hotelCoupomService.useCoupons( hotelCoupon, hotelCouponStatus);
+        if (i > 0) {
+            jsonObject.put("code", 200);
+            jsonObject.put("success", true);
+            jsonObject.put("message", "成功");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        jsonObject.put("message", "未知异常");
+        jsonObject.put("success", false);
+        jsonObject.put("code", 205);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+
+    }
+
+
+}

+ 8 - 0
mhotel/src/com/happy/dao/HotelCoupomStatusDao.java

@@ -1,5 +1,7 @@
 package com.happy.dao;
 package com.happy.dao;
 
 
+import com.happy.Model.HotelCouponStatus;
+
 import java.util.List;
 import java.util.List;
 
 
 public interface HotelCoupomStatusDao {
 public interface HotelCoupomStatusDao {
@@ -17,4 +19,10 @@ public interface HotelCoupomStatusDao {
      */
      */
     int updateExpir();
     int updateExpir();
 
 
+    int insert(HotelCouponStatus hotelCouponStatus);
+
+    HotelCouponStatus getById(String id);
+
+    int update(HotelCouponStatus hotelCouponStatus);
+
 }
 }

+ 20 - 0
mhotel/src/com/happy/dao/HotelCouponDao.java

@@ -1,6 +1,7 @@
 package com.happy.dao;
 package com.happy.dao;
 
 
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
+import com.happy.vo.*;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -61,4 +62,23 @@ public interface HotelCouponDao {
 
 
     int updateLapse(List<String> coupomIds);
     int updateLapse(List<String> coupomIds);
 
 
+    List<CouponCollectionVo> couponCollection(String date, int page, int rows);
+
+    int couponCollectionTotal(String date);
+
+    DesignatedHotelVo designatedHotel(String hotelIds);
+
+    QuotaVo quota(String complaintId);
+
+
+    int updateRemainderNumber(String complaintId, String modifyDate);
+
+    List<CardCouponPageVo> cardCouponPage(String types, String userId, int page, int rows);
+
+    int cardCouponPageTotal(String types, String userId);
+
+    List<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows);
+
+    int usefulCouponTotal(String hotelId, String userId);
+
 }
 }

+ 73 - 0
mhotel/src/com/happy/dao/impl/HotelCoupomStatusImplDao.java

@@ -1,8 +1,10 @@
 package com.happy.dao.impl;
 package com.happy.dao.impl;
 
 
+import com.happy.Model.HotelCouponStatus;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.HotelCoupomStatusDao;
 import com.happy.dao.HotelCoupomStatusDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.namedparam.EmptySqlParameterSource;
 import org.springframework.jdbc.core.namedparam.EmptySqlParameterSource;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -10,6 +12,7 @@ import org.springframework.stereotype.Repository;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
+import java.util.UUID;
 
 
 @Repository("HotelCoupomStatusDao")
 @Repository("HotelCoupomStatusDao")
 public class HotelCoupomStatusImplDao implements HotelCoupomStatusDao {
 public class HotelCoupomStatusImplDao implements HotelCoupomStatusDao {
@@ -66,4 +69,74 @@ public class HotelCoupomStatusImplDao implements HotelCoupomStatusDao {
         }
         }
         return num;
         return num;
     }
     }
+
+
+    @Override
+    public int insert(HotelCouponStatus hotelCouponStatus) {
+        String sql="insert into hotel_coupon_status (id,complaint_id,user_id,create_id,create_date,modify_date,lapse_date,status) values (:id,:complaint_id,:user_id,:create_id,:create_date,:modify_date,:lapse_date,:status)";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("complaint_id", hotelCouponStatus.getComplaintId());
+        sps.addValue("user_id",hotelCouponStatus.getUserId());
+        sps.addValue("create_id", hotelCouponStatus.getCreateId());
+        sps.addValue("create_date", hotelCouponStatus.getCreateDate());
+        sps.addValue("modify_date", hotelCouponStatus.getModifyDate());
+        sps.addValue("lapse_date", hotelCouponStatus.getLapseDate());
+        sps.addValue("status", 1);
+        String id = "";
+        if (hotelCouponStatus.getId() == null) {
+            id = UUID.randomUUID() + "";
+            sps.addValue("id", id);
+        } else {
+            id = hotelCouponStatus.getId() + "";
+            sps.addValue("id", id);
+        }
+        int num = 0;
+        try {
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return num;
+    }
+
+    @Override
+    public HotelCouponStatus getById(String id) {
+        String sql = "select * from hotel_coupon_status AND id = :id ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("id",id);
+        List<HotelCouponStatus> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,
+                    new BeanPropertyRowMapper<>(HotelCouponStatus.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list.get(0);
+        return null;
+    }
+
+    @Override
+    public int update(HotelCouponStatus hotelCouponStatus) {
+        String sql="update hotel_coupon_status SET complaint_id=:complaint_id,user_id=:user_id,create_id=:create_id,create_date=:create_date,modify_date=:modify_date,lapse_date=:lapse_date,status=:status where id=:id";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("id",hotelCouponStatus.getId());
+        sps.addValue("complaint_id",hotelCouponStatus.getComplaintId());
+        sps.addValue("user_id",hotelCouponStatus.getUserId());
+        sps.addValue("create_id",hotelCouponStatus.getCreateId());
+        sps.addValue("create_date",hotelCouponStatus.getCreateDate());
+        sps.addValue("modify_date",hotelCouponStatus.getModifyDate());
+        sps.addValue("lapse_date",hotelCouponStatus.getLapseDate());
+        sps.addValue("status",hotelCouponStatus.getStatus());
+
+        int num = 0;
+        try{
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        return num;
+
+    }
 }
 }

+ 206 - 0
mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java

@@ -6,6 +6,7 @@ import com.happy.Until.Func;
 import com.happy.Until.SqlUtil;
 import com.happy.Until.SqlUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dao.HotelCouponDao;
+import com.happy.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.SqlOutParameter;
 import org.springframework.jdbc.core.SqlOutParameter;
@@ -201,6 +202,211 @@ public class HotelCouponImplDao implements HotelCouponDao {
         return num;
         return num;
     }
     }
 
 
+ @Override
+    public List<CouponCollectionVo> couponCollection(String dateTime, int page, int rows) {
+        int start = (page - 1) * rows;// 每页的起始下标
+        String sql="SELECT\n" +
+                "\t hc.id as id,hc.hotelIds as hotelIds,\n" +
+                "\thc.type as type,\n" +
+                "\thc.`name` as name,\n" +
+                "\thc.rebate_price as rebatePrice,\n" +
+                "\thc.deduction_price as deductionPrice,\n" +
+                "\thc.max_deduction AS maxDeduction,\n" +
+                "\thc.meet_price as meetPrice,\n" +
+                "\thc.effective_start_date AS  effectiveStartDate,(SELECT COUNT( hcs.complaint_id ) AS totalCount FROM `hotel_coupon_status` hcs WHERE hcs.complaint_id = hc.id ) AS totalCount, hc.limit_number as limitNumber,hc.remainder_number as remainderNumber, \n" +
+                "\thc.effective_end_date AS effectiveEndDate \n" +
+                "FROM\n" +
+                "\t`hotel_coupon` hc     where hc.effective_start_date < :dateTime and hc.effective_end_date> :dateTime and hc.`status` = 1  ORDER BY hc.effective_start_date DESC limit :start,:rows";
+
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("dateTime", dateTime);
+        sps.addValue("start", start);
+        sps.addValue("rows", rows);
+        List<CouponCollectionVo> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,new BeanPropertyRowMapper<>(CouponCollectionVo.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list;
+        return null;
+    }
+
+    @Override
+    public int couponCollectionTotal(String date) {
+        String sql="SELECT\n" +
+                "\t count(1)\n" +
+                "FROM\n" +
+                "\t`hotel_coupon` hc where hc.effective_start_date<:date and hc.effective_end_date>:date";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("date", date);
+        return namedParameterJdbcTemplate.queryForInt(sql, sps);
+    }
+
+    @Override
+    public DesignatedHotelVo designatedHotel(String hotelIds) {
+        String sql="SELECT GROUP_CONCAT( h.hname ) as name FROM hotel h where FIND_IN_SET(h.id,:hotelIds)";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("hotelIds", hotelIds);
+        List<DesignatedHotelVo> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,new BeanPropertyRowMapper<>(DesignatedHotelVo.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list.get(0);
+        return null;
+    }
+
+    @Override
+    public QuotaVo quota(String complaintId) {
+        String sql="SELECT\n" +
+                "\tCOUNT( hcs.complaint_id ) AS totalCount,\n" +
+                "\t( SELECT hc.limit_number FROM hotel_coupon hc WHERE hc.id = :complaintId and hc.`status`=1 ) AS limitNumber, \n" +
+                "\t( SELECT hc.remainder_number FROM hotel_coupon hc WHERE hc.id = :complaintId and hc.`status`=1 ) AS remainderNumber \n" +
+                "FROM\n" +
+                "\t`hotel_coupon_status` hcs \n" +
+                "WHERE\n" +
+                "\thcs.complaint_id = :complaintId ";
+
+           MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("complaintId", complaintId);
+        List<QuotaVo> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,new BeanPropertyRowMapper<>(QuotaVo.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list.get(0);
+        return null;
+    }
+
+    @Override
+    public int updateRemainderNumber(String complaintId,String modifyDate) {
+        String sql="UPDATE `hotel_coupon`  SET remainder_number=remainder_number-1 ,modify_date=:modifyDate WHERE id=:complaintId ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("modifyDate", modifyDate);
+        sps.addValue("complaintId", complaintId);
+        int num = 0;
+        try{
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        return num;
+    }
+
+    @Override
+    public List<CardCouponPageVo> cardCouponPage(String types, String userId, int page, int rows) {
+        int start = (page - 1) * rows;// 每页的起始下标
+        String sql="SELECT\n" +
+                "\thc.id as id,\n" +
+                "\thc.hotelIds as hotelIds,\n" +
+                "\thc.`name` as name,\n" +
+                "\thc.type as type,\n" +
+                "\thc.rebate_price as rebatePrice,\n" +
+                "\thc.deduction_price as deductionPrice,\n" +
+                "\thc.max_deduction as maxDeduction,\n" +
+                "\thc.meet_price as meetPrice,\n" +
+                "\thc.effective_end_date as effectiveEndDate ,\n" +
+                "\tcount(hcs.complaint_id) AS count\n" +
+                "FROM\n" +
+                "\thotel_coupon_status hcs\n" +
+                "\tLEFT JOIN hotel_coupon hc ON hc.id = hcs.complaint_id where FIND_IN_SET(hc.type,:status) and hcs.user_id=:userId and hcs.status=1 \n" +
+                "\tGROUP BY hcs.complaint_id ORDER BY hc.effective_start_date DESC limit :start,:rows";
+
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("status", types);
+        sps.addValue("userId", userId);
+        sps.addValue("start", start);
+        sps.addValue("rows", rows);
+        List<CardCouponPageVo> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,new BeanPropertyRowMapper<>(CardCouponPageVo.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list;
+        return null;
+    }
+
+    @Override
+    public int cardCouponPageTotal(String types, String userId) {
+        String sql="SELECT COUNT(1) FROM (SELECT\n" +
+                "\thc.id as id,\n" +
+                "\thc.hotelIds as hotelIds,\n" +
+                "\thc.`name` as name,\n" +
+                "\thc.type as type,\n" +
+                "\thc.rebate_price as rebatePrice,\n" +
+                "\thc.deduction_price as deductionPrice,\n" +
+                "\thc.max_deduction as maxDeduction,\n" +
+                "\thc.meet_price as meetPrice,\n" +
+                "\thc.effective_end_date as effectiveEndDate ,\n" +
+                "\tcount(hcs.complaint_id) AS count\n" +
+                "FROM\n" +
+                "\thotel_coupon_status hcs\n" +
+                "\tLEFT JOIN hotel_coupon hc ON hc.id = hcs.complaint_id where FIND_IN_SET(hc.type,:status) and hcs.user_id=:userId and hcs.status=1 \n" +
+                "\tGROUP BY hcs.complaint_id ORDER BY hc.effective_start_date DESC ) hcs2";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("status", types);
+        sps.addValue("userId", userId);
+
+        return namedParameterJdbcTemplate.queryForInt(sql, sps);
+    }
+
+    @Override
+    public List<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows) {
+        int start = (page - 1) * rows;// 每页的起始下标
+        String sql="SELECT\n" +
+                "\t hcs.id as id , hcs.complaint_id AS complaintId,\n" +
+                "\thc.hotelIds as hotelIds,\n" +
+                "\thc.`name` as name,\n" +
+                "\thc.type as type,\n" +
+                "\thc.rebate_price as rebatePrice,\n" +
+                "\thc.deduction_price as deductionPrice,\n" +
+                "\thc.max_deduction as maxDeduction,\n" +
+                "\thc.meet_price as meetPrice,\n" +
+                "\thc.effective_end_date as effectiveEndDate \n" +
+                "FROM\n" +
+                "\thotel_coupon_status hcs\n" +
+                "\tLEFT JOIN hotel_coupon hc ON hc.id = hcs.complaint_id where (FIND_IN_SET(:hotelId, hc.hotelIds) or hc.hotelIds=-1 ) and hcs.user_id=:userId and hcs.status=1 \n" +
+                "\t ORDER BY hc.effective_start_date DESC limit :start,:rows";
+
+
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("hotelId", hotelId);
+        sps.addValue("userId", userId);
+        sps.addValue("start", start);
+        sps.addValue("rows", rows);
+        List<UsefulCouponVo> list = null;
+        try{
+            list = namedParameterJdbcTemplate.query(sql, sps,new BeanPropertyRowMapper<>(UsefulCouponVo.class));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        if(list != null && list.size()>0) return list;
+        return null;
+    }
+
+    @Override
+    public int usefulCouponTotal(String hotelId, String userId) {
+        String sql="SELECT\n" +
+                "\tCOUNT( 1 ) \n" +
+                "FROM\n" +
+                "\thotel_coupon_status hcs\n" +
+                "\tLEFT JOIN hotel_coupon hc ON hc.id = hcs.complaint_id \n" +
+                "WHERE\n" +
+                "\t(FIND_IN_SET(:hotelId, hc.hotelIds) or hc.hotelIds=-1 ) \n" +
+                "\tAND hcs.user_id = :userId \n" +
+                "\tAND hcs.`status` = 1";
+
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("hotelId", hotelId);
+        sps.addValue("userId", userId);
+
+        return namedParameterJdbcTemplate.queryForInt(sql, sps);
+    }
     private void appendValue(HotelCoupon hotelCoupon, StringBuffer stringBuffer, MapSqlParameterSource sps){
     private void appendValue(HotelCoupon hotelCoupon, StringBuffer stringBuffer, MapSqlParameterSource sps){
         if (!Func.checkNull(String.valueOf(hotelCoupon.getHotelIds()))){
         if (!Func.checkNull(String.valueOf(hotelCoupon.getHotelIds()))){
             stringBuffer.append(" hotelIds=:hotelIds ,");
             stringBuffer.append(" hotelIds=:hotelIds ,");

+ 11 - 0
mhotel/src/com/happy/dto/CancelUseCouponsDto.java

@@ -0,0 +1,11 @@
+package com.happy.dto;
+
+import lombok.Data;
+
+@Data
+public class CancelUseCouponsDto {
+    private String id;//领取的优惠券id
+    private String complaintId;//优惠券id
+    private Double capitalSum;//本金
+
+}

+ 26 - 0
mhotel/src/com/happy/dto/OrderComplaintDto.java

@@ -0,0 +1,26 @@
+package com.happy.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class OrderComplaintDto {
+    private String bookingId;//投诉订单id
+
+    private String hotelId;//投诉民宿id
+
+    private String houseId;//投诉房型id
+
+    private String title;//投诉标题
+
+    private String content;//内容
+
+    private String createId;//创建人
+
+    private String createDate;//创建时间
+
+    private String modifyDate;//修改时间
+
+    private List<String> pictureList; //图片
+}

+ 9 - 0
mhotel/src/com/happy/dto/UpdateHotelCouponDto.java

@@ -0,0 +1,9 @@
+package com.happy.dto;
+
+import lombok.Data;
+
+@Data
+public class UpdateHotelCouponDto {
+    private String id;
+    private String complaintId;
+}

+ 10 - 0
mhotel/src/com/happy/dto/UseCouponsDto.java

@@ -0,0 +1,10 @@
+package com.happy.dto;
+
+import lombok.Data;
+
+@Data
+public class UseCouponsDto {
+    private String id;
+    private String complaintId;
+    private Double totalPrice;
+}

+ 1 - 1
mhotel/src/com/happy/service/AppBookService.java

@@ -19,7 +19,7 @@ public interface AppBookService {
      * @param userId
      * @param userId
      * @return
      * @return
      */
      */
-    public String createOrder(String bookingId, String houseId,String startTime,String endTime,String houseOrderNumber,String userName,String userPhone, String userId);
+    public String createOrder(String bookingId, String houseId,String startTime,String endTime,String houseOrderNumber,String userName,String userPhone, String userId,String complaintId);
 
 
 
 
 //    /**
 //    /**

+ 41 - 0
mhotel/src/com/happy/service/HotelCoupomService.java

@@ -1,8 +1,15 @@
 package com.happy.service;
 package com.happy.service;
 
 
+import com.happy.Model.Booking;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
+import com.happy.Model.HotelCouponStatus;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
+import com.happy.vo.CardCouponPageVo;
+import com.happy.vo.CouponCollectionVo;
+import com.happy.vo.DesignatedHotelVo;
+import com.happy.vo.UsefulCouponVo;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 public interface HotelCoupomService {
 public interface HotelCoupomService {
@@ -54,4 +61,38 @@ public interface HotelCoupomService {
     int updateExpire();
     int updateExpire();
 
 
     int updateLapse(List<String> coupomIds);
     int updateLapse(List<String> coupomIds);
+
+
+    IPage<CouponCollectionVo> couponCollection(String date, int page, int rows);
+
+    DesignatedHotelVo designatedHotel(String hotelIds);
+
+    Boolean quota(String complaintId);
+
+    int coupon(HotelCouponStatus hotelCouponStatus);
+
+    /**
+     * 我的卡卷
+     * @param types
+     * @param userId
+     * @param page
+     * @param rows
+     * @return
+     */
+    IPage<CardCouponPageVo> cardCouponPage(String types, String userId, int page, int rows);
+
+    /**
+     * 可用优惠券
+     * @param hotelId
+     * @param userId
+     * @param page
+     * @param rows
+     * @return
+     */
+    IPage<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows);
+
+
+    int useCoupons(HotelCoupon hotelCoupon, HotelCouponStatus hotelCouponStatus);
+
+
 }
 }

+ 13 - 0
mhotel/src/com/happy/service/HotelCoupomStatusService.java

@@ -1,5 +1,7 @@
 package com.happy.service;
 package com.happy.service;
 
 
+import com.happy.Model.HotelCouponStatus;
+
 import java.util.List;
 import java.util.List;
 
 
 public interface HotelCoupomStatusService {
 public interface HotelCoupomStatusService {
@@ -12,4 +14,15 @@ public interface HotelCoupomStatusService {
      * 描述:定时任务 批量过期
      * 描述:定时任务 批量过期
      */
      */
     int updateExpir();
     int updateExpir();
+
+    int insert(HotelCouponStatus hotelCouponStatus);
+
+    /**
+     * 通过id获取数据
+     * @param id
+     * @return
+     */
+    HotelCouponStatus getById(String id);
+
+    int update(HotelCouponStatus hotelCouponStatus);
 }
 }

+ 51 - 1
mhotel/src/com/happy/service/impl/AppBookImplService.java

@@ -17,6 +17,7 @@ import com.happy.service.*;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
 
 
 
 
@@ -38,8 +39,11 @@ public class AppBookImplService implements AppBookService {
     @Resource
     @Resource
     public AdminManagerService adminManagerService;
     public AdminManagerService adminManagerService;
 
 
+    @Resource
+    public HotelCoupomService hotelCoupomService;
+
     @Override
     @Override
-    public String createOrder(String bookingId, String houseId, String startTime, String endTime, String houseOrderNumber, String userName, String userPhone, String userId) {
+    public String createOrder(String bookingId, String houseId, String startTime, String endTime, String houseOrderNumber, String userName, String userPhone, String userId,String complaintId) {
         if (Func.checkNull(houseId) ||Func.checkNull(startTime) ||Func.checkNull(endTime)
         if (Func.checkNull(houseId) ||Func.checkNull(startTime) ||Func.checkNull(endTime)
                 ||Func.checkNull(houseOrderNumber) ||Func.checkNull(userName) ||Func.checkNull(userPhone) ||Func.checkNull(userId))
                 ||Func.checkNull(houseOrderNumber) ||Func.checkNull(userName) ||Func.checkNull(userPhone) ||Func.checkNull(userId))
             return null;
             return null;
@@ -85,6 +89,52 @@ public class AppBookImplService implements AppBookService {
         booking.setHouseAreas(house.gethAreas());
         booking.setHouseAreas(house.gethAreas());
         booking.setHouseRemake(house.getRemark());
         booking.setHouseRemake(house.getRemark());
         double totalPrice = Func.parseDbl(houseOrderNumber) * house.getPrice() * day;
         double totalPrice = Func.parseDbl(houseOrderNumber) * house.getPrice() * day;
+
+        if (!Func.checkNull(complaintId)) {
+            BigDecimal totalPriceBigDecimal = new BigDecimal(totalPrice);
+
+            //        优惠券
+            HotelCoupon hotelCoupon = hotelCoupomService.getById(complaintId);
+            Integer type = hotelCoupon.getType();
+            if (1 == type) {
+//            满减金额
+                Double meetPrice = hotelCoupon.getMeetPrice();
+                BigDecimal meetPriceBigDecimal = new BigDecimal(meetPrice);
+
+                if (meetPrice < totalPrice) {
+                    //            减免金额
+                    Double deductionPrice = hotelCoupon.getDeductionPrice();
+                    BigDecimal deductionPriceBigDecimal = new BigDecimal(deductionPrice);
+                    //            实付金额
+                    BigDecimal subtract = totalPriceBigDecimal.subtract(deductionPriceBigDecimal);
+                    totalPrice=subtract.doubleValue();
+                }
+
+            } else if (2 == type) {
+//            享受的折扣
+                Double rebatePrice = hotelCoupon.getRebatePrice();
+                BigDecimal rebatePriceBigDecimal = new BigDecimal(rebatePrice/10);
+
+//            最大减免金额
+                Double maxDeduction = hotelCoupon.getMaxDeduction();
+                BigDecimal maxDeductionBigDecimal = new BigDecimal(maxDeduction);
+
+//            折扣后的价格
+                BigDecimal bigDecimal = totalPriceBigDecimal.multiply(rebatePriceBigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
+                double v = bigDecimal.doubleValue();
+
+//            减去最大折扣后的价格
+                BigDecimal subtract = totalPriceBigDecimal.subtract(maxDeductionBigDecimal);
+                double v1 = subtract.doubleValue();
+
+                if (v > v1) {
+                    totalPrice=v;
+                } else if (v < v1) {
+                    totalPrice=v1;
+                }
+            }
+        }
+
         booking.setHouseTotalPrice(totalPrice);
         booking.setHouseTotalPrice(totalPrice);
 
 
 
 

+ 162 - 0
mhotel/src/com/happy/service/impl/HotelCoupomImplService.java

@@ -3,12 +3,17 @@ package com.happy.service.impl;
 import com.happy.Model.AdminManager;
 import com.happy.Model.AdminManager;
 import com.happy.Model.Hotel;
 import com.happy.Model.Hotel;
 import com.happy.Model.HotelCoupon;
 import com.happy.Model.HotelCoupon;
+import com.happy.Model.HotelCouponStatus;
 import com.happy.Until.DateUtil;
 import com.happy.Until.DateUtil;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dao.HotelCouponDao;
 import com.happy.dao.HotelDao;
 import com.happy.dao.HotelDao;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
+import com.happy.service.BookService;
 import com.happy.service.HotelCoupomService;
 import com.happy.service.HotelCoupomService;
+import com.happy.service.HotelCoupomStatusService;
+import com.happy.vo.*;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -22,6 +27,12 @@ public class HotelCoupomImplService implements HotelCoupomService {
 
 
     @Resource
     @Resource
     public HotelDao hotelDao;
     public HotelDao hotelDao;
+	
+	@Resource
+    public HotelCoupomStatusService hotelCoupomStatusService;
+	
+    @Resource
+    public BookService bookService;
 
 
     @Override
     @Override
     public int insert(HotelCoupon hotelCoupon) {
     public int insert(HotelCoupon hotelCoupon) {
@@ -83,4 +94,155 @@ public class HotelCoupomImplService implements HotelCoupomService {
     public int updateLapse(List<String> coupomIds) {
     public int updateLapse(List<String> coupomIds) {
         return hotelCouponDao.updateLapse(coupomIds);
         return hotelCouponDao.updateLapse(coupomIds);
     }
     }
+
+
+    /**
+     * ��ȯ����
+     *
+     * @param date
+     * @return
+     */
+    @Override
+    public IPage<CouponCollectionVo> couponCollection(String date, int page, int rows) {
+        IPage<CouponCollectionVo> iPage = new IPage();
+        List<CouponCollectionVo> hotelCouponList = hotelCouponDao.couponCollection(date, page, rows);
+        if (hotelCouponList!=null&&hotelCouponList.size()>0) {
+            for (CouponCollectionVo couponCollectionVo : hotelCouponList) {
+                if (couponCollectionVo != null) {
+                    Integer limitNumber = couponCollectionVo.getLimitNumber();
+                    if (limitNumber == null) {
+                        limitNumber = 0;
+                    }
+                    Integer totalCount = couponCollectionVo.getTotalCount();
+                    if (totalCount == null) {
+                        totalCount = 0;
+                    }
+                    Integer remainderNumber = couponCollectionVo.getRemainderNumber();
+                    if (remainderNumber == null) {
+                        remainderNumber = 0;
+                    }
+                    if (limitNumber > totalCount && remainderNumber > 0) {
+                        couponCollectionVo.setClaimStatus(1);
+                    } else {
+                        couponCollectionVo.setClaimStatus(2);
+                    }
+                }
+            }
+        }
+
+        int total = hotelCouponDao.couponCollectionTotal(date);
+        iPage.setPageList(hotelCouponList);
+        iPage.setPage(page);
+        iPage.setTotalPage((int) Math.ceil((double) total / rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        return iPage;
+
+    }
+
+    /**
+     * ָ������
+     *
+     * @param hotelIds
+     * @return
+     */
+    @Override
+    public DesignatedHotelVo designatedHotel(String hotelIds) {
+        return hotelCouponDao.designatedHotel(hotelIds);
+    }
+
+    /**
+     * ͨ���Ż�ȯid�ж��Ƿ������ȯ
+     *
+     * @param complaintId
+     * @return
+     */
+    @Override
+    public Boolean quota(String complaintId) {
+
+        QuotaVo quotaVo = hotelCouponDao.quota(complaintId);
+
+        if (quotaVo != null) {
+            Integer limitNumber = quotaVo.getLimitNumber();
+            if (limitNumber == null) {
+                limitNumber = 0;
+            }
+            Integer totalCount = quotaVo.getTotalCount();
+            if (totalCount == null) {
+                totalCount = 0;
+            }
+            Integer remainderNumber = quotaVo.getRemainderNumber();
+            if (remainderNumber == null) {
+                remainderNumber = 0;
+            }
+            if (limitNumber > totalCount && remainderNumber > 0) {
+                return true;
+            } else {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * ��ȡ�Ż�ȯ
+     *
+     * @param hotelCouponStatus
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class, readOnly = false)
+    public int coupon(HotelCouponStatus hotelCouponStatus) {
+        try {
+            //        �����޸��Ż�ȯ������
+            int num = hotelCouponDao.updateRemainderNumber(hotelCouponStatus.getComplaintId(), hotelCouponStatus.getModifyDate());
+            num = hotelCoupomStatusService.insert(hotelCouponStatus);
+            return num;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return 0;
+
+    }
+
+    @Override
+    public IPage<CardCouponPageVo> cardCouponPage(String types, String userId, int page, int rows) {
+        IPage<CardCouponPageVo> iPage = new IPage();
+        List<CardCouponPageVo> hotelCouponList = hotelCouponDao.cardCouponPage(types, userId, page, rows);
+        int total = hotelCouponDao.cardCouponPageTotal(types, userId);
+        iPage.setPageList(hotelCouponList);
+        iPage.setPage(page);
+        iPage.setTotalPage((int) Math.ceil((double) total / rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        return iPage;
+    }
+
+    @Override
+    public IPage<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows) {
+        IPage<UsefulCouponVo> iPage = new IPage();
+        List<UsefulCouponVo> hotelCouponList = hotelCouponDao.usefulCoupon(hotelId, userId, page, rows);
+        int total = hotelCouponDao.usefulCouponTotal(hotelId, userId);
+        iPage.setPageList(hotelCouponList);
+        iPage.setPage(page);
+        iPage.setTotalPage((int) Math.ceil((double) total / rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        return iPage;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int useCoupons( HotelCoupon hotelCoupon, HotelCouponStatus hotelCouponStatus) {
+        int update = hotelCouponDao.update(hotelCoupon);
+        int u=hotelCoupomStatusService.update(hotelCouponStatus);
+
+        if (update>0&&u>0) {
+            return update;
+        }
+        return 0;
+    }
+
+
 }
 }

+ 16 - 0
mhotel/src/com/happy/service/impl/HotelCoupomStatusImplService.java

@@ -1,5 +1,6 @@
 package com.happy.service.impl;
 package com.happy.service.impl;
 
 
+import com.happy.Model.HotelCouponStatus;
 import com.happy.dao.AdminDao;
 import com.happy.dao.AdminDao;
 import com.happy.dao.HotelCoupomStatusDao;
 import com.happy.dao.HotelCoupomStatusDao;
 import com.happy.service.HotelCoupomStatusService;
 import com.happy.service.HotelCoupomStatusService;
@@ -24,4 +25,19 @@ public class HotelCoupomStatusImplService implements HotelCoupomStatusService {
     public int updateExpir() {
     public int updateExpir() {
         return hotelCoupomStatusDao.updateExpir();
         return hotelCoupomStatusDao.updateExpir();
     }
     }
+
+    @Override
+    public int insert(HotelCouponStatus hotelCouponStatus) {
+        return hotelCoupomStatusDao.insert(hotelCouponStatus);
+    }
+
+    @Override
+    public HotelCouponStatus getById(String id) {
+        return hotelCoupomStatusDao.getById(id);
+    }
+
+    @Override
+    public int update(HotelCouponStatus hotelCouponStatus) {
+        return hotelCoupomStatusDao.update(hotelCouponStatus);
+    }
 }
 }

+ 28 - 0
mhotel/src/com/happy/vo/CardCouponPageVo.java

@@ -0,0 +1,28 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class CardCouponPageVo {
+
+    private String id; // 主键
+
+    private String hotelIds; // 适用民宿
+
+    private String name; // 名称
+
+    private Integer type; // 类型(1.优惠卷 2.折扣卷)
+
+    private Double rebatePrice; // 折扣
+
+    private Double deductionPrice; // 减免金额
+
+    private Double maxDeduction; // 最大减免金额
+
+    private Double meetPrice; // 满减金额
+
+    private String effectiveEndDate; //有效期结束时间
+//    领取张数
+    private Integer count;
+
+}

+ 33 - 0
mhotel/src/com/happy/vo/CouponCollectionVo.java

@@ -0,0 +1,33 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class CouponCollectionVo {
+    private String id; // 主键
+    private String hotelIds; // 适用民宿
+    private String name; // 名称
+    private Integer type; // 类型(1.优惠卷 2.折扣卷)
+    private Double rebatePrice; // 折扣
+    private Double deductionPrice; // 减免金额
+    private Double maxDeduction; // 最大减免金额
+    private Integer grantNumber; // 发放数量
+    private Integer limitNumber; // 每人限领
+    private String grantStartDate; // 发放开始时间
+    private String grantEndDate; // 发放结束时间
+    private Double meetPrice; // 满减金额
+    private String effectiveStartDate; // 有效期开始时间
+    private String effectiveEndDate; // 有效期结束时间
+    private Integer effectiveType;//有效期类型
+    private Integer effectiveDay; // 生效时间天数
+    private Integer effectiveLoseDay; // 失效时间天数
+    private Integer createId; // 创建人
+    private String createDate; // 创建时间
+    private String modifyDate; // 修改时间
+    private Integer status; // 状态(0删除 1正常)
+    private Integer remainderNumber; //剩余数量
+    private Integer reversedNumber; //已核销数量
+    private Integer totalCount;//    领取数
+    private Integer claimStatus;//可领取1,不可领取2
+
+}

+ 8 - 0
mhotel/src/com/happy/vo/DesignatedHotelVo.java

@@ -0,0 +1,8 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class DesignatedHotelVo {
+    private String name;
+}

+ 20 - 0
mhotel/src/com/happy/vo/DetailsVo.java

@@ -0,0 +1,20 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DetailsVo {
+    //   投诉标题
+    private String title;
+
+    //    内容
+    private String content;
+    //    图片
+    private List<String> urlList;
+    //    投诉进度时间
+    private String dateTime;
+    //    状态
+    private String progressType;
+}

+ 25 - 0
mhotel/src/com/happy/vo/ProgressDetailsVo.java

@@ -0,0 +1,25 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ProgressDetailsVo {
+    //   投诉标题
+    private String title;
+
+
+    //    订单号
+    private String bookingId;
+//     投诉订单号
+    private String complaintId;
+//    投诉时间
+    private String dateTime;
+
+//  详情
+    private List<DetailsVo> detailsVoList;
+
+
+
+}

+ 13 - 0
mhotel/src/com/happy/vo/QuotaVo.java

@@ -0,0 +1,13 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class QuotaVo {
+//    领取张数
+    private Integer totalCount;
+//    可领取张数
+    private Integer limitNumber;
+//    剩余张数
+    private Integer remainderNumber;
+}

+ 13 - 0
mhotel/src/com/happy/vo/UseCouponsVo.java

@@ -0,0 +1,13 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class UseCouponsVo {
+    private String id;//领取的优惠券id
+    private String complaintId;//优惠券id
+    private String hotelCouponName;//优惠券名称
+    private String typeName;//优惠券类型
+    private Double discountAmount;//优惠金额
+    private Double capitalSum;//本金
+}

+ 27 - 0
mhotel/src/com/happy/vo/UsefulCouponVo.java

@@ -0,0 +1,27 @@
+package com.happy.vo;
+
+import lombok.Data;
+
+@Data
+public class UsefulCouponVo {
+
+    private String id; // 领取的优惠券主键
+
+    private String complaintId; // 优惠券id
+
+    private String hotelIds; // 适用民宿
+
+    private String name; // 名称
+
+    private Integer type; // 类型(1.优惠卷 2.折扣卷)
+
+    private Double rebatePrice; // 折扣
+
+    private Double deductionPrice; // 减免金额
+
+    private Double maxDeduction; // 最大减免金额
+
+    private Double meetPrice; // 满减金额
+
+    private String effectiveEndDate; //有效期结束时间
+}