diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 34552787..e5f4f8b4 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1038,7 +1038,7 @@ class AccountController < ApplicationController apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization", :status => 0).first school_ids = School.where(:auto_users_trial => 1).map(&:id) user_ex = User.current.user_extensions - if (user_ex.identity == 0 || (user_ex.identity == 1 && user_ex.student_id.present?)) && !user_ex.school.nil? && school_ids.include?(user_ex.school_id) + if user_ex.identity == 1 && user_ex.student_id.present? && !user_ex.school.nil? && school_ids.include?(user_ex.school_id) User.current.update_attributes(:certification => 1) logger.warn("apply_trail #######{User.current.login} ****#{User.current.user_extensions.school_id}") @tip = "申请已提交,我们将在1分钟内完成审核" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 262efb00..8bb217cc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,15 +65,62 @@ class ApplicationController < ActionController::Base include Redmine::MenuManager::MenuController helper Redmine::MenuManager::MenuHelper - def ecloud_auth ucloud_user_id - euser = EcloudUser.where("id =? and opttype not in(3, 5)", ucloud_user_id).first - if euser.present? # 开通过业务 - # - else - false - end + # 云启训练场(EduCoder)个人版 产品编码(appId) 9200108 + # 产品名称 计费类型 套餐编码 + # 云启训练场(EduCoder)个人版 固定包月 9200108001 + # 固定包月 9200108002 + # 固定包月 9200108003 + # --------------------------------------------------- + # 产品名称 计费类型 套餐编码 + # 云启训练场(EduCoder))院校版 包月+按license 9200109001 + # 包月+按license 9200109002 + + # 云启训练场(EduCoder))院校版 产品编码(appId) 9200109 + def ecloud_auth subject_id + # euser = EcloudUser.where("userid =? and opttype not in(3, 5)", User.current.id).first + # if euser.present? # 开通过业务 + # # 获取用户的套餐信息 + # e_service = euser.ecloud_services.where("opttype != 1") + # # 如果用户开通过服务 + # if e_service.present? + # if e_service.count >1 # 说明有重复开通过业务 + # else + # code = e_service.first.try(:code) + # + # end + # end + # else + # false # 没开通过服务,或者服务被禁用则不允许访问 + # end + # + # + # + # + # if e_service.count > 1 # 说明有重复订购过套餐 + # else + # code = e_service.try(:code) + # end + # service_count = euser.ecloud_services.where("opttype != 1").try(:code) + # + # end + # 如果不是Ecloud过来的用户,则不改变用户的使用状态及权限,按现有模式即可 + end + + # 根据业务确定权限 + def ecloud_services_auth code, subject_id + subject = Subject.find(subject_id) + subject_level = subject.subject_level_system.try(:level) + # case code + # when "9200108001" + # subject_level.to_i == 1 ? true : false + # when "9200108002" + # + # end + # end + end + def ec_public_auth major_school unless User.current.admin? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 || major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0 || diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index c49b34a6..969640fc 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -43,7 +43,7 @@ class EcloudController < ApplicationController CLIENT_ID = '1056' CLIENT_SECRET = '2e84256a-3de4-4713-9e02-10ee88a14592' SERVER_URL = "https://221.176.53.130:44390/services/" - +q ## 签名 @@ -63,12 +63,12 @@ class EcloudController < ApplicationController begin if params['opttype'] == 0 # 开通企业/个人业务 ecloud = Ecloud.create!(eloud_params) - create_service(params['services'], ecloud.try(:id)) + create_service(params['services'], ecloud.try(:id)) if params['services'].present? create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? # 为管理员添加一条记录 # 开通的时候都是用户的opttype也是0 # 如果管理员已经存在,则不用重复开通 - euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first + euser = EcloudUser.where(userid: params['userid'], custid: params['custid']).first unless euser EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], username: params['username'], useralias: params['useralias'], @@ -96,7 +96,8 @@ class EcloudController < ApplicationController elsif params['opttype'] == 1 # 业务变更 ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first # 套餐变更 - # 新增业务 + # 操作代码 0:新增业务,1:注销业务2:修改业务 + # # 新增服务 add_service = params['services'].select{|s| s['opttype'] == 0} create_service(add_service, ecloud.try(:id)) if add_service.present? @@ -114,8 +115,8 @@ class EcloudController < ApplicationController if edt_services.present? edt_services.each do |es| ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first - ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) - create_serviceparas es['serviceparas'].first, ese.id + ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) if ese.present? + create_serviceparas(es['serviceparas'].first, ese.id) if ese.present? end end @@ -128,6 +129,7 @@ class EcloudController < ApplicationController # ecloud_id = ecloud.try(:id) elsif params['opttype'] == 4 # 再次重复开通 + # 再次申请开通,这种情况就是累加时间 ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first create_service(params['services'], ecloud.try(:id)) create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9992d000..599e8da4 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2104,25 +2104,36 @@ end condition = (params[:research_condition].nil? || params[:research_condition] == "name") ? "concat(lastname, firstname)" : params[:research_condition] if 0 == status if params[:research_condition] == "phone" && params[:research_contents].blank? - @users = User.order("#{@order_key} #{@us_order}") + @users = User.where(nil) else - @users = User.where("#{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}") + @users = User.where("#{condition} like '%#{params[:research_contents]}%'") end else if params[:research_condition] == "phone" && params[:research_contents].blank? - @users = User.where(:status => status).order("#{@order_key} #{@us_order}") + @users = User.where(:status => status) else - @users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}") + @users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'") end end + if params[:identity] && params[:identity].to_i != -1 + @users = @users.includes(:user_extensions).where("user_extensions.identity = ?", params[:identity].to_i) + end + + if params[:auto_school] && params[:auto_school].to_i != 0 + @users = @users.includes(:user_extensions => [:school]).where("schools.auto_users_trial = ?", params[:auto_school].to_i == 1 ? 1 : 0) + end + if params[:school] && params[:school] != '' school_name = params[:school] school = School.where("name like '%#{school_name}%'") school_id = school.map(&:id) user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) - @users = @users.where(:id => user_id).order("#{@order_key} #{@us_order}") + @users = @users.where(:id => user_id) end + + @users = @users.order("#{@order_key} #{@us_order}") + @page = (params['page'] || 1).to_i @users_count = @users.count @limit = 20 @@ -3186,25 +3197,44 @@ end search = params[:search] @status = trial_authorization_status(params[:status]) # @status = (params[:status].blank? || params[:status] == "0") ? 0 : [1,2] - if search.blank? - @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status).includes(:user) - else - user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'") - @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status, :user_id => user_id).includes(:user) + user_id = [] + search = false + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status) + + unless search.blank? + user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'").map(&:id) end - if params[:sname] && params[:sname] != '' + if params[:sname] && params[:sname].strip != '' school_id = School.where("name like '%#{params[:sname]}%'") - user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) - @authorizations = @authorizations.where(:user_id => user_id).order("updated_at desc") + new_user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true + end + + if params[:identity] && params[:identity].to_i != -1 + new_user_id = UserExtensions.where(:identity => params[:identity].to_i).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true end + if params[:auto_school] && params[:auto_school].to_i != 0 + school_id = School.where(auto_users_trial: params[:auto_school].to_i == 1 ? 1 : 0) + new_user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true + end + + @authorizations = user_id.size == 0 && !search ? @authorizations.order("updated_at desc") : @authorizations.where(:user_id => user_id.uniq).order("updated_at desc") + @autu_count = @authorizations.count @limit = 15 @is_remote = true @autu_pages = Paginator.new @autu_count, @limit, params['page'] || 1 @offset ||= @autu_pages.offset @authorizations = paginateHelper @authorizations, @limit + + @authorizations = @authorizations.includes(:user) respond_to do |format| format.js format.html diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2537c465..a368f88b 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -113,7 +113,7 @@ class StudentWorkController < ApplicationController pass_consume_time += (game.cost_time / 60.0).to_f end all_time += (game.cost_time / 60.0).to_f - user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0 if myshixun.user_id == @work.user.id @game_user_query << [game.id, game.outputs.first.try(:query_index).to_i] end diff --git a/app/helpers/shixuns_helper.rb b/app/helpers/shixuns_helper.rb index 23168ccf..a42225cd 100644 --- a/app/helpers/shixuns_helper.rb +++ b/app/helpers/shixuns_helper.rb @@ -5,7 +5,7 @@ module ShixunsHelper def myshixun_exp myshixun score = 0 myshixun.games.each do |game| - score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0 end score end diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb index 4a388ed4..dba4a7b2 100644 --- a/app/models/ecloud_service.rb +++ b/app/models/ecloud_service.rb @@ -1,3 +1,4 @@ +# 操作代码 0:新增业务,1:注销业务2:修改业务 class EcloudService < ActiveRecord::Base attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid belongs_to :ecloud diff --git a/app/models/user.rb b/app/models/user.rb index fdb9566a..31c58f26 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1693,31 +1693,37 @@ class User < Principal end def self.create_with_ecoder!(info) - user = User.new - user.admin = false - user.login = "ecoder_" + info["mobile"] + user = User.find_by_phone(info["mobile"]) - user.phone = info["mobile"] + # 如果手机号存在,则直接绑定用户 + # 因为手机号可以取回密码,所以可以视为同一用户 + unless user + user = User.new + user.admin = false + user.login = "ecoder_" + info["mobile"] - unless User.find_by_mail(info["email"]) - user.mail = info["email"] - end - user.nickname = info["username"] + user.phone = info["mobile"] + + unless User.find_by_mail(info["email"]) + user.mail = info["email"] + end + user.nickname = info["username"] - user.activate - user.last_login_on = Time.now + user.activate + user.last_login_on = Time.now - user.ecoder_user_id = info["userid"] + user.ecoder_user_id = info["userid"] - user.save!(:validate => false) + user.save!(:validate => false) - UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) - ue = user.user_extensions ||= UserExtensions.new - ue.user_id = user.id - ue.save! + ue = user.user_extensions ||= UserExtensions.new + ue.user_id = user.id + ue.save! + end user end diff --git a/app/views/managements/_user_list.html.erb b/app/views/managements/_user_list.html.erb index d77fa954..d2bc0fef 100644 --- a/app/views/managements/_user_list.html.erb +++ b/app/views/managements/_user_list.html.erb @@ -65,15 +65,9 @@ }else{ var order = "desc" } - var user_status = $("input[name='user_status']").val(); - var research_condition = $("input[name='research_condition']").val(); - var research_contents = $("input[name='research_contents']").val(); - $.ajax({ - url: "<%= users_managements_path %>", - type: "post", - dataType: "script", - data: {us_order : order, order_key: "created_on", user_status:user_status, research_condition:research_condition, research_contents:research_contents} - }); + $("input[name='us_order']").val(order); + $("input[name='order_key']").val("created_on"); + $("#managements_users_search").submit(); }); // 按最后登录时间排序 $("#user_last_order").on("click", function(){ @@ -83,15 +77,9 @@ }else{ var order = "desc" } - var user_status = $("input[name='user_status']").val(); - var research_condition = $("input[name='research_condition']").val(); - var research_contents = $("input[name='research_contents']").val(); - $.ajax({ - url: "<%= users_managements_path %>", - type: "post", - dataType: "script", - data: {us_order : order, order_key: "last_login_on", user_status:user_status, research_condition:research_condition, research_contents:research_contents} - }); + $("input[name='us_order']").val(order); + $("input[name='order_key']").val("last_login_on"); + $("#managements_users_search").submit(); }); // 按经验值排序 $("#user_experience_order").on("click", function(){ @@ -101,16 +89,10 @@ }else{ var order = "desc" } - var user_status = $("input[name='user_status']").val(); - var research_condition = $("input[name='research_condition']").val(); - var research_contents = $("input[name='research_contents']").val(); - $.ajax({ - url: "<%= users_managements_path %>", - type: "post", - dataType: "script", - data: {us_order : order, order_key: "experience", user_status:user_status, research_condition:research_condition, research_contents:research_contents} - }); - }) + $("input[name='us_order']").val(order); + $("input[name='order_key']").val("experience"); + $("#managements_users_search").submit(); + }); // 按金币排序 $("#user_grade_order").on("click", function(){ @@ -120,14 +102,8 @@ }else{ var order = "desc" } - var user_status = $("input[name='user_status']").val(); - var research_condition = $("input[name='research_condition']").val(); - var research_contents = $("input[name='research_contents']").val(); - $.ajax({ - url: "<%= users_managements_path %>", - type: "post", - dataType: "script", - data: {us_order : order, order_key: "grade", user_status:user_status, research_condition:research_condition, research_contents:research_contents} - }); + $("input[name='us_order']").val(order); + $("input[name='order_key']").val("grade"); + $("#managements_users_search").submit(); }) \ No newline at end of file diff --git a/app/views/managements/trial_authorization.html.erb b/app/views/managements/trial_authorization.html.erb index 5f2c17a1..acdc4d69 100644 --- a/app/views/managements/trial_authorization.html.erb +++ b/app/views/managements/trial_authorization.html.erb @@ -28,11 +28,22 @@
+
+ +全部状态
- -真实姓名搜索
- -全部状态
+ +真实姓名搜索
+ +