offerCode = offerService.saveOfferCode(offerCode);
return offerCode;
}
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.setDeliveryType(OfferDeliveryType.CODE);
offer.setStackable(true);
offer.setAppliesToOrderRules(orderRule);
offer.setAppliesToCustomerRules(customerRule);
offer.setCombinableWithOtherOffers(true);
offer = offerService.save(offer);
offer.setMaxUses(50);
return offer;
}