update oqs action cable for order cahnnel and oqs channel

This commit is contained in:
Aung Myo
2017-09-05 09:41:05 +06:30
parent d715809b20
commit eeb2a91ce9
12 changed files with 261 additions and 108 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")