training: add offline pay

dev_trainings
p31729568 6 years ago
parent 6c3054f8a4
commit 3ac89e3f65

@ -57,7 +57,11 @@ class TrainingsController < ApplicationController
return return
end end
@training.training_payinfo ||= TrainingPayinfo.new @training.training_payinfo ||= begin
payinfo = TrainingPayinfo.new
payinfo.fee = @training.registration_fee # 默认值价格不对
payinfo
end
end end
def pay_callback def pay_callback
@ -114,8 +118,7 @@ class TrainingsController < ApplicationController
flash[:message] = '提交成功' flash[:message] = '提交成功'
redirect_to enroll_training_path(id: @tag_id) redirect_to pay_training_path(id: @tag_id)
# redirect_to pay_training_path(id: @tag_id)
end end
@ -134,8 +137,7 @@ class TrainingsController < ApplicationController
flash[:message] = '提交成功' flash[:message] = '提交成功'
redirect_to enroll_training_path(id: @tag_id) redirect_to pay_training_path(id: @tag_id)
# redirect_to pay_training_path(id: @tag_id)
end end
@ -163,7 +165,7 @@ class TrainingsController < ApplicationController
training_info = TrainingPayinfo.new(params) training_info = TrainingPayinfo.new(params)
end end
training_info.num = params[:enlistN].to_i < 1 ? 1 : params[:enlistN].to_i training_info.num = params[:enlistNum].to_i < 1 ? 1 : params[:enlistNum].to_i
training_info.fee = @training.registration_fee(training_info.num) training_info.fee = @training.registration_fee(training_info.num)

@ -152,58 +152,26 @@
name="position" name="position"
value="<%= @training.position %>"/> value="<%= @training.position %>"/>
</li> </li>
<% if @training_type == 3 %>
<p class="subtitle">您的授课/研究领域最少选1项</p>
<li class="clearfix infoBar">
<span class="left_tag fl">机器学习/深度学习</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="机器学习/深度学习" <%= @training.research_field_include?("机器学习/深度学习") ? "checked" : "" %> id="check_1" class="magic-checkbox">
<label for="check_1" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机结构与组成</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机结构与组成" <%= @training.research_field_include?("计算机结构与组成") ? "checked" : "" %> id="check_2" class="magic-checkbox">
<label for="check_2" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机系统</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机系统" <%= @training.research_field_include?("计算机系统") ? "checked" : "" %> id="check_3" class="magic-checkbox">
<label for="check_3" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机软件技术和应用</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机软件技术和应用" <%= @training.research_field_include?("计算机软件技术和应用") ? "checked" : "" %> id="check_4" class="magic-checkbox">
<label for="check_4" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机理论</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机理论" <%= @training.research_field_include?("计算机理论") ? "checked" : "" %> id="check_5" class="magic-checkbox">
<label for="check_5" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar"> <li class="clearfix infoBar">
<span class="left_tag fl">计算机应用与学科交叉</span> <span class="left_tag fl">手机号码</span>
<span class="fr"> <input type="text" class="right_input" placeholder="请输入手机号" id="userphone"
<input type="checkbox" name="research_field[]" value="计算机应用与学科交叉" <%= @training.research_field_include?("计算机应用与学科交叉") ? "checked" : "" %> id="check_6" class="magic-checkbox"> name="phone"
<label for="check_6" style="top:8px">&nbsp;</label> value="<%= @training.phone %>"/>
</span>
</li> </li>
<% if @training_type == 3 %>
<p class="subtitle">您关注的课程类型最少选1项</p>
<% %w(程序设计 操作系统 数据库 软件工程 云计算 大数据 人工智能 计算机网络 物联网 信息安全 其他).each_with_index do |name, index| %>
<li class="clearfix infoBar"> <li class="clearfix infoBar">
<span class="left_tag fl">其他</span> <span class="left_tag fl"><%= name %></span>
<span class="fr"> <span class="fr">
<input type="checkbox" name="research_field[]" value="其他" <%= @training.research_field_include?("其他") ? "checked" : "" %> id="check_7" class="magic-checkbox"> <input type="checkbox" name="research_field[]" value="<%= name %>" <%= @training.research_field_include?(name) ? "checked" : "" %> id="check_<%= index %>" class="magic-checkbox">
<label for="check_7" style="top:8px">&nbsp;</label> <label for="check_<%= index %>" style="top:8px">&nbsp;</label>
</span> </span>
</li> </li>
<% end %> <% end %>
<% end %>
<!-- <p class="subtitle">通讯地址</p>--> <!-- <p class="subtitle">通讯地址</p>-->
<!-- <li class="clearfix infoBar">--> <!-- <li class="clearfix infoBar">-->
@ -214,12 +182,6 @@
<!-- </div>--> <!-- </div>-->
<!-- <textarea class="DetailAddress" placeholder="请输入详细地址" name="address" id="DetailAdd" style="margin-top: 15px;"><%#= @training.address %></textarea>--> <!-- <textarea class="DetailAddress" placeholder="请输入详细地址" name="address" id="DetailAdd" style="margin-top: 15px;"><%#= @training.address %></textarea>-->
<!-- </li>--> <!-- </li>-->
<li class="clearfix infoBar">
<span class="left_tag fl">手机号码</span>
<input type="text" class="right_input" placeholder="请输入手机号" id="userphone"
name="phone"
value="<%= @training.phone %>"/>
</li>
<!-- <li class="clearfix infoBar">--> <!-- <li class="clearfix infoBar">-->
<!-- <span class="left_tag fl">Email</span>--> <!-- <span class="left_tag fl">Email</span>-->
<!-- <input type="text" class="right_input" placeholder="请输入Email" id="userEmail" name="email" value="<%#= @training.email %>"/>--> <!-- <input type="text" class="right_input" placeholder="请输入Email" id="userEmail" name="email" value="<%#= @training.email %>"/>-->
@ -259,30 +221,23 @@
//下一步 //下一步
function NextStep() { function NextStep() {
var username = $("#username").val(); var username = $("#username").val();
var userMajor = $("#userMajor").val(); var userUnit = $("#userUnit").val();
var userPositional = $("#userPositional").val();
var userphone = $("#userphone").val(); var userphone = $("#userphone").val();
var userID = $("#userID").val();
if (username == '') { if (username == '') {
alert("请输入真实姓名"); alert("请输入姓名");
return;
}
if (userMajor == '') {
alert("请输入专业");
return; return;
} }
if (userUnit == '') {
if (userID == '') { alert("请输入单位名称或者学校");
alert("请输入学号");
return; return;
} }
<% if @training_type == 3 %> if (userPositional == '') {
if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) { alert("请输入职称");
alert('请选择授课类型/研究领域');
return; return;
} }
<% end %>
if (userphone == '') { if (userphone == '') {
alert("请输入手机号码"); alert("请输入手机号码");
@ -292,6 +247,13 @@
return; return;
} }
<% if @training_type == 3 %>
if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) {
alert('请选择您关注的课程类型');
return;
}
<% end %>
$('form').submit(); $('form').submit();
} }

