Commit 41f2fb4a by wuwenlong

available coupon check is weekend;

parent fd228302
...@@ -6,6 +6,7 @@ import java.util.*; ...@@ -6,6 +6,7 @@ import java.util.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -188,7 +189,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -188,7 +189,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
List<SPack> sPacks = packService.list(); List<SPack> sPacks = packService.list();
//迭代 //迭代
sConsumerCoupons.forEach(item -> { sConsumerCoupons.forEach(item -> {
item.setIsAvailable(AvailableEnum.AVAILABLE.getCode());
checkCoupon(item,couponRequest,sStores,sRooms,sPacks,timeLong); checkCoupon(item,couponRequest,sStores,sRooms,sPacks,timeLong);
}); });
return sConsumerCoupons; return sConsumerCoupons;
...@@ -196,12 +196,24 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -196,12 +196,24 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
private Boolean checkCoupon(SConsumerCoupon item, CouponRequest couponRequest private Boolean checkCoupon(SConsumerCoupon item, CouponRequest couponRequest
, List<SStore> sStores, List<SRoom> sRooms, List<SPack> sPacks, BigDecimal timeLong){ , List<SStore> sStores, List<SRoom> sRooms, List<SPack> sPacks, BigDecimal timeLong){
item.setIsAvailable(AvailableEnum.AVAILABLE.getCode());
return checkAvailableDate(item,couponRequest) return checkAvailableDate(item,couponRequest)
&&checkCouponPeriod(item,couponRequest) &&checkCouponPeriod(item,couponRequest)
&&checkStore(item,couponRequest,sStores) &&checkStore(item,couponRequest,sStores)
&&checkCouponType(item,couponRequest,sStores,sRooms,timeLong) &&checkCouponType(item,couponRequest,sStores,sRooms,timeLong)
&&checkOrderType(item,couponRequest) &&checkOrderType(item,couponRequest)
&&checkPack(item,couponRequest,sPacks); &&checkPack(item,couponRequest,sPacks)
&&chekcSunday(item,couponRequest);
}
private Boolean chekcSunday(SConsumerCoupon item, CouponRequest couponRequest) {
if(Objects.nonNull(item.getIsSunday())&&item.getIsSunday().compareTo(YesNoEnum.yes.getIndex())==0){
if(!DateUtil.isWeekend(couponRequest.getPreStartDate())||DateUtil.isWeekend(couponRequest.getPreEndDate())){
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("优惠卷周末可用");
}
}
return item.getIsAvailable()==0;
} }
private Boolean checkPack(SConsumerCoupon item, CouponRequest couponRequest, List<SPack> sPacks){ private Boolean checkPack(SConsumerCoupon item, CouponRequest couponRequest, List<SPack> sPacks){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment