dev_library
caishi 6 years ago
commit 66607ae158

@ -878,7 +878,7 @@ class AccountController < ApplicationController
if ApplyUserAuthentication.where(:user_id => @user.id, :status => 0, :auth_type => 1).count == 0 if ApplyUserAuthentication.where(:user_id => @user.id, :status => 0, :auth_type => 1).count == 0
ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 1) ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 1)
begin begin
status = Trustie::Sms.send(mobile: '18173242757', send_type:'apply_auth' , name: '管理员') status = Trustie::Sms.send(mobile: '18711085785', send_type:'apply_auth' , name: '管理员')
rescue => e rescue => e
Rails.logger.error "发送验证码出错: #{e}" Rails.logger.error "发送验证码出错: #{e}"
end end
@ -937,7 +937,7 @@ class AccountController < ApplicationController
if ApplyUserAuthentication.where(:user_id => @user.id, :status => 0, :auth_type => 2).count == 0 if ApplyUserAuthentication.where(:user_id => @user.id, :status => 0, :auth_type => 2).count == 0
ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2) ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2)
begin begin
status = Trustie::Sms.send(mobile: '18173242757', send_type:'apply_pro_certification' , name: '管理员') status = Trustie::Sms.send(mobile: '18711085785', send_type:'apply_pro_certification' , name: '管理员')
rescue => e rescue => e
Rails.logger.error "发送验证码出错: #{e}" Rails.logger.error "发送验证码出错: #{e}"
end end
@ -946,7 +946,7 @@ class AccountController < ApplicationController
if File.exist?(diskfile2) if File.exist?(diskfile2)
ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2) ApplyUserAuthentication.create(:user_id => @user.id, :status => 0, :auth_type => 2)
begin begin
status = Trustie::Sms.send(mobile: '18173242757', send_type:'apply_pro_certification' , name: '管理员') status = Trustie::Sms.send(mobile: '18711085785', send_type:'apply_pro_certification' , name: '管理员')
rescue => e rescue => e
Rails.logger.error "发送验证码出错: #{e}" Rails.logger.error "发送验证码出错: #{e}"
end end

