liu пре 2 година
родитељ
комит
530aaee6bb

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

@@ -857,8 +857,10 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
                 //通过订单id找到所属优惠券
                 List<HotelCouponStatus> hotelCouponStatusList = hotelCoupomStatusService.getBookingId(bookingId);
                 if (hotelCouponStatusList != null && hotelCouponStatusList.size() > 0) {
+                    System.out.println("进入核销优惠券");
                     for (HotelCouponStatus hotelCouponStatus : hotelCouponStatusList) {
                         String complaintId = hotelCouponStatus.getComplaintId();
+                        System.out.println("核销优惠券id"+complaintId);
                         HotelCoupon hotelCoupon = hotelCoupomService.getById(complaintId);
                         if (hotelCoupon!=null) {
                             Integer reversedNumber = hotelCoupon.getReversedNumber();

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

@@ -307,7 +307,7 @@ public class AppHotelCouponAction extends ActionSupport implements ServletReques
     public JSONObject usefulCoupon() {
         JSONObject jsonObject = new JSONObject();
 
-        if (Func.checkNull(hotelId) && Func.checkNull(userId) && totalPrice==null) {
+        if (Func.checkNull(hotelId) || Func.checkNull(userId) || totalPrice==null) {
             jsonObject.put("code", 400);
             jsonObject.put("success", false);
             jsonObject.put("message", "缺少数据hotelId,userId,totalPrice---usefulCoupon");

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

@@ -380,10 +380,10 @@ public class HotelCouponImplDao implements HotelCouponDao {
                 "\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" +
+                "\thc.effective_end_date as effectiveEndDate ,hc.effective_start_date as effectiveStartDate, hc.effective_day as effectiveDay,hc.effective_lose_day as effectiveLoseDay , hc.effective_type as effectiveType, hcs.create_date as dateTime \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 and hc.meet_price<= :totalPrice \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 and hc.meet_price<= :totalPrice   \n" +
                 "\t ORDER BY hc.effective_start_date DESC limit :start,:rows";
 
 

+ 40 - 1
mhotel/src/com/happy/service/impl/HotelCoupomImplService.java

@@ -248,9 +248,48 @@ public class HotelCoupomImplService implements HotelCoupomService {
     @Override
     public IPage<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows,Double totalPrice) {
         IPage<UsefulCouponVo> iPage = new IPage();
+        //判断当前时间是否在有效期内
         List<UsefulCouponVo> hotelCouponList = hotelCouponDao.usefulCoupon(hotelId, userId, page, rows,totalPrice);
+        ArrayList<UsefulCouponVo> vos = new ArrayList<>();
+        if (hotelCouponList!=null && hotelCouponList.size()>0) {
+            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            for (UsefulCouponVo vo : hotelCouponList) {
+                Integer effectiveType = vo.getEffectiveType();
+                if (2==effectiveType) {
+                    //生效天数
+                    Integer effectiveDay = vo.getEffectiveDay();
+                    //失效时间天数
+                    Integer effectiveLoseDay = vo.getEffectiveLoseDay();
+                    //领券时间
+                    String dateTime = vo.getDateTime();
+
+                    String substring = dateTime.substring(0, 19);
+                    LocalDateTime parse = LocalDateTime.parse(substring, dateTimeFormatter);
+//                    开始时间
+                    LocalDateTime localDateTime = parse.plusDays(effectiveDay);
+                    vo.setEffectiveStartDate(localDateTime.format(dateTimeFormatter));
+//                    结束时间
+                    LocalDateTime localDateTime1 = localDateTime.plusDays(effectiveLoseDay);
+                    vo.setEffectiveEndDate(localDateTime1.format(dateTimeFormatter));
+
+                }
+
+                String effectiveStartDate = vo.getEffectiveStartDate();
+                String effectiveEndDate = vo.getEffectiveEndDate();
+                String substring = effectiveStartDate.substring(0, 19);
+                String substring2 = effectiveEndDate.substring(0, 19);
+                LocalDateTime now = LocalDateTime.now();
+
+                if (now.isAfter(LocalDateTime.parse(substring, dateTimeFormatter))&& now.isBefore(LocalDateTime.parse(substring2, dateTimeFormatter))) {
+                    vos.add(vo);
+                }
+
+            }
+        }
+
         int total = hotelCouponDao.usefulCouponTotal(hotelId, userId,totalPrice);
-        iPage.setPageList(hotelCouponList);
+        iPage.setPageList(vos);
         iPage.setPage(page);
         iPage.setTotalPage((int) Math.ceil((double) total / rows));
         iPage.setRows(rows);

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

@@ -24,4 +24,14 @@ public class UsefulCouponVo {
     private Double meetPrice; // 满减金额
 
     private String effectiveEndDate; //有效期结束时间
+
+    private String effectiveStartDate;//有效期开始时间
+
+    private Integer effectiveType;//有效期类型(1.时间段 2.生效失效天数)
+
+    private Integer effectiveDay;//生效时间天数
+    private Integer effectiveLoseDay;//失效时间天数
+
+    private String dateTime;//领券时间
+
 }