dev_bj
cxt 6 years ago
commit b128c9721f

@ -145,6 +145,7 @@ class AccountController < ApplicationController
@com_coop_img = CooImg.where(:img_type => 'com_coop').order("position asc")
@edu_coop_img = CooImg.where(:img_type => 'edu_coop').order("position asc")
@alliance_img = CooImg.where(:img_type => 'alliance_coop').order("position asc")
render :layout => 'base_edu'
end
@ -152,6 +153,7 @@ class AccountController < ApplicationController
def update_help
@edu_coop = "edu_coop"
@com_coop = "com_coop"
@alliance_coop = "alliance_coop"
end
def update_agreement

@ -66,6 +66,8 @@ class ApplicationController < ActionController::Base
include Redmine::MenuManager::MenuController
helper Redmine::MenuManager::MenuHelper
helper_method :admin_or_business?
# 云启训练场EduCoder个人版 产品编码appId 9200108
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder个人版 固定包月 9200108001
@ -133,7 +135,7 @@ class ApplicationController < ActionController::Base
end
def ec_public_auth major_school
unless User.current.admin? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 ||
unless admin_or_business? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 ||
major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0 ||
EcCourseUser.where(:user_id => User.current.id, :ec_course_id => EcCourse.where(:ec_year_id => major_school.ec_years.pluck(:id)).pluck(:id)).count > 0
render_403
@ -376,7 +378,7 @@ class ApplicationController < ActionController::Base
def require_admin
return unless require_login
if !User.current.admin? && @shixun.status > 1
if !User.current.admin?
render_403
return false
end
@ -390,6 +392,10 @@ class ApplicationController < ActionController::Base
end
end
def admin_or_business?
User.current.business? || User.current.admin?
end
def deny_access
User.current.logged? ? render_403 : require_login
end

@ -309,7 +309,7 @@ class EcCourseAchievementMethodsController < ApplicationController
@ec_course = EcCourse.find(params[:ec_course_id])
@year = @ec_course.ec_year
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end

@ -298,7 +298,7 @@ class EcCourseEvaluationsController < ApplicationController
def find_course
@ec_course = EcCourse.find params[:ec_course_id]
ec_major_school = @ec_course.ec_year.ec_major_school
@is_manager = User.current.admin? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@is_manager = admin_or_business? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
@ -306,7 +306,7 @@ class EcCourseEvaluationsController < ApplicationController
@ce = EcCourseEvaluation.find params[:id]
@ec_course = @ce.ec_course
ec_major_school = @ec_course.ec_year.ec_major_school
@is_manager = User.current.admin? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@is_manager = admin_or_business? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
end

@ -50,7 +50,7 @@ class EcCourseSupportsController < ApplicationController
max_support_count = 0
subitems_count = 0
major_school = @year.ec_major_school
is_manager = User.current.admin? || major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
is_manager = admin_or_business? || major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
ec_graduation_requirements.each_with_index do |gr, i|
logger.info("#############index:#{i}#####_ec_gradiation_reqiorements: #{gr.id}")
subitems_count += gr.ec_graduation_subitems.count

@ -346,7 +346,7 @@ class EcCoursesController < ApplicationController
# 关联课堂弹框-搜索
def search_courses
user = User.where(:id => params[:user_id]).first
if user.try(:admin?)
if user.try(:admin?) || user.try(:business?)
courses = Course.where(:is_delete => 0)
else
course_ids = Member.where("user_id = #{user.try(:id)} and course_id != -1").pluck(:course_id)
@ -588,7 +588,7 @@ class EcCoursesController < ApplicationController
@ec_course = EcCourse.find(params[:id])
@year = @ec_course.ec_year
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
@ -596,7 +596,7 @@ class EcCoursesController < ApplicationController
def find_year
@year = EcYear.find(params[:ec_year_id])
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
#@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end

@ -34,7 +34,7 @@ class EcGraduationRequirementsController < ApplicationController
ActiveRecord::Base.transaction do
@year = EcYear.find params[:year_id]
position = @year.ec_graduation_requirements ? @year.ec_graduation_requirements.count + 1 : 1
@template_major = User.current.admin? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
ec_requirement_id = EcGraduationRequirement.create(content: params[:requirement], :ec_year_id => @year.id, :position => position)
params[:subitems].try(:each_with_index) do |sub, index|
EcGraduationSubitem.create(content: sub, ec_graduation_requirement_id: ec_requirement_id.id, position: index+1)
@ -48,7 +48,7 @@ class EcGraduationRequirementsController < ApplicationController
def update
requirement = EcGraduationRequirement.find params[:id]
@year = requirement.ec_year
@template_major = User.current.admin? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
requirement.update_attribute(:content, params[:requirement])
requirement.ec_graduation_subitems.destroy_all
params[:subitems].try(:each_with_index) do |sub, index|

@ -13,7 +13,7 @@ class EcMajorSchoolsController < ApplicationController
# 这个status 用于创建界别时,局部刷新的状态
@status = params[:status]
@btn_text = @major_school.template_major && User.current.admin? ? "立即配置" :
@btn_text = @major_school.template_major && admin_or_business? ? "立即配置" :
(!@major_school.template_major && @major_manager ? "立即配置" : "查看")
if params[:search]
@ -84,7 +84,7 @@ class EcMajorSchoolsController < ApplicationController
user_url = user_path(User.current)
year = @year.year
# 学校操作权限
template_major = User.current.admin? || major.school.ec_school_users.pluck(:user_id).include?(User.current.id)
template_major = admin_or_business? || major.school.ec_school_users.pluck(:user_id).include?(User.current.id)
# 示例专业
example_major = major.template_major
ec_course_support_setting_url = ec_course_support_setting_ec_course_path(ec_course) if ec_course.present?
@ -130,7 +130,7 @@ class EcMajorSchoolsController < ApplicationController
competition_calculation_info_url: competition_calculation_info_url,
score_level_setting_url: score_level_setting_url,
example_major: example_major,
allow_visit: User.current.admin? || (User.current.ec_school.present? && User.current.ec_school == major.school.id)
allow_visit: admin_or_business? || (User.current.ec_school.present? && User.current.ec_school == major.school.id)
}
end
@ -159,7 +159,7 @@ class EcMajorSchoolsController < ApplicationController
end
def add_manager
@is_school_manager = User.current.admin? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = admin_or_business? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
if @is_school_manager || @major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0
params[:user_id].each do |user_id|
if @major_school.ec_major_school_users.count < 5 && @major_school.ec_major_school_users.where(:user_id => user_id).count == 0
@ -172,7 +172,7 @@ class EcMajorSchoolsController < ApplicationController
end
def delete_manager
@is_school_manager = User.current.admin? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = admin_or_business? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
if @is_school_manager || @major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0
@major_school.ec_major_school_users.where(:user_id => params[:user_id]).destroy_all
else
@ -184,7 +184,7 @@ class EcMajorSchoolsController < ApplicationController
def find_major_school
@major_school = EcMajorSchool.find(params[:id])
# 管理员权限
@major_manager = User.current.admin? || @major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@major_manager = admin_or_business? || @major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
end
# 职业认证的权限判断

@ -25,7 +25,7 @@ class EcYearsController < ApplicationController
@status = 1
end
@major_manager = true
@btn_text = @major_school.template_major && User.current.admin? ? "立即配置" :
@btn_text = @major_school.template_major && admin_or_business? ? "立即配置" :
(!@major_school.template_major && @major_manager ? "立即配置" : "查看")
@years = EcYear.where(:ec_major_school_id => @major_school.id)
@years = paginateHelper @years, 10
@ -338,7 +338,7 @@ class EcYearsController < ApplicationController
@ec_major_school = EcMajorSchool.find(params[:ec_major_school_id])
@year = EcYear.find(params[:id])
# 专业管理员身份
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
end
# 职业认证的权限判断

@ -7,7 +7,7 @@ class EcsController < ApplicationController
def department
@template_major = EcMajorSchool.where(:template_major => true).first
@school_managers = @school.users
@is_school_manager = User.current.admin? || @school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = User.current.admin? || User.current.business? || @school.users.where(:id => User.current.id).count > 0 # 学校管理员
@major_schools = @school.ec_major_schools.where(:template_major => false)
unless @is_school_manager
@ -70,7 +70,7 @@ class EcsController < ApplicationController
end
def school_manager
unless User.current.admin? || @school.users.where(:id => User.current.id).count > 0
unless User.current.admin? || User.current.business? || @school.users.where(:id => User.current.id).count > 0
render_403
end
end