@ -346,19 +346,19 @@ class ManagementsController < ApplicationController
if mirror.blank? if mirror.blank?
raise("choose_update_mirror exception") raise("choose_update_mirror exception")
end end
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] #shixun_tomcat = Redmine::Configuration['shixun_tomcat']
params = {imageName: mirror.name, imageID: old_id, flag: flag} #params = {imageName: mirror.name, imageID: old_id, flag: flag}
uri = "#{shixun_tomcat}/bridge/docker/updateImage" #uri = "#{shixun_tomcat}/bridge/docker/updateImage"
res = uri_exec uri, params #res = uri_exec uri, params
if (res && res['code'] != 0) # if (res && res['code'] != 0)
raise("choose_update_mirror exception") #raise("choose_update_mirror exception")
end #end
if flag == 0 if flag == 0
mirror.update_attributes(:mirrorID => change_id, :status => 0) mirror.update_attributes(:mirrorID => change_id, :status => 1)
# 用户操作的的行为需要记录 user_id 中间层操作的行为user_id = -1 # 用户操作的的行为需要记录 user_id 中间层操作的行为user_id = -1
MirrorOperationRecord.create!(:mirror_repository_id => mirror.id, :mirror_id => change_id, :mirror_name => mirror.name, :status => 1, :user_id => User.current.id, :old_tag => old_id, :new_tag => change_id) MirrorOperationRecord.create!(:mirror_repository_id => mirror.id, :mirror_id => change_id, :mirror_name => mirror.name, :status => 1, :user_id => User.current.id, :old_tag => old_id, :new_tag => change_id)
else else
mirror.update_attribute(:status, 0) mirror.update_attribute(:status, 1)
end end
respond_to do |format| respond_to do |format|
format.js{ redirect_to mirror_repository_managements_path(:reaction => "choose_update_mirror")} format.js{ redirect_to mirror_repository_managements_path(:reaction => "choose_update_mirror")}
@ -720,20 +720,25 @@ class ManagementsController < ApplicationController
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] shixun_tomcat = Redmine::Configuration['shixun_tomcat']
params = {imageName: @mirror.name} params = {imageName: @mirror.name}
# 主从节点同步镜像 # 主从节点同步镜像
uri = "#{shixun_tomcat}/bridge/docker/syncImage" #uri = "#{shixun_tomcat}/bridge/docker/syncImage"
res = uri_exec uri, params #res = uri_exec uri, params
if (res && res['code'] != 0) #if (res && res['code'] != 0)
raise("Synchronize Mirror exception") # raise("Synchronize Mirror exception")
end #end
end end
if @_params[:type_name] != @mirror.type_name if @_params[:type_name] != @mirror.type_name
MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 5, :user_id => User.current.id, :old_tag => @mirror.type_name, :new_tag => @_params[:type_name]) MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 5,
:user_id => User.current.id, :old_tag => @mirror.type_name,
:new_tag => @_params[:type_name])
elsif @_params[:status].to_i != @mirror.status elsif @_params[:status].to_i != @mirror.status
MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 6, :user_id => User.current.id, :old_tag => @mirror.status, :new_tag => @_params[:status]) MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 6,
:user_id => User.current.id, :old_tag => @mirror.status,
:new_tag => @_params[:status])
end end
@mirror.update_attributes(:description => @_params[:description], :status => @_params[:status], :main_type => @_params[:mirror_type], @mirror.update_attributes(:description => @_params[:description], :status => @_params[:status],
:type_name => @_params[:type_name], :resource_limit => @_params[:mirror_resource_limit], :cpu_limit => @_params[:mirror_cpu_limit], :main_type => @_params[:mirror_type], :type_name => @_params[:type_name],
:memory_limit => @_params[:mirror_memory_limit], :time_limit => @_params[:mirror_time_limit]) :resource_limit => @_params[:mirror_resource_limit], :cpu_limit => @_params[:mirror_cpu_limit],
:memory_limit => @_params[:mirror_memory_limit], :time_limit => @_params[:mirror_time_limit])
@index = MirrorRepository.order("created_at desc").map(&:id).index(@mirror.id) @index = MirrorRepository.order("created_at desc").map(&:id).index(@mirror.id)
respond_to do |format| respond_to do |format|
format.js format.js

@ -13,20 +13,6 @@ class TrainingsController < ApplicationController
before_filter :check_training_type, only: [:enroll] before_filter :check_training_type, only: [:enroll]
before_filter :check_current_training, only: [:show, :update, :pay, :pay_js, :update_payinfo, :result] 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' layout 'base_trainings'
def show def show
@ -37,18 +23,22 @@ class TrainingsController < ApplicationController
return return
end end
# TODO: 测试完成后删除
@test_wxpay = ALLOW_OPENID_LIST.include?(session[:wechat_open_id])
render 'trainingsInfo' render 'trainingsInfo'
end end
def enroll def enroll
@training = current_training || Training.new @training = current_training || Training.new
if @training.training_payinfo.present? && params[:disable_redirect].blank? if params[:disable_redirect].blank?
redirect_to result_training_path(id: friendly_id) if @training.training_payinfo.present?
return redirect_to result_training_path(id: friendly_id)
return
end
unless @training.new_record?
redirect_to training_path(id: friendly_id)
return
end
end end
end end
@ -60,9 +50,6 @@ 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
@ -168,13 +155,8 @@ 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?
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 else
redirect_to result_training_path(id: friendly_id) redirect_to result_training_path(id: friendly_id)
end end
@ -203,6 +185,7 @@ class TrainingsController < ApplicationController
#js获取支付参数 #js获取支付参数
def _pay_js(fee) def _pay_js(fee)
Rails.logger.info("### start wechat pay => fee: #{fee}")
@training = current_training @training = current_training
js_function_call do js_function_call do
out_trade_no = Wechat.pay.gen_trade_no out_trade_no = Wechat.pay.gen_trade_no

