コード例 #1
0
 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;
 }
コード例 #2
0
 @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;
 }
コード例 #3
0
 public Offer updateOfferCodeMaxCustomerUses(OfferCode code, Long maxUses) {
   code.getOffer().setMaxUsesPerCustomer(maxUses);
   return offerService.save(code.getOffer());
 }
コード例 #4
0
 public void delete(OfferCode offerCode) {
   if (!em.contains(offerCode)) {
     offerCode = readOfferCodeById(offerCode.getId());
   }
   em.remove(offerCode);
 }