@ -2,11 +2,10 @@
class ManagementsController < ApplicationController
before_filter :require_business
before_filter :require_admin, :only => [:shixun_setting_list, :mirror_repository, :mirror_picture_shixuns, :editmd_template,
:editmd_template, :subject_level_system, :subject_setting_list, :auto_users_trial,
:evaluate_records, :identity_authentication, :identity_authentication, :professional_authentication,
:shixun_authorization, :graduation_standard, :ec_template, :codemirror_template,
:editmd_template, :subject_level_system, :subject_setting_list,
:shixun_authorization, :ec_template, :codemirror_template,
:course_guide_template, :shixun_quality_score, :tech_system, :update_notice, :setting_banner,
:training_2018]
:training_2018, :create_standard]
layout 'base_management'
include ManagementsHelper
include SortHelper
@ -32,6 +31,15 @@ class ManagementsController < ApplicationController
# 实训课程等级体系
def subject_level_system
@levels = SubjectLevelSystem.all
respond_to do |format|
format.js
format.html
format.xls{
time = Time.now.strftime("%Y%m%d")
filename = "实训课程体系#{time}.xls"
send_data(export_subject_level_system(), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
end
# 创建课程等级体系
@ -4152,7 +4160,7 @@ end
sheet1 = book.create_worksheet :name => "sheet"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["姓名", "手机号","邮箱","单位名称", "职位","专业", "学号", "支付方式","支付状态","支付时间", "发票类型", "发票抬头","税务登记号", "发票内容", "备注", "微信支付单号", "报名时间"])
sheet1.row(0).concat(["姓名", "手机号","邮箱","单位名称", "职位","专业", "学号", '授课/研究领域', "支付方式","支付状态","支付时间", "发票类型", "发票抬头","税务登记号", "发票内容", "备注", "微信支付单号", "报名时间"])
count_row = 1
trainings.find_each do |t|
sheet1[count_row, 0] = t.name
@ -4162,16 +4170,17 @@ end
sheet1[count_row, 4] = t.position
sheet1[count_row, 5] = t.major
sheet1[count_row, 6] = t.student_id
sheet1[count_row, 7] = t.training_payinfo.try(:pay_type_str)
sheet1[count_row, 8] = t.training_payinfo.try(:pay_status_str)
sheet1[count_row, 9] = format_time t.training_payinfo.try(:pay_time)
sheet1[count_row, 10] = t.training_payinfo.try(:invoice_title).present? ? '需要' : '不需要'
sheet1[count_row, 11] = t.training_payinfo.try(:invoice_title)
sheet1[count_row, 12] = t.training_payinfo.try(:invoice_no)
sheet1[count_row, 13] = t.training_payinfo.try(:invoice_content)
sheet1[count_row, 14] = t.training_payinfo.try(:info)
sheet1[count_row, 15] = t.training_payinfo.try(:out_trade_no)
sheet1[count_row, 16] = format_time t.created_at
sheet1[count_row, 7] = t.research_field
sheet1[count_row, 8] = t.training_payinfo.try(:pay_type_str)
sheet1[count_row, 9] = t.training_payinfo.try(:pay_status_str)
sheet1[count_row, 10] = format_time t.training_payinfo.try(:pay_time)
sheet1[count_row, 11] = t.training_payinfo.try(:invoice_title).present? ? '需要' : '不需要'
sheet1[count_row, 12] = t.training_payinfo.try(:invoice_title)
sheet1[count_row, 13] = t.training_payinfo.try(:invoice_no)
sheet1[count_row, 14] = t.training_payinfo.try(:invoice_content)
sheet1[count_row, 15] = t.training_payinfo.try(:info)
sheet1[count_row, 16] = t.training_payinfo.try(:out_trade_no)
sheet1[count_row, 17] = format_time t.created_at
count_row += 1
end
book.write xls_report
@ -4286,6 +4295,33 @@ end
return sheet.rows
end
def export_subject_level_system
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "实训课程等级体系"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
count_row = 1
sheet1.row(0).concat(["序号", "等级", "实训课程名称", "实训课程url", "实训名称"])
levels = SubjectLevelSystem.includes(subjects: [stage_shixuns: :shixun]).where(nil)
levels.each_with_index do |level, i|
sheet1[count_row, 0] = i + 1
sheet1[count_row, 1] = level.name
level.subjects.each do |subject|
sheet1[count_row, 2] = subject.name
sheet1[count_row, 3] = "#{Setting.protocol}://#{Setting.host_name}#{subject_path(subject)}"
count_row += 1
subject.shixuns.each do |shixun|
sheet1[count_row, 4] = shixun.name
count_row += 1
end
end
count_row += 1
end
book.write xls_report
xls_report.string
end
def shixun_feedback_xls shixun_ids, beginTime, endTime
xls_report = StringIO.new
book = Spreadsheet::Workbook.new

@ -358,7 +358,7 @@ class MyshixunsController < ApplicationController
def vnc
vnc_password = Redmine::Configuration['vnc']
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
host = Redmine::Configuration['tomcat_php']
host = Redmine::Configuration['vnc_url']
begin
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
shixun = @myshixun.shixun
@ -368,7 +368,7 @@ class MyshixunsController < ApplicationController
raise("实训云平台繁忙繁忙等级99")
end
# url = host + ":" + res['port'] + "?password=" + vnc_password
url = host +":#{res['port']}/vnc.html"
url = "https://#{res['port']}.#{host}/vnc.html"
render :json => {:url => url}
rescue Exception => e
logger.error(e)

@ -10,7 +10,7 @@ class ShixunsController < ApplicationController
before_filter :view_allow, :only => [:collaborators, :propaedeutics, :shixun_discuss, :ranking_list]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update, :destroy]
before_filter :validation_email, :only => [:new]
before_filter :require_admin, :only => [:destroy]
#before_filter :require_manager, :only => [:destroy]
# 移动云ToC模式权限控制
# before_filter :ecloud_auth, :except => [:show, :index]
@ -1117,6 +1117,7 @@ class ShixunsController < ApplicationController
end
def destroy
render_403 if @shixun.status > 1 && !User.current.admin?
ActiveRecord::Base.transaction do
g = Gitlab.client
g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present?

@ -496,7 +496,7 @@ class StudentWorkController < ApplicationController
def _index
# REDO:分班信息提前查出来,然后循环中根据匹配去取
@is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) : false
@is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin? || User.current.business?) : false
@member = @course.members.where(:user_id => User.current.id).first
# 判断学生是否有权限查看(作业未发布、作业已发布但不是统一设置的未分班学生、分班设置的作业未发布)
if User.current.member_of_course?(@course) && !@is_teacher

@ -3,54 +3,53 @@ require 'base64'
class TrainingsController < ApplicationController
wechat_responder
skip_before_filter :verify_signature, only: [:show, :create, :test]
skip_before_filter :check_if_login_required
skip_before_filter :verify_signature, except: [:auth, :auth_callback, :pay_callback]
ROOT_URL = ENV["wechat_url"] || "#{Setting.protocol}://#{Setting.host_name}"
before_filter :authenticate, except: [:auth, :auth_callback, :pay_callback]
before_filter :find_training, only: [:show, :test]
before_filter :valid_training, only: [:pay, :result, :pay_js]
before_filter :check_training_type, only: [:enroll]
before_filter :check_current_training, only: [:show, :update, :pay, :pay_js, :update_payinfo, :result]
layout 'base_trainings'
TAG_ID = 'bigdata_hnjcxy_2019'
def show
@training = current_training
url = nil
if @training && !@training.pay?
url = enroll_training_path(id: TAG_ID)
elsif @training && @training.pay?
url = result_training_path(id: TAG_ID)
else
url = enroll_training_path(id: TAG_ID)
if @training.training_payinfo.present? && !@training.training_payinfo.not_payed? && params[:disable_redirect].blank?
redirect_to result_training_path(id: friendly_id)
return
end
redirect_to url
render 'trainingsInfo'
end
def enroll
@training = current_training || Training.new
end
if params[:disable_redirect].blank?
if @training.training_payinfo.present?
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
def pay
_pay_params
@training = current_training
# 防止重复支付,对于已支付过的,不应该再到这个页来
if @training.payed?
redirect_to result_training_path(id: TAG_ID)
return
if @training.training_payinfo.blank?
@training.build_training_payinfo
@training.training_payinfo.fee = @training.registration_fee
@training.training_payinfo.pay_type = params[:pay_type].presence || 3
end
@training.training_payinfo ||= TrainingPayinfo.new
end
def pay_callback
@ -93,30 +92,29 @@ class TrainingsController < ApplicationController
end
def result
_pay_params
@training = current_training
end
if @training.training_payinfo.blank?
redirect_to training_path(id: friendly_id)
return
end
end
def create
@training = current_training || Training.new(params)
@training.training_type = Training::Training_Type
@training = Training.new
@training.training_type = @training_type
@training.openid = session[:wechat_open_id]
@training.save!
redirect_to pay_training_path(id: TAG_ID)
end
save_training
redirect_to training_path(id: friendly_id, disable_redirect: true)
end
def update
@training = current_training
unless @training
render_404
return
end
save_training
@training.update_attributes(params)
redirect_to pay_training_path(id: TAG_ID)
redirect_to training_path(id: friendly_id, disable_redirect: true)
end
@ -126,49 +124,42 @@ class TrainingsController < ApplicationController
# 采用ajax调用方式返回支付参数
def update_payinfo
@training = current_training
unless @training
render_404
return
end
_pay_params
training_info = @training.training_payinfo || @training.build_training_payinfo
training_info.assign_attributes(params)
ActiveRecord::Base.transaction do
if training_info.pay_type.to_i == TrainingPayinfo::PayType_bank
attachment = nil
if params[:image]
attachment = Attachment.create!(file: params[:image], author: User.first)
end
attachment = Attachment.create!(file: params[:image], author: User.first) if params[:image]
#修改以前的订单信息
training_info = @training.training_payinfo
if training_info.present?
training_info.update_attributes(params)
else
training_info = TrainingPayinfo.new(params)
if training_info.attachment.blank? && attachment.blank? && training_info.not_payed?
flash[:message] = '请先上传支付凭证'
render 'pay'
return
end
training_info.num = params[:enlistN].to_i
if training_info.num < 1
training_info.num = 1
training_info.attachment = attachment if attachment.present?
end
training_info.fee = (training_info.num * @pay_fee).to_i
training_info.attachment = attachment if attachment.present?
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
training_info.status = TrainingPayinfo::Status_Wait
end
training_info.training_id = @training.id
end
training_info.save!
if params[:js] == 'true'
if params[:js] == 'true' && training_info.not_payed?
_pay_js(training_info.fee)
else
redirect_to url = result_training_path(id: TAG_ID)
redirect_to result_training_path(id: friendly_id)
end
end
end
@ -180,6 +171,7 @@ class TrainingsController < ApplicationController
attachment = Attachment.create!(file: params[:image], author: User.first)
training_payinfo = @training.training_payinfo
training_payinfo.attachment = attachment
training_payinfo.status = TrainingPayinfo::Status_Wait if training_payinfo.status == TrainingPayinfo::Status_None
training_payinfo.save!
render json: {status: 0}
end
@ -193,6 +185,7 @@ class TrainingsController < ApplicationController
#js获取支付参数
def _pay_js(fee)
Rails.logger.info("### start wechat pay => fee: #{fee}")
@training = current_training
js_function_call do
out_trade_no = Wechat.pay.gen_trade_no
@ -201,7 +194,7 @@ class TrainingsController < ApplicationController
#
# 写入wechat_pay付费表
WechatPay.create!(training_id: @training.id, out_trade_no: out_trade_no)
render json: {status: 0, data: unifiedorder(out_trade_no, fee)}
render json: {status: 0, data: unifiedorder(out_trade_no, fee, @training.pay_order_title)}
end
end
@ -209,7 +202,7 @@ class TrainingsController < ApplicationController
# 用于权限跳转
def auth
state = params[:state]
url = "#{ROOT_URL}/trainings/auth_callback"
url = CGI.escape("#{ROOT_URL}/trainings/auth_callback?return_url=#{params[:return_url]}")
authorize_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{url}&response_type=code&scope=snsapi_base&state=#{state}&connect_redirect=1#wechat_redirect"
redirect_to authorize_url
end
@ -221,26 +214,9 @@ class TrainingsController < ApplicationController
render 'wechats/open_wechat', layout: nil and return
end
session[:wechat_open_id] = open_id
# 考虑状态
# 1. 无记录或未支付
# 2. 已填写未付款
#
@training = current_training
url = ''
if !@training
url = training_path(id: TAG_ID)
elsif !@training.pay?
url = enroll_training_path(id: TAG_ID)
else
url = result_training_path(id: TAG_ID)
end
redirect_to url
redirect_to params[:return_url].present? ? params[:return_url] : '/'
end
def test
@ -248,40 +224,67 @@ class TrainingsController < ApplicationController
end
private
def _pay_params
@pay_fee = Redmine::Configuration['training_fee'].to_f || 5000
end
def authenticate
if Rails.env.development?
# session[:wechat_open_id] = "o5fSc0607iR3rp4-h_VnuBTp8CiM"
session[:wechat_open_id] = "o5fSc0607iR3rp4-h_VnuBTp8CiM"
end
unless session[:wechat_open_id].present?
redirect_to auth_trainings_path
redirect_to auth_trainings_path(return_url: CGI.escape(request.path))
end
end
def find_training
if params[:id] == TAG_ID
@training = current_training
else
render_404
def save_training
@training.assign_attributes(params)
@training.training_type = training_type
if @training.training_type == 3
@training.research_field = params[:research_field].select(&:present?).uniq.join(",")
end
@training.save!
end
def current_training
Training.where(openid: session[:wechat_open_id], training_type: Training::Training_Type).first
def friendly_id
@friendly_id ||= params[:friendly_id].presence || params[:id]
end
def valid_training
unless current_training
redirect_to training_path(id: TAG_ID)
def training_type
@training_type ||=
case friendly_id
when 'aeee0601_2019' then 3
when 'ceeaa06_2019' then 4
end
end
def current_training
@_current_training ||= begin
Rails.logger.info("##########openid:#{session[:wechat_open_id]}, friendly_id: #{friendly_id}")
private
return if training_type.blank?
Training.where(openid: session[:wechat_open_id], training_type: training_type).first
end
end
def check_training_type
return if training_type.present?
render_404
end
def check_current_training
if current_training.blank?
if training_type.blank?
render_404
return
end
redirect_to enroll_training_path(id: friendly_id)
return
end
end
def js_function_call
begin
@ -321,14 +324,10 @@ class TrainingsController < ApplicationController
end
def unifiedorder(out_trade_no, fee)
def unifiedorder(out_trade_no, fee, title)
@config = {}
output = Wechat.pay.unifiedorder('湖南警察学院大数据培训会-报名费',
(fee * 100).to_i,
session[:wechat_open_id],
client_ip,
out_trade_no)
output = Wechat.pay.unifiedorder(title, (fee * 100).to_i, session[:wechat_open_id], client_ip, out_trade_no)
data = output.fetch("xml")
if data.nil?
raise "获取微信统一单错误"
@ -356,5 +355,4 @@ class TrainingsController < ApplicationController
@config
end
end

