use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class ItemOfferProcessorImpl method markQualifiers.
/**
* Loop through ItemCriteria and mark qualifiers required to give the promotion to 1 or more targets.
* @param itemOffer
* @param order
* @return
*/
protected boolean markQualifiers(PromotableCandidateItemOffer itemOffer, PromotableOrder order) {
for (OfferItemCriteria itemCriteria : itemOffer.getCandidateQualifiersMap().keySet()) {
List<PromotableOrderItem> promotableItems = itemOffer.getCandidateQualifiersMap().get(itemCriteria);
List<PromotableOrderItemPriceDetail> priceDetails = buildPriceDetailListFromOrderItems(promotableItems);
int qualifierQtyNeeded = offerServiceUtilities.markQualifiersForCriteria(itemOffer, itemCriteria, priceDetails);
if (qualifierQtyNeeded != 0) {
return false;
}
}
return true;
}
use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class OrderOfferProcessorImpl method filterOrderLevelOffer.
@Override
public void filterOrderLevelOffer(PromotableOrder promotableOrder, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, Offer offer) {
if (offer.getDiscountType().getType().equals(OfferDiscountType.FIX_PRICE.getType())) {
LOG.warn("Offers of type ORDER may not have a discount type of FIX_PRICE. Ignoring order offer (name=" + offer.getName() + ")");
return;
}
boolean orderLevelQualification = false;
// Order Qualification
orderQualification: {
if (couldOfferApplyToOrder(offer, promotableOrder)) {
orderLevelQualification = true;
break orderQualification;
}
for (PromotableOrderItem orderItem : promotableOrder.getDiscountableOrderItems(offer.getApplyDiscountToSalePrice())) {
if (couldOfferApplyToOrder(offer, promotableOrder, orderItem)) {
orderLevelQualification = true;
break orderQualification;
}
}
for (PromotableFulfillmentGroup fulfillmentGroup : promotableOrder.getFulfillmentGroups()) {
if (couldOfferApplyToOrder(offer, promotableOrder, fulfillmentGroup)) {
orderLevelQualification = true;
break orderQualification;
}
}
}
// Item Qualification - new for 1.5!
if (orderLevelQualification) {
CandidatePromotionItems candidates = couldOfferApplyToOrderItems(offer, promotableOrder.getDiscountableOrderItems(offer.getApplyDiscountToSalePrice()));
if (candidates.isMatchedQualifier()) {
PromotableCandidateOrderOffer candidateOffer = createCandidateOrderOffer(promotableOrder, qualifiedOrderOffers, offer);
candidateOffer.getCandidateQualifiersMap().putAll(candidates.getCandidateQualifiersMap());
}
}
}
use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class OrderOfferProcessorImpl method synchronizeOrderItems.
protected void synchronizeOrderItems(PromotableOrder promotableOrder) {
Order order = promotableOrder.getOrder();
Map<OrderItem, PromotableOrderItem> promotableItemMap = offerServiceUtilities.buildPromotableItemMap(promotableOrder);
List<OrderItem> orderItemList = offerServiceUtilities.buildOrderItemList(order);
for (OrderItem orderItem : orderItemList) {
PromotableOrderItem promotableItem = promotableItemMap.get(orderItem);
if (promotableItem == null) {
continue;
}
synchronizeItemPriceDetails(orderItem, promotableItem);
synchronizeItemQualifiers(orderItem, promotableItem);
}
}
use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class AbstractBaseProcessor method checkForItemRequirements.
protected void checkForItemRequirements(Offer offer, CandidatePromotionItems candidates, OfferItemCriteria criteria, List<PromotableOrderItem> promotableOrderItems, boolean isQualifier) {
boolean matchFound = false;
int criteriaQuantity = criteria.getQuantity();
int matchedQuantity = 0;
if (criteriaQuantity > 0) {
// for this promotion.
for (PromotableOrderItem item : promotableOrderItems) {
if (couldOrderItemMeetOfferRequirement(criteria, item)) {
if (isQualifier) {
candidates.addQualifier(criteria, item);
} else {
candidates.addTarget(criteria, item);
addChildOrderItemsToCandidates(offer, candidates, criteria, promotableOrderItems, item);
}
matchedQuantity += item.getQuantity();
}
}
matchFound = (matchedQuantity >= criteriaQuantity);
}
if (isQualifier) {
candidates.setMatchedQualifier(matchFound);
} else {
candidates.setMatchedTarget(matchFound);
}
}
use of org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class AbstractBaseProcessor method addChildOrderItemsToCandidates.
protected void addChildOrderItemsToCandidates(Offer offer, CandidatePromotionItems candidates, OfferItemCriteria criteria, List<PromotableOrderItem> promotableOrderItems, PromotableOrderItem item) {
if (offer.getApplyToChildItems()) {
final List<OrderItem> childItems = item.getOrderItem().getChildOrderItems();
if (CollectionUtils.isEmpty(childItems)) {
return;
}
List<PromotableOrderItem> filteredItems = new ArrayList<>();
filteredItems.addAll(promotableOrderItems);
CollectionUtils.filter(filteredItems, new TypedPredicate<PromotableOrderItem>() {
@Override
public boolean eval(PromotableOrderItem promotableOrderItem) {
return childItems.contains(promotableOrderItem.getOrderItem());
}
});
for (PromotableOrderItem promotableOrderItem : filteredItems) {
candidates.addTarget(criteria, promotableOrderItem);
}
}
}
Aggregations