Merge remote-tracking branch 'origin/develop' into develop

dev_aliyun
杨树明 5 years ago
commit 1d1c8ad33d

@ -33,9 +33,9 @@ module Mobile
if params[:edu] if params[:edu]
Rails.logger.info("####11111222##{@env['HTTP_X_REAL_IP']}") Rails.logger.info("####11111222##{@env['HTTP_X_REAL_IP']}")
ip = @env['HTTP_X_REAL_IP'] ip = @env['HTTP_X_REAL_IP']
ua = UserAgent.find_by_ip(ip) ua = UserAgent.where(:ip => ip, :type => UserAgent::AD)
unless ua unless ua
UserAgent.create(:key => params[:edu].strip, :ip => ip) UserAgent.create(:key => params[:edu].strip, :ip => ip, :type => UserAgent::AD)
end end
end end
MemosService.new.show params, current_user MemosService.new.show params, current_user

@ -377,36 +377,6 @@ class AccountController < ApplicationController
else else
us = UsersService.new us = UsersService.new
@user = us.register user_params.merge(:should_confirmation_password => false) @user = us.register user_params.merge(:should_confirmation_password => false)
=begin
case Setting.self_registration
when '1'
#register_by_email_activation(@user)
unless @user.new_record?
# if params[:user][:phone] =~ /^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
# redirect_to account_email_valid_path(:mail => @user.mail, :user_id => @user.id)
# else
self.logged_user = @user
redirect_to user_info_path()
# end
# flash[:notice] = l(:notice_account_register_done)
# render action: 'email_valid', locals: {:mail => @user.mail}
end
when '3'
#register_automatically(@user)
if !@user.new_record?
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to user_info_path()
else
redirect_to signin_path
end
else
#register_manually_by_administrator(@user)
unless @user.new_record?
account_pending
end
end
=end
if !@user.new_record? if !@user.new_record?
self.logged_user = @user self.logged_user = @user
flash[:notice] = l(:notice_account_activated) flash[:notice] = l(:notice_account_activated)

@ -113,6 +113,8 @@ class CompetitionTeamsController < ApplicationController
next if user_id.to_i == User.current.id next if user_id.to_i == User.current.id
new_team.team_members.create!(user_id: user_id, role: 3, competition_id: @competition.id, is_teacher: 1) new_team.team_members.create!(user_id: user_id, role: 3, competition_id: @competition.id, is_teacher: 1)
end end
# 创建时,记录是否是引流用户
record_agent_user_action
end end
end end
@ -226,6 +228,8 @@ class CompetitionTeamsController < ApplicationController
end end
team.team_members.create!(user_id: User.current.id, role: 2, competition_id: @competition.id) team.team_members.create!(user_id: User.current.id, role: 2, competition_id: @competition.id)
# 创建时,记录是否是引流用户
record_agent_user_action
end end
end end
@ -341,4 +345,13 @@ class CompetitionTeamsController < ApplicationController
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('shixun_id').count .group('shixun_id').count
end end
def record_agent_user_action
# 注册时,记录是否是引流用户
ip = @env['HTTP_X_REAL_IP']
ua = UserAgent.where(:ip => ip, :type => UserAgent::AD).take
if ua && UserAgent.where(:ip => ip, :type => UserAgent::COMPETITION).blank?
UserAgent.create(:key => ua.key, :ip => ip, :type => UserAgent::COMPETITION, :user_id => User.current.id)
end
end
end end

@ -1,3 +1,6 @@
class UserAgent < ActiveRecord::Base class UserAgent < ActiveRecord::Base
AD = 1 # 广告宣传的引流
REGISTER = 2 # 引流注册
COMPETITION = 3 # 引流参加竞赛
end end

@ -136,6 +136,10 @@ class UsersService
ue = @user.user_extensions ||= UserExtensions.new ue = @user.user_extensions ||= UserExtensions.new
ue.user_id = @user.id ue.user_id = @user.id
ue.save ue.save
# 注册时,记录是否是引流用户
ip = @env['HTTP_X_REAL_IP']
ua = UserAgent.where(:ip => ip, :type => UserAgent::AD).take
UserAgent.create(:key => ua.key, :ip => ip, :type => UserAgent::REGISTER, :user_id => @user.id) if ua
end end
@user @user
#img_url = url_to_avatar(@user) #img_url = url_to_avatar(@user)

Loading…
Cancel
Save