@ -3,7 +3,7 @@ class Training < ActiveRecord::Base
attr_accessible :address, :email, :name, :phone, :position, :school, :sex, :openid, :training_type,
:major, :student_id
# training_type 1 2018-培训会 2 警察学院大数据培训会
# training_type 1 2018-培训会 2 警察学院大数据培训会 3 大数据和人工智能 4 工程教育认证
has_one :training_payinfo
@ -21,4 +21,26 @@ class Training < ActiveRecord::Base
pay? && training_payinfo.payed?
end
def research_field_include?(str)
research_field.present? && research_field.split(',').include?(str)
end
def pay_order_title
case training_type
when 3 then '全国高校大数据和人工智能暑期师资培训会-报名费'
when 4 then '工程教育认证培训会-报名费'
end
end
def registration_fee(num = 1)
case training_type
when 3 then
# 三人以上 8折
num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num
when 4 then
700.0 * num
else
raise ArgumentError
end
end
end

@ -15,7 +15,12 @@ class TrainingPayinfo < ActiveRecord::Base
PayType_bank = 3 #银行卡支付
def pay_type_str
pay_type==PayType_Wechat ? '微信支付' : (pay_type==PayType_alipay ? '支付宝支付' : (pay_type==PayType_bank ? '银行卡支付' : ''))
case pay_type
when PayType_Wechat then '微信支付'
when PayType_alipay then '支付宝支付'
when PayType_bank then '银行卡支付'
else ''
end
end
def pay_status_str
@ -30,13 +35,20 @@ class TrainingPayinfo < ActiveRecord::Base
end
def pay_time
WechatPay.where(:out_trade_no => self.out_trade_no).first.try(:created_at)
WechatPay.where(out_trade_no: out_trade_no).first.try(:created_at)
end
def wechat_wait_pay?
pay_type.to_i == PayType_Wechat && status != Status_Payed
end
def not_payed?
status.nil? || status == Status_None
end
def offline_pay?
pay_type.to_i == PayType_bank
end
def payed?
status == Status_Payed

@ -1119,7 +1119,7 @@ class User < Principal
end
def member_of_course?(course)
courses.to_a.include?(course)
courses.to_a.include?(course) || User.current.business?
end
def member_of_contest?(contest)
@ -1323,7 +1323,7 @@ class User < Principal
if Project === context
return false unless context.allows_to?(action)
# Admin users are authorized for anything else
return true if admin?
return true if admin? || business?
# 课程:作品关联项目的老师也可以访问私有项目
course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")"

@ -80,14 +80,14 @@ class GamesService
if shixun.vnc
begin
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
service_host = Redmine::Configuration['tomcat_php']
service_host = Redmine::Configuration['vnc_url']
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}"}
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
url = "#{service_host}" +":#{res['port']}/vnc_lite.html?password=headless"
url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
Rails.logger.info("66666666sssssss#{url}")
container = container.merge(:vnc_url => url)
Rails.logger.info("777777666sssssss#{container}")

@ -25,13 +25,12 @@ class StatisticSchoolDailyReportTask
.where(homework_type: 4, created_at: yesterday).count
# 新增实训评测数量
shixun_evaluate_count = Output.joins(game: :challenge)
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
shixun_evaluate_count = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = games.user_id')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.where(courses: { school_id: school.id })
.where(created_at: yesterday).count
.where(created_at: yesterday).reorder(nil).count
# 无有效数据时不记录
data = [teacher_count, student_count, course_count, shixun_count, active_user_count,

@ -2,7 +2,27 @@
<div class="edu-back-white ml20 clearfix">
<p class="font-16 edu-line padding30-20">合作伙伴</p>
<div class="clearfix">
<p class="font-16 ml20 mb15 mt15"> 企业合作 </p>
<p class="font-16 ml20 mb15 mt15"> 产学联盟 </p>
<ul class='edu-cooperation clearfix cooperation-team' id="sortable2">
<% @alliance_img.each do |alliance_img| %>
<li class="bor-grey-e pr" data-id="<%= alliance_img.id %>" data-position="<%= alliance_img.position %>">
<% if User.current.admin? %>
<a href="javascript:void(0)" onclick="delete_confirm_box('<%= delete_coop_path(:id => alliance_img.id) %>', '确定要删除该图片吗?')"><i data-tip-down="删除" class="fa fa-times-circle mr10 color-orange05 font-16" style="position:absolute;right:0px;top:8px"></i></a>
<% end %>
<a href="<%= alliance_img.src_states == '' ? 'javascript:void(0)' : alliance_img.src_states %>" target="_blank">
<img src="<%= alliance_img.url_states %>" alt=""/>
</a>
</li>
<% end %>
<% if User.current.admin? %>
<li style="border: 1px dashed #FF7500" class="font-16"><a href="<%= update_help_path(:tab => 3,:resubmit => @resubmit)%>" data-remote="true">+ &nbsp;新建</a></li>
<% end %>
</ul>
</div>
<div class="clearfix">
<p class="font-16 ml20 mb15 mt15"> 知名企业 </p>
<ul class='edu-cooperation clearfix cooperation-item' id="sortable">
<% @com_coop_img.each do |coop_img| %>
<li class="bor-grey-e pr" data-id="<%= coop_img.id %>" data-position="<%= coop_img.position %>">
@ -21,7 +41,7 @@
</div>
<div class="clearfix">
<p class="font-16 ml20 mb15">高校合作 </p>
<p class="font-16 ml20 mb15">各类院校 </p>
<ul class='edu-cooperation cooperation-school clearfix' id="sortable1">
<% @edu_coop_img.each do |coop_img| %>
<li class="bor-grey-e pr" data-id="<%= coop_img.id %>" data-position="<%= coop_img.position %>">
@ -51,6 +71,8 @@
var id = 0;
var pos_1 = 0;
var id_1 = 0;
var pos_2 = 0;
var id_2 = 0;
$( "#sortable" ).sortable({
containment:".cooperation-item",
sort:function(e, ui){
@ -121,7 +143,40 @@
});
$( "#sortable1" ).disableSelection();
$( "#sortable2" ).sortable({
containment:".cooperation-team",
sort:function(e, ui){
select_item = ui.item; //当前拖动的元素
pos_2 = $(select_item[0]).prev().attr("data-position");
id_2 = $(select_item[0]).attr("data-id");
if(pos == undefined || id == undefined){
pos_2 = 0;
}
},
stop:function(e, ui){
select_item = ui.item; //当前拖动的元素
console.log(ui.item);
pos_2 = $(select_item[0]).prev().attr("data-position");
id_2 = $(select_item[0]).attr("data-id");
if(pos_2 == undefined || id_2 == undefined){
pos_2 = 0;
}
console.log("pos: " + pos_2);
$.ajax({
url: "<%= change_coop_position_path %>",
data: {id: id_2, position: pos_2, type: "alliance_coop"},
success: function(data) {
if(data.status == 1){
console.log("更新成功!");
$(select_item[0]).attr("data-position", pos_2+1)
}
}
});
}
});
$( "#sortable2" ).disableSelection();
})

