check checkout time and server time when order from api
This commit is contained in:
@@ -49,7 +49,9 @@ 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
|
||||
#for extratime
|
||||
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
@@ -64,7 +66,8 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
#end extra time
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@@ -119,13 +122,16 @@ class Api::OrdersController < Api::ApiController
|
||||
# @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
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
message: msg
|
||||
# booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
@@ -174,4 +180,18 @@ class Api::OrdersController < Api::ApiController
|
||||
:customer_id,:guest_info, :table_id, :room_id,
|
||||
order_items: [:item_code, :qty, :option, :remark])
|
||||
end
|
||||
|
||||
#checked checkin and checkout time
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
today = Time.now.utc
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if !booking.nil?
|
||||
checkout_time = booking.checkout_at.utc
|
||||
if checkout_time <= today
|
||||
status = false
|
||||
end
|
||||
end
|
||||
return status
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user