引流情况

dev_aliyun
daiao 5 years ago
parent f8c5a67396
commit 64c078abf2

@ -80,7 +80,7 @@ class AccountController < ApplicationController
set_autologin_cookie(@user)
end
# 记录用户登录行为
UserActions.create(:action_id => @user.id, :action_type => "Login", :user_id => @user.id)
UserActions.create(:action_id => @user.id, :action_type => "Login", :user_id => @user.id, :ip => request.remote_ip)
end
respond_to do |format|
format.js
@ -381,6 +381,7 @@ class AccountController < ApplicationController
ip = request.remote_ip
ua = UserAgent.find_by_ip(ip)
ua.update_column(:agent_type, UserAgent::USER_REGISTER) if ua
UserActions.create(:action_id => @user.id, :action_type => "Register", :user_id => @user.id, :ip => ip)
if !@user.new_record?
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
@ -1403,7 +1404,7 @@ class AccountController < ApplicationController
code = /\d*/
# 记录用户登录行为
UserActions.create(:action_id => User.current.id, :action_type => "Login", :user_id => User.current.id)
UserActions.create(:action_id => User.current.id, :action_type => "Login", :user_id => User.current.id, :ip => request.remote_ip)
=begin
if user.created_on.strftime('%Y-%m-%d %H:%M:%S') > "2018-01-01 00:00:00" && user.phone.blank?
redirect_to change_or_bind_path(:type => 'phone')

@ -40,6 +40,17 @@ class WelcomeController < ApplicationController
render :json => {status: 0, message: "success"}
end
# 运营引流个人数据展示
def user_agents
@user_agents = UserAgent.find_by_key(params[:edu])
@agents_count = @user_agents.count
limit = 20
@agents_pages = Paginator.new @agents_count, limit, params['page'] || 1
@offset ||= @agents_pages.offset
@user_agents = paginateHelper @user_agents, limit
end
def shixun_to_local
identifiers = params[:identifiers].split(",")

@ -22,6 +22,27 @@ module WelcomeHelper
include CoursesHelper
include ProjectsHelper
# 引流注册情况
def register_info user_agent
if user_agent.agent_type.to_i == UserAgent::USER_AD
user_id = UserActions.find_by_ip(user_agent.ip).try(:user_id)
if user_id && UserActions.where("user_id = #{user_id} and created_at < '2019-07-15 00:00:00'").present?
"代理前注册"
else
"未转换"
end
elsif user_agent.agent_type.to_i == UserAgent::USER_REGISTER || UserActions.find_by_ip(user_agent.ip)
"代理后注册"
else
user_id = UserActions.find_by_ip(user_agent.ip).try(:user_id)
if user_id && UserActions.where("user_id = #{user_id} and created_at < '2019-07-15 00:00:00'").present?
"代理前注册"
else
"代理后注册"
end
end
end
def color_change index
case index
when 0

@ -0,0 +1,33 @@
<table class="edu-pop-table edu-txt-center" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<thead>
<th width="10%">ID</th>
<th width="15%">代理人登录名</th>
<th width="15%">代理人姓名</th>
<th width="20%">注册情况</th>
<th width="20%">竞赛报名</th>
<th width="20%">ip</th>
</thead>
<tbody>
<% @user_agents.each_with_index do |ua, index| %>
<% user = User.find_by_login(ua.key) %>
<tr>
<td><%= index+1 %></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><%= register_info(ua) %></td>
<td><%= user.agent_type.to_i == UserAgent::USER_COMPETITION ? "已报名" : "未报名" %></td>
<td><%= ua.ip %></td>
<td><%= "理由" %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @agents_pages, @agents_count, :per_page_links => false, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>

@ -0,0 +1,9 @@
<div class="edu-con-bg01 clearfix mt10 bor-grey-e pt10 pb10">
<div class="pl15">
统计总计:
引流总人数<span class="color-red"><%= @agents_count %></span>人,
</div>
</div>
<div class="edu-con-bg01 mt15" id="managements_department_part_list">
<%= render :partial => "welcome/user_agent_list" %>
</div>

@ -0,0 +1,10 @@
class AddIpForUserActions < ActiveRecord::Migration
def up
add_column :user_actions, :ip, :string
UserAgent.where("agent_type is null").update_all(:agent_type => 1)
end
def down
end
end
Loading…
Cancel
Save