|
|
package com.yohoufo.order.charge;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yohobuy.ufo.model.order.constants.OrderConstant;
|
|
|
import com.yohobuy.ufo.model.order.constants.RegionEnum;
|
|
|
import com.yohobuy.ufo.model.promotion.UserCouponsBo;
|
|
|
import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
|
...
|
...
|
@@ -9,7 +10,9 @@ import com.yohobuy.ufo.model.promotion.constant.CouponUseLimitTypeEnum; |
|
|
import com.yohoufo.order.charge.model.ChargeGoods;
|
|
|
import com.yohoufo.order.charge.model.CouponMatchResult;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.order.utils.SellerGoodsHelper;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
...
|
...
|
@@ -17,6 +20,7 @@ import java.math.BigDecimal; |
|
|
import java.util.Arrays;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by jiexiang.wu on 2018/11/19.
|
...
|
...
|
@@ -37,7 +41,7 @@ public class CouponRuleMatcher { |
|
|
RULE_MATCHERS.add(new UseLimitRuleMatcher());
|
|
|
|
|
|
// skup类型匹配
|
|
|
RULE_MATCHERS.add(new SkupForbidRuleMatcher());
|
|
|
// RULE_MATCHERS.add(new SkupForbidRuleMatcher());
|
|
|
|
|
|
// 按商品区域匹配
|
|
|
RULE_MATCHERS.add(new SkupRegionRuleMatcher());
|
...
|
...
|
@@ -150,24 +154,63 @@ public class CouponRuleMatcher { |
|
|
}
|
|
|
}
|
|
|
|
|
|
private static class SkupForbidRuleMatcher implements IRuleMatcher {
|
|
|
// 6.9.10之后 从[禁用] 改成 [可用]
|
|
|
// private static class SkupForbidRuleMatcher implements IRuleMatcher {
|
|
|
// @Override
|
|
|
// public String ruleName() {
|
|
|
// return "SkupForbid";
|
|
|
// }
|
|
|
//
|
|
|
// @Override
|
|
|
// public boolean match(ChargeGoods chargeGoods, UserCouponsBo couponsBo) {
|
|
|
//
|
|
|
// if (couponsBo.getSkupForbidType() == null){
|
|
|
// return true;
|
|
|
// }
|
|
|
//
|
|
|
// if (Arrays.asList(couponsBo.getSkupForbidType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){
|
|
|
// return false;
|
|
|
// }
|
|
|
//
|
|
|
// return true;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
private static class SkupAllowRuleMatcher implements IRuleMatcher{
|
|
|
|
|
|
@Override
|
|
|
public String ruleName() {
|
|
|
return "SkupForbid";
|
|
|
return "SkupAllow";
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean match(ChargeGoods chargeGoods, UserCouponsBo couponsBo) {
|
|
|
|
|
|
if (couponsBo.getSkupForbidType() == null){
|
|
|
|
|
|
if (StringUtils.isEmpty(couponsBo.getSkupAllowType())){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if (Arrays.asList(couponsBo.getSkupForbidType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){
|
|
|
return false;
|
|
|
// 该优惠券允许的skup属性
|
|
|
if (Arrays.asList(couponsBo.getSkupAllowType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
// 特殊处理
|
|
|
// 现货: 现货发货1-N & 现货寄存1-Y
|
|
|
// 闪购: 闪购发货3-N & 闪购寄存3-Y
|
|
|
String depositRequirement = chargeGoods.isDepositRequirement()? OrderConstant.Y_STR: OrderConstant.N_STR;
|
|
|
|
|
|
List<String> specialAttributeList = Arrays.stream(couponsBo.getSkupAllowType().split(",")).filter(x->x.contains(OrderConstant.SPLIT_STR)).collect(Collectors.toList());
|
|
|
for (String specialAttribute : specialAttributeList){
|
|
|
String[] items = specialAttribute.split(OrderConstant.SPLIT_STR);
|
|
|
if (items[0].equalsIgnoreCase(String.valueOf(chargeGoods.getAttributes())) && depositRequirement.equalsIgnoreCase(items[1])){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|