|
@@ -248,9 +248,48 @@ public class HotelCoupomImplService implements HotelCoupomService {
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows,Double totalPrice) {
|
|
public IPage<UsefulCouponVo> usefulCoupon(String hotelId, String userId, int page, int rows,Double totalPrice) {
|
|
|
IPage<UsefulCouponVo> iPage = new IPage();
|
|
IPage<UsefulCouponVo> iPage = new IPage();
|
|
|
|
|
+ //判断当前时间是否在有效期内
|
|
|
List<UsefulCouponVo> hotelCouponList = hotelCouponDao.usefulCoupon(hotelId, userId, page, rows,totalPrice);
|
|
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);
|
|
int total = hotelCouponDao.usefulCouponTotal(hotelId, userId,totalPrice);
|
|
|
- iPage.setPageList(hotelCouponList);
|
|
|
|
|
|
|
+ iPage.setPageList(vos);
|
|
|
iPage.setPage(page);
|
|
iPage.setPage(page);
|
|
|
iPage.setTotalPage((int) Math.ceil((double) total / rows));
|
|
iPage.setTotalPage((int) Math.ceil((double) total / rows));
|
|
|
iPage.setRows(rows);
|
|
iPage.setRows(rows);
|