Search in sources :

Example 1 with OfferItemCriteriaImpl

use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createItemBasedOfferWithItemCriteria.

public List<Offer> createItemBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String qualRule, String targetRule) {
    List<Offer> offers = createItemBasedOffer(orderRule, targetRule, discountType);
    if (qualRule != null) {
        Offer firstOffer = offers.get(0);
        OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
        // qualCriteria.setQualifyingOffer(offers.get(0));
        qualCriteria.setQuantity(1);
        qualCriteria.setMatchRule(qualRule);
        Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
        OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
        xref.setOffer(firstOffer);
        xref.setOfferItemCriteria(qualCriteria);
        criterias.add(xref);
        firstOffer.setQualifyingItemCriteriaXref(criterias);
    }
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 2 with OfferItemCriteriaImpl

use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createOrderBasedOfferWithItemCriteria.

public List<Offer> createOrderBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String orderItemMatchRule) {
    List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
    Offer firstOffer = offers.get(0);
    OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
    // qualCriteria.setQualifyingOffer(offers.get(0));
    qualCriteria.setQuantity(1);
    qualCriteria.setMatchRule(orderItemMatchRule);
    Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
    OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
    xref.setOffer(firstOffer);
    xref.setOfferItemCriteria(qualCriteria);
    criterias.add(xref);
    firstOffer.setQualifyingItemCriteriaXref(criterias);
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 3 with OfferItemCriteriaImpl

use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createFGBasedOfferWithItemCriteria.

public List<Offer> createFGBasedOfferWithItemCriteria(String orderRule, String fgRule, OfferDiscountType discountType, String orderItemMatchRule) {
    List<Offer> offers = createFGBasedOffer(orderRule, fgRule, discountType);
    Offer firstOffer = offers.get(0);
    OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
    qualCriteria.setQuantity(1);
    qualCriteria.setMatchRule(orderItemMatchRule);
    Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
    OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
    xref.setOffer(firstOffer);
    xref.setOfferItemCriteria(qualCriteria);
    criterias.add(xref);
    firstOffer.setQualifyingItemCriteriaXref(criterias);
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 4 with OfferItemCriteriaImpl

use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createItemBasedOffer.

public List<Offer> createItemBasedOffer(String orderRule, String targetRule, OfferDiscountType discountType) {
    List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
    offers.get(0).setType(OfferType.ORDER_ITEM);
    if (targetRule != null) {
        Offer offer = offers.get(0);
        OfferItemCriteria targetCriteria = new OfferItemCriteriaImpl();
        // targetCriteria.setQualifyingOffer(offers.get(0));
        targetCriteria.setQuantity(1);
        targetCriteria.setMatchRule(targetRule);
        OfferTargetCriteriaXref targetXref = new OfferTargetCriteriaXrefImpl();
        targetXref.setOffer(offer);
        targetXref.setOfferItemCriteria(targetCriteria);
        offer.setTargetItemCriteriaXref(Collections.singleton(targetXref));
    }
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) OfferTargetCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferTargetCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)

Example 5 with OfferItemCriteriaImpl

use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.

the class PricingTest method createOffer.

private Offer createOffer(String offerName, OfferType offerType, OfferDiscountType discountType, double value, String customerRule, String orderRule) {
    Offer offer = new OfferImpl();
    offer.setName(offerName);
    offer.setStartDate(SystemTime.asDate());
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -1);
    offer.setStartDate(calendar.getTime());
    calendar.add(Calendar.DATE, 2);
    offer.setEndDate(calendar.getTime());
    offer.setType(offerType);
    offer.setDiscountType(discountType);
    offer.setValue(BigDecimal.valueOf(value));
    offer.setAutomaticallyAdded(true);
    OfferItemCriteria oic = new OfferItemCriteriaImpl();
    oic.setQuantity(1);
    oic.setMatchRule(orderRule);
    OfferTargetCriteriaXref targetXref = new OfferTargetCriteriaXrefImpl();
    targetXref.setOffer(offer);
    targetXref.setOfferItemCriteria(oic);
    offer.setTargetItemCriteriaXref(Collections.singleton(targetXref));
    offer.setCombinableWithOtherOffers(true);
    offer = offerService.save(offer);
    offer.setMaxUsesPerOrder(50);
    return offer;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) OfferTargetCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) Calendar(java.util.Calendar) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferImpl(org.broadleafcommerce.core.offer.domain.OfferImpl) OfferTargetCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)

Aggregations

Offer (org.broadleafcommerce.core.offer.domain.Offer)7 OfferItemCriteria (org.broadleafcommerce.core.offer.domain.OfferItemCriteria)7 OfferItemCriteriaImpl (org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl)7 OfferQualifyingCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)5 OfferQualifyingCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl)5 HashSet (java.util.HashSet)4 OfferTargetCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)3 OfferTargetCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl)3 Calendar (java.util.Calendar)2 ArrayList (java.util.ArrayList)1 OfferImpl (org.broadleafcommerce.core.offer.domain.OfferImpl)1 CandidatePromotionItems (org.broadleafcommerce.core.offer.service.discount.CandidatePromotionItems)1 PromotableCandidateOrderOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateOrderOffer)1 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)1 PromotableOrderItem (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem)1