diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index c0abee20..05f04630 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -42,7 +42,7 @@ class WelcomeController < ApplicationController # 运营引流个人数据展示 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 limit = 20 @agents_pages = Paginator.new @agents_count, limit, params['page'] || 1 diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 395bb07a..1d4eb879 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -24,22 +24,41 @@ module WelcomeHelper # 引流注册情况 def register_info user_agent - if user_agent.agent_type.to_i == UserAgent::USER_AD - 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 - 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 + case user_agent.register_status + when 0 + "改IP未登录" + when 1 + "代理之前注册" + when 2 + "代理之后注册" + end + # if user_agent.agent_type.to_i == UserAgent::USER_AD + # 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 + # 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 diff --git a/app/models/user_agent.rb b/app/models/user_agent.rb index 3bb16582..0fabe469 100644 --- a/app/models/user_agent.rb +++ b/app/models/user_agent.rb @@ -1,3 +1,5 @@ +# register_status: 0:未注册;1: 代理之前注册;2:代理之后注册 +# action_status: 0:未注册;1: 代理之前报名;2:代理之后报名 class UserAgent < ActiveRecord::Base has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip" USER_AD = 1 # 广告宣传的引流 diff --git a/app/views/welcome/_user_agent_list.html.erb b/app/views/welcome/_user_agent_list.html.erb index 34792244..607392bd 100644 --- a/app/views/welcome/_user_agent_list.html.erb +++ b/app/views/welcome/_user_agent_list.html.erb @@ -15,7 +15,7 @@