diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 02a3255d..948d97be 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -63,10 +63,9 @@ class TrainingsController < ApplicationController return end - @training.training_payinfo ||= begin - payinfo = TrainingPayinfo.new - payinfo.fee = @training.registration_fee # 默认值价格不对 - payinfo + if @training.training_payinfo.blank? + @training.build_training_payinfo + @training.training_payinfo.fee = @training.registration_fee end end diff --git a/app/views/trainings/pay.html.erb b/app/views/trainings/pay.html.erb index 0fe3bd89..5b683b30 100644 --- a/app/views/trainings/pay.html.erb +++ b/app/views/trainings/pay.html.erb @@ -142,10 +142,11 @@ // 2 支付宝支付 // 3 银行卡支付 // payType: <%#= @training.training_payinfo.pay_type.to_i %>, + newPayinfo: <%= @training.training_payinfo.new_record? %>, payType: 3, //发票抬头 //为空则代表不需要发票 - invoiceTitle: '<%= @training.training_payinfo.invoice_title %>', + invoiceTitle: '<%= @training.training_payinfo.invoice_title || @training.school %>', //税号 invoiceNo: '<%= @training.training_payinfo.invoice_no %>' }; @@ -305,13 +306,15 @@ function InitBill(userInfo){ var index=0; $("#billDemand").html("单位").attr("status",0); - if(userInfo.invoiceTitle == "" && userInfo.invoiceNo == ""){ + if (!userInfo.newPayinfo) { + if(userInfo.invoiceTitle == "" && userInfo.invoiceNo == ""){ index=2; $("#billDemand").html("不需要").attr("status",2); - } - if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){ + } + if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){ index=1; $("#billDemand").html("个人").attr("status",1); + } } $(".billType li").removeClass("active"); $(".billType li").eq(index).addClass("active");