Merge branch 'dev_trainings' into develop

dev_library
p31729568 6 years ago
commit 673e62fc55

@ -38,12 +38,6 @@ class TrainingsController < ApplicationController
def pay
@training = current_training
# 防止重复支付,对于已支付过的,不应该再到这个页来
if @training.payed?
redirect_to result_training_path(id: friendly_id)
return
end
if @training.training_payinfo.blank?
@training.build_training_payinfo
@training.training_payinfo.fee = @training.registration_fee
@ -126,27 +120,25 @@ class TrainingsController < ApplicationController
training_info = @training.training_payinfo || @training.build_training_payinfo
training_info.assign_attributes(params)
# 已支付不能修改人数
if training_info.not_payed?
training_info.num = params[:enlistNum].to_i < 1 ? 1 : params[:enlistNum].to_i
training_info.fee = @training.registration_fee(training_info.num)
end
ActiveRecord::Base.transaction do
if training_info.pay_type.to_i == TrainingPayinfo::PayType_bank
attachment = nil
attachment = Attachment.create!(file: params[:image], author: User.first) if params[:image]
if attachment.blank?
if attachment.blank? && training_info.not_payed?
flash[:message] = '请先上传支付凭证'
render 'pay'
return
end
training_info.attachment = attachment
training_info.attachment = attachment if attachment.present?
end
if training_info.not_payed?
# 已支付不能修改人数
training_info.num = params[:enlistNum].to_i < 1 ? 1 : params[:enlistNum].to_i
training_info.fee = @training.registration_fee(training_info.num)
if training_info.pay_type.to_i == TrainingPayinfo::PayType_Wechat
training_info.status = TrainingPayinfo::Status_None
else
@ -156,7 +148,7 @@ class TrainingsController < ApplicationController
training_info.save!
if params[:js] == 'true'
if params[:js] == 'true' && training_info.not_payed?
Rails.logger.info("### start wechat pay => fee: #{training_info.fee}")
_pay_js(training_info.fee)
else

@ -77,20 +77,24 @@
<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="fr font-16">
<a href="javascript:void(0)" class="minusNum" onclick="minusNum(this)">
<i class="iconfont icon-default sky_blue font-18"></i>
</a>
<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)">
<i class="iconfont icon-roundaddfill blue font-18"></i>
</a>
<% if @training.training_payinfo.not_payed? %>
<a href="javascript:void(0)" class="minusNum" onclick="minusNum(this)">
<i class="iconfont icon-default sky_blue font-18"></i>
</a>
<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)">
<i class="iconfont icon-roundaddfill blue font-18"></i>
</a>
<% else %>
<span class="mr5 ml5 font-14"><span id="enlistN"><%= @training.training_payinfo.num || 1 %></span>人</span>
<% end %>
</span>
</p>
</div>
<p style="height: 44px;"></p>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "none" : "" %>" id="offlinePaySubmitBtn">
<a href="<%= training_path(id: @friendly_id, disable_redirect: true) %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="submitFormBtn">完成转账</a>
<a href="javascript:void(0)" class="rightbtn" id="submitFormBtn"><%= @training.training_payinfo.new_record? ? '完成转账' : '提交' %></a>
</div>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "" : "none" %>" id="paySubmitBtn">
@ -244,11 +248,13 @@
$('#submitFormBtn').on('click', function () {
if(!checkBillInfo()){ return; }
var image = $("input[name='image']").val()
if (!image || image.length < 0) {
alert('请先上传支付凭证');
return;
}
<% if @training.training_payinfo.not_payed? %>
var image = $("input[name='image']").val()
if (!image || image.length < 0) {
alert('请先上传支付凭证');
return;
}
<% end %>
$('form').submit();
});

@ -105,7 +105,7 @@
<%= link_to "返回", training_path(id: @friendly_id, disable_redirect: true), class: 'leftbtn' %>
<a href="javascript:void(0)" class="rightbtn" id="wechatPayBtn">立即支付</a>
<% else%>
<%= link_to "返回", training_path(id: @friendly_id, disable_redirect: true), class: 'rightbtn', style: 'width: 100%' %>
<%= link_to "返回", pay_training_path(id: @friendly_id, disable_redirect: true), class: 'rightbtn', style: 'width: 100%' %>
<% end %>
</div>
</div>

Loading…
Cancel
Save