@ -1,13 +1,16 @@
<form action="/trainings/update_payinfo" method="post" accept-charset="UTF-8" enctype="multipart/form-data"> <form action="/trainings/update_payinfo" method="post" accept-charset="UTF-8" enctype="multipart/form-data">
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<%= hidden_field_tag(:tag_id, params[:id]) %> <%= hidden_field_tag(:tag_id, params[:id]) %>
<div class="showPanel" id="payTypeLine" NavShow> <!-- <div class="showPanel" id="payTypeLine" NavShow>-->
<div class="showPanel" id="payTypeLine">
<p class="clearfix pr"> <p class="clearfix pr">
<label>支付方式</label> <label>支付方式</label>
<span class="mr5" style="margin-right: 24px;" id="payTypeName"><%= @training.training_payinfo.pay_type.to_i == 3 ? "线下支付" : "微信支付" %></span> <!-- <span class="mr5" style="margin-right: 24px;" id="payTypeName"><%#= @training.training_payinfo.pay_type.to_i == 3 ? "线下支付" : "微信支付" %></span>-->
<span class="mr5" style="margin-right: 24px;">线下支付</span>
<i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 4px"></i> <i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 4px"></i>
</p> </p>
<div class="<%= @training.training_payinfo.pay_type.to_i == 3 ? "" : "none" %> mt5" id="payInfos"> <!-- <div class="<%#= @training.training_payinfo.pay_type.to_i == 3 ? "" : "none" %> mt5" id="payInfos">-->
<div class="mt5" id="payInfos">
<div class="payInfo df"> <div class="payInfo df">
<span class="fl accountIcon"> <span class="fl accountIcon">
<i class="iconfont icon-yinhangqia blue"></i> <i class="iconfont icon-yinhangqia blue"></i>
@ -57,15 +60,15 @@
</p> </p>
<p class="break-word justify moneyDetail">含会议注册费、场地费、培训费、教材资料费、餐费、专家差率费等</p> <p class="break-word justify moneyDetail">含会议注册费、场地费、培训费、教材资料费、餐费、专家差率费等</p>
<p class="clearfix"> <p class="clearfix">
<input type="hidden" name="enlistNum" value="1"/> <input type="hidden" name="enlistNum" value="<%= @training.training_payinfo.num || 1 %>"/>
<input type="hidden" name="enlistMoney" value="<%= @training.registration_fee %>"/> <input type="hidden" name="enlistMoney" value="<%= @training.training_payinfo.fee || @training.registration_fee %>"/>
<span class="fl red mr5 font-16">¥<span id="enlistM"><%= @training.registration_fee %></span></span> <span class="fl red mr5 font-16">¥<span id="enlistM"><%= @training.training_payinfo.fee || @training.registration_fee %></span></span>
<span class="lastPrice"></span> <span class="lastPrice"></span>
<span class="fr font-16"> <span class="fr font-16">
<a href="javascript:void(0)" class="minusNum" onclick="minusNum(this)"> <a href="javascript:void(0)" class="minusNum" onclick="minusNum(this)">
<i class="iconfont icon-default sky_blue font-18"></i> <i class="iconfont icon-default sky_blue font-18"></i>
</a> </a>
<span class="mr5 ml5 font-14"><span id="enlistN">1</span>人</span> <span class="mr5 ml5 font-14"><span id="enlistN"><%= @training.training_payinfo.num || 1 %></span>人</span>
<a href="javascript:void(0)" class="plusNum" onclick="plusNum(this)"> <a href="javascript:void(0)" class="plusNum" onclick="plusNum(this)">
<i class="iconfont icon-roundaddfill blue font-18"></i> <i class="iconfont icon-roundaddfill blue font-18"></i>
</a> </a>
@ -73,12 +76,12 @@
</p> </p>
</div> </div>
<p style="height: 44px;"></p> <p style="height: 44px;"></p>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i ==3 ? "" : "none" %>" id="offlinePaySubmitBtn"> <div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "none" : "" %>" id="offlinePaySubmitBtn">
<a href="<%= enroll_training_path(id: @tag_id) %>" class="leftbtn">返回</a> <a href="<%= enroll_training_path(id: @tag_id) %>" class="leftbtn">稍后支付</a>
<a href="javascript:void(0)" class="rightbtn" id="submitFormBtn">提交</a> <a href="javascript:void(0)" class="rightbtn" id="submitFormBtn">立即支付</a>
</div> </div>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i ==3 ? "none" : "" %>" id="paySubmitBtn"> <div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "" : "none" %>" id="paySubmitBtn">
<a href="<%= enroll_training_path(id: @tag_id) %>" class="leftbtn">返回</a> <a href="<%= enroll_training_path(id: @tag_id) %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="payBtn">立即支付</a> <a href="javascript:void(0)" class="rightbtn" id="payBtn">立即支付</a>
</div> </div>
@ -120,7 +123,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<input type="hidden" id="pay_type" name="pay_type" value="<%= @training.training_payinfo.pay_type.presence || 1 %>"> <input type="hidden" id="pay_type" name="pay_type" value="<%= @training.training_payinfo.pay_type.presence || 3 %>">
</form> </form>
<!--<script src="https://cdn.jsdelivr.net/npm/eruda" type="text/javascript"></script>--> <!--<script src="https://cdn.jsdelivr.net/npm/eruda" type="text/javascript"></script>-->
@ -136,7 +139,8 @@
// 1 微信支付 // 1 微信支付
// 2 支付宝支付 // 2 支付宝支付
// 3 银行卡支付 // 3 银行卡支付
payType: <%= @training.training_payinfo.pay_type.to_i %>, // payType: <%#= @training.training_payinfo.pay_type.to_i %>,
payType: 3,
//发票抬头 //发票抬头
//为空则代表不需要发票 //为空则代表不需要发票
invoiceTitle: '<%= @training.training_payinfo.invoice_title %>', invoiceTitle: '<%= @training.training_payinfo.invoice_title %>',