@ -1,7 +1,7 @@
#encoding: utf-8 #encoding: utf-8
class Training < ActiveRecord::Base class Training < ActiveRecord::Base
attr_accessible :address, :email, :name, :phone, :position, :school, :sex, :openid, :training_type, attr_accessible :address, :email, :name, :phone, :position, :school, :sex, :openid, :training_type,
:major, :student_id :major, :student_id, :job_title, :uncertified_major
# training_type 1 2018-培训会 2 警察学院大数据培训会 3 大数据和人工智能 4 工程教育认证 # training_type 1 2018-培训会 2 警察学院大数据培训会 3 大数据和人工智能 4 工程教育认证
@ -38,7 +38,7 @@ class Training < ActiveRecord::Base
# 三人以上 8折 # 三人以上 8折
num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num
when 4 then when 4 then
1200.0 * num 700.0 * num
else else
raise ArgumentError raise ArgumentError
end end

@ -137,7 +137,7 @@
<li style="width: 120px"><%= link_to "技术体系", tech_system_managements_path %></li> <li style="width: 120px"><%= link_to "技术体系", tech_system_managements_path %></li>
<li style="width: 120px"><%= link_to "升级通知", update_notice_managements_path %></li> <li style="width: 120px"><%= link_to "升级通知", update_notice_managements_path %></li>
<li style="width: 120px"><%= link_to "门户banner设置", setting_banner_managements_path %></li> <li style="width: 120px"><%= link_to "门户banner设置", setting_banner_managements_path %></li>
<li style="width: 120px"><%= link_to "2018培训会", training_2018_managements_path %></li> <li style="width: 120px"><%= link_to "培训会", training_2018_managements_path %></li>
</ul> </ul>
</li> </li>
</ul> </ul>

