add alert for new,send_to_kitchen and ready_to_delivery

This commit is contained in:
phyusin
2018-05-03 17:22:59 +06:30
parent 0748478bb4
commit 9ff3018323
15 changed files with 445 additions and 235 deletions

View File

@@ -207,6 +207,35 @@ class OrderReservation < ApplicationRecord
.order("order_reservations.order_reservation_id desc, order_reservations.created_at desc")
end
def self.check_new_order
order_reservation = OrderReservation.where("status='new'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation
end
end
end
def self.check_order_send_to_kitchen
today = Time.now.utc
order_reservation = OrderReservation.where("status='accepted' and requested_time > '#{today}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation
end
end
end
def self.check_order_ready_to_delivery
today = Time.now.utc
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time > '#{today}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation
end
end
end
private
def generate_custom_id
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")