membership setting
This commit is contained in:
@@ -103,9 +103,10 @@ class Settings::PromotionsController < ApplicationController
|
||||
arr_inst = []
|
||||
item_inst = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
||||
if item_inst.nil?
|
||||
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
|
||||
res.push(product.name)
|
||||
res.push(product.item_code)
|
||||
product = Product.where("item_code = ?",params[:item_instance_code])
|
||||
product.each do |pdt|
|
||||
res.push({pdt.item_code => pdt.name})
|
||||
end
|
||||
else
|
||||
# menu_item = item_inst.menu_item.pluck(:name,:item_code)
|
||||
# res.push(item_inst.item_instance_name)
|
||||
|
||||
@@ -18,36 +18,39 @@ class Customer < ApplicationRecord
|
||||
paginates_per 50
|
||||
|
||||
def self.get_member_account(customer)
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
|
||||
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
# urltest =self.url_exist?(url)
|
||||
if !membership.nil? && !memberaction.nil?
|
||||
begin
|
||||
response = HTTParty.get(url, :body => {
|
||||
membership_id: customer.membership_id,
|
||||
merchant_uid:merchant_uid,
|
||||
type: "summary",
|
||||
auth_token:auth_token
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {status: false, message: "Server Error"}
|
||||
|
||||
begin
|
||||
response = HTTParty.get(url, :body => {
|
||||
membership_id: customer.membership_id,
|
||||
merchant_uid:merchant_uid,
|
||||
type: "summary",
|
||||
auth_token:auth_token
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {status: false, message: "Server Error"}
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false , message: "Server Time out"}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false , message: "Server Time out"}
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
end
|
||||
else
|
||||
response = {status: false, message: "There is no membership setting."}
|
||||
end
|
||||
Rails.logger.debug "--------Get Member Account response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
class MembershipAction < ApplicationRecord
|
||||
scope :active, -> { where(is_active: true) }
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
class MembershipSetting < ApplicationRecord
|
||||
scope :active, -> { where(is_active: true) }
|
||||
|
||||
MembershipSetting = MembershipSetting.find_by_id(1)
|
||||
end
|
||||
|
||||
@@ -385,14 +385,18 @@
|
||||
|
||||
if(result.length > 0){
|
||||
var iteminstlists;
|
||||
$.each(arr_item_inst,function(k2,v2al){
|
||||
$("select#"+select_id).empty();
|
||||
var selected = "";
|
||||
$.each(v2al,function(k3,v3al){
|
||||
if(k3 == item_code) selected = "selected";
|
||||
iteminstlists += "<option value='"+k3+"' "+selected+">"+v3al+"</option>";
|
||||
if(arr_item_inst instanceof Array){
|
||||
$.each(arr_item_inst,function(k2,v2al){
|
||||
$("select#"+select_id).empty();
|
||||
var selected = "";
|
||||
$.each(v2al,function(k3,v3al){
|
||||
if(k3 == item_code) selected = "selected";
|
||||
iteminstlists += "<option value='"+k3+"' "+selected+">"+v3al+"</option>";
|
||||
});
|
||||
});
|
||||
});
|
||||
}else if(arr_item_inst != ""){
|
||||
iteminstlists += "<option value='"+par_item_code+"' selected>"+arr_item_inst+"</option>";
|
||||
}
|
||||
$("select#"+select_id).append(iteminstlists);
|
||||
|
||||
$("select#"+select_id).parent().parent().siblings("div.menu_item_choose").find("select").find("option[value='"+par_item_code+"']").attr("selected","true")
|
||||
|
||||
Reference in New Issue
Block a user