sync order
This commit is contained in:
@@ -74,7 +74,7 @@ authorize_resource :class => false
|
|||||||
@orders, @order_items = Booking.get_sync_data(params[:sale_id])
|
@orders, @order_items = Booking.get_sync_data(params[:sale_id])
|
||||||
|
|
||||||
# Here comes to call the sync api
|
# Here comes to call the sync api
|
||||||
url = "http://192.168.1.187:3000/api/sync_records"
|
url = "http://192.168.1.176:3000/en/api/sync_data"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@result = HTTParty.post(url.to_str,
|
@result = HTTParty.post(url.to_str,
|
||||||
@@ -83,7 +83,7 @@ authorize_resource :class => false
|
|||||||
}.to_json,
|
}.to_json,
|
||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Authorization' => 'bearer 88fa8a47ba8b52a43cbc'
|
'Authorization' => 'Bearer 698bd32190e86d076325'
|
||||||
}, :timeout => 10,
|
}, :timeout => 10,
|
||||||
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
||||||
:verify => false )
|
:verify => false )
|
||||||
|
|||||||
@@ -563,19 +563,20 @@ class Order < ApplicationRecord
|
|||||||
def self.sync_order_records(orders)
|
def self.sync_order_records(orders)
|
||||||
if !orders.nil?
|
if !orders.nil?
|
||||||
orders.each do |o|
|
orders.each do |o|
|
||||||
unless Order.exists?(o.order_id)
|
unless Order.exists?(o['order_id'])
|
||||||
order = Order.new()
|
order = Order.new
|
||||||
order.order_id = o.order_id
|
order.order_id = o['order_id']
|
||||||
order.date = o.date
|
order.date = o['date']
|
||||||
order.source = o.source
|
order.source = o['source']
|
||||||
order.order_type = o.order_type
|
order.order_type = o['order_type']
|
||||||
order.customer_id = o.customer_id
|
order.customer_id = o['customer_id']
|
||||||
order.item_count = o.item_count
|
order.item_count = o['item_count']
|
||||||
order.quantity_count = o.quantity_count
|
order.quantity_count = o['quantity_count']
|
||||||
order.status = o.status
|
order.status = o['status']
|
||||||
order.waiters = o.waiters
|
order.waiters = o['waiters']
|
||||||
order.guest_info = o.guest_info
|
order.guest_info = o['guest_info']
|
||||||
order.save
|
order.save
|
||||||
|
puts '...... order has been created .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,25 +68,26 @@ class OrderItem < ApplicationRecord
|
|||||||
def self.sync_order_item_records(order_items)
|
def self.sync_order_item_records(order_items)
|
||||||
if !order_items.nil?
|
if !order_items.nil?
|
||||||
order_items.each do |item|
|
order_items.each do |item|
|
||||||
unless OrderItem.exists?(item.order_items_id)
|
unless OrderItem.exists?(item['order_items_id'])
|
||||||
order_item = OrderItem.new()
|
order_item = OrderItem.new
|
||||||
order_item.order_items_id = item.order_items_id
|
order_item.order_items_id = item['order_items_id']
|
||||||
order_item.order_id = item.order_id
|
order_item.order_id = item['order_id']
|
||||||
order_item.order_item_status = item.order_item_status
|
order_item.order_item_status = item['order_item_status']
|
||||||
order_item.item_order_by = item.item_order_by
|
order_item.item_order_by = item['item_order_by']
|
||||||
order_item.item_code = item.item_code
|
order_item.item_code = item['item_code']
|
||||||
order_item.item_instance_code = item.item_instance_code
|
order_item.item_instance_code = item['item_instance_code']
|
||||||
order_item.item_name = item.item_name
|
order_item.item_name = item['item_name']
|
||||||
order_item.alt_name = item.alt_name
|
order_item.alt_name = item['alt_name']
|
||||||
order_item.account_id = item.account_id
|
order_item.account_id = item['account_id']
|
||||||
order_item.qty = item.qty
|
order_item.qty = item['qty']
|
||||||
order_item.price = item.price
|
order_item.price = item['price']
|
||||||
order_item.remark = item.remark
|
order_item.remark = item['remark']
|
||||||
order_item.options = item.options
|
order_item.options = item['options']
|
||||||
order_item.set_menu_items = item.set_menu_items
|
order_item.set_menu_items = item['set_menu_items']
|
||||||
order_item.taxable = item.taxable
|
order_item.taxable = item['taxable']
|
||||||
order_item.completed_by = item.completed_by
|
order_item.completed_by = item['completed_by']
|
||||||
order_item.save
|
order_item.save
|
||||||
|
puts '...... order item has been created. .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
application_path="#{File.expand_path("../..", __FILE__)}"
|
application_path="#{File.expand_path("../..", __FILE__)}"
|
||||||
directory application_path
|
directory application_path
|
||||||
#environment ENV.fetch("RAILS_ENV") { "production" }
|
#environment ENV.fetch("RAILS_ENV") { "production" }
|
||||||
|
|||||||
Reference in New Issue
Block a user