shop code

This commit is contained in:
Nweni
2019-12-04 13:57:26 +06:30
parent 7afddcdf2b
commit 8b5d28524e
18 changed files with 85 additions and 126 deletions

View File

@@ -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