use of org.broadleafcommerce.core.offer.domain.OfferCodeImpl in project BroadleafCommerce by BroadleafCommerce.
the class PricingTest method createOfferCode.
private OfferCode createOfferCode(String offerName, OfferType offerType, OfferDiscountType discountType, double value, String customerRule, String orderRule) {
OfferCode offerCode = new OfferCodeImpl();
Offer offer = createOffer(offerName, offerType, discountType, value, customerRule, orderRule);
offerCode.setOffer(offer);
offerCode.setOfferCode("OPRAH");
offerCode = offerService.saveOfferCode(offerCode);
return offerCode;
}
use of org.broadleafcommerce.core.offer.domain.OfferCodeImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferCodeDaoImpl method offerCodeIsUsed.
@Override
public Boolean offerCodeIsUsed(OfferCode code) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Order> criteria = builder.createQuery(Order.class);
Root<OrderImpl> baseOrder = criteria.from(OrderImpl.class);
criteria.select(baseOrder);
Join<OrderImpl, OfferCodeImpl> join = baseOrder.join("addedOfferCodes");
criteria.where(builder.equal(join.get("id"), code.getId()));
TypedQuery<Order> query = em.createQuery(criteria);
try {
query.getSingleResult();
} catch (NoResultException e) {
return false;
}
return true;
}
Aggregations