@ -1,7 +1,10 @@
<% if params[:tab] == '1' %>
var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit =>params[:resubmit],:sourse_type => @com_coop}) %>";
pop_box_new(htmlvalue, 400, 260);
<% else %>
<% elsif params[:tab] == '2' %>
var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit => params[:resubmit],:sourse_type => @edu_coop}) %>";
pop_box_new(htmlvalue, 400, 260);
<% else %>
var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit => params[:resubmit],:sourse_type => @alliance_coop}) %>";
pop_box_new(htmlvalue, 400, 260);
<% end %>

@ -49,7 +49,7 @@
<!--</span>-->
</span>
<span class="column-2 fr edu-txt-center">
<% if @major_manager && !@major_school.template_major || User.current.admin? %>
<% if @major_manager && !@major_school.template_major || User.current.admin? || User.current.business? %>
<a href="javascript:void(0);" onclick="delete_confirm_box_3('<%= ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school) %>','您确定要删除吗?')" class="mr15 color-grey-c">删除</a>
<% end %>
<%#= link_to '删除', ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school), method: :delete, :class => "mr15 color-grey-c", data: { confirm: '您确定要删除吗' } %>

@ -8,7 +8,7 @@
<li class="fl">
<p class="font-18 clearfix">
<span class="fl"><%= @major.name %></span>
<% if @major.schools && User.current.admin? %>
<% if @major.schools && (User.current.admin? || User.current.business?) %>
<i class="iconfont icon-youjiantou font-14 newxiajiantou fl ml20" ></i>
<ul class="edu-menu-list" id="ecmajorschools">
<% @major.schools.each do |school| %>

@ -17,7 +17,7 @@
<ul>
<% @ec_courses.each_with_index do |course, index| %>
<% course_manager = course.ec_course_users.pluck(:user_id).include?(User.current.id) %>
<% btn_text = ((@ec_major_school.template_major && User.current.admin?) || (!@ec_major_school.template_major && @template_major) || course_manager) ? "立即配置" : "查看" %>
<% btn_text = ((@ec_major_school.template_major && (User.current.admin? || User.current.business?)) || (!@ec_major_school.template_major && @template_major) || course_manager) ? "立即配置" : "查看" %>
<li class="clearfix">
<span class="column-No"><%= index + 1 %></span>
<span class="column-9"><%= course.name %></span>

@ -20,7 +20,11 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
<input class="magic-radio fl mt5 magic-checkbox_show" id="sx_<%= exercise_choice.id %>" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" type="radio">
<label class="fl color-grey3" for="sx_<%= exercise_choice.id %>"><%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%></label>
<label class="fl color-grey3" for="sx_<%= exercise_choice.id %>">
<div class="fl">
<%= convert_to_char((index+1).to_s)%>
</div><pre class="fl ml10"><%= exercise_choice.choice_text%></pre>
</label>
</li>
<% end %>
</div>

@ -20,7 +20,11 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="dx_<%= exercise_choice.id %>" value="<%= exercise_choice.choice_text%>" type="checkbox">
<label class="fl color-grey3" for="dx_<%= exercise_choice.id %>"><%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%></label>
<label class="fl color-grey3" for="dx_<%= exercise_choice.id %>">
<div class="fl">
<%= convert_to_char((index+1).to_s)%>
</div><pre class="fl ml10"><%= exercise_choice.choice_text%></pre>
</label>
</li>
<% end %>
</div>

@ -2,13 +2,16 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title><%= if params[:controller] == "trainings" && params[:action] == "enroll"
"报名"
elsif params[:controller] == "trainings" && params[:action] == "pay"
"费用支付"
elsif params[:controller] == "trainings" && params[:action] == "result"
"支付状态"
end %></title>
<title>
<%=
case "#{params[:controller]}-#{params[:action]}"
when 'trainings-show' then '报名信息'
when 'trainings-enroll' then '报名'
when 'trainings-pay' then '费用支付和发票信息'
when 'trainings-result' then '支付信息'
end
%>
</title>
<meta name="description" content="高校智能课堂与综合实训平台" />
<meta name="keywords" content="智能课堂,实训项目" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,target-densitydpi=device-dpi" />

@ -1,3 +1,6 @@
<div class="edu-con-top clearfix xmt10 bor-grey-e mt10">
<a href="<%= subject_level_system_managements_path(:format => "xls") %>" class="fr task-btn task-btn-orange ml5" >导出excel</a>
</div>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<th width="10%">等级</th>

@ -1,5 +1,6 @@
<div class="edu-back-white mt20 padding20">
<p class="clearfix"><span class="font-16 fl">毕业要求通用标准</span><span class="ml5 btn-cir btn-cir-grey mt6 fl" id="standard_count"><%= @standards.count %></span></p>
<% if User.current.admin? %>
<p class="clearfix mb10"><a href="javascript:void(0)" class="fr white-btn edu-greenback-btn" id="addBtn" show="0" onclick="addStandardPanel(this);">+ 新增</a></p>
<div class="padding20 clearfix edu-back-greyf5 mb15 none" id="addStandardPanel">
<p class="clearfix df mb15">
@ -11,6 +12,7 @@
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="submit_data()">保存</a>
</p>
</div>
<% end %>
<input type="hidden" name="standard_id" value="-1">
<div>
<table class="edu-pop-table interval-td interval-all edu-txt-left" cellpadding="0" cellspacing="0" style="border-bottom: none;">

@ -5,6 +5,8 @@
<option value="-1">选择活动名称</option>
<option value="1">2018深圳培训会</option>
<option value="2">2019湖南警察学院大数据培训</option>
<option value="3">信息技术新工科产学研联盟师资培训班</option>
<option value="4">工程教育认证</option>
</select>
<select class="fl mr10 winput-120-30" name="pay_type">
<option value="-1">选择支付方式</option>

@ -1,4 +1,5 @@
<div id="sendPhoto" class="<%= training.training_payinfo.pay_type.to_i == 3 ? "" : "none" %>" style="padding-bottom: 10px;">
<% disabled ||= false %>
<div id="sendPhoto" style="padding-bottom: 10px;">
<div class="weui-uploader__bd">
<% if training.training_payinfo.attachment_url.present? %>
<li id="uploaderFiles" class="weui-uploader__file"
@ -6,8 +7,10 @@
<% else %>
<li id="uploaderFiles" class="weui-uploader__file"></li>
<% end %>
<% unless disabled %>
<div class="weui-uploader__input-box">
<input name="image" id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple="">
</div>
<% end %>
</div>
</div>

