|
|
@ -2820,17 +2820,17 @@ end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
"status = 1"
|
|
|
|
"status = 1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@users = User.where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on #{@sx_order}")
|
|
|
|
@users = User.where("#{sql}").includes(:real_name_authentication_apply, :professional_authentication_apply,
|
|
|
|
|
|
|
|
user_extensions: [:department, :school]).order("last_login_on #{@sx_order}")
|
|
|
|
@has_cer_count = User.where(:status => 1, :certification => 1).count
|
|
|
|
@has_cer_count = User.where(:status => 1, :certification => 1).count
|
|
|
|
@reject_cer_count = User.where(:status => 1, :certification => 2).count
|
|
|
|
@reject_cer_count = User.where(:status => 1, :certification => 2).count
|
|
|
|
@deal_cer_count = ApplyAction.where(:status => 0).select("distinct user_id").count
|
|
|
|
@deal_cer_count = ApplyAction.where(:status => 0).select("distinct user_id").count
|
|
|
|
time = Time.at(Time.now.to_i - 86400)
|
|
|
|
|
|
|
|
cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id)
|
|
|
|
subquery = UserDayCertification.where("created_at > ?", Time.now.ago(1.days)).select(:user_id).to_sql
|
|
|
|
cer_ids = cer.join(",")
|
|
|
|
@trial_cer_count = User.where("status = 1 and certification != 1 and id in (#{subquery})").count
|
|
|
|
@trial_cer_count = cer.blank? ? 0 : User.where("status = 1 and certification != 1 and id in (#{cer_ids})").count
|
|
|
|
|
|
|
|
apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id)
|
|
|
|
apply_subquery = ApplyAction.where(container_type: "TrialAuthorization").select(:user_id).to_sql
|
|
|
|
apply_ids = apply.join(",")
|
|
|
|
@nonn_cer_count = User.where("status = 1 and certification = 0 and id not in (#{apply_subquery}) ").count
|
|
|
|
@nonn_cer_count = apply.blank? ? 0 : User.where("status = 1 and certification = 0 and id not in (#{apply_ids}) ").count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@page = (params['page'] || 1).to_i
|
|
|
|
@page = (params['page'] || 1).to_i
|
|
|
|
@users_count = @users.count
|
|
|
|
@users_count = @users.count
|
|
|
@ -3310,83 +3310,82 @@ end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
all_user_ids = User.where(:status => 1).pluck(:id)
|
|
|
|
users = User.where(nil)
|
|
|
|
if params[:trial] == "-1"
|
|
|
|
if params[:trial] == "-1"
|
|
|
|
apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id)
|
|
|
|
users = users.where(status: 1, certification: 0)
|
|
|
|
apply_id = apply.blank? ? -1 : "(" + apply.join(",") + ")"
|
|
|
|
.joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id AND apply_actions.container_type = "TrialAuthorization"')
|
|
|
|
apply_user_id = User.where("status = 1 and certification = 0 and id not in #{apply_id} ").pluck(:id)
|
|
|
|
.where('apply_actions.user_id IS NULL')
|
|
|
|
elsif params[:trial] == "-2"
|
|
|
|
elsif params[:trial] == "-2"
|
|
|
|
apply_user_id = all_user_ids
|
|
|
|
users = users.where(status: 1)
|
|
|
|
elsif params[:trial] == "0"
|
|
|
|
elsif params[:trial] == "0"
|
|
|
|
apply_user_id = ApplyAction.where(:status => 0).pluck(:user_id)
|
|
|
|
users = users.joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id').where(apply_actions: { status: 0 })
|
|
|
|
elsif params[:trial] == "3"
|
|
|
|
elsif params[:trial] == "3"
|
|
|
|
time = Time.at(Time.now.to_i - 86400)
|
|
|
|
users = users.joins('LEFT JOIN user_day_certifications udc ON udc.user_id = users.id')
|
|
|
|
user_cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id)
|
|
|
|
.where('users.certification != 1').where('udc.created_at > ?', Time.now.ago(1.days))
|
|
|
|
cer_id = user_cer.blank? ? "(-1)" : "(" + user_cer.map{|a| a.user_id}.join(",") + ")"
|
|
|
|
|
|
|
|
apply_user_id = User.where("status = 1 and certification != 1 and id in #{cer_id} ").pluck(:id)
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
apply_user_id = User.where(:status => 1, :certification => params[:trial]).pluck(:id)
|
|
|
|
users = users.where(status: 1, certification: params[:trial])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if params[:school] == ""
|
|
|
|
users = users.joins('LEFT JOIN user_extensions ON user_extensions.user_id = users.id')
|
|
|
|
s_user_id = all_user_ids
|
|
|
|
.joins('LEFT JOIN departments ON departments.id = user_extensions.department_id')
|
|
|
|
else
|
|
|
|
.joins('LEFT JOIN schools ON schools.id = user_extensions.school_id')
|
|
|
|
school_ids = School.where("name like '%#{params[:school]}%'").pluck(:id)
|
|
|
|
|
|
|
|
s_user_id = UserExtensions.where(:school_id => school_ids).pluck(:user_id)
|
|
|
|
if params[:school].present?
|
|
|
|
|
|
|
|
users = users.where("schools.name LIKE ?", "%#{params[:school]}%")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if params[:department] == ""
|
|
|
|
if params[:department].present?
|
|
|
|
d_user_id = all_user_ids
|
|
|
|
users = users.where("departments.name LIKE ?", "%#{params[:department]}%")
|
|
|
|
else
|
|
|
|
|
|
|
|
dep_ids = Department.where("name like '%#{params[:department]}%'").pluck(:id)
|
|
|
|
|
|
|
|
d_user_id = UserExtensions.where(:department_id => dep_ids).pluck(:user_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ide_user_id = all_user_ids
|
|
|
|
|
|
|
|
if params[:identity] == "1" || (params[:identity] == "0" && params[:te_technical_title] == "0") || (params[:identity] == "2" && params[:pro_technical_title] == "0")
|
|
|
|
if params[:identity] == "1" || (params[:identity] == "0" && params[:te_technical_title] == "0") || (params[:identity] == "2" && params[:pro_technical_title] == "0")
|
|
|
|
ide_user_id = UserExtensions.where("identity = #{params[:identity]}").pluck(:user_id)
|
|
|
|
users = users.where(user_extensions: { identity: params[:identity] })
|
|
|
|
elsif (params[:identity] == "0" && params[:te_technical_title] != "0") || (params[:identity] == "2" && params[:pro_technical_title] != "0")
|
|
|
|
elsif (params[:identity] == "0" && params[:te_technical_title] != "0") || (params[:identity] == "2" && params[:pro_technical_title] != "0")
|
|
|
|
technical_title = params[:identity] == "0" ? params[:te_technical_title] : params[:pro_technical_title]
|
|
|
|
technical_title = params[:identity] == "0" ? params[:te_technical_title] : params[:pro_technical_title]
|
|
|
|
ide_user_id = UserExtensions.where("identity = #{params[:identity]} and technical_title = '#{technical_title}'").pluck(:user_id)
|
|
|
|
users = users.where(user_extensions: { identity: params[:identity], technical_title: technical_title })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if params[:student_id] && params[:student_id] != ''
|
|
|
|
if params[:student_id].present?
|
|
|
|
stu_user_id = UserExtensions.where("student_id like '%#{params[:student_id]}%'").pluck(:user_id)
|
|
|
|
users = users.where('user_extensions.student_id like ?', "%#{params[:student_id]}%")
|
|
|
|
else
|
|
|
|
|
|
|
|
stu_user_id = all_user_ids
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
user_id = s_user_id & d_user_id & apply_user_id & stu_user_id & ide_user_id
|
|
|
|
if params[:research_contents].present?
|
|
|
|
sql = ""
|
|
|
|
keyword = "%#{params[:research_contents]}%"
|
|
|
|
sql =
|
|
|
|
|
|
|
|
if params[:research_condition] == "name"
|
|
|
|
if params[:research_condition] == "name"
|
|
|
|
"concat(lastname, firstname) like '%#{params[:research_contents]}%'"
|
|
|
|
users = users.where('concat(lastname, firstname) like ?', keyword)
|
|
|
|
elsif params[:research_condition] == "email"
|
|
|
|
elsif params[:research_condition] == "email"
|
|
|
|
"mail like '%#{params[:research_contents]}%'"
|
|
|
|
users = users.where("mail like ?", keyword)
|
|
|
|
elsif params[:research_condition] == "phone"
|
|
|
|
elsif params[:research_condition] == "phone"
|
|
|
|
"phone like '%#{params[:research_contents]}%'"
|
|
|
|
users = users.where("phone like ?", keyword)
|
|
|
|
elsif params[:research_condition] == "nickname"
|
|
|
|
elsif params[:research_condition] == "nickname"
|
|
|
|
if params[:research_contents].present?
|
|
|
|
users = users.where("nickname like ?", keyword)
|
|
|
|
"nickname like '%#{params[:research_contents]}%'"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
elsif params[:research_condition] == "login"
|
|
|
|
elsif params[:research_condition] == "login"
|
|
|
|
params[:research_contents].present? ? "login like '%#{params[:research_contents]}%'" : ""
|
|
|
|
users = users.where("login like ?", keyword)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if params[:province].present?
|
|
|
|
|
|
|
|
users = users.where(schools: { province: params[:province] })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc")
|
|
|
|
users = users.select('distinct users.*').order("last_login_on desc")
|
|
|
|
@xls_users = @users.reorder("created_on desc").limit(3000) #导出excel用户
|
|
|
|
|
|
|
|
@page = (params['page'] || 1).to_i
|
|
|
|
@page = (params['page'] || 1).to_i
|
|
|
|
@users_count = @users.count
|
|
|
|
@users_count = users.count
|
|
|
|
@limit = 20
|
|
|
|
@limit = 20
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
|
@users_pages = Paginator.new @users_count, @limit, params['page'] || 1
|
|
|
|
@users_pages = Paginator.new @users_count, @limit, params['page'] || 1
|
|
|
|
@offset ||= @users_pages.offset
|
|
|
|
@offset ||= @users_pages.offset
|
|
|
|
@users = paginateHelper @users, @limit
|
|
|
|
@users = paginateHelper users.includes(:real_name_authentication_apply, :professional_authentication_apply,
|
|
|
|
|
|
|
|
user_extensions: [:department, :school]), @limit
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.xls{
|
|
|
|
format.xls{
|
|
|
|
# @export_shixun_task = @export_shixun_task.all
|
|
|
|
# @export_shixun_task = @export_shixun_task.all
|
|
|
|
|
|
|
|
@xls_users = users.reorder("created_on desc").limit(3000) #导出excel用户
|
|
|
|
|
|
|
|
@xls_users = @xls_users.includes(:real_name_authentication_apply, :professional_authentication_apply,
|
|
|
|
|
|
|
|
user_extensions: [:department, :school])
|
|
|
|
filename = "用户列表.xls"
|
|
|
|
filename = "用户列表.xls"
|
|
|
|
send_data(user_list_xls(@xls_users), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
|
|
|
send_data(user_list_xls(@xls_users), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
|
|
|
}
|
|
|
|
}
|
|
|
|