fixed conflict

This commit is contained in:
Nweni
2019-12-02 17:43:02 +06:30
118 changed files with 14390 additions and 190 deletions

View File

@@ -61,77 +61,89 @@ class Api::OrdersController < Api::ApiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
@shop = Shop.find_by_shop_code(params[:shop_code])
current_shift = ShiftSale.current_shift(@shop.shop_code)
if current_shift.nil?
@status = false
@message = "No Current Open Shift for This Employee"
else
current_user =Employee.find(current_shift.employee_id)
if checkin_checkout_time(params[:booking_id])
if checkin_checkout_time(params[:booking_id])
if params[:booking_id].present?
booking = Booking.find(params[:booking_id])
end
if params[:table_id].present?
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
table = DiningFacility.find(params[:table_id])
booking = table.get_current_booking
if params[:booking_id].present?
booking = Booking.find(params[:booking_id])
end
if params[:table_id].present?
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
table = DiningFacility.find(params[:table_id])
booking = table.get_current_booking
end
end
end
#for extratime
is_extra_time = false
extra_time = ''
#for extratime
is_extra_time = false
extra_time = ''
params[:order_items].each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
params[:order_items].each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
}
#end extra time
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items]
@order.guest = params[:guest_info]
@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.shop_code =@shop.shop_code
@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
else
@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)
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
if current_user.role != "waiter" && params[:create_type] == "create_pay"
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
@status, @sale = Sale.request_bill(@order,current_user,current_user)
end
end
}
#end extra time
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items]
@order.guest = params[:guest_info]
@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
else
@order.new_booking = false
@order.booking_id = booking.booking_id
return return_json_status_with_code(406, "Checkout time is over!")
end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
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
return return_json_status_with_code(406, "Checkout time is over!")
end
end