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
|
def create
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].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
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
|
|
||||||
@@ -64,7 +66,8 @@ class Api::OrdersController < Api::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
#end extra time
|
#end extra time
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@@ -119,13 +122,16 @@ class Api::OrdersController < Api::ApiController
|
|||||||
# @status, @booking = @order.generate
|
# @status, @booking = @order.generate
|
||||||
# remoteIP = request.remote_ip
|
# remoteIP = request.remote_ip
|
||||||
# end while request.remote_ip != remoteIP
|
# end while request.remote_ip != remoteIP
|
||||||
|
else
|
||||||
|
return return_json_status_with_code(406, "Checkout time is over!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# render json for http status code
|
# render json for http status code
|
||||||
def return_json_status_with_code(code, msg)
|
def return_json_status_with_code(code, msg)
|
||||||
render status: code, json: {
|
render status: code, json: {
|
||||||
message: msg,
|
message: msg
|
||||||
booking_id: booking_id
|
# booking_id: booking_id
|
||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,4 +180,18 @@ class Api::OrdersController < Api::ApiController
|
|||||||
:customer_id,:guest_info, :table_id, :room_id,
|
:customer_id,:guest_info, :table_id, :room_id,
|
||||||
order_items: [:item_code, :qty, :option, :remark])
|
order_items: [:item_code, :qty, :option, :remark])
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user