@ -1,3 +1,4 @@
<% if false %>
<div>
<p class="collegeInfo">湖南警察学院大数据培训缴费</p>
<%= form_for @training do |f| %>
@ -121,3 +122,135 @@
}
</script>
<% end %>
<div>
<p class="collegeInfo"><%= @training_type == 3 ? '信息技术新工科产学研联盟师资培训班' : '工程教育认证' %></p>
<%= form_for @training do |f| %>
<%= hidden_field_tag(:friendly_id, @friendly_id) %>
<p class="subtitle">基本信息</p>
<li class="clearfix infoBar">
<span class="left_tag fl">姓名</span>
<input type="text" class="right_input" id="username" name="name"
placeholder="请输入真实姓名" value="<%= @training.name %>"/>
</li>
<li class="clearfix infoBar" id="userSex" NavShow>
<span class="left_tag fl">性别</span>
<label class="fr" id="sexl" style="margin-right: 24px;"><%= @training.sex == 1 ? '男' : '女' %></label>
<i class="iconfont icon-youjiantou rightArrow"></i>
<input type="hidden" id="sex" name="sex" value="<%= @training.sex == 1 ? 1 : 2 %>">
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">单位</span>
<input type="text" class="right_input" id="userUnit" placeholder="请输入单位名称或者学校"
name="school"
value="<%= @training.school %>"/>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">职称</span>
<input type="text" class="right_input" id="userPositional" placeholder="请输入职称"
name="position"
value="<%= @training.position %>"/>
</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>
<% if @training_type == 3 %>
<p class="subtitle">您关注的课程类型最少选1项</p>
<% %w(程序设计 操作系统 数据库 软件工程 云计算 大数据 人工智能 计算机网络 物联网 信息安全 其他).each_with_index do |name, index| %>
<li class="clearfix infoBar">
<span class="left_tag fl"><%= name %></span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="<%= name %>" <%= @training.research_field_include?(name) ? "checked" : "" %> id="check_<%= index %>" class="magic-checkbox">
<label for="check_<%= index %>" style="top:8px">&nbsp;</label>
</span>
</li>
<% end %>
<% end %>
<!-- <p class="subtitle">通讯地址</p>-->
<!-- <li class="clearfix infoBar">-->
<!-- <div class="clearfix" id="userArea" NavShow>-->
<!-- <span class="left_tag fl">地区</span>-->
<!-- <input type="text" class="right_input" id="usertitle" placeholder="填写区域"/>-->
<!-- <i class="iconfont icon-youjiantou rightArrow"></i>-->
<!-- </div>-->
<!-- <textarea class="DetailAddress" placeholder="请输入详细地址" name="address" id="DetailAdd" style="margin-top: 15px;"><%#= @training.address %></textarea>-->
<!-- </li>-->
<!-- <li class="clearfix infoBar">-->
<!-- <span class="left_tag fl">Email</span>-->
<!-- <input type="text" class="right_input" placeholder="请输入Email" id="userEmail" name="email" value="<%#= @training.email %>"/>-->
<!-- </li>-->
<p style="height: 50px;"></p>
<a href="javascript:void(0)" class="EnrollNext" onclick="NextStep();"><%= @training.new_record? ? '我要报名' : '保存' %></a>
<% end %>
</div>
<div class="sexDownNav downNav">
<li>男</li>
<li>女</li>
</div>
<script>
$(function () {
var down = $('#userSex');
var downNav = $(".sexDownNav");
showNav(down, downNav, "down");
$(".sexDownNav li").on("click", function () {
$(down).find("#sexl").html($(this).html());
hideNav(downNav);
if ($(this).html() == '男') {
$('#sex').val("1");
} else {
$('#sex').val("2");
}
});
})
//下一步
function NextStep() {
var username = $("#username").val();
var userUnit = $("#userUnit").val();
var userPositional = $("#userPositional").val();
var userphone = $("#userphone").val();
if (username == '') {
alert("请输入姓名");
return;
}
if (userUnit == '') {
alert("请输入单位名称或者学校");
return;
}
if (userPositional == '') {
alert("请输入职称");
return;
}
if (userphone == '') {
alert("请输入手机号码");
return;
} else if (!/^1\d{10}$/.test(userphone) && !/^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(userphone)) {
alert("请输入正确的手机号码");
return;
}
<% if @training_type == 3 %>
if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) {
alert('请选择您关注的课程类型');
return;
}
<% end %>
$('form').submit();
}
</script>

