14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/workers/workarea/mark_discounts_as_redeemed.rb', line 14
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
|