fix promotion

This commit is contained in:
Myat Zin Wai Maw
2019-07-30 14:13:14 +06:30
parent cdc9675511
commit 0d735ac26b

View File

@@ -97,9 +97,11 @@ class Promotion < ApplicationRecord
end end
# same, promo_product = check_giveaway_product(promo, orderitem[0][0]) # same, promo_product = check_giveaway_product(promo, orderitem[0][0])
if promo.promo_type == Promotion::PROMO_TYPE1 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) 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) give_promotion_second_product(orderitem[:qty], promo.min_qty, promo_product.item_code, orderitem, sale_id)
end end
@@ -207,7 +209,7 @@ class Promotion < ApplicationRecord
sale_order.each do|order| sale_order.each do|order|
source = Order.find(order.order_id).source source = Order.find(order.order_id).source
end 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 ={
item_code:item.item_code, item_code:item.item_code,
item_instance_code:item.item_instance_code, item_instance_code:item.item_instance_code,