@ -29,6 +29,14 @@
</div>--> </div>-->
<div class="showPanel"> <div class="showPanel">
<p class="clearfix">
<label>报名人数</label>
<span><%= @training.training_payinfo.num %>人 </span>
</p>
<p class="clearfix">
<label>支付金额</label>
<span class="red" style="font-weight: bold;">¥<%= @training.training_payinfo.fee %> </span>
</p>
<p class="clearfix"> <p class="clearfix">
<label>支付状态</label> <label>支付状态</label>
<span class="red" style="font-weight: bold;"><%= @training.training_payinfo.pay_status_str %> </span> <span class="red" style="font-weight: bold;"><%= @training.training_payinfo.pay_status_str %> </span>
@ -85,8 +93,10 @@
<!--图片上传--> <!--图片上传-->
<%= render :partial => 'upload_img', :locals => {:training => @training} %> <%= render :partial => 'upload_img', :locals => {:training => @training} %>
<% end %> <% end %>
<p class="sendMoney clearfix"><span class="red font-16 fr">¥<%= @training.training_payinfo.fee %></span><span class="mr5 font-12 fr"><%= @training.training_payinfo.num %>人</span></p> <!-- <p class="sendMoney clearfix"><span class="red font-16 fr">¥<%#= @training.training_payinfo.fee %></span><span class="mr5 font-12 fr"><%#= @training.training_payinfo.num %>人</span></p>-->
</div> </div>
<br/>
<br/>
<!-- <p class="clearfix enrollNum"> <!-- <p class="clearfix enrollNum">
<%#= link_to '查看会议信息', training_path(id: 'bigdata_hnjcxy_2019', force: true), class:'fl meetInfo' %> <%#= link_to '查看会议信息', training_path(id: 'bigdata_hnjcxy_2019', force: true), class:'fl meetInfo' %>
<span class="fr">已报名人数:<%#= TrainingPayinfo.total_num %>人</span> <span class="fr">已报名人数:<%#= TrainingPayinfo.total_num %>人</span>

Loading…
Cancel
Save