@ -152,6 +152,16 @@
name="position" name="position"
value="<%= @training.position %>"/> value="<%= @training.position %>"/>
</li> </li>
<% if @training_type == 4 %>
<li class="clearfix infoBar">
<span class="left_tag fl">职务</span>
<input type="text" class="right_input" placeholder="请输入职务" id="jobTitle"
name="job_title"
value="<%= @training.job_title %>"/>
</li>
<% end %>
<li class="clearfix infoBar"> <li class="clearfix infoBar">
<span class="left_tag fl">手机号码</span> <span class="left_tag fl">手机号码</span>
<input type="text" class="right_input" placeholder="请输入手机号" id="userphone" <input type="text" class="right_input" placeholder="请输入手机号" id="userphone"
@ -159,6 +169,15 @@
value="<%= @training.phone %>"/> value="<%= @training.phone %>"/>
</li> </li>
<% if @training_type == 4 %>
<li class="clearfix infoBar">
<span class="left_tag fl">待认证专业</span>
<input type="text" class="right_input" placeholder="请输入专业名称" id="uncertifiedMajor"
name="uncertified_major"
value="<%= @training.uncertified_major %>"/>
</li>
<% end %>
<% if @training_type == 3 %> <% if @training_type == 3 %>
<p class="subtitle">您关注的课程类型最少选1项</p> <p class="subtitle">您关注的课程类型最少选1项</p>
@ -242,6 +261,13 @@
return; return;
} }
<% if @training_type == 4 %>
if ($("#uncertifiedMajor").val() == '') {
alert("请输入专业名称");
return;
}
<% end %>
<% if @training_type == 3 %> <% if @training_type == 3 %>
if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) { if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) {
alert('请选择您关注的课程类型'); alert('请选择您关注的课程类型');

@ -2,18 +2,10 @@
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<%= hidden_field_tag(:friendly_id, @friendly_id) %> <%= hidden_field_tag(:friendly_id, @friendly_id) %>
<% if @test_wxpay %> <div class="showPanel" id="payTypeLine" <%= @training.training_payinfo.not_payed? ? 'NavShow' : '' %>>
<div class="showPanel" id="payTypeLine" NavShow>
<% else %>
<div class="showPanel" id="payTypeLine">
<% end %>
<p class="clearfix pr"> <p class="clearfix pr">
<label>支付方式</label> <label>支付方式</label>
<% if @test_wxpay %> <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>
<% else %>
<span class="mr5" style="margin-right: 24px;">线下支付</span>
<% end %>
<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">
@ -107,7 +99,11 @@
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "" : "none" %>" id="paySubmitBtn"> <div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i == 1 ? "" : "none" %>" id="paySubmitBtn">
<a href="<%= training_path(id: @friendly_id, disable_redirect: true) %>" class="leftbtn">返回</a> <a href="<%= training_path(id: @friendly_id, disable_redirect: true) %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="payBtn">立即支付</a> <% if @training.training_payinfo.not_payed? %>
<a href="javascript:void(0)" class="rightbtn" id="payBtn">立即支付</a>
<% else %>
<a href="javascript:void(0)" class="rightbtn" id="submitWxpayFormBtn">提交</a>
<% end %>
</div> </div>
</div> </div>
@ -186,10 +182,10 @@
// $(this).addClass("active"); // $(this).addClass("active");
// billTypeShowFun(parseInt($(this).index()), userInfo); // billTypeShowFun(parseInt($(this).index()), userInfo);
// }) // })
// //关闭弹窗 //关闭弹窗
// $(".billClose").on("click", function () { $(".billClose").on("click", function () {
// hideNav($(".downNav")); hideNav($(".downNav"));
// }); });
//延迟支付,直接提交 //延迟支付,直接提交
$('#delayPayBtn').on('click', function () { $('#delayPayBtn').on('click', function () {
@ -266,6 +262,12 @@
$('form').submit(); $('form').submit();
}); });
// 微信支付后修改内容提交
$("#submitWxpayFormBtn").on('click', function () {
if(!checkBillInfo()){ return; }
$('form').submit();
});
//上传头像 //上传头像
InitPhoto(); InitPhoto();

@ -17,10 +17,22 @@
<label>职位</label> <label>职位</label>
<span><%= @training.position %></span> <span><%= @training.position %></span>
</p> </p>
<% if @training_type == 4 %>
<p class="clearfix">
<label>职位</label>
<span><%= @training.job_title %></span>
</p>
<% end %>
<p class="clearfix"> <p class="clearfix">
<label>手机号</label> <label>手机号</label>
<span><%= @training.phone %></span> <span><%= @training.phone %></span>
</p> </p>
<% if @training_type == 4 %>
<p class="clearfix">
<label>待认证专业</label>
<span><%= @training.uncertified_major %></span>
</p>
<% end %>
</div> </div>
<!-- 地址<div class="df showPanel"> <!-- 地址<div class="df showPanel">
@ -85,18 +97,20 @@
<% end %> <% end %>
</div> </div>
<div class="showPanel"> <% if @training.training_payinfo.info.present? || (@training.training_payinfo.attachment_id.to_i > 0 || @training.training_payinfo.pay_type != TrainingPayinfo::PayType_Wechat) %>
<% if @training.training_payinfo.info.present? %> <div class="showPanel">
<p class="clearfix mb5"><label>备注信息</label></p> <% if @training.training_payinfo.info.present? %>
<p class="mb5 line20"><%= @training.training_payinfo.info %></p> <p class="clearfix mb5"><label>备注信息</label></p>
<% end %> <p class="mb5 line20"><%= @training.training_payinfo.info %></p>
<% end %>
<% if @training.training_payinfo.attachment_id.to_i > 0 || @training.training_payinfo.pay_type != TrainingPayinfo::PayType_Wechat %>
<p class="clearfix mb5"><label>支付凭证</label></p> <% if @training.training_payinfo.attachment_id.to_i > 0 || @training.training_payinfo.pay_type != TrainingPayinfo::PayType_Wechat %>
<!--图片上传--> <p class="clearfix mb5"><label>支付凭证</label></p>
<%= render partial: 'upload_img', locals: { training: @training, disabled: true } %> <!--图片上传-->
<% end %> <%= render partial: 'upload_img', locals: { training: @training, disabled: true } %>
</div> <% end %>
</div>
<% end %>
<br/> <br/>
<br/> <br/>
@ -121,7 +135,7 @@
// eruda.init(); // eruda.init();
function wechatPay() { function wechatPay() {
$.ajax({ $.ajax({
url: '<%= pay_js_trainings_path %>', url: '<%= pay_js_trainings_path(friendly_id: @friendly_id) %>',
type: "POST", type: "POST",
data: '{}' data: '{}'
} }
@ -147,7 +161,7 @@
// 使用以上方式判断前端返回,微信团队郑重提示: // 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。 //res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。
setTimeout(function () { setTimeout(function () {
window.location.href = "/trainings/<% @tag_id %>/result"; window.location.href = "/trainings/<% @friendly_id %>/result";
}, 500); }, 500);
} else if (res.err_msg == 'get_brand_wcpay_request:cancel') { } else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
@ -189,7 +203,7 @@
var data = new FormData(); var data = new FormData();
data.append('image', files[0]); data.append('image', files[0]);
data.append('tag_id', '<%= @tag_id %>'); data.append('friendly_id', '<%= @friendly_id %>');
$.ajax({ $.ajax({
url: '<%= update_picture_trainings_path %>', url: '<%= update_picture_trainings_path %>',

@ -21,10 +21,22 @@
<span>职称</span> <span>职称</span>
<span><%= @training.position %></span> <span><%= @training.position %></span>
</li> </li>
<% if @training_type == 4 %>
<li class="clearfix">
<span>职务</span>
<span><%= @training.job_title %></span>
</li>
<% end %>
<li class="clearfix"> <li class="clearfix">
<span>手机号</span> <span>手机号</span>
<span><%= @training.phone %></span> <span><%= @training.phone %></span>
</li> </li>
<% if @training_type == 4 %>
<li class="clearfix">
<span>待认证专业</span>
<span><%= @training.uncertified_major %></span>
</li>
<% end %>
</div> </div>
<% if @training.training_type == 3 %> <% if @training.training_type == 3 %>
@ -42,12 +54,7 @@
<p class="notice_pay">温馨提示:支持现场缴费</p> <p class="notice_pay">温馨提示:支持现场缴费</p>
<div class="bottomBtn"> <div class="bottomBtn">
<%= link_to '转账支付', pay_training_path(id: @friendly_id, pay_type: 3), class: 'leftbtn' %> <%= link_to '转账支付', pay_training_path(id: @friendly_id, pay_type: 3), class: 'leftbtn' %>
<!-- TODO:: 测试微信支付,待删除 --> <%= link_to '微信支付', pay_training_path(id: @friendly_id, pay_type: 1), class: 'rightbtn' %>
<% if @test_wxpay %>
<%= link_to '微信支付', pay_training_path(id: @friendly_id, pay_type: 1), class: 'rightbtn' %>
<% else %>
<a href="javascript:void(0)" onclick="alert('即将开通');" class="rightbtn">微信支付</a>
<% end %>
</div> </div>
<% else %> <% else %>
<div class="bottomBtn"> <div class="bottomBtn">

@ -0,0 +1,6 @@
class AddColumnsToTrainings < ActiveRecord::Migration
def change
add_column :trainings, :job_title, :string
add_column :trainings, :uncertified_major, :string
end
end
Loading…
Cancel
Save