From 0d735ac26b6bc5d0f884ae4e8f854868451cb5b2 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 30 Jul 2019 14:13:14 +0630 Subject: [PATCH] fix promotion --- app/models/promotion.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/promotion.rb b/app/models/promotion.rb index e6487afb..9f107f3f 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -97,9 +97,11 @@ class Promotion < ApplicationRecord end # same, promo_product = check_giveaway_product(promo, orderitem[0][0]) if promo.promo_type == Promotion::PROMO_TYPE1 - if same + if same + puts "Hello this is same" give_promotion_same_product(orderitem[:qty], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code) - else + else + puts "Hello this is not same" give_promotion_second_product(orderitem[:qty], promo.min_qty, promo_product.item_code, orderitem, sale_id) end @@ -207,7 +209,7 @@ class Promotion < ApplicationRecord sale_order.each do|order| source = Order.find(order.order_id).source end - item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first + item = OrderItem.where("item_instance_code = ?",promo_product).order("order_items_id DESC").first item ={ item_code:item.item_code, item_instance_code:item.item_instance_code,