move customer func: from doemal
This commit is contained in:
@@ -22,7 +22,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
if !check_customer.nil?
|
||||
customer_id = check_customer.customer_id
|
||||
else
|
||||
customer = Customer.addCustomer(params)
|
||||
customer = OrderReservation.addCustomer(params)
|
||||
customer_id = customer.id
|
||||
end
|
||||
render :json => { :status => true, :data => { :customer_id => customer_id} }
|
||||
|
||||
@@ -352,28 +352,6 @@ class Customer < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
#new customer for doemal
|
||||
def self.addCustomer(params)
|
||||
if params[:gender] == "female"
|
||||
gender = "Female"
|
||||
else
|
||||
gender = "Male"
|
||||
end
|
||||
customer = Customer.new
|
||||
customer.name = params[:name]
|
||||
customer.email = params[:email]
|
||||
customer.contact_no = params[:contact_no] ? params[:contact_no] : ''
|
||||
customer.gender = gender
|
||||
customer.address = params[:address] ? params[:address] : ''
|
||||
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
|
||||
customer.membership_id = params[:membership_id]
|
||||
customer.customer_type = "Takeaway"
|
||||
customer.tax_profiles = ["2"]
|
||||
customer.save
|
||||
|
||||
return customer
|
||||
end
|
||||
|
||||
WALKIN = "CUS-000000000001"
|
||||
TAKEAWAY = "CUS-000000000002"
|
||||
|
||||
|
||||
@@ -15,6 +15,28 @@ class OrderReservation < ApplicationRecord
|
||||
DELIVERED = "delivered"
|
||||
COMPLETED = "completed"
|
||||
|
||||
#new customer for doemal
|
||||
def self.addCustomer(params)
|
||||
if params[:gender] == "female"
|
||||
gender = "Female"
|
||||
else
|
||||
gender = "Male"
|
||||
end
|
||||
customer = Customer.new
|
||||
customer.name = params[:name]
|
||||
customer.email = params[:email]
|
||||
customer.contact_no = params[:contact_no] ? params[:contact_no] : ''
|
||||
customer.gender = gender
|
||||
customer.address = params[:address] ? params[:address] : ''
|
||||
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
|
||||
customer.membership_id = params[:membership_id]
|
||||
customer.customer_type = "Takeaway"
|
||||
customer.tax_profiles = ["2"]
|
||||
customer.save
|
||||
|
||||
return customer
|
||||
end
|
||||
|
||||
def self.addOrderReservationInfo(order_reserve)
|
||||
Rails.logger.debug order_reserve.to_s
|
||||
check_order_reservation = OrderReservation.where("transaction_ref = ?",order_reserve[:reference])
|
||||
|
||||
Reference in New Issue
Block a user