shop code
This commit is contained in:
@@ -15,11 +15,11 @@ class Promotion < ApplicationRecord
|
||||
promo_day.include? Date.today.wday.to_s
|
||||
end
|
||||
|
||||
def self.promo_activate(saleObj,shop_code)
|
||||
def self.promo_activate(saleObj)
|
||||
current_day = Time.now.strftime("%Y-%m-%d")
|
||||
current_time = Time.now.strftime('%H:%M:%S')
|
||||
day = Date.today.wday
|
||||
promoList = is_between_promo_datetime(current_day,current_time,shop_code)
|
||||
promoList = is_between_promo_datetime(current_day,current_time)
|
||||
|
||||
promoList.each do |promo|
|
||||
if promo.is_promo_day
|
||||
@@ -30,8 +30,8 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time,shop_code) #database is not local time
|
||||
promoList = Promotion.where("shop_code='#{shop_code}' and (Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user