This commit is contained in:
Myat Zin Wai Maw
2020-01-15 12:19:27 +06:30
parent 0d2bc27792
commit bad510c6b4
2 changed files with 36 additions and 41 deletions

View File

@@ -96,50 +96,45 @@ class Api::OrdersController < Api::ApiController
end end
} }
#end extra time #end extra time
Order.transaction do
# begin # begin
@order = Order.new @order = Order.new
@order.source = params[:order_source] @order.source = params[:order_source]
@order.order_type = params[:order_type] @order.order_type = params[:order_type]
@order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile @order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
@order.items = params[:order_items] @order.items = params[:order_items]
@order.guest = params[:guest_info] @order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id @order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
@order.new_booking = true @order.new_booking = true
else @order.waiters = current_login_employee.name
@order.new_booking = false @order.employee_name = current_login_employee.name
@order.booking_id = booking.booking_id
end
@status, @booking = @order.generate @order.is_extra_time = is_extra_time
@order.extra_time = extra_time
if @status && @booking #Create Table Booking or Room Booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source) if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
if @order.source == 'app' @order.new_booking = true
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee) else
end @order.new_booking = false
@order.booking_id = booking.booking_id
end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
if @order.source == 'app'
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
end
end
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
end end
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
# # for parallel order
# remoteIP = ""
# begin
# @status, @booking = @order.generate
# remoteIP = request.remote_ip
# end while request.remote_ip != remoteIP
else else
return return_json_status_with_code(406, "Checkout time is over!") return return_json_status_with_code(406, "Checkout time is over!")
end end

View File

@@ -159,7 +159,7 @@ class Sale < ApplicationRecord
}) })
end end
end end
puts sale.sale_items.to_json
sale.orders << booking.orders sale.orders << booking.orders
sale.customer_id = booking.orders[0].customer_id sale.customer_id = booking.orders[0].customer_id