Merge branch 'educoder' into develop

dev_aliyun
jingquan huang 5 years ago
commit 421312ee44

@ -3,7 +3,7 @@ class ManagementsController < ApplicationController
before_filter :require_business before_filter :require_business
before_filter :require_admin, :only => [:shixun_setting_list, :mirror_repository, :mirror_picture_shixuns, :editmd_template, before_filter :require_admin, :only => [:shixun_setting_list, :mirror_repository, :mirror_picture_shixuns, :editmd_template,
:editmd_template, :subject_level_system, :subject_setting_list, :editmd_template, :subject_level_system, :subject_setting_list,
:shixun_authorization, :ec_template, :codemirror_template, :shixun_authorization, :ec_template, :codemirror_template, :update_user,
:course_guide_template, :shixun_quality_score, :tech_system, :update_notice, :setting_banner, :course_guide_template, :shixun_quality_score, :tech_system, :update_notice, :setting_banner,
:training_2018, :create_standard] :training_2018, :create_standard]
layout 'base_management' layout 'base_management'

@ -42,7 +42,7 @@ class WelcomeController < ApplicationController
# 运营引流个人数据展示 # 运营引流个人数据展示
def user_agents def user_agents
@user_agents = UserAgent.where(key: params[:edu]).includes(:user_actionss) @user_agents = UserAgent.where(key: params[:edu])
@agents_count = @user_agents.count @agents_count = @user_agents.count
limit = 20 limit = 20
@agents_pages = Paginator.new @agents_count, limit, params['page'] || 1 @agents_pages = Paginator.new @agents_count, limit, params['page'] || 1

