Merge branch 'oqs' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-09-05 14:14:10 +06:30
24 changed files with 298 additions and 121 deletions

View File

@@ -17,6 +17,29 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.save
end
def self.assigned_order_item_by_job(order_id)
order_item = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
assigned_order_items.order_queue_station_id,
oqs.id as station_id, oqs.station_name,
oqs.is_active, oqpz.zone_id,
df.name as zone, df.type as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options,
cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.order_id = '#{order_id}' AND assigned_order_items.delivery_status = false AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
.order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id")
return order_item
end
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")

View File

@@ -49,7 +49,7 @@ class Order < ApplicationRecord
process_order_queue
#send order to broadcast job
#send_order_broadcast
send_order_broadcast(booking)
return true, booking
@@ -214,9 +214,10 @@ class Order < ApplicationRecord
#send order items and send to order queue
def send_order_broadcast
def send_order_broadcast(booking)
table = DiningFacility.find(booking.dining_facility_id)
#Send to background job for processing
OrderBroadcastJob.perform_later(self.id)
OrderBroadcastJob.perform_later(table)
end
#Origami: Cashier : to view order Table