Sha256: f82125099871e74b867c53f6b4a81822a2a9c0aca773c66b17bac82e13937c1a
Contents?: true
Size: 884 Bytes
Versions: 62
Compression:
Stored size: 884 Bytes
Contents
module Workarea class MarkDiscountsAsRedeemed include Sidekiq::Worker include Sidekiq::CallbacksWorker sidekiq_options enqueue_on: { Order => :place }, queue: 'low' def perform(order_id) order = Order.find(order_id) shippings = Shipping.where(order_id: order_id).to_a mark_redeemed(order, shippings) end def mark_redeemed(order, shippings) discount_ids = order.discount_ids + shippings.map(&:discount_ids).flatten discount_ids.each do |applied_discount_id| discount = Pricing::Discount.find(applied_discount_id) discount.log_redemption(order.email) discount.touch end Pricing::Discount::GeneratedPromoCode .in(code: order.promo_codes.map(&:strip).map(&:downcase)) .asc(:created_at) .uniq { |code| code.code_list_id.to_s } .each(&:used!) end end end
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
workarea-core-3.4.13 | app/workers/workarea/mark_discounts_as_redeemed.rb |
workarea-core-3.4.12 | app/workers/workarea/mark_discounts_as_redeemed.rb |