@ -24,22 +24,41 @@ module WelcomeHelper
# 引流注册情况 # 引流注册情况
def register_info user_agent def register_info user_agent
if user_agent.agent_type.to_i == UserAgent::USER_AD case user_agent.register_status
user_id = user_agent.user_actionss.first.try(:user_id) when 0
if user_id && User.where("id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "改IP未登录"
"代理前注册" when 1
else "代理之前注册"
"未转换" when 2
end "代理之后注册"
elsif user_agent.agent_type.to_i == UserAgent::USER_REGISTER || UserActions.find_by_ip(user_agent.ip) end
"代理后注册" # if user_agent.agent_type.to_i == UserAgent::USER_AD
else # user_id = user_agent.user_actionss.first.try(:user_id)
user_id = user_agent.user_actionss.first.try(:user_id) # if user_id && User.where("id = #{user_id} and created_on < '2019-07-15 00:00:00'").present?
if user_id && User.where("id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? # "代理前注册"
"代理前注册" # else
else # "未转换"
"代理后注册" # end
end # elsif user_agent.agent_type.to_i == UserAgent::USER_REGISTER || UserActions.find_by_ip(user_agent.ip)
# "代理后注册"
# else
# user_id = user_agent.user_actionss.first.try(:user_id)
# if user_id && User.where("id = #{user_id} and created_on < '2019-07-15 00:00:00'").present?
# "代理前注册"
# else
# "代理后注册"
# end
# end
end
def competion_info user_agent
case user_agent.action_status
when 0
"未报名"
when 1
"代理之前报名"
when 2
"代理之后报名"
end end
end end

@ -1,3 +1,5 @@
# register_status: 0未注册1: 代理之前注册2代理之后注册
# action_status: 0未注册1: 代理之前报名2代理之后报名
class UserAgent < ActiveRecord::Base class UserAgent < ActiveRecord::Base
has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip" has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip"
USER_AD = 1 # 广告宣传的引流 USER_AD = 1 # 广告宣传的引流

@ -171,7 +171,8 @@ class SourcesService
def get_user_info params def get_user_info params
user = User.find params[:id] user = User.find params[:id]
{username: user.show_real_name, user_id: user.id, email: user.mail, phone: user.phone, sex: user.sex, school_name: user.school_name} mail = user.mail.presence || "login@educoder.net"
{username: user.show_real_name, user_id: user.id, email: mail, phone: user.phone, sex: user.sex, school_name: user.school_name}
end end
# courses start ############################################ # courses start ############################################

@ -1,10 +1,6 @@
<div class="newFooter edu-txt-center"> <!-- 底部导航栏 --> <div class="newFooter edu-txt-center"> <!-- 底部导航栏 -->
<div class="inner-footer_con"> <div class="inner-footer_con">
<div class="footercon"> <div class="footercon">
<div class="inline mt40">
<%= link_to image_tag("/images/educoder/headNavLogo.png", alt:"高校智能化教学与实训平台" , width: "70px"), home_path,:class => "fl",:style => "height:70px" %>
<span class="fl color-grey-c cdefault font-28 ml30" style="line-height:74px">EduCoder.NET</span>
</div>
<ul class="clearfix inner-footernav"> <ul class="clearfix inner-footernav">
<li><a href="<%= home_path %>" class="fl">网站首页</a></li> <li><a href="<%= home_path %>" class="fl">网站首页</a></li>
<li><a href="<%= help_path(:index => 1) %>" class="fl">关于我们</a></li> <li><a href="<%= help_path(:index => 1) %>" class="fl">关于我们</a></li>

@ -51,9 +51,10 @@
</div> </div>
<span class="font-15 fr mt15 ml15"> <span class="font-15 fr mt15 ml15">
<%= link_to '登录', signin_path, :class => "mr5 color-white" %> <a href="www.educoder.net/login" class="mr5 color-white">登录</a>
<em class="vertical-line"></em> <em class="vertical-line"></em>
<%= link_to '注册', user_join_path, :class => "ml5 color-white" %> <a href="www.educoder.net/register" class="mr5 color-white">登录</a>
<%#= link_to '注册', user_join_path, :class => "ml5 color-white" %>
</span> </span>
<div class="fr head-right"> <div class="fr head-right">
<a href="javascript:void(0)" id="search-open" class="fl headIcon"> <a href="javascript:void(0)" id="search-open" class="fl headIcon">
@ -65,7 +66,6 @@
<div class="edu-menu-list" style="top:60px;width: 240px;"> <div class="edu-menu-list" style="top:60px;width: 240px;">
<div class="overPart"></div> <div class="overPart"></div>
<ul class="fl with50 edu-txt-center pr ul-leftline"> <ul class="fl with50 edu-txt-center pr ul-leftline">
<li><%= link_to '新建课堂', new_course_path() %></li>
<li><%= link_to '新建实训', new_shixun_path() %></li> <li><%= link_to '新建实训', new_shixun_path() %></li>
<li><%= link_to '新建实践课程', new_subject_path() %></li> <li><%= link_to '新建实践课程', new_subject_path() %></li>
<li><%= link_to '新建项目', new_project_path() %></li> <li><%= link_to '新建项目', new_project_path() %></li>

@ -15,7 +15,7 @@
<td class="edu-txt-left"><span><%= link_to ua.key, user_path(ua.key), :target => "_blank" %></span></td> <td class="edu-txt-left"><span><%= link_to ua.key, user_path(ua.key), :target => "_blank" %></span></td>
<td><%= link_to user.try(:show_real_name), user_path(user), target:'_blank' %></td> <td><%= link_to user.try(:show_real_name), user_path(user), target:'_blank' %></td>
<td><%= register_info(ua) %></td> <td><%= register_info(ua) %></td>
<td><%= ua.agent_type.to_i == UserAgent::USER_COMPETITION ? "已报名" : "未报名" %></td> <td><%= competion_info(ua) %></td>
<td><%= ua.ip %></td> <td><%= ua.ip %></td>
</tr> </tr>
<% end %> <% end %>

@ -0,0 +1,6 @@
class AddRegisterStatusToUserAgents < ActiveRecord::Migration
def change
add_column :user_agents, :register_status, :integer, :default => 0
add_column :user_agents, :action_status, :integer, :default => 0
end
end

@ -0,0 +1,37 @@
# register_status: 0未注册1: 代理之前注册2代理之后注册
# register_action: 0未报名1: 代理之前报名2代理之后报名
desc "sync user_agents"
namespace :sync do
task :user_agent => :environment do
UserAgent.find_each do |ua|
puts ua.id
user_action = UserActions.find_by_ip(ua.ip)
params = {}
# 用户注册情况
if user_action
user = User.find(user_action.try(:user_id))
# 即代理之前注册
if user.created_on < ua.created_at
params = params.merge(:register_status => 1)
else
# 代理之后注册的
params = params.merge(:register_status => 2)
end
end
# 用户报名情况
team_member = TeamMember.find_by_user_id(user_action.try(:user_id))
if team_member
# 即代理之前报名的
if team_member.created_on < ua.created_at
params = params.merge(:action_status => 1)
else
# 代理之后报名的
params = params.merge(:action_status => 2)
end
end
ua.update_attributes(params)
end
end
end
Loading…
Cancel
Save