@ -1,6 +1,8 @@
<form action="/trainings/update_payinfo" method="post" accept-charset="UTF-8" enctype="multipart/form-data">
<div style="padding-top: 10px">
<div class="showPanel" id="payTypeLine" NavShow>
<%= hidden_field_tag(:friendly_id, @friendly_id) %>
<div class="showPanel" id="payTypeLine" <%= @training.training_payinfo.not_payed? ? 'NavShow' : '' %>>
<p class="clearfix pr">
<label>支付方式</label>
<span class="mr5" style="margin-right: 24px;" id="payTypeName"><%= @training.training_payinfo.pay_type.to_i == 3 ? "线下支付" : "微信支付" %></span>
@ -15,89 +17,118 @@
<div class="flex1 accountRight">
<li class="df">
<label class="fl">账&nbsp;&nbsp;&nbsp;号:</label>
<p class="fl flex1 break-word">800190320609016</p>
<p class="fl flex1 break-word">1901008009200085901</p>
</li>
<li class="df">
<label class="fl">户&nbsp;&nbsp;&nbsp;名:</label>
<p class="fl flex1">湖南酷得网络科技有限公司</p>
<p class="fl flex1">长沙智擎信息技术有限公司</p>
</li>
<li class="df">
<label class="fl">开户行:</label>
<p class="fl flex1">长沙银行股份有限公司四方支行</p>
<p class="fl flex1">工商银行长沙市岳麓山支行</p>
</li>
</div>
</div>
<p class="payTip">完成线下支付后,请将支付截图粘贴到备注中,以便财务审核</p>
<p class="payTip">完成银行转账后,请上传转账凭证,由会务组审核</p>
</div>
</div>
<!--发票<div class="infoBar mb10">
<p class="clearfix" id="billLine" NavShow>
<span class="grey fl">发票</span>
<label class="fr" id="billDemand" status=2 style="margin-right: 24px;">不需要</label>
<i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 14px"></i>
<div class="infoBar mb10">
<!-- <p class="clearfix" id="billLine" NavShow>-->
<!-- <span class="grey fl">发票</span>-->
<!-- <label class="fr" id="billDemand" status=2 style="margin-right: 24px;">不需要</label>-->
<!-- <i class="iconfont icon-gengduo1 rightArrow" style="color: #323232;right: 14px"></i>-->
<!-- </p>-->
<p class="clearfix" id="billRemark">
<span class="grey fl">发票抬头</span>
<input type="text" name="invoice_title" class="right_input" placeholder="请填写发票抬头"
value="<%= @training.training_payinfo.try(:invoice_title) || @training.school %>"/>
</p>
<p class="clearfix" id="billRemark">
<span class="grey fl">税务登记号</span>
<input type="text" name="invoice_no" class="right_input" placeholder="请填写税务登记号"
value="<%= @training.training_payinfo.try(:invoice_no) %>"/>
</p>
<p class="clearfix" id="billRemark">
<span class="grey fl">发票内容</span>
<input type="text" name="invoice_content" class="right_input"
value="<%#= @training.training_payinfo.invoice_content.presence || '会议注册费' %>"/>
value="<%= @training.training_payinfo.try(:invoice_content).presence || '会议注册费' %>"/>
</p>
</div>-->
</div>
<div class="infoBar mb10">
<p>备注</p>
<textarea class="remarkAccount" name="info" id="info"><%= @training.training_payinfo.info %></textarea>
<textarea class="remarkAccount" name="info" id="info" placeholder="请您在此输入您的留言"><%= @training.training_payinfo.info %></textarea>
</div>
<div class="infoBar mb10 pay-image <%= @training.training_payinfo.pay_type.to_i == 3 ? "" : "none" %>">
<p>上传转账凭证</p>
<!--图片上传-->
<%= render :partial => 'upload_img', :locals => {:training => @training} %>
</div>
<div class="infoBar mb10">
<p>费用明细</p>
<p class="break-word justify moneyDetail">大数据培训缴费</p>
<div style="text-align: right">
<p class="inline">
<input type="hidden" name="enlistN" value="<%= @training.training_payinfo.num %>"/>
<span class="fl mr10 font-12"><span id="enlistNum"><%= @training.training_payinfo.num %></span>人</span>
<span class="fl font-16">
<a href="javascript:void(0)" class="minusNum"><i class="iconfont icon-default sky_blue font-18"></i></a>
<span class="red mr5">¥<span id="enlistMoney"><%= @pay_fee * @training.training_payinfo.num %></span></span>
<a href="javascript:void(0)" class="plusNum"><i class="iconfont icon-roundaddfill blue font-18"></i></a>
<p>费用明细
<% if @training.training_type == 3 %>
<span class="color-orange" id="percentPay">3人及以上8折优惠)</span>
<% end %>
</p>
<p class="break-word justify moneyDetail">含会务费、培训费、教材资料费、餐费、专家差旅费等</p>
<p class="clearfix">
<input type="hidden" name="enlistNum" value="<%= @training.training_payinfo.num || 1 %>"/>
<input type="hidden" name="enlistMoney" value="<%= @training.training_payinfo.fee || @training.registration_fee %>"/>
<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">
<% 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>
</div>
<p style="height: 44px;"></p>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i ==3 ? "" : "none" %>" id="offlinePaySubmitBtn">
<a href="<%= enroll_training_path(id: 'bigdata_hnjcxy_2019') %>" class="leftbtn">返回</a>
<a href="javascript:void(0)" class="rightbtn" id="submitFormBtn">提交</a>
<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"><%= @training.training_payinfo.new_record? ? '完成转账' : '提交' %></a>
</div>
<div class="bottomBtn <%= @training.training_payinfo.pay_type.to_i ==3 ? "none" : "" %>" id="paySubmitBtn">
<a href="<%= enroll_training_path(id: 'bigdata_hnjcxy_2019') %>" class="leftbtn">返回</a>
<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>
<% 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 class="billDownNav downNav">
<div class="pr billPanel">
<p class="clearfix mb10">
<span class="fl billBigTitle">发票抬头</span>
<a href="javascript:void(0)" class="fr" id="closeTypeNav"><i class="iconfont icon-guanbi billClose"></i></a>
</p>
<ul class="clearfix billType">
<li>单位</li>
<li>个人</li>
<li class="active">不需要</li>
</ul>
<p class="clearfix needWrite none">
<span class="fl billSmallTitle mb10">发票抬头</span>
</p>
<ul class="clearfix needWrite none">
<input placeholder="请填写公司单位名称" name="invoice_title" class="billInput billUnit"/>
<input placeholder="请填写税务登记号" name="invoice_no" class="billInput taxNumber"/>
</ul>
<p style="height:48px;"></p>
<a href="javascript:void(0)" class="submitBillInfo" id="commonSubmit" onclick="submitBillInfo();">确定</a>
</div>
</div>-->
<!-- <div class="billDownNav downNav">-->
<!-- <div class="pr billPanel">-->
<!-- <p class="clearfix mb10">-->
<!-- <span class="fl billBigTitle">发票类型</span>-->
<!-- <a href="javascript:void(0)" class="fr" id="closeTypeNav"><i class="iconfont icon-guanbi billClose"></i></a>-->
<!-- </p>-->
<!-- <ul class="clearfix billType">-->
<!-- <li>个人</li>-->
<!-- <li>单位</li>-->
<!-- </ul>-->
<!-- <p class="clearfix needWrite none">-->
<!-- <span class="fl billSmallTitle mb10">发票信息</span>-->
<!-- </p>-->
<!-- <ul class="clearfix needWrite none">-->
<!-- <input placeholder="请填写公司单位名称" name="invoice_title" class="billInput billUnit"/>-->
<!-- <input placeholder="请填写税务登记号" name="invoice_no" class="billInput taxNumber"/>-->
<!-- </ul>-->
<!-- <p style="height:48px;"></p>-->
<!-- <a href="javascript:void(0)" class="submitBillInfo" id="commonSubmit" onclick="submitBillInfo();">确定</a>-->
<!-- </div>-->
<!-- </div>-->
<div class="payTypeDownNav downNav">
<div class="pr billPanel">
@ -111,7 +142,7 @@
</ul>
</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>
<!--<script src="https://cdn.jsdelivr.net/npm/eruda" type="text/javascript"></script>-->
@ -120,22 +151,22 @@
//
// eruda.init();
// var userInfo = {
// name: '<%= @training.name %>',
// school: '<%= @training.school %>',
// //支付方式默认为0
// // 1 微信支付
// // 2 支付宝支付
// // 3 银行卡支付
var userInfo = {
name: '<%= @training.name %>',
school: '<%= @training.school %>',
//支付方式默认为0
// 1 微信支付
// 2 支付宝支付
// 3 银行卡支付
// payType: <%#= @training.training_payinfo.pay_type.to_i %>,
//
// //发票抬头
// //为空则代表不需要发票
// invoiceTitle: '<%#= @training.training_payinfo.invoice_title %>',
//
// //税号
// invoiceNo: '<%#= @training.training_payinfo.invoice_no %>'
// };
newPayinfo: <%= @training.training_payinfo.new_record? %>,
payType: 3,
//发票抬头
//为空则代表不需要发票
invoiceTitle: '<%= @training.training_payinfo.invoice_title || @training.school %>',
//税号
invoiceNo: '<%= @training.training_payinfo.invoice_no %>'
};
//点击弹出发票弹框
// aboutBillType(userInfo);
@ -143,34 +174,34 @@
aboutPayType();
//初始化发票类型
/*InitBill(userInfo);*/
// InitBill(userInfo);
//切换发票类型
/*$(".billType li").on("click", function () {
$(".billType li").removeClass("active");
$(this).addClass("active");
billTypeShowFun(parseInt($(this).index()),userInfo);
})*/
//关闭弹窗
$(".billClose").on("click", function () {
hideNav($(".downNav"));
});
// $(".billType li").on("click", function () {
// $(".billType li").removeClass("active");
// $(this).addClass("active");
// billTypeShowFun(parseInt($(this).index()), userInfo);
// })
// //关闭弹窗
// $(".billClose").on("click", function () {
// hideNav($(".downNav"));
// });
//延迟支付,直接提交
$('#delayPayBtn').on('click', function () {
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
if(!checkBillInfo()){ return }
alert("报名成功,请尽快支付");
$('form').submit();
});
$(".billInput").on("blur",function(){
document.body && (document.body.scrollTop = document.body.scrollTop);
})
//立即支付
$('#payBtn').on('click', function () {
if(!checkBillInfo()){ return }
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
var postData = $('form').serialize();
postData += '&js=true'
console.log(postData);
@ -201,7 +232,7 @@
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。
setTimeout(function () {
window.location.href = "/trainings/bigdata_hnjcxy_2019/result";
window.location.href = "/trainings/<%= @friendly_id %>/result";
}, 500);
} else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
@ -219,80 +250,109 @@
//线下支付提交
$('#submitFormBtn').on('click', function () {
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
if(!checkBillInfo()){ return; }
<% if @training.training_payinfo.blank? || (@training.training_payinfo.not_payed? && @training.training_payinfo.attachment.blank?) %>
var image = $("input[name='image']").val()
if (!image || image.length < 0) {
alert('请先上传支付凭证');
return;
}
<% end %>
$('form').submit();
});
// 微信支付后修改内容提交
$("#submitWxpayFormBtn").on('click', function () {
if(!checkBillInfo()){ return; }
$('form').submit();
});
//上传头像
InitPhoto();
})
//加减报名人数
$(".minusNum").click(function(){
var num=parseInt($("#enlistNum").html());
var money=parseFloat($("#enlistMoney").html()).toFixed(2);
function minusNum(item){
var num=parseInt($("#enlistN").html());
var money=parseFloat(<%= @training.registration_fee %>).toFixed(2);
var percent=$("#percentPay");
if(num>1){
money=parseFloat(parseFloat(money)-parseFloat(money)/parseFloat(num)).toFixed(2);
num=num-1;
$("#enlistNum").html(num);
$("#enlistMoney").html(money);
if(num == 1){
$(".icon-default").removeClass("blue").addClass("sky_blue");
}
$("input[name='enlistN']").val(num);
money=parseFloat(parseFloat(money) *num).toFixed(2);
if($(percent).length>0 && num>2){
$(".lastPrice").html("¥"+ money);
money = parseFloat(parseFloat(money) *0.8);
}else{
$(".lastPrice").html("");
}
})
$(".plusNum").click(function(){
var num=parseInt($("#enlistNum").html());
if(num==1){
$(".icon-default").removeClass("sky_blue").addClass("blue");
$("#enlistN").html(num);
$("#enlistM").html(money);
$("#enlistNum").val(num);
$("#enlistMoney").val(money);
$("input[name='enlistNum']").val(num);
}
var money=parseFloat($("#enlistMoney").html()).toFixed(2);
money=parseFloat(parseFloat(money)+parseFloat(money)/parseFloat(num)).toFixed(2);
}
function plusNum(item){
var num=parseInt($("#enlistN").html());
var money=parseFloat(<%= @training.registration_fee %>).toFixed(2);
var percent=$("#percentPay");
num=num+1;
if(num > 1){
$(".icon-default").removeClass("sky_blue").addClass("blue");
}
money=parseFloat(parseFloat(money) *num).toFixed(2);
$("#enlistNum").html(num);
$("#enlistMoney").html(money);
$("input[name='enlistN']").val(num);
})
})
if($(percent).length>0 && num>2){
$(".lastPrice").html("¥"+ money);
money = parseFloat(parseFloat(money) * 0.8).toFixed(2);
}else{
$(".lastPrice").html("");
}
$("#enlistN").html(num);
$("#enlistM").html(money);
$("#enlistNum").val(num);
$("#enlistMoney").val(money);
$("input[name='enlistNum']").val(num);
}
//页面加载时,初始化发票类型
/*function InitBill(userInfo){
var index=2;
$("#billDemand").html("不需要").attr("status",2);
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo != ""){
function InitBill(userInfo){
var index=1;
$("#billDemand").html("单位").attr("status",1);
if (!userInfo.newPayinfo) {
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){
index=0;
$("#billDemand").html("单位").attr("status",0);
$("#billDemand").html("个人").attr("status",0);
}
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){
index=1;
$("#billDemand").html("个人").attr("status",1);
}
$(".billType li").removeClass("active");
$(".billType li").eq(index).addClass("active");
billTypeShowFun(index,userInfo);
}*/
}
function billTypeShowFun(index, userInfo){
if (parseInt(index) == 0) {
if (parseInt(index) == 1) {
$(".needWrite").removeClass("none");
$(".billUnit").attr("placeholder", "请填写公司单位名称").val(userInfo.school);
$(".taxNumber").removeClass("none");
} else if (parseInt(index) == 1) {
$(".billUnit").attr("placeholder", "请填写公司单位名称").val(userInfo.invoiceTitle || userInfo.school);
$(".taxNumber").removeClass("none").val(userInfo.invoiceNo);
} else if (parseInt(index) == 0) {
$(".needWrite").removeClass("none");
$(".billUnit").attr("placeholder", "请填写姓名").val(userInfo.name);
$(".taxNumber").addClass("none");
} else {
$(".needWrite").addClass("none");
$(".billInput").val('');
$(".taxNumber").val('').addClass("none");
}
}
//点击弹出发票类型弹框
/*function aboutBillType(userInfo){
function aboutBillType(userInfo){
var bill = $("#billLine");
var billNav = $(".billDownNav");
showNav(bill, billNav, "down");
}*/
}
//点击弹出支付方式弹框
function aboutPayType() {
@ -308,14 +368,14 @@
$("#payTypeName").html($(this).html().trim());
console.log($(this).index());
if ($(this).index() == 0) { //微信支付
$("#payInfos,#sendPhoto").addClass("none");
$("#payInfos,.pay-image").addClass("none");
//切换显示按钮
$("#offlinePaySubmitBtn").addClass("none");
$("#paySubmitBtn").removeClass("none");
$('#pay_type').val("1");
} else { //线下支付
$("#payInfos,#sendPhoto").removeClass("none");
$("#payInfos,.pay-image").removeClass("none");
//切换显示按钮
$("#offlinePaySubmitBtn").removeClass("none");
$("#paySubmitBtn").addClass("none");
@ -328,18 +388,20 @@
//提交发票信息
/*function submitBillInfo() {
function submitBillInfo() {
var type = $(".billType li.active").html();
var unit = $(".billUnit").val();
var tax = $(".taxNumber").val();
//只有选择了单位时才需要判断三个是否都已经填写
if (type == "单位") {
if (type == "单位" || type == "个人") {
if (unit == "") {
$(".billUnit").addClass("nullVal");
return;
} else {
$(".billUnit").removeClass("nullVal");
}
}
if (type == "单位") {
if (tax == "") {
$(".taxNumber").addClass("nullVal");
return;
@ -348,20 +410,37 @@
}
}
//选择单位或者个人都要判断是否填写了发票内容
if (type == "单位" || type == "个人") {
var remark = $("input[name='invoice_content']").val();
if (remark == "") {
$("input[name='invoice_content']").addClass("nullVal");
return;
} else {
$("input[name='invoice_content']").removeClass("nullVal");
}
}
// if (type == "单位" || type == "个人") {
// var remark = $("input[name='invoice_content']").val();
// if (remark == "") {
// $("input[name='invoice_content']").addClass("nullVal");
// return;
// } else {
// $("input[name='invoice_content']").removeClass("nullVal");
// }
// }
$("#billDemand").html(type);
//记录选中的发票类型
$("#billDemand").attr("status",$(".billType li.active").index());
hideNav($(".billDownNav"));
}*/
}
function checkBillInfo() {
if ($("input[name='invoice_title']").val() == '') {
alert("请填写发票抬头");
return false;
}
if ($("input[name='invoice_no']").val() == '') {
alert("请填写税务登记号");
return false;
}
if ($("input[name='invoice_content']").val() == '') {
alert("请填写发票内容");
return false;
}
return true;
}
function InitPhoto() {
var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',

@ -10,12 +10,12 @@
<span><%= @training.sex == 1 ? '男' : '女' %></span>
</p>
<p class="clearfix">
<label>专业</label>
<span><%= @training.major %></span>
<label>单位</label>
<span><%= @training.school %></span>
</p>
<p class="clearfix">
<label>学号</label>
<span><%= @training.student_id %></span>
<label>职位</label>
<span><%= @training.position %></span>
</p>
<p class="clearfix">
<label>手机号</label>
@ -29,6 +29,14 @@
</div>-->
<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">
<label>支付状态</label>
<span class="red" style="font-weight: bold;"><%= @training.training_payinfo.pay_status_str %> </span>
@ -55,57 +63,52 @@
<% end %>
<% end %>
<!--发票<div class="showPanel">
<div class="showPanel">
<p class="clearfix">
<label>发票类型</label>
<span><%#= @training.training_payinfo.invoice_title.present? ? '普通发票' : '不需要' %></span>
<span><%= @training.training_payinfo.invoice_title.present? ? '普通发票' : '不需要' %></span>
</p>
<%# if @training.training_payinfo.invoice_title.present? %>
<% if @training.training_payinfo.invoice_title.present? %>
<p class="clearfix">
<label>发票内容</label>
<span><%#= @training.training_payinfo.invoice_content %></span>
<span><%= @training.training_payinfo.invoice_content %></span>
</p>
<p class="clearfix">
<label>发票抬头</label>
<span><%#= @training.training_payinfo.invoice_title %></span>
<span><%= @training.training_payinfo.invoice_title %></span>
</p>
<p class="clearfix">
<label>税务登记号</label>
<span><%#= @training.training_payinfo.invoice_no %></span>
<span><%= @training.training_payinfo.invoice_no %></span>
</p>
<%# end %>
</div>-->
<% end %>
</div>
<div class="showPanel">
<p class="clearfix mb5"><label>其他信息</label></p>
<% if @training.training_payinfo.info.present? %>
<p class="clearfix mb5"><label>备注信息</label></p>
<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>
<!--图片上传-->
<%= render :partial => 'upload_img', :locals => {:training => @training} %>
<%= render partial: 'upload_img', locals: { training: @training, disabled: true } %>
<% 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>
</div>
<!-- <p class="clearfix enrollNum">
<%#= link_to '查看会议信息', training_path(id: 'bigdata_hnjcxy_2019', force: true), class:'fl meetInfo' %>
<span class="fr">已报名人数:<%#= TrainingPayinfo.total_num %>人</span>
</p>
<p style="height: 50px;"></p>-->
<br/>
<br/>
<% if @training.payed? %>
<a href="javascript:void(0);" onclick="closeWx();" class="submitForm">完成</a>
<% else %>
<% if @training.training_payinfo.wechat_wait_pay? %>
<div class="bottomBtn">
<%= link_to "返回", pay_training_path(id: 'bigdata_hnjcxy_2019'), class: 'leftbtn' %>
<% if @training.training_payinfo.wechat_wait_pay? %>
<%= link_to "返回", training_path(id: @friendly_id, disable_redirect: true), class: 'leftbtn' %>
<a href="javascript:void(0)" class="rightbtn" id="wechatPayBtn">立即支付</a>
</div>
<% elsif !@training.payed? %>
<%= link_to "返回", pay_training_path(id: 'bigdata_hnjcxy_2019'), class: 'returnBtn' %>
<% end %>
<% else%>
<%= link_to "返回", pay_training_path(id: @friendly_id, disable_redirect: true), class: 'rightbtn', style: 'width: 100%' %>
<% end %>
</div>
</div>
</div>
<script>
@ -118,7 +121,7 @@
// eruda.init();
function wechatPay() {
$.ajax({
url: '<%= pay_js_trainings_path %>',
url: '<%= pay_js_trainings_path(friendly_id: @friendly_id) %>',
type: "POST",
data: '{}'
}
@ -144,7 +147,7 @@
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。
setTimeout(function () {
window.location.href = "/trainings/bigdata_hnjcxy_2019/result";
window.location.href = "/trainings/<% @friendly_id %>/result";
}, 500);
} else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
@ -186,6 +189,7 @@
var data = new FormData();
data.append('image', files[0]);
data.append('friendly_id', '<%= @friendly_id %>');
$.ajax({
url: '<%= update_picture_trainings_path %>',

@ -0,0 +1,51 @@
<div class="InfoTop">
<div>
<p class="font-22 color-white" style="text-align: center;"><span class="inline"><i class="iconfont icon-wancheng font-30 color-white mr10 fl" style="font-size: 20px;"></i>报名成功</span></p>
</div>
</div>
<div class="Infos">
<p class="Infos_title">基本信息</p>
<li class="clearfix">
<span>姓名</span>
<span><%= @training.name %></span>
</li>
<li class="clearfix">
<span>性别</span>
<span><%= @training.sex == 1 ? '男' : '女' %></span>
</li>
<li class="clearfix">
<span>单位</span>
<span><%= @training.school %></span>
</li>
<li class="clearfix">
<span>职称</span>
<span><%= @training.position %></span>
</li>
<li class="clearfix">
<span>手机号</span>
<span><%= @training.phone %></span>
</li>
</div>
<% if @training.training_type == 3 %>
<div class="Infos clearfix">
<p class="Infos_title">您关注的课程类型</p>
<% @training.research_field.to_s.split(',').each do |name| %>
<a href="javascript:void(0)" class="Infos_tag"><%= name %></a>
<% end %>
</div>
<% end %>
<%= link_to('修改资料', enroll_training_path(id: @friendly_id, disable_redirect: true), class: 'info_updateBtn') %>
<% if @training.training_payinfo.blank? || @training.training_payinfo.not_payed? %>
<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: 1), class: 'rightbtn' %>
</div>
<% else %>
<div class="bottomBtn">
<%= link_to '支付详情', pay_training_path(id: @friendly_id, pay_type: @training.training_payinfo.pay_type),
class: 'rightbtn', style: 'width: 100%;' %>
</div>
<% end %>

@ -46,7 +46,7 @@
<%#= render :partial => "users/course_item", :locals => {:objects => @objects} %>
<% @objects.each do |object| %>
<% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) %>
<% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) || User.current.business? %>
<div class="square-Item" onclick="open_course(<%= object.id %>, <%= allow_visit %>)" style="cursor: pointer;">
<% if object.is_public == 1 %>
<div class="publicpart <%= object.id == 1309 ? 'orangeBlack' : '' %>"></div>

@ -0,0 +1,5 @@
class AddReseachFieldToTrainings < ActiveRecord::Migration
def change
add_column :trainings, :research_field, :string
end
end

@ -0,0 +1,8 @@
class ModifyInputForTestSets < ActiveRecord::Migration
def up
change_column :test_sets, :input, :text
end
def down
end
end

@ -0,0 +1,5 @@
class AddTrainingCategoryToTrainings < ActiveRecord::Migration
def change
add_column :trainings, :training_category, :string
end
end

@ -0,0 +1,9 @@
class RemoveTrainingCategoryInTrainings < ActiveRecord::Migration
def up
remove_column :trainings, :training_category
end
def down
add_column :trainings, :training_category, :string
end
end

@ -70,55 +70,106 @@ namespace :school_daily_report do
end
end
desc 'statistic old shixun homework count and shixun evaluate count'
task :statistic_shixun_info_count, [:date] => :environment do |_, args|
# 统计学校历史每天实训作业新增数
desc 'statistic school shixun homework count everyday'
task :statistic_shixun_homework_count, [:date] => :environment do |_, args|
date = Time.zone.parse(args[:date]).beginning_of_day
current_date = (Time.zone.now - 5.hour).beginning_of_day
custom_logger("statistic range: #{date}..#{current_date}")
while current_date > date
date_str = date.strftime('%Y-%m-%d')
# 检查当天数据是否已经统计
school_count = School.count
query_times = school_count % query_size == 0 ? school_count / query_size : (school_count / query_size) + 1
custom_logger("Start statistic => Date: #{date_str} ~")
custom_logger("Start statistic => Date: #{date_str}, school count: #{school_count}, insert times: #{query_times} ~")
query_times.times do |index|
sql = school_daily_report_sql(date, query_size, index * query_size)
reports = School.find_by_sql(sql)
begin_date = (date + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
end_date = (date + 1.day + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
if SchoolDailyReport.exists?(date: date)
data = []
reports.each do |report|
next if %w(teacher_count student_count course_count shixun_count shixun_homework_count shixun_evaluate_count active_user_count).all? { |key| report[key].zero? }
homework_count_map = HomeworkCommon.joins('LEFT JOIN courses cs ON homework_commons.course_id = cs.id')
.where('cs.school_id IS NOT NULL')
.where(homework_type: 4, created_at: begin_date...end_date).reorder(nil)
.group('cs.school_id').count
record = SchoolDailyReport.where(school_id: report['id'], date: date_str).first
ActiveRecord::Base.transaction do
exist_school_ids = SchoolDailyReport.where(date: date_str).pluck(:school_id)
if record.present?
record.update_attributes(shixun_homework_count: report['shixun_homework_count'], shixun_evaluate_count: report['shixun_evaluate_count'])
updated_school_ids = homework_count_map.keys & exist_school_ids # 需要更新的
updated_reports = []
created_reports = []
homework_count_map.each do |school_id, homework_count|
if updated_school_ids.include?(school_id)
updated_reports << "WHEN #{school_id} THEN #{homework_count}"
else
data << [
report['id'], report['name'], report['teacher_count'], report['student_count'], report['course_count'],
report['shixun_count'], report['shixun_homework_count'], report['shixun_evaluate_count'],
report['active_user_count'], date_str, current_datetime, current_datetime
]
created_reports << "(#{school_id}, '#{date_str}', #{homework_count})"
end
end
if updated_reports.present?
# 这样更新快些
SchoolDailyReport.connection.execute("UPDATE school_daily_reports SET shixun_homework_count = CASE school_id #{updated_reports.join(' ')} END "\
"WHERE school_id IN (#{updated_school_ids.join(',')}) AND date = '#{date_str}'")
end
if created_reports.present?
SchoolDailyReport.connection.execute("INSERT INTO school_daily_reports(school_id, date, shixun_homework_count) VALUES#{created_reports.join(',')}")
end
end
custom_logger("Statistic complete! date: #{date_str}")
date += 1.day
end
end
# 统计学校历史每天实训评测新增数
desc 'statistic school shixun evaluate count everyday'
task :statistic_shixun_evaluate_count, [:date] => :environment do |_, args|
date = Time.zone.parse(args[:date]).beginning_of_day
current_date = (Time.zone.now - 5.hour).beginning_of_day
custom_logger("statistic range: #{date}..#{current_date}")
while current_date > date
date_str = date.strftime('%Y-%m-%d')
custom_logger("Start statistic => Date: #{date_str} ~")
begin_date = (date + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
end_date = (date + 1.day + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
evaluate_count_map = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.where(created_at: begin_date...end_date).where('courses.school_id IS NOT NULL')
.reorder(nil).group('courses.school_id').count
ActiveRecord::Base.transaction do
exist_school_ids = SchoolDailyReport.where(date: date_str).pluck(:school_id)
updated_school_ids = evaluate_count_map.keys & exist_school_ids # 需要更新的
updated_reports = []
created_reports = []
evaluate_count_map.each do |school_id, evaluate_count|
if updated_school_ids.include?(school_id)
updated_reports << "WHEN #{school_id} THEN #{evaluate_count}"
else
data = reports.map do |report|
# 无效数据不记录
next if %w(teacher_count student_count course_count shixun_count shixun_homework_count shixun_evaluate_count active_user_count).all? { |key| report[key].zero? }
created_reports << "(#{school_id}, '#{date_str}', #{evaluate_count})"
end
end
[
report['id'], report['name'], report['teacher_count'], report['student_count'], report['course_count'],
report['shixun_count'], report['shixun_homework_count'], report['shixun_evaluate_count'],
report['active_user_count'], date_str, current_datetime, current_datetime
]
end.compact
batch_create_school_daily_reports!(data) if data.present?
if updated_reports.present?
# 这样更新快些
SchoolDailyReport.connection.execute("UPDATE school_daily_reports SET shixun_evaluate_count = CASE school_id #{updated_reports.join(' ')} END "\
"WHERE school_id IN (#{updated_school_ids.join(',')}) AND date = '#{date_str}'")
end
if created_reports.present?
SchoolDailyReport.connection.execute("INSERT INTO school_daily_reports(school_id, date, shixun_evaluate_count) VALUES#{created_reports.join(',')}")
end
end
custom_logger("Statistic complete! date: #{date_str}")
date += 1.day
@ -181,14 +232,12 @@ namespace :school_daily_report do
LEFT JOIN courses cs ON hc.course_id = cs.id
WHERE cs.school_id = schools.id AND hc.homework_type = 4 AND hc.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
) shixun_homework_count, (
SELECT COUNT(*) FROM outputs os
LEFT JOIN games gs ON os.game_id = gs.id
LEFT JOIN members ON members.user_id = gs.user_id
LEFT JOIN challenges cls ON gs.challenge_id = cls.id
LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = cls.shixun_id
SELECT COUNT(*) FROM evaluate_records er
LEFT JOIN members ON members.user_id = er.user_id
LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = er.shixun_id
LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id
LEFT JOIN courses ON hc.course_id = courses.id AND members.course_id = courses.id
WHERE courses.school_id = schools.id AND os.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
WHERE courses.school_id = schools.id AND er.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
) shixun_evaluate_count, (
SELECT COUNT(*) FROM users u
LEFT JOIN user_extensions ue ON ue.user_id = u.id

File diff suppressed because one or more lines are too long

@ -88,11 +88,11 @@ class VNCDisplay extends Component {
status("Connecting");
// Build the websocket URL used to connect
let url;
// if (window.location.protocol === "https:") {
// url = 'wss';
// } else {
if (vnc_url.indexOf("https:") != -1) {
url = 'wss';
} else {
url = 'ws';
// }
}
url += '://' + host;
if(port) {
url += ':' + port;

@ -20,12 +20,13 @@ a{text-decoration: none}
.flex1{flex: 1}
li{list-style-type: none;}
.color-orange{color: #FC682D!important;}
.mb5{margin-bottom: 5px}.mb10{margin-bottom: 10px!important;}
.mt5{margin-top: 5px}
.mr5{margin-right: 5px}
.ml10{margin-left: 10px;}
.ml5{margin-left: 5px;}.ml10{margin-left: 10px;}
.mr10{margin-right: 10px;}
.line20{line-height: 20px;}
@ -120,8 +121,15 @@ input::-ms-input-placeholder,textarea::-ms-input-placeholder {color:#cccccc;}
span.left_tag{font-weight:bold; }
input[type='text'].right_input{
float: right;border: none;text-align: right;height: 44px;line-height: 44px;outline: none;
font-size: 1.4rem;width: 70%;margin-right: 24px;
font-size: 1.4rem;width: 70%;/*margin-right: 24px;*/
}
.PositionalRight .magic-radio + label:before,.PositionalRight .magic-checkbox + label:before{
top:13px!important;
}
.PositionalRight .magic-radio + label:after{
top: 18px!important;
}
.mr15{margin-right: 15px;}
.infoBar label.right_tag{
float: right;color: #cccccc;font-size: 1.4rem;margin-right: 24px;
}
@ -167,7 +175,7 @@ input[type='text'].right_input{
float: right;color: #333;
}
.bottomBtn{
position: fixed;bottom: 0px;left: 0px;width: 100%;height: 44px;line-height: 44px;font-size: 1.6rem;text-align: center;
position: fixed;bottom: 0px;left: 0px;width: 100%;height: 44px;line-height: 44px;font-size: 1.6rem;text-align: center;z-index: 20;
}
.bottomBtn .leftbtn{
width: 50%;float: left;background-color: #fff;color: #676767;
@ -195,7 +203,7 @@ input[type='text'].right_input{
line-height: 20px;margin-top: 3px;
}
.remarkAccount{
width: 100%;resize: none;height: 80px;margin-bottom:14px;border: 1px solid #eee;padding: 5px;box-sizing: border-box;
width: 100%;resize: none;height: 80px;border: 1px solid #eee;padding: 5px;box-sizing: border-box;margin-bottom: 1rem;
}
.moneyDetail{
line-height: 20px;color: #4B4B4B;
@ -233,6 +241,7 @@ input[type='text'].right_input{
.billInput.nullVal{border:1px solid #DD1717;}
.meetInfo{color: #4CACFF;}
.enrollNum{margin:10px 15px;font-size: 1.4rem;}
.lastPrice{color: #bfbfbf;font-size: 0.8em;text-decoration: line-through;margin-left: 5px;margin-top: 2px;}
/*上传图片*/
.weui-uploader__bd {position: relative;width: 100px;height: 100px;}
.weui-uploader__files {list-style: none;}
@ -256,3 +265,38 @@ input[type='text'].right_input{
content: " ";position: absolute;top: 50%;left: 50%;-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);background-color: #D9D9D9;
}
/* 支付信息 */
.InfoTop{width: 100%;height: 6.5rem;background: linear-gradient(to right, #4CC6FF , #6588F8);justify-content: center;
align-items: center;display: -webkit-flex;font-size: 1.6rem;color: white;}
.info_updateBtn{
display: block;
width: 60%;
height: 35px;
line-height: 35px;
text-align: center;
border: 1px solid #4CC6FF;
border-radius: 24px;
font-size: 1.6rem;
color: #4CC6FF!important;
margin-top: 1rem;margin:2rem auto;
}
.Infos{
padding:15px;box-sizing: border-box;background: #fff;
}
.Infos {margin-bottom: 1rem;}
.Infos .Infos_title{font-size: 1.5rem;color: #000;margin-bottom: 1rem;}
.Infos li{margin-bottom: 8px;}
.Infos li span:first-child{color: #666666;font-size: 1.4rem;float: left;}
.Infos li span:last-child{color: #333;font-size: 1.4rem;float: right;}
.Infos .Infos_tag{float: left;height:2.0rem;padding: 0px 0.5rem;box-sizing: border-box;line-height: 2.0rem;
background: #E6F3FF;color: #4CACFF;cursor: default;margin-right: 1.5rem;margin-bottom: 1.0rem;
}
.Infos_btn {background: #fff;height: 5rem;line-height: 5rem;position: absolute;bottom: 0px;left:0px;width: 100%;}
.Infos_btn a{
float: left;width: 50%;text-align: center;color: #4CACFF!important;font-size: 1.8rem;
}
.Infos_btn a:last-child{
background: #4CACFF!important;color: #fff!important;
}

Loading…
Cancel
Save