From f7588bd8d99050c966a45b49878389aec1c4ac68 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 26 Jul 2017 16:42:51 +0630 Subject: [PATCH] update member for already register member --- app/controllers/crm/customers_controller.rb | 13 ++++++++++++- lib/tasks/menu_import.rake | 12 ++++++------ lib/tasks/menu_osaka.rake | 12 ++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index c0123945..c819af7b 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -224,7 +224,12 @@ end else customer = Customer.find(@crm_customer.customer_id) - status = customer.update_attributes(membership_type:member_group_id ) + # Check membership id and bind to user + if response["membership_id"] != nil + status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + else + status = customer.update_attributes(membership_type:member_group_id) + end format.html { redirect_to crm_customers_path, notice: response["error"] } end @@ -262,6 +267,12 @@ end format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } format.json { render :show, status: :ok, location: @crm_customer } else + # Check membership id and bind to user + if response["membership_id"] != nil + status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + else + status = customer.update_attributes(membership_type:member_group_id) + end format.html { redirect_to crm_customers_path, notice: response["message"] } end diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 61234dd9..cdf175bf 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -636,7 +636,7 @@ zone3 = Zone.create({id:3, name: "H3", is_active:true, created_by: "SYSTEM DEFAU table = Table.create({name:"77", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) table = Table.create({name:"78", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://membership.paypar.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, @@ -650,11 +650,11 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"get_member_campaign",gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:6},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, ]) -payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://membership.paypar.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) #Default Order Queue stations order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"}) diff --git a/lib/tasks/menu_osaka.rake b/lib/tasks/menu_osaka.rake index 313c8974..941494aa 100644 --- a/lib/tasks/menu_osaka.rake +++ b/lib/tasks/menu_osaka.rake @@ -896,7 +896,7 @@ zone3 = Zone.create({id:3, name: "H3", is_active:true, created_by: "SYSTEM DEFAU table = Table.create({zone: zone3, name:"34", status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) table = Table.create({zone: zone3, name:"35", status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"am-15QFGS9xGBxDrV6bV"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"am-15QFGS9xGBxDrV6bV"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"am-15QFGS9xGBxDrV6bV",auth_token:"code2lab"}, {membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"am-15QFGS9xGBxDrV6bV",auth_token:"code2lab"}, @@ -910,11 +910,11 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"get_member_campaign",gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:6},merchant_account_id:"am-15QFGS9xGBxDrV6bV",auth_token:"code2lab"}, ]) -payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"am-15QFGS9xGBxDrV6bV"}) +payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://staging.membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://staging.membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://staging.membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://staging.membership.paypar.ws"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"am-15QFGS9xGBxDrV6bV"}) #Default Order Queue stations order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['I0001','I0002','I0003','I0004']), print_copy:false, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})