check customer
This commit is contained in:
@@ -2,31 +2,13 @@ class Api::OrderReservation::OrderReservationController < Api::ApiController
|
|||||||
# skip_before_action :authenticate
|
# skip_before_action :authenticate
|
||||||
|
|
||||||
def check_customer
|
def check_customer
|
||||||
customer_name = params[:name]
|
|
||||||
customer_email = params[:email]
|
|
||||||
customer_contact_no = params[:contact_no]
|
|
||||||
customer_gender = params[:gender]
|
|
||||||
customer_addr = params[:address]
|
|
||||||
customer_membership_id = params[:membership_id]
|
|
||||||
customer_date_of_birth = params[:date_of_birth]
|
|
||||||
customer_id = 0
|
customer_id = 0
|
||||||
|
|
||||||
check_customer = Customer.find_by_email_and_contact_no_and_membership_id(customer_email,customer_contact_no,customer_membership_id)
|
check_customer = Customer.find_by_email_and_contact_no_and_membership_id(params[:email],params[:contact_no],params[:membership_id])
|
||||||
if !check_customer.nil?
|
if !check_customer.nil?
|
||||||
customer_id = check_customer.customer_id
|
customer_id = check_customer.customer_id
|
||||||
else
|
else
|
||||||
customer = Customer.new
|
customer = Customer.addCustomer(params)
|
||||||
customer.name = customer_name
|
|
||||||
customer.email = customer_email
|
|
||||||
customer.contact_no = customer_contact_no
|
|
||||||
customer.gender = customer_gender
|
|
||||||
customer.address = customer_addr
|
|
||||||
customer.date_of_birth = Time.parse(customer_date_of_birth).strftime("%Y-%m-%d")
|
|
||||||
customer.membership_id = customer_membership_id
|
|
||||||
customer.customer_type = "Doemal"
|
|
||||||
customer.tax_profiles = ["2"]
|
|
||||||
customer.save
|
|
||||||
|
|
||||||
customer_id = customer.id
|
customer_id = customer.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -352,6 +352,23 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#new customer for doemal
|
||||||
|
def self.addCustomer(params)
|
||||||
|
customer = Customer.new
|
||||||
|
customer.name = params[:name]
|
||||||
|
customer.email = params[:email]
|
||||||
|
customer.contact_no = params[:contact_no]
|
||||||
|
customer.gender = params[:gender]
|
||||||
|
customer.address = params[:address]
|
||||||
|
customer.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"
|
WALKIN = "CUS-000000000001"
|
||||||
TAKEAWAY = "CUS-000000000002"
|
TAKEAWAY = "CUS-000000000002"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user