diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 05f04630..c0abee20 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]) + @user_agents = UserAgent.where(key: params[:edu]).includes(:user_actionss) @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 87d1097d..df7df41c 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -25,8 +25,8 @@ module WelcomeHelper # 引流注册情况 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? + user_id = user_agent.user_actionss.first.try(:user_id) + if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else "未转换" @@ -34,8 +34,8 @@ module WelcomeHelper 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? + user_id = user_agent.user_actionss.first.try(:user_id) + if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else "代理后注册" diff --git a/app/models/user_agent.rb b/app/models/user_agent.rb index acc45a8a..3bb16582 100644 --- a/app/models/user_agent.rb +++ b/app/models/user_agent.rb @@ -1,5 +1,5 @@ class UserAgent < ActiveRecord::Base - + has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip" USER_AD = 1 # 广告宣传的引流 USER_REGISTER = 2 # 引流注册 USER_COMPETITION = 3 # 引流参加竞赛