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