|
|
@ -15,6 +15,20 @@ class TrainingsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
layout 'base_trainings'
|
|
|
|
layout 'base_trainings'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: 测试完成后删除
|
|
|
|
|
|
|
|
ALLOW_OPENID_LIST = [
|
|
|
|
|
|
|
|
'oSrqE59d6uMBkANfXnJcGuUwuGds',
|
|
|
|
|
|
|
|
'oSrqE5-j3rT3f9nt4iFhSICPF1Vo',
|
|
|
|
|
|
|
|
'oSrqE5w6dtsRyjFkFBahQ1jeurTk',
|
|
|
|
|
|
|
|
'oSrqE52fgGMooW3B1K4mZ0Le5G9I',
|
|
|
|
|
|
|
|
'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
|
|
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
def show
|
|
|
|
@training = current_training
|
|
|
|
@training = current_training
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +37,9 @@ class TrainingsController < ApplicationController
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: 测试完成后删除
|
|
|
|
|
|
|
|
@test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id])
|
|
|
|
|
|
|
|
|
|
|
|
render 'trainingsInfo'
|
|
|
|
render 'trainingsInfo'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -50,6 +67,8 @@ class TrainingsController < ApplicationController
|
|
|
|
@training.training_payinfo.fee = @training.registration_fee
|
|
|
|
@training.training_payinfo.fee = @training.registration_fee
|
|
|
|
@training.training_payinfo.pay_type = params[:pay_type].presence || 3
|
|
|
|
@training.training_payinfo.pay_type = params[:pay_type].presence || 3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: 测试完成后删除
|
|
|
|
|
|
|
|
@test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def pay_callback
|
|
|
|
def pay_callback
|
|
|
@ -155,8 +174,12 @@ class TrainingsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
training_info.save!
|
|
|
|
training_info.save!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: 测试完成后删除
|
|
|
|
|
|
|
|
@test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id])
|
|
|
|
|
|
|
|
|
|
|
|
if params[:js] == 'true' && training_info.not_payed?
|
|
|
|
if params[:js] == 'true' && training_info.not_payed?
|
|
|
|
_pay_js(training_info.fee)
|
|
|
|
# TODO: 测试完成后删除
|
|
|
|
|
|
|
|
_pay_js(@test_wxpay ? 0.01 : training_info.fee)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
redirect_to result_training_path(id: friendly_id)
|
|
|
|
redirect_to result_training_path(id: friendly_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|