promotions product issue and membership setting checked

This commit is contained in:
Aung Kyaw Phyoe
2019-02-08 14:07:18 +06:30
parent 8112ee95f1
commit d7d437e1d9
5 changed files with 50 additions and 37 deletions

View File

@@ -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)

View File

@@ -56,38 +56,43 @@ class Customer < ApplicationRecord
end
def self.get_membership_transactions(customer,receipt_no = nil)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_transactions")
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)
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
memberaction = MembershipAction.active.find_by_membership_type("get_member_transactions")
if !membership.nil? && !memberaction.nil?
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)
begin
response = HTTParty.get(url,
:body => { membership_id: customer.membership_id,
receipt_no:receipt_no,
merchant_uid:merchant_uid,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: "Can't open membership server " }
begin
response = HTTParty.get(url,
:body => { membership_id: customer.membership_id,
receipt_no:receipt_no,
merchant_uid:merchant_uid,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: "Can't open membership server " }
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."}
end
Rails.logger.debug "get membership transactions !!!!!!!"
Rails.logger.debug response
return response;
end

View File

@@ -1,2 +1,3 @@
class MembershipAction < ApplicationRecord
scope :active, -> { where(is_active: true) }
end

View File

@@ -1,3 +1,5 @@
class MembershipSetting < ApplicationRecord
scope :active, -> { where(is_active: true) }
MembershipSetting = MembershipSetting.find_by_id(1)
end

View File

@@ -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")