diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 2e11eaab..c88cee80 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -13,6 +13,20 @@ class TrainingsController < ApplicationController before_filter :check_training_type, only: [:enroll] before_filter :check_current_training, only: [:show, :update, :pay, :pay_js, :update_payinfo, :result] + # TODO: 测试完成后删除 + ALLOW_OPENID_LIST = [ + 'o5fSc08-NDxC2564k9USCuiuC9cY', + 'o5fSc097mQbwhYVLK9DAIa3uz_ug', + 'o5fSc0607iR3rp4-h_VnuBTp8CiM', + 'o5fSc0-nX6bUGQNQt3FrRhUKVNIw', + 'o5fSc0607iR3rp4-h_VnuBTp8CiM' + ] + before_filter :check_openid, only: [:update_payinfo] + def check_openid + return if ALLOW_OPENID_LIST.include?(session[:wechat_open_id]) + render plain: '暂未开放' + end + layout 'base_trainings' def show @@ -23,6 +37,9 @@ class TrainingsController < ApplicationController return end + # TODO: 测试完成后删除 + @test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id]) + render 'trainingsInfo' end @@ -43,6 +60,9 @@ class TrainingsController < ApplicationController @training.training_payinfo.fee = @training.registration_fee @training.training_payinfo.pay_type = params[:pay_type].presence || 3 end + + # TODO: 测试完成后删除 + @test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id]) end def pay_callback @@ -148,9 +168,13 @@ class TrainingsController < ApplicationController training_info.save! + # TODO: 测试完成后删除 + @test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id]) + if params[:js] == 'true' && training_info.not_payed? Rails.logger.info("### start wechat pay => fee: #{training_info.fee}") - _pay_js(training_info.fee) + # TODO: 测试完成后删除 + _pay_js(@test_wxpay ? 0.01 : training_info.fee) else redirect_to result_training_path(id: friendly_id) end diff --git a/app/views/trainings/_upload_img.html.erb b/app/views/trainings/_upload_img.html.erb index 7eebaffe..7cd7056a 100644 --- a/app/views/trainings/_upload_img.html.erb +++ b/app/views/trainings/_upload_img.html.erb @@ -1,5 +1,5 @@ <% disabled ||= false %> -