public OfferCode createOfferCode(
     String offerCodeName,
     String offerName,
     OfferType offerType,
     OfferDiscountType discountType,
     double value,
     String customerRule,
     String orderRule,
     boolean stackable,
     boolean combinable,
     int priority) {
   OfferCode offerCode = offerCodeDao.create();
   Offer offer =
       createOffer(
           offerName,
           offerType,
           discountType,
           value,
           customerRule,
           orderRule,
           stackable,
           combinable,
           priority);
   offerCode.setOffer(offer);
   offerCode.setOfferCode(offerCodeName);
   offerCode = offerService.saveOfferCode(offerCode);
   return offerCode;
 }
 @Override
 @Transactional("blTransactionManager")
 public Order addOfferCode(Order order, OfferCode offerCode, boolean priceOrder)
     throws PricingException, OfferMaxUseExceededException {
   if (!order.getAddedOfferCodes().contains(offerCode)) {
     if (!offerService.verifyMaxCustomerUsageThreshold(
         order.getCustomer(), offerCode.getOffer())) {
       throw new OfferMaxUseExceededException(
           "The customer has used this offer code more than the maximum allowed number of times.");
     }
     order.getAddedOfferCodes().add(offerCode);
     order = save(order, priceOrder);
   }
   return order;
 }
 public Offer updateOfferCodeMaxCustomerUses(OfferCode code, Long maxUses) {
   code.getOffer().setMaxUsesPerCustomer(maxUses);
   return offerService.save(code.getOffer());
 }
 public void delete(OfferCode offerCode) {
   if (!em.contains(offerCode)) {
     offerCode = readOfferCodeById(offerCode.getId());
   }
   em.remove